Skip to content

Commit

Permalink
Updating based on c4a16288
Browse files Browse the repository at this point in the history
  • Loading branch information
hc-github-team-tf-azure committed Apr 16, 2024
1 parent b9bf6d7 commit a3853dc
Show file tree
Hide file tree
Showing 46 changed files with 2,774 additions and 0 deletions.
46 changes: 46 additions & 0 deletions resource-manager/quota/2023-02-01/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package v2023_02_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/quota/2023-02-01/quotainformation"
"github.com/hashicorp/go-azure-sdk/resource-manager/quota/2023-02-01/quotarequests"
"github.com/hashicorp/go-azure-sdk/resource-manager/quota/2023-02-01/usagesinformation"
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments"
)

type Client struct {
QuotaInformation *quotainformation.QuotaInformationClient
QuotaRequests *quotarequests.QuotaRequestsClient
UsagesInformation *usagesinformation.UsagesInformationClient
}

func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) {
quotaInformationClient, err := quotainformation.NewQuotaInformationClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building QuotaInformation client: %+v", err)
}
configureFunc(quotaInformationClient.Client)

quotaRequestsClient, err := quotarequests.NewQuotaRequestsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building QuotaRequests client: %+v", err)
}
configureFunc(quotaRequestsClient.Client)

usagesInformationClient, err := usagesinformation.NewUsagesInformationClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building UsagesInformation client: %+v", err)
}
configureFunc(usagesInformationClient.Client)

return &Client{
QuotaInformation: quotaInformationClient,
QuotaRequests: quotaRequestsClient,
UsagesInformation: usagesInformationClient,
}, nil
}
88 changes: 88 additions & 0 deletions resource-manager/quota/2023-02-01/quotainformation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

## `github.com/hashicorp/go-azure-sdk/resource-manager/quota/2023-02-01/quotainformation` Documentation

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


### Client Initialization

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


### Example Usage: `QuotaInformationClient.QuotaCreateOrUpdate`

```go
ctx := context.TODO()
id := quotainformation.NewScopedQuotaID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "quotaValue")

payload := quotainformation.CurrentQuotaLimitBase{
// ...
}


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


### Example Usage: `QuotaInformationClient.QuotaGet`

```go
ctx := context.TODO()
id := quotainformation.NewScopedQuotaID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "quotaValue")

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


### Example Usage: `QuotaInformationClient.QuotaList`

```go
ctx := context.TODO()
id := commonids.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group")

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


### Example Usage: `QuotaInformationClient.QuotaUpdate`

```go
ctx := context.TODO()
id := quotainformation.NewScopedQuotaID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "quotaValue")

payload := quotainformation.CurrentQuotaLimitBase{
// ...
}


if err := client.QuotaUpdateThenPoll(ctx, id, payload); err != nil {
// handle the error
}
```
26 changes: 26 additions & 0 deletions resource-manager/quota/2023-02-01/quotainformation/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package quotainformation

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

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

return &QuotaInformationClient{
Client: client,
}, nil
}
89 changes: 89 additions & 0 deletions resource-manager/quota/2023-02-01/quotainformation/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package quotainformation

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

const (
LimitTypeLimitValue LimitType = "LimitValue"
)

func PossibleValuesForLimitType() []string {
return []string{
string(LimitTypeLimitValue),
}
}

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

func parseLimitType(input string) (*LimitType, error) {
vals := map[string]LimitType{
"limitvalue": LimitTypeLimitValue,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}

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

type QuotaLimitTypes string

const (
QuotaLimitTypesIndependent QuotaLimitTypes = "Independent"
QuotaLimitTypesShared QuotaLimitTypes = "Shared"
)

func PossibleValuesForQuotaLimitTypes() []string {
return []string{
string(QuotaLimitTypesIndependent),
string(QuotaLimitTypesShared),
}
}

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

func parseQuotaLimitTypes(input string) (*QuotaLimitTypes, error) {
vals := map[string]QuotaLimitTypes{
"independent": QuotaLimitTypesIndependent,
"shared": QuotaLimitTypesShared,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}

// otherwise presume it's an undefined value and best-effort it
out := QuotaLimitTypes(input)
return &out, nil
}
120 changes: 120 additions & 0 deletions resource-manager/quota/2023-02-01/quotainformation/id_scopedquota.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package quotainformation

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(&ScopedQuotaId{})
}

var _ resourceids.ResourceId = &ScopedQuotaId{}

// ScopedQuotaId is a struct representing the Resource ID for a Scoped Quota
type ScopedQuotaId struct {
Scope string
QuotaName string
}

// NewScopedQuotaID returns a new ScopedQuotaId struct
func NewScopedQuotaID(scope string, quotaName string) ScopedQuotaId {
return ScopedQuotaId{
Scope: scope,
QuotaName: quotaName,
}
}

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

id := ScopedQuotaId{}
if err := id.FromParseResult(*parsed); err != nil {
return nil, err
}

return &id, nil
}

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

id := ScopedQuotaId{}
if err := id.FromParseResult(*parsed); err != nil {
return nil, err
}

return &id, nil
}

func (id *ScopedQuotaId) FromParseResult(input resourceids.ParseResult) error {
var ok bool

if id.Scope, ok = input.Parsed["scope"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "scope", input)
}

if id.QuotaName, ok = input.Parsed["quotaName"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "quotaName", input)
}

return nil
}

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

return
}

// ID returns the formatted Scoped Quota ID
func (id ScopedQuotaId) ID() string {
fmtString := "/%s/providers/Microsoft.Quota/quotas/%s"
return fmt.Sprintf(fmtString, strings.TrimPrefix(id.Scope, "/"), id.QuotaName)
}

// Segments returns a slice of Resource ID Segments which comprise this Scoped Quota ID
func (id ScopedQuotaId) Segments() []resourceids.Segment {
return []resourceids.Segment{
resourceids.ScopeSegment("scope", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group"),
resourceids.StaticSegment("staticProviders", "providers", "providers"),
resourceids.ResourceProviderSegment("staticMicrosoftQuota", "Microsoft.Quota", "Microsoft.Quota"),
resourceids.StaticSegment("staticQuotas", "quotas", "quotas"),
resourceids.UserSpecifiedSegment("quotaName", "quotaValue"),
}
}

// String returns a human-readable description of this Scoped Quota ID
func (id ScopedQuotaId) String() string {
components := []string{
fmt.Sprintf("Scope: %q", id.Scope),
fmt.Sprintf("Quota Name: %q", id.QuotaName),
}
return fmt.Sprintf("Scoped Quota (%s)", strings.Join(components, "\n"))
}
Loading

0 comments on commit a3853dc

Please sign in to comment.