Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
220 changes: 220 additions & 0 deletions resource-manager/compute/2024-11-01/availabilitysets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@

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

The `availabilitysets` SDK allows for interaction with Azure Resource Manager `compute` (API Version `2024-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-helpers/resourcemanager/commonids"
import "github.com/hashicorp/go-azure-sdk/resource-manager/compute/2024-11-01/availabilitysets"
```


### Client Initialization

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


### Example Usage: `AvailabilitySetsClient.CancelMigrationToVirtualMachineScaleSet`

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

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


### Example Usage: `AvailabilitySetsClient.ConvertToVirtualMachineScaleSet`

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

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


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


### Example Usage: `AvailabilitySetsClient.CreateOrUpdate`

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

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 := commonids.NewAvailabilitySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "availabilitySetName")

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 := commonids.NewAvailabilitySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "availabilitySetName")

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 := commonids.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 := commonids.NewAvailabilitySetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "availabilitySetName")

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 := commonids.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.StartMigrationToVirtualMachineScaleSet`

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

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


read, err := client.StartMigrationToVirtualMachineScaleSet(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.Update`

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

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
}
```


### Example Usage: `AvailabilitySetsClient.ValidateMigrationToVirtualMachineScaleSet`

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

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


read, err := client.ValidateMigrationToVirtualMachineScaleSet(ctx, id, payload)
if err != nil {
// handle the error
}
if model := read.Model; model != nil {
// do something with the model/response object
}
```
26 changes: 26 additions & 0 deletions resource-manager/compute/2024-11-01/availabilitysets/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package availabilitysets

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

func NewAvailabilitySetsClientWithBaseURI(sdkApi sdkEnv.Api) (*AvailabilitySetsClient, error) {
client, err := resourcemanager.NewClient(sdkApi, "availabilitysets", defaultApiVersion)
if err != nil {
return nil, fmt.Errorf("instantiating AvailabilitySetsClient: %+v", err)
}

return &AvailabilitySetsClient{
Client: client,
}, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package availabilitysets

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

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

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

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

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,48 @@
package availabilitysets

import (
"context"
"fmt"
"net/http"

"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
"github.com/hashicorp/go-azure-sdk/sdk/client"
"github.com/hashicorp/go-azure-sdk/sdk/odata"
)

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

type CancelMigrationToVirtualMachineScaleSetOperationResponse struct {
HttpResponse *http.Response
OData *odata.OData
}

// CancelMigrationToVirtualMachineScaleSet ...
func (c AvailabilitySetsClient) CancelMigrationToVirtualMachineScaleSet(ctx context.Context, id commonids.AvailabilitySetId) (result CancelMigrationToVirtualMachineScaleSetOperationResponse, err error) {
opts := client.RequestOptions{
ContentType: "application/json; charset=utf-8",
ExpectedStatusCodes: []int{
http.StatusNoContent,
},
HttpMethod: http.MethodPost,
Path: fmt.Sprintf("%s/cancelMigrationToVirtualMachineScaleSet", id.ID()),
}

req, err := c.Client.NewRequest(ctx, opts)
if err != nil {
return
}

var resp *client.Response
resp, err = req.Execute(ctx)
if resp != nil {
result.OData = resp.OData
result.HttpResponse = resp.Response
}
if err != nil {
return
}

return
}
Loading
Loading