Skip to content

Commit

Permalink
Merge pull request #596 from hashicorp/auto-pr/5266df9f0
Browse files Browse the repository at this point in the history
Auto PR: Regenerating the Go SDK (80b4336)
  • Loading branch information
tombuildsstuff committed Aug 3, 2023
2 parents 2a15fc0 + 80b4336 commit 0526c2a
Show file tree
Hide file tree
Showing 884 changed files with 57,346 additions and 52 deletions.
144 changes: 144 additions & 0 deletions resource-manager/compute/2023-03-01/availabilitysets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@

## `github.com/hashicorp/go-azure-sdk/resource-manager/compute/2023-03-01/availabilitysets` Documentation

The `availabilitysets` SDK allows for interaction with the Azure Resource Manager Service `compute` (API Version `2023-03-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/compute/2023-03-01/availabilitysets"
```


### Client Initialization

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


### Example Usage: `AvailabilitySetsClient.CreateOrUpdate`

```go
ctx := context.TODO()
id := availabilitysets.NewAvailabilitySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "availabilitySetValue")

payload := availabilitysets.AvailabilitySet{
// ...
}


read, err := client.CreateOrUpdate(ctx, id, payload)
if err != nil {
// handle the error
}
if model := read.Model; model != nil {
// do something with the model/response object
}
```


### Example Usage: `AvailabilitySetsClient.Delete`

```go
ctx := context.TODO()
id := availabilitysets.NewAvailabilitySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "availabilitySetValue")

read, err := client.Delete(ctx, id)
if err != nil {
// handle the error
}
if model := read.Model; model != nil {
// do something with the model/response object
}
```


### Example Usage: `AvailabilitySetsClient.Get`

```go
ctx := context.TODO()
id := availabilitysets.NewAvailabilitySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "availabilitySetValue")

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: `AvailabilitySetsClient.List`

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

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


### Example Usage: `AvailabilitySetsClient.ListAvailableSizes`

```go
ctx := context.TODO()
id := availabilitysets.NewAvailabilitySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "availabilitySetValue")

read, err := client.ListAvailableSizes(ctx, id)
if err != nil {
// handle the error
}
if model := read.Model; model != nil {
// do something with the model/response object
}
```


### Example Usage: `AvailabilitySetsClient.ListBySubscription`

```go
ctx := context.TODO()
id := availabilitysets.NewSubscriptionID("12345678-1234-9876-4563-123456789012")

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


### Example Usage: `AvailabilitySetsClient.Update`

```go
ctx := context.TODO()
id := availabilitysets.NewAvailabilitySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "availabilitySetValue")

payload := availabilitysets.AvailabilitySetUpdate{
// ...
}


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
}
```
18 changes: 18 additions & 0 deletions resource-manager/compute/2023-03-01/availabilitysets/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package availabilitysets

import "github.com/Azure/go-autorest/autorest"

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type AvailabilitySetsClient struct {
Client autorest.Client
baseUri string
}

func NewAvailabilitySetsClientWithBaseURI(endpoint string) AvailabilitySetsClient {
return AvailabilitySetsClient{
Client: autorest.NewClientWithUserAgent(userAgent()),
baseUri: endpoint,
}
}
37 changes: 37 additions & 0 deletions resource-manager/compute/2023-03-01/availabilitysets/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package availabilitysets

import "strings"

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type StatusLevelTypes string

const (
StatusLevelTypesError StatusLevelTypes = "Error"
StatusLevelTypesInfo StatusLevelTypes = "Info"
StatusLevelTypesWarning StatusLevelTypes = "Warning"
)

func PossibleValuesForStatusLevelTypes() []string {
return []string{
string(StatusLevelTypesError),
string(StatusLevelTypesInfo),
string(StatusLevelTypesWarning),
}
}

func parseStatusLevelTypes(input string) (*StatusLevelTypes, error) {
vals := map[string]StatusLevelTypes{
"error": StatusLevelTypesError,
"info": StatusLevelTypesInfo,
"warning": StatusLevelTypesWarning,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}

// otherwise presume it's an undefined value and best-effort it
out := StatusLevelTypes(input)
return &out, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package availabilitysets

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 = AvailabilitySetId{}

// AvailabilitySetId is a struct representing the Resource ID for a Availability Set
type AvailabilitySetId struct {
SubscriptionId string
ResourceGroupName string
AvailabilitySetName string
}

// NewAvailabilitySetID returns a new AvailabilitySetId struct
func NewAvailabilitySetID(subscriptionId string, resourceGroupName string, availabilitySetName string) AvailabilitySetId {
return AvailabilitySetId{
SubscriptionId: subscriptionId,
ResourceGroupName: resourceGroupName,
AvailabilitySetName: availabilitySetName,
}
}

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

var ok bool
id := AvailabilitySetId{}

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.AvailabilitySetName, ok = parsed.Parsed["availabilitySetName"]; !ok {
return nil, resourceids.NewSegmentNotSpecifiedError(id, "availabilitySetName", *parsed)
}

return &id, nil
}

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

var ok bool
id := AvailabilitySetId{}

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.AvailabilitySetName, ok = parsed.Parsed["availabilitySetName"]; !ok {
return nil, resourceids.NewSegmentNotSpecifiedError(id, "availabilitySetName", *parsed)
}

return &id, nil
}

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

return
}

// ID returns the formatted Availability Set ID
func (id AvailabilitySetId) ID() string {
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Compute/availabilitySets/%s"
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AvailabilitySetName)
}

// Segments returns a slice of Resource ID Segments which comprise this Availability Set ID
func (id AvailabilitySetId) 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("staticMicrosoftCompute", "Microsoft.Compute", "Microsoft.Compute"),
resourceids.StaticSegment("staticAvailabilitySets", "availabilitySets", "availabilitySets"),
resourceids.UserSpecifiedSegment("availabilitySetName", "availabilitySetValue"),
}
}

// String returns a human-readable description of this Availability Set ID
func (id AvailabilitySetId) String() string {
components := []string{
fmt.Sprintf("Subscription: %q", id.SubscriptionId),
fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName),
fmt.Sprintf("Availability Set Name: %q", id.AvailabilitySetName),
}
return fmt.Sprintf("Availability Set (%s)", strings.Join(components, "\n"))
}

0 comments on commit 0526c2a

Please sign in to comment.