Skip to content

Commit

Permalink
Updating based on 2a79718ec
Browse files Browse the repository at this point in the history
  • Loading branch information
hc-github-team-tf-azure committed Oct 24, 2023
1 parent 0853173 commit 89c90cb
Show file tree
Hide file tree
Showing 55 changed files with 4,232 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@

## `github.com/hashicorp/go-azure-sdk/resource-manager/servicenetworking/2023-11-01/associationsinterface` Documentation

The `associationsinterface` SDK allows for interaction with the Azure Resource Manager Service `servicenetworking` (API Version `2023-11-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-sdk/resource-manager/servicenetworking/2023-11-01/associationsinterface"
```


### Client Initialization

```go
client := associationsinterface.NewAssociationsInterfaceClientWithBaseURI("https://management.azure.com")
client.Client.Authorizer = authorizer
```


### Example Usage: `AssociationsInterfaceClient.CreateOrUpdate`

```go
ctx := context.TODO()
id := associationsinterface.NewAssociationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "trafficControllerValue", "associationValue")

payload := associationsinterface.Association{
// ...
}


if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil {
// handle the error
}
```


### Example Usage: `AssociationsInterfaceClient.Delete`

```go
ctx := context.TODO()
id := associationsinterface.NewAssociationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "trafficControllerValue", "associationValue")

if err := client.DeleteThenPoll(ctx, id); err != nil {
// handle the error
}
```


### Example Usage: `AssociationsInterfaceClient.Get`

```go
ctx := context.TODO()
id := associationsinterface.NewAssociationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "trafficControllerValue", "associationValue")

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: `AssociationsInterfaceClient.ListByTrafficController`

```go
ctx := context.TODO()
id := associationsinterface.NewTrafficControllerID("12345678-1234-9876-4563-123456789012", "example-resource-group", "trafficControllerValue")

// alternatively `client.ListByTrafficController(ctx, id)` can be used to do batched pagination
items, err := client.ListByTrafficControllerComplete(ctx, id)
if err != nil {
// handle the error
}
for _, item := range items {
// do something
}
```


### Example Usage: `AssociationsInterfaceClient.Update`

```go
ctx := context.TODO()
id := associationsinterface.NewAssociationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "trafficControllerValue", "associationValue")

payload := associationsinterface.AssociationUpdate{
// ...
}


read, err := client.Update(ctx, id, payload)
if err != nil {
// handle the error
}
if model := read.Model; model != nil {
// do something with the model/response object
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package associationsinterface

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 AssociationsInterfaceClient struct {
Client *resourcemanager.Client
}

func NewAssociationsInterfaceClientWithBaseURI(sdkApi sdkEnv.Api) (*AssociationsInterfaceClient, error) {
client, err := resourcemanager.NewResourceManagerClient(sdkApi, "associationsinterface", defaultApiVersion)
if err != nil {
return nil, fmt.Errorf("instantiating AssociationsInterfaceClient: %+v", err)
}

return &AssociationsInterfaceClient{
Client: client,
}, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package associationsinterface

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 AssociationType string

const (
AssociationTypeSubnets AssociationType = "subnets"
)

func PossibleValuesForAssociationType() []string {
return []string{
string(AssociationTypeSubnets),
}
}

func (s *AssociationType) UnmarshalJSON(bytes []byte) error {
var decoded string
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling: %+v", err)
}
out, err := parseAssociationType(decoded)
if err != nil {
return fmt.Errorf("parsing %q: %+v", decoded, err)
}
*s = *out
return nil
}

func parseAssociationType(input string) (*AssociationType, error) {
vals := map[string]AssociationType{
"subnets": AssociationTypeSubnets,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}

// otherwise presume it's an undefined value and best-effort it
out := AssociationType(input)
return &out, nil
}

type ProvisioningState string

const (
ProvisioningStateAccepted ProvisioningState = "Accepted"
ProvisioningStateCanceled ProvisioningState = "Canceled"
ProvisioningStateDeleting ProvisioningState = "Deleting"
ProvisioningStateFailed ProvisioningState = "Failed"
ProvisioningStateProvisioning ProvisioningState = "Provisioning"
ProvisioningStateSucceeded ProvisioningState = "Succeeded"
ProvisioningStateUpdating ProvisioningState = "Updating"
)

func PossibleValuesForProvisioningState() []string {
return []string{
string(ProvisioningStateAccepted),
string(ProvisioningStateCanceled),
string(ProvisioningStateDeleting),
string(ProvisioningStateFailed),
string(ProvisioningStateProvisioning),
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{
"accepted": ProvisioningStateAccepted,
"canceled": ProvisioningStateCanceled,
"deleting": ProvisioningStateDeleting,
"failed": ProvisioningStateFailed,
"provisioning": ProvisioningStateProvisioning,
"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
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
package associationsinterface

import (
"fmt"
"strings"

"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.

var _ resourceids.ResourceId = AssociationId{}

// AssociationId is a struct representing the Resource ID for a Association
type AssociationId struct {
SubscriptionId string
ResourceGroupName string
TrafficControllerName string
AssociationName string
}

// NewAssociationID returns a new AssociationId struct
func NewAssociationID(subscriptionId string, resourceGroupName string, trafficControllerName string, associationName string) AssociationId {
return AssociationId{
SubscriptionId: subscriptionId,
ResourceGroupName: resourceGroupName,
TrafficControllerName: trafficControllerName,
AssociationName: associationName,
}
}

// ParseAssociationID parses 'input' into a AssociationId
func ParseAssociationID(input string) (*AssociationId, error) {
parser := resourceids.NewParserFromResourceIdType(AssociationId{})
parsed, err := parser.Parse(input, false)
if err != nil {
return nil, fmt.Errorf("parsing %q: %+v", input, err)
}

var ok bool
id := AssociationId{}

if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok {
return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed)
}

if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok {
return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed)
}

if id.TrafficControllerName, ok = parsed.Parsed["trafficControllerName"]; !ok {
return nil, resourceids.NewSegmentNotSpecifiedError(id, "trafficControllerName", *parsed)
}

if id.AssociationName, ok = parsed.Parsed["associationName"]; !ok {
return nil, resourceids.NewSegmentNotSpecifiedError(id, "associationName", *parsed)
}

return &id, nil
}

// ParseAssociationIDInsensitively parses 'input' case-insensitively into a AssociationId
// note: this method should only be used for API response data and not user input
func ParseAssociationIDInsensitively(input string) (*AssociationId, error) {
parser := resourceids.NewParserFromResourceIdType(AssociationId{})
parsed, err := parser.Parse(input, true)
if err != nil {
return nil, fmt.Errorf("parsing %q: %+v", input, err)
}

var ok bool
id := AssociationId{}

if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok {
return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed)
}

if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok {
return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed)
}

if id.TrafficControllerName, ok = parsed.Parsed["trafficControllerName"]; !ok {
return nil, resourceids.NewSegmentNotSpecifiedError(id, "trafficControllerName", *parsed)
}

if id.AssociationName, ok = parsed.Parsed["associationName"]; !ok {
return nil, resourceids.NewSegmentNotSpecifiedError(id, "associationName", *parsed)
}

return &id, nil
}

// ValidateAssociationID checks that 'input' can be parsed as a Association ID
func ValidateAssociationID(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 := ParseAssociationID(v); err != nil {
errors = append(errors, err)
}

return
}

// ID returns the formatted Association ID
func (id AssociationId) ID() string {
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ServiceNetworking/trafficControllers/%s/associations/%s"
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.TrafficControllerName, id.AssociationName)
}

// Segments returns a slice of Resource ID Segments which comprise this Association ID
func (id AssociationId) 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("staticMicrosoftServiceNetworking", "Microsoft.ServiceNetworking", "Microsoft.ServiceNetworking"),
resourceids.StaticSegment("staticTrafficControllers", "trafficControllers", "trafficControllers"),
resourceids.UserSpecifiedSegment("trafficControllerName", "trafficControllerValue"),
resourceids.StaticSegment("staticAssociations", "associations", "associations"),
resourceids.UserSpecifiedSegment("associationName", "associationValue"),
}
}

// String returns a human-readable description of this Association ID
func (id AssociationId) String() string {
components := []string{
fmt.Sprintf("Subscription: %q", id.SubscriptionId),
fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName),
fmt.Sprintf("Traffic Controller Name: %q", id.TrafficControllerName),
fmt.Sprintf("Association Name: %q", id.AssociationName),
}
return fmt.Sprintf("Association (%s)", strings.Join(components, "\n"))
}
Loading

0 comments on commit 89c90cb

Please sign in to comment.