Skip to content

Commit e40063c

Browse files
authored
Merge pull request #1110 from hashicorp/auto-pr/f87ca5fe6
Auto PR: Regenerating the Go SDK (f77d2b5)
2 parents 3887a1d + f77d2b5 commit e40063c

File tree

530 files changed

+40171
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

530 files changed

+40171
-3
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
2+
## `github.com/hashicorp/go-azure-sdk/resource-manager/containerregistry/2023-11-01-preview/archives` Documentation
3+
4+
The `archives` SDK allows for interaction with Azure Resource Manager `containerregistry` (API Version `2023-11-01-preview`).
5+
6+
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).
7+
8+
### Import Path
9+
10+
```go
11+
import "github.com/hashicorp/go-azure-sdk/resource-manager/containerregistry/2023-11-01-preview/archives"
12+
```
13+
14+
15+
### Client Initialization
16+
17+
```go
18+
client := archives.NewArchivesClientWithBaseURI("https://management.azure.com")
19+
client.Client.Authorizer = authorizer
20+
```
21+
22+
23+
### Example Usage: `ArchivesClient.Create`
24+
25+
```go
26+
ctx := context.TODO()
27+
id := archives.NewArchiveID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "packageName", "archiveName")
28+
29+
payload := archives.Archive{
30+
// ...
31+
}
32+
33+
34+
if err := client.CreateThenPoll(ctx, id, payload); err != nil {
35+
// handle the error
36+
}
37+
```
38+
39+
40+
### Example Usage: `ArchivesClient.Delete`
41+
42+
```go
43+
ctx := context.TODO()
44+
id := archives.NewArchiveID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "packageName", "archiveName")
45+
46+
if err := client.DeleteThenPoll(ctx, id); err != nil {
47+
// handle the error
48+
}
49+
```
50+
51+
52+
### Example Usage: `ArchivesClient.Get`
53+
54+
```go
55+
ctx := context.TODO()
56+
id := archives.NewArchiveID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "packageName", "archiveName")
57+
58+
read, err := client.Get(ctx, id)
59+
if err != nil {
60+
// handle the error
61+
}
62+
if model := read.Model; model != nil {
63+
// do something with the model/response object
64+
}
65+
```
66+
67+
68+
### Example Usage: `ArchivesClient.List`
69+
70+
```go
71+
ctx := context.TODO()
72+
id := archives.NewPackageID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "packageName")
73+
74+
// alternatively `client.List(ctx, id)` can be used to do batched pagination
75+
items, err := client.ListComplete(ctx, id)
76+
if err != nil {
77+
// handle the error
78+
}
79+
for _, item := range items {
80+
// do something
81+
}
82+
```
83+
84+
85+
### Example Usage: `ArchivesClient.Update`
86+
87+
```go
88+
ctx := context.TODO()
89+
id := archives.NewArchiveID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "packageName", "archiveName")
90+
91+
payload := archives.ArchiveUpdateParameters{
92+
// ...
93+
}
94+
95+
96+
read, err := client.Update(ctx, id, payload)
97+
if err != nil {
98+
// handle the error
99+
}
100+
if model := read.Model; model != nil {
101+
// do something with the model/response object
102+
}
103+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package archives
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
7+
sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments"
8+
)
9+
10+
// Copyright (c) Microsoft Corporation. All rights reserved.
11+
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.
12+
13+
type ArchivesClient struct {
14+
Client *resourcemanager.Client
15+
}
16+
17+
func NewArchivesClientWithBaseURI(sdkApi sdkEnv.Api) (*ArchivesClient, error) {
18+
client, err := resourcemanager.NewClient(sdkApi, "archives", defaultApiVersion)
19+
if err != nil {
20+
return nil, fmt.Errorf("instantiating ArchivesClient: %+v", err)
21+
}
22+
23+
return &ArchivesClient{
24+
Client: client,
25+
}, nil
26+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
package archives
2+
3+
import (
4+
"encoding/json"
5+
"fmt"
6+
"strings"
7+
)
8+
9+
// Copyright (c) Microsoft Corporation. All rights reserved.
10+
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.
11+
12+
type PackageSourceType string
13+
14+
const (
15+
PackageSourceTypeRemote PackageSourceType = "remote"
16+
)
17+
18+
func PossibleValuesForPackageSourceType() []string {
19+
return []string{
20+
string(PackageSourceTypeRemote),
21+
}
22+
}
23+
24+
func (s *PackageSourceType) UnmarshalJSON(bytes []byte) error {
25+
var decoded string
26+
if err := json.Unmarshal(bytes, &decoded); err != nil {
27+
return fmt.Errorf("unmarshaling: %+v", err)
28+
}
29+
out, err := parsePackageSourceType(decoded)
30+
if err != nil {
31+
return fmt.Errorf("parsing %q: %+v", decoded, err)
32+
}
33+
*s = *out
34+
return nil
35+
}
36+
37+
func parsePackageSourceType(input string) (*PackageSourceType, error) {
38+
vals := map[string]PackageSourceType{
39+
"remote": PackageSourceTypeRemote,
40+
}
41+
if v, ok := vals[strings.ToLower(input)]; ok {
42+
return &v, nil
43+
}
44+
45+
// otherwise presume it's an undefined value and best-effort it
46+
out := PackageSourceType(input)
47+
return &out, nil
48+
}
49+
50+
type ProvisioningState string
51+
52+
const (
53+
ProvisioningStateCanceled ProvisioningState = "Canceled"
54+
ProvisioningStateCreating ProvisioningState = "Creating"
55+
ProvisioningStateDeleting ProvisioningState = "Deleting"
56+
ProvisioningStateFailed ProvisioningState = "Failed"
57+
ProvisioningStateSucceeded ProvisioningState = "Succeeded"
58+
ProvisioningStateUpdating ProvisioningState = "Updating"
59+
)
60+
61+
func PossibleValuesForProvisioningState() []string {
62+
return []string{
63+
string(ProvisioningStateCanceled),
64+
string(ProvisioningStateCreating),
65+
string(ProvisioningStateDeleting),
66+
string(ProvisioningStateFailed),
67+
string(ProvisioningStateSucceeded),
68+
string(ProvisioningStateUpdating),
69+
}
70+
}
71+
72+
func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error {
73+
var decoded string
74+
if err := json.Unmarshal(bytes, &decoded); err != nil {
75+
return fmt.Errorf("unmarshaling: %+v", err)
76+
}
77+
out, err := parseProvisioningState(decoded)
78+
if err != nil {
79+
return fmt.Errorf("parsing %q: %+v", decoded, err)
80+
}
81+
*s = *out
82+
return nil
83+
}
84+
85+
func parseProvisioningState(input string) (*ProvisioningState, error) {
86+
vals := map[string]ProvisioningState{
87+
"canceled": ProvisioningStateCanceled,
88+
"creating": ProvisioningStateCreating,
89+
"deleting": ProvisioningStateDeleting,
90+
"failed": ProvisioningStateFailed,
91+
"succeeded": ProvisioningStateSucceeded,
92+
"updating": ProvisioningStateUpdating,
93+
}
94+
if v, ok := vals[strings.ToLower(input)]; ok {
95+
return &v, nil
96+
}
97+
98+
// otherwise presume it's an undefined value and best-effort it
99+
out := ProvisioningState(input)
100+
return &out, nil
101+
}
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
package archives
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
7+
"github.com/hashicorp/go-azure-helpers/resourcemanager/recaser"
8+
"github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids"
9+
)
10+
11+
// Copyright (c) Microsoft Corporation. All rights reserved.
12+
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.
13+
14+
func init() {
15+
recaser.RegisterResourceId(&ArchiveId{})
16+
}
17+
18+
var _ resourceids.ResourceId = &ArchiveId{}
19+
20+
// ArchiveId is a struct representing the Resource ID for a Archive
21+
type ArchiveId struct {
22+
SubscriptionId string
23+
ResourceGroupName string
24+
RegistryName string
25+
PackageName string
26+
ArchiveName string
27+
}
28+
29+
// NewArchiveID returns a new ArchiveId struct
30+
func NewArchiveID(subscriptionId string, resourceGroupName string, registryName string, packageName string, archiveName string) ArchiveId {
31+
return ArchiveId{
32+
SubscriptionId: subscriptionId,
33+
ResourceGroupName: resourceGroupName,
34+
RegistryName: registryName,
35+
PackageName: packageName,
36+
ArchiveName: archiveName,
37+
}
38+
}
39+
40+
// ParseArchiveID parses 'input' into a ArchiveId
41+
func ParseArchiveID(input string) (*ArchiveId, error) {
42+
parser := resourceids.NewParserFromResourceIdType(&ArchiveId{})
43+
parsed, err := parser.Parse(input, false)
44+
if err != nil {
45+
return nil, fmt.Errorf("parsing %q: %+v", input, err)
46+
}
47+
48+
id := ArchiveId{}
49+
if err = id.FromParseResult(*parsed); err != nil {
50+
return nil, err
51+
}
52+
53+
return &id, nil
54+
}
55+
56+
// ParseArchiveIDInsensitively parses 'input' case-insensitively into a ArchiveId
57+
// note: this method should only be used for API response data and not user input
58+
func ParseArchiveIDInsensitively(input string) (*ArchiveId, error) {
59+
parser := resourceids.NewParserFromResourceIdType(&ArchiveId{})
60+
parsed, err := parser.Parse(input, true)
61+
if err != nil {
62+
return nil, fmt.Errorf("parsing %q: %+v", input, err)
63+
}
64+
65+
id := ArchiveId{}
66+
if err = id.FromParseResult(*parsed); err != nil {
67+
return nil, err
68+
}
69+
70+
return &id, nil
71+
}
72+
73+
func (id *ArchiveId) FromParseResult(input resourceids.ParseResult) error {
74+
var ok bool
75+
76+
if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok {
77+
return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input)
78+
}
79+
80+
if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok {
81+
return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input)
82+
}
83+
84+
if id.RegistryName, ok = input.Parsed["registryName"]; !ok {
85+
return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input)
86+
}
87+
88+
if id.PackageName, ok = input.Parsed["packageName"]; !ok {
89+
return resourceids.NewSegmentNotSpecifiedError(id, "packageName", input)
90+
}
91+
92+
if id.ArchiveName, ok = input.Parsed["archiveName"]; !ok {
93+
return resourceids.NewSegmentNotSpecifiedError(id, "archiveName", input)
94+
}
95+
96+
return nil
97+
}
98+
99+
// ValidateArchiveID checks that 'input' can be parsed as a Archive ID
100+
func ValidateArchiveID(input interface{}, key string) (warnings []string, errors []error) {
101+
v, ok := input.(string)
102+
if !ok {
103+
errors = append(errors, fmt.Errorf("expected %q to be a string", key))
104+
return
105+
}
106+
107+
if _, err := ParseArchiveID(v); err != nil {
108+
errors = append(errors, err)
109+
}
110+
111+
return
112+
}
113+
114+
// ID returns the formatted Archive ID
115+
func (id ArchiveId) ID() string {
116+
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerRegistry/registries/%s/packages/%s/archives/%s"
117+
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.PackageName, id.ArchiveName)
118+
}
119+
120+
// Segments returns a slice of Resource ID Segments which comprise this Archive ID
121+
func (id ArchiveId) Segments() []resourceids.Segment {
122+
return []resourceids.Segment{
123+
resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"),
124+
resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"),
125+
resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"),
126+
resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"),
127+
resourceids.StaticSegment("staticProviders", "providers", "providers"),
128+
resourceids.ResourceProviderSegment("staticMicrosoftContainerRegistry", "Microsoft.ContainerRegistry", "Microsoft.ContainerRegistry"),
129+
resourceids.StaticSegment("staticRegistries", "registries", "registries"),
130+
resourceids.UserSpecifiedSegment("registryName", "registryName"),
131+
resourceids.StaticSegment("staticPackages", "packages", "packages"),
132+
resourceids.UserSpecifiedSegment("packageName", "packageName"),
133+
resourceids.StaticSegment("staticArchives", "archives", "archives"),
134+
resourceids.UserSpecifiedSegment("archiveName", "archiveName"),
135+
}
136+
}
137+
138+
// String returns a human-readable description of this Archive ID
139+
func (id ArchiveId) String() string {
140+
components := []string{
141+
fmt.Sprintf("Subscription: %q", id.SubscriptionId),
142+
fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName),
143+
fmt.Sprintf("Registry Name: %q", id.RegistryName),
144+
fmt.Sprintf("Package Name: %q", id.PackageName),
145+
fmt.Sprintf("Archive Name: %q", id.ArchiveName),
146+
}
147+
return fmt.Sprintf("Archive (%s)", strings.Join(components, "\n"))
148+
}

0 commit comments

Comments
 (0)