Skip to content

Commit

Permalink
Updating based on 6332558f4
Browse files Browse the repository at this point in the history
  • Loading branch information
hc-github-team-tf-azure committed Oct 16, 2024
1 parent 0a8354b commit 78f93ab
Show file tree
Hide file tree
Showing 340 changed files with 21,445 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@

## `github.com/hashicorp/go-azure-sdk/resource-manager/deviceregistry/2024-09-01-preview/assetendpointprofiles` Documentation

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


### Client Initialization

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


### Example Usage: `AssetEndpointProfilesClient.CreateOrReplace`

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

payload := assetendpointprofiles.AssetEndpointProfile{
// ...
}


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


### Example Usage: `AssetEndpointProfilesClient.Delete`

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

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


### Example Usage: `AssetEndpointProfilesClient.Get`

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

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: `AssetEndpointProfilesClient.ListByResourceGroup`

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

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


### Example Usage: `AssetEndpointProfilesClient.ListBySubscription`

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

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


### Example Usage: `AssetEndpointProfilesClient.Update`

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

payload := assetendpointprofiles.AssetEndpointProfileUpdate{
// ...
}


if err := client.UpdateThenPoll(ctx, id, payload); err != nil {
// handle the error
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package assetendpointprofiles

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

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

return &AssetEndpointProfilesClient{
Client: client,
}, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package assetendpointprofiles

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

const (
AuthenticationMethodAnonymous AuthenticationMethod = "Anonymous"
AuthenticationMethodCertificate AuthenticationMethod = "Certificate"
AuthenticationMethodUsernamePassword AuthenticationMethod = "UsernamePassword"
)

func PossibleValuesForAuthenticationMethod() []string {
return []string{
string(AuthenticationMethodAnonymous),
string(AuthenticationMethodCertificate),
string(AuthenticationMethodUsernamePassword),
}
}

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

func parseAuthenticationMethod(input string) (*AuthenticationMethod, error) {
vals := map[string]AuthenticationMethod{
"anonymous": AuthenticationMethodAnonymous,
"certificate": AuthenticationMethodCertificate,
"usernamepassword": AuthenticationMethodUsernamePassword,
}
if v, ok := vals[strings.ToLower(input)]; ok {
return &v, nil
}

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

type ProvisioningState string

const (
ProvisioningStateAccepted ProvisioningState = "Accepted"
ProvisioningStateCanceled ProvisioningState = "Canceled"
ProvisioningStateDeleting ProvisioningState = "Deleting"
ProvisioningStateFailed ProvisioningState = "Failed"
ProvisioningStateSucceeded ProvisioningState = "Succeeded"
)

func PossibleValuesForProvisioningState() []string {
return []string{
string(ProvisioningStateAccepted),
string(ProvisioningStateCanceled),
string(ProvisioningStateDeleting),
string(ProvisioningStateFailed),
string(ProvisioningStateSucceeded),
}
}

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{
"accepted": ProvisioningStateAccepted,
"canceled": ProvisioningStateCanceled,
"deleting": ProvisioningStateDeleting,
"failed": ProvisioningStateFailed,
"succeeded": ProvisioningStateSucceeded,
}
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,130 @@
package assetendpointprofiles

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

var _ resourceids.ResourceId = &AssetEndpointProfileId{}

// AssetEndpointProfileId is a struct representing the Resource ID for a Asset Endpoint Profile
type AssetEndpointProfileId struct {
SubscriptionId string
ResourceGroupName string
AssetEndpointProfileName string
}

// NewAssetEndpointProfileID returns a new AssetEndpointProfileId struct
func NewAssetEndpointProfileID(subscriptionId string, resourceGroupName string, assetEndpointProfileName string) AssetEndpointProfileId {
return AssetEndpointProfileId{
SubscriptionId: subscriptionId,
ResourceGroupName: resourceGroupName,
AssetEndpointProfileName: assetEndpointProfileName,
}
}

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

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

return &id, nil
}

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

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

return &id, nil
}

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

return nil
}

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

return
}

// ID returns the formatted Asset Endpoint Profile ID
func (id AssetEndpointProfileId) ID() string {
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DeviceRegistry/assetEndpointProfiles/%s"
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AssetEndpointProfileName)
}

// Segments returns a slice of Resource ID Segments which comprise this Asset Endpoint Profile ID
func (id AssetEndpointProfileId) 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("staticMicrosoftDeviceRegistry", "Microsoft.DeviceRegistry", "Microsoft.DeviceRegistry"),
resourceids.StaticSegment("staticAssetEndpointProfiles", "assetEndpointProfiles", "assetEndpointProfiles"),
resourceids.UserSpecifiedSegment("assetEndpointProfileName", "assetEndpointProfileName"),
}
}

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

0 comments on commit 78f93ab

Please sign in to comment.