Skip to content

Commit

Permalink
Merge pull request #1110 from hashicorp/auto-pr/f87ca5fe6
Browse files Browse the repository at this point in the history
Auto PR: Regenerating the Go SDK (f77d2b5)
  • Loading branch information
stephybun authored Oct 29, 2024
2 parents 3887a1d + f77d2b5 commit e40063c
Show file tree
Hide file tree
Showing 530 changed files with 40,171 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@

## `github.com/hashicorp/go-azure-sdk/resource-manager/containerregistry/2023-11-01-preview/archives` Documentation

The `archives` SDK allows for interaction with Azure Resource Manager `containerregistry` (API Version `2023-11-01-preview`).

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/containerregistry/2023-11-01-preview/archives"
```


### Client Initialization

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


### Example Usage: `ArchivesClient.Create`

```go
ctx := context.TODO()
id := archives.NewArchiveID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "packageName", "archiveName")

payload := archives.Archive{
// ...
}


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


### Example Usage: `ArchivesClient.Delete`

```go
ctx := context.TODO()
id := archives.NewArchiveID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "packageName", "archiveName")

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


### Example Usage: `ArchivesClient.Get`

```go
ctx := context.TODO()
id := archives.NewArchiveID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "packageName", "archiveName")

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

```go
ctx := context.TODO()
id := archives.NewPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "packageName")

// 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: `ArchivesClient.Update`

```go
ctx := context.TODO()
id := archives.NewArchiveID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "packageName", "archiveName")

payload := archives.ArchiveUpdateParameters{
// ...
}


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 archives

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

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

return &ArchivesClient{
Client: client,
}, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package archives

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

const (
PackageSourceTypeRemote PackageSourceType = "remote"
)

func PossibleValuesForPackageSourceType() []string {
return []string{
string(PackageSourceTypeRemote),
}
}

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

func parsePackageSourceType(input string) (*PackageSourceType, error) {
vals := map[string]PackageSourceType{
"remote": PackageSourceTypeRemote,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}

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

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
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
package archives

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

var _ resourceids.ResourceId = &ArchiveId{}

// ArchiveId is a struct representing the Resource ID for a Archive
type ArchiveId struct {
SubscriptionId string
ResourceGroupName string
RegistryName string
PackageName string
ArchiveName string
}

// NewArchiveID returns a new ArchiveId struct
func NewArchiveID(subscriptionId string, resourceGroupName string, registryName string, packageName string, archiveName string) ArchiveId {
return ArchiveId{
SubscriptionId: subscriptionId,
ResourceGroupName: resourceGroupName,
RegistryName: registryName,
PackageName: packageName,
ArchiveName: archiveName,
}
}

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

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

return &id, nil
}

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

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

return &id, nil
}

func (id *ArchiveId) 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.RegistryName, ok = input.Parsed["registryName"]; !ok {
return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input)
}

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

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

return nil
}

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

return
}

// ID returns the formatted Archive ID
func (id ArchiveId) ID() string {
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerRegistry/registries/%s/packages/%s/archives/%s"
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.PackageName, id.ArchiveName)
}

// Segments returns a slice of Resource ID Segments which comprise this Archive ID
func (id ArchiveId) 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("staticMicrosoftContainerRegistry", "Microsoft.ContainerRegistry", "Microsoft.ContainerRegistry"),
resourceids.StaticSegment("staticRegistries", "registries", "registries"),
resourceids.UserSpecifiedSegment("registryName", "registryName"),
resourceids.StaticSegment("staticPackages", "packages", "packages"),
resourceids.UserSpecifiedSegment("packageName", "packageName"),
resourceids.StaticSegment("staticArchives", "archives", "archives"),
resourceids.UserSpecifiedSegment("archiveName", "archiveName"),
}
}

// String returns a human-readable description of this Archive ID
func (id ArchiveId) String() string {
components := []string{
fmt.Sprintf("Subscription: %q", id.SubscriptionId),
fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName),
fmt.Sprintf("Registry Name: %q", id.RegistryName),
fmt.Sprintf("Package Name: %q", id.PackageName),
fmt.Sprintf("Archive Name: %q", id.ArchiveName),
}
return fmt.Sprintf("Archive (%s)", strings.Join(components, "\n"))
}
Loading

0 comments on commit e40063c

Please sign in to comment.