-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
hc-github-team-tf-azure
committed
Jul 10, 2024
1 parent
1061556
commit b704533
Showing
60 changed files
with
5,423 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package v2024_06_01 | ||
|
||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See NOTICE.txt in the project root for license information. | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/go-azure-sdk/resource-manager/privatedns/2024-06-01/privatezones" | ||
"github.com/hashicorp/go-azure-sdk/resource-manager/privatedns/2024-06-01/recordsets" | ||
"github.com/hashicorp/go-azure-sdk/resource-manager/privatedns/2024-06-01/virtualnetworklinks" | ||
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" | ||
sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" | ||
) | ||
|
||
type Client struct { | ||
PrivateZones *privatezones.PrivateZonesClient | ||
RecordSets *recordsets.RecordSetsClient | ||
VirtualNetworkLinks *virtualnetworklinks.VirtualNetworkLinksClient | ||
} | ||
|
||
func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { | ||
privateZonesClient, err := privatezones.NewPrivateZonesClientWithBaseURI(sdkApi) | ||
if err != nil { | ||
return nil, fmt.Errorf("building PrivateZones client: %+v", err) | ||
} | ||
configureFunc(privateZonesClient.Client) | ||
|
||
recordSetsClient, err := recordsets.NewRecordSetsClientWithBaseURI(sdkApi) | ||
if err != nil { | ||
return nil, fmt.Errorf("building RecordSets client: %+v", err) | ||
} | ||
configureFunc(recordSetsClient.Client) | ||
|
||
virtualNetworkLinksClient, err := virtualnetworklinks.NewVirtualNetworkLinksClientWithBaseURI(sdkApi) | ||
if err != nil { | ||
return nil, fmt.Errorf("building VirtualNetworkLinks client: %+v", err) | ||
} | ||
configureFunc(virtualNetworkLinksClient.Client) | ||
|
||
return &Client{ | ||
PrivateZones: privateZonesClient, | ||
RecordSets: recordSetsClient, | ||
VirtualNetworkLinks: virtualNetworkLinksClient, | ||
}, nil | ||
} |
117 changes: 117 additions & 0 deletions
117
resource-manager/privatedns/2024-06-01/privatezones/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
|
||
## `github.com/hashicorp/go-azure-sdk/resource-manager/privatedns/2024-06-01/privatezones` Documentation | ||
|
||
The `privatezones` SDK allows for interaction with the Azure Resource Manager Service `privatedns` (API Version `2024-06-01`). | ||
|
||
This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). | ||
|
||
### Import Path | ||
|
||
```go | ||
import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" | ||
import "github.com/hashicorp/go-azure-sdk/resource-manager/privatedns/2024-06-01/privatezones" | ||
``` | ||
|
||
|
||
### Client Initialization | ||
|
||
```go | ||
client := privatezones.NewPrivateZonesClientWithBaseURI("https://management.azure.com") | ||
client.Client.Authorizer = authorizer | ||
``` | ||
|
||
|
||
### Example Usage: `PrivateZonesClient.CreateOrUpdate` | ||
|
||
```go | ||
ctx := context.TODO() | ||
id := privatezones.NewPrivateDnsZoneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateDnsZoneValue") | ||
|
||
payload := privatezones.PrivateZone{ | ||
// ... | ||
} | ||
|
||
|
||
if err := client.CreateOrUpdateThenPoll(ctx, id, payload, privatezones.DefaultCreateOrUpdateOperationOptions()); err != nil { | ||
// handle the error | ||
} | ||
``` | ||
|
||
|
||
### Example Usage: `PrivateZonesClient.Delete` | ||
|
||
```go | ||
ctx := context.TODO() | ||
id := privatezones.NewPrivateDnsZoneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateDnsZoneValue") | ||
|
||
if err := client.DeleteThenPoll(ctx, id, privatezones.DefaultDeleteOperationOptions()); err != nil { | ||
// handle the error | ||
} | ||
``` | ||
|
||
|
||
### Example Usage: `PrivateZonesClient.Get` | ||
|
||
```go | ||
ctx := context.TODO() | ||
id := privatezones.NewPrivateDnsZoneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateDnsZoneValue") | ||
|
||
read, err := client.Get(ctx, id) | ||
if err != nil { | ||
// handle the error | ||
} | ||
if model := read.Model; model != nil { | ||
// do something with the model/response object | ||
} | ||
``` | ||
|
||
|
||
### Example Usage: `PrivateZonesClient.List` | ||
|
||
```go | ||
ctx := context.TODO() | ||
id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") | ||
|
||
// alternatively `client.List(ctx, id, privatezones.DefaultListOperationOptions())` can be used to do batched pagination | ||
items, err := client.ListComplete(ctx, id, privatezones.DefaultListOperationOptions()) | ||
if err != nil { | ||
// handle the error | ||
} | ||
for _, item := range items { | ||
// do something | ||
} | ||
``` | ||
|
||
|
||
### Example Usage: `PrivateZonesClient.ListByResourceGroup` | ||
|
||
```go | ||
ctx := context.TODO() | ||
id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") | ||
|
||
// alternatively `client.ListByResourceGroup(ctx, id, privatezones.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination | ||
items, err := client.ListByResourceGroupComplete(ctx, id, privatezones.DefaultListByResourceGroupOperationOptions()) | ||
if err != nil { | ||
// handle the error | ||
} | ||
for _, item := range items { | ||
// do something | ||
} | ||
``` | ||
|
||
|
||
### Example Usage: `PrivateZonesClient.Update` | ||
|
||
```go | ||
ctx := context.TODO() | ||
id := privatezones.NewPrivateDnsZoneID("12345678-1234-9876-4563-123456789012", "example-resource-group", "privateDnsZoneValue") | ||
|
||
payload := privatezones.PrivateZone{ | ||
// ... | ||
} | ||
|
||
|
||
if err := client.UpdateThenPoll(ctx, id, payload, privatezones.DefaultUpdateOperationOptions()); err != nil { | ||
// handle the error | ||
} | ||
``` |
26 changes: 26 additions & 0 deletions
26
resource-manager/privatedns/2024-06-01/privatezones/client.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package privatezones | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" | ||
sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" | ||
) | ||
|
||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See NOTICE.txt in the project root for license information. | ||
|
||
type PrivateZonesClient struct { | ||
Client *resourcemanager.Client | ||
} | ||
|
||
func NewPrivateZonesClientWithBaseURI(sdkApi sdkEnv.Api) (*PrivateZonesClient, error) { | ||
client, err := resourcemanager.NewResourceManagerClient(sdkApi, "privatezones", defaultApiVersion) | ||
if err != nil { | ||
return nil, fmt.Errorf("instantiating PrivateZonesClient: %+v", err) | ||
} | ||
|
||
return &PrivateZonesClient{ | ||
Client: client, | ||
}, nil | ||
} |
63 changes: 63 additions & 0 deletions
63
resource-manager/privatedns/2024-06-01/privatezones/constants.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package privatezones | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See NOTICE.txt in the project root for license information. | ||
|
||
type ProvisioningState string | ||
|
||
const ( | ||
ProvisioningStateCanceled ProvisioningState = "Canceled" | ||
ProvisioningStateCreating ProvisioningState = "Creating" | ||
ProvisioningStateDeleting ProvisioningState = "Deleting" | ||
ProvisioningStateFailed ProvisioningState = "Failed" | ||
ProvisioningStateSucceeded ProvisioningState = "Succeeded" | ||
ProvisioningStateUpdating ProvisioningState = "Updating" | ||
) | ||
|
||
func PossibleValuesForProvisioningState() []string { | ||
return []string{ | ||
string(ProvisioningStateCanceled), | ||
string(ProvisioningStateCreating), | ||
string(ProvisioningStateDeleting), | ||
string(ProvisioningStateFailed), | ||
string(ProvisioningStateSucceeded), | ||
string(ProvisioningStateUpdating), | ||
} | ||
} | ||
|
||
func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { | ||
var decoded string | ||
if err := json.Unmarshal(bytes, &decoded); err != nil { | ||
return fmt.Errorf("unmarshaling: %+v", err) | ||
} | ||
out, err := parseProvisioningState(decoded) | ||
if err != nil { | ||
return fmt.Errorf("parsing %q: %+v", decoded, err) | ||
} | ||
*s = *out | ||
return nil | ||
} | ||
|
||
func parseProvisioningState(input string) (*ProvisioningState, error) { | ||
vals := map[string]ProvisioningState{ | ||
"canceled": ProvisioningStateCanceled, | ||
"creating": ProvisioningStateCreating, | ||
"deleting": ProvisioningStateDeleting, | ||
"failed": ProvisioningStateFailed, | ||
"succeeded": ProvisioningStateSucceeded, | ||
"updating": ProvisioningStateUpdating, | ||
} | ||
if v, ok := vals[strings.ToLower(input)]; ok { | ||
return &v, nil | ||
} | ||
|
||
// otherwise presume it's an undefined value and best-effort it | ||
out := ProvisioningState(input) | ||
return &out, nil | ||
} |
130 changes: 130 additions & 0 deletions
130
resource-manager/privatedns/2024-06-01/privatezones/id_privatednszone.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
package privatezones | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" | ||
"github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" | ||
) | ||
|
||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See NOTICE.txt in the project root for license information. | ||
|
||
func init() { | ||
recaser.RegisterResourceId(&PrivateDnsZoneId{}) | ||
} | ||
|
||
var _ resourceids.ResourceId = &PrivateDnsZoneId{} | ||
|
||
// PrivateDnsZoneId is a struct representing the Resource ID for a Private Dns Zone | ||
type PrivateDnsZoneId struct { | ||
SubscriptionId string | ||
ResourceGroupName string | ||
PrivateDnsZoneName string | ||
} | ||
|
||
// NewPrivateDnsZoneID returns a new PrivateDnsZoneId struct | ||
func NewPrivateDnsZoneID(subscriptionId string, resourceGroupName string, privateDnsZoneName string) PrivateDnsZoneId { | ||
return PrivateDnsZoneId{ | ||
SubscriptionId: subscriptionId, | ||
ResourceGroupName: resourceGroupName, | ||
PrivateDnsZoneName: privateDnsZoneName, | ||
} | ||
} | ||
|
||
// ParsePrivateDnsZoneID parses 'input' into a PrivateDnsZoneId | ||
func ParsePrivateDnsZoneID(input string) (*PrivateDnsZoneId, error) { | ||
parser := resourceids.NewParserFromResourceIdType(&PrivateDnsZoneId{}) | ||
parsed, err := parser.Parse(input, false) | ||
if err != nil { | ||
return nil, fmt.Errorf("parsing %q: %+v", input, err) | ||
} | ||
|
||
id := PrivateDnsZoneId{} | ||
if err := id.FromParseResult(*parsed); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &id, nil | ||
} | ||
|
||
// ParsePrivateDnsZoneIDInsensitively parses 'input' case-insensitively into a PrivateDnsZoneId | ||
// note: this method should only be used for API response data and not user input | ||
func ParsePrivateDnsZoneIDInsensitively(input string) (*PrivateDnsZoneId, error) { | ||
parser := resourceids.NewParserFromResourceIdType(&PrivateDnsZoneId{}) | ||
parsed, err := parser.Parse(input, true) | ||
if err != nil { | ||
return nil, fmt.Errorf("parsing %q: %+v", input, err) | ||
} | ||
|
||
id := PrivateDnsZoneId{} | ||
if err := id.FromParseResult(*parsed); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &id, nil | ||
} | ||
|
||
func (id *PrivateDnsZoneId) FromParseResult(input resourceids.ParseResult) error { | ||
var ok bool | ||
|
||
if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { | ||
return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) | ||
} | ||
|
||
if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { | ||
return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) | ||
} | ||
|
||
if id.PrivateDnsZoneName, ok = input.Parsed["privateDnsZoneName"]; !ok { | ||
return resourceids.NewSegmentNotSpecifiedError(id, "privateDnsZoneName", input) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// ValidatePrivateDnsZoneID checks that 'input' can be parsed as a Private Dns Zone ID | ||
func ValidatePrivateDnsZoneID(input interface{}, key string) (warnings []string, errors []error) { | ||
v, ok := input.(string) | ||
if !ok { | ||
errors = append(errors, fmt.Errorf("expected %q to be a string", key)) | ||
return | ||
} | ||
|
||
if _, err := ParsePrivateDnsZoneID(v); err != nil { | ||
errors = append(errors, err) | ||
} | ||
|
||
return | ||
} | ||
|
||
// ID returns the formatted Private Dns Zone ID | ||
func (id PrivateDnsZoneId) ID() string { | ||
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/privateDnsZones/%s" | ||
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.PrivateDnsZoneName) | ||
} | ||
|
||
// Segments returns a slice of Resource ID Segments which comprise this Private Dns Zone ID | ||
func (id PrivateDnsZoneId) Segments() []resourceids.Segment { | ||
return []resourceids.Segment{ | ||
resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), | ||
resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), | ||
resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), | ||
resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), | ||
resourceids.StaticSegment("staticProviders", "providers", "providers"), | ||
resourceids.ResourceProviderSegment("staticMicrosoftNetwork", "Microsoft.Network", "Microsoft.Network"), | ||
resourceids.StaticSegment("staticPrivateDnsZones", "privateDnsZones", "privateDnsZones"), | ||
resourceids.UserSpecifiedSegment("privateDnsZoneName", "privateDnsZoneValue"), | ||
} | ||
} | ||
|
||
// String returns a human-readable description of this Private Dns Zone ID | ||
func (id PrivateDnsZoneId) String() string { | ||
components := []string{ | ||
fmt.Sprintf("Subscription: %q", id.SubscriptionId), | ||
fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), | ||
fmt.Sprintf("Private Dns Zone Name: %q", id.PrivateDnsZoneName), | ||
} | ||
return fmt.Sprintf("Private Dns Zone (%s)", strings.Join(components, "\n")) | ||
} |
Oops, something went wrong.