Skip to content

Commit

Permalink
Updating based on 135dd4b7
Browse files Browse the repository at this point in the history
  • Loading branch information
hc-github-team-tf-azure committed Sep 10, 2024
1 parent 4c5d3e5 commit 6654396
Show file tree
Hide file tree
Showing 218 changed files with 14,787 additions and 0 deletions.
64 changes: 64 additions & 0 deletions resource-manager/devopsinfrastructure/2024-04-04-preview/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package v2024_04_04_preview

// 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/devopsinfrastructure/2024-04-04-preview/imageversions"
"github.com/hashicorp/go-azure-sdk/resource-manager/devopsinfrastructure/2024-04-04-preview/pools"
"github.com/hashicorp/go-azure-sdk/resource-manager/devopsinfrastructure/2024-04-04-preview/resourcedetails"
"github.com/hashicorp/go-azure-sdk/resource-manager/devopsinfrastructure/2024-04-04-preview/sku"
"github.com/hashicorp/go-azure-sdk/resource-manager/devopsinfrastructure/2024-04-04-preview/subscriptionusages"
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments"
)

type Client struct {
ImageVersions *imageversions.ImageVersionsClient
Pools *pools.PoolsClient
ResourceDetails *resourcedetails.ResourceDetailsClient
Sku *sku.SkuClient
SubscriptionUsages *subscriptionusages.SubscriptionUsagesClient
}

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

poolsClient, err := pools.NewPoolsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Pools client: %+v", err)
}
configureFunc(poolsClient.Client)

resourceDetailsClient, err := resourcedetails.NewResourceDetailsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building ResourceDetails client: %+v", err)
}
configureFunc(resourceDetailsClient.Client)

skuClient, err := sku.NewSkuClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Sku client: %+v", err)
}
configureFunc(skuClient.Client)

subscriptionUsagesClient, err := subscriptionusages.NewSubscriptionUsagesClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building SubscriptionUsages client: %+v", err)
}
configureFunc(subscriptionUsagesClient.Client)

return &Client{
ImageVersions: imageVersionsClient,
Pools: poolsClient,
ResourceDetails: resourceDetailsClient,
Sku: skuClient,
SubscriptionUsages: subscriptionUsagesClient,
}, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

## `github.com/hashicorp/go-azure-sdk/resource-manager/devopsinfrastructure/2024-04-04-preview/imageversions` Documentation

The `imageversions` SDK allows for interaction with the Azure Resource Manager Service `devopsinfrastructure` (API Version `2024-04-04-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/devopsinfrastructure/2024-04-04-preview/imageversions"
```


### Client Initialization

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


### Example Usage: `ImageVersionsClient.ListByImage`

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

// alternatively `client.ListByImage(ctx, id)` can be used to do batched pagination
items, err := client.ListByImageComplete(ctx, id)
if err != nil {
// handle the error
}
for _, item := range items {
// do something
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package imageversions

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

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

return &ImageVersionsClient{
Client: client,
}, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package imageversions

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

var _ resourceids.ResourceId = &ImageId{}

// ImageId is a struct representing the Resource ID for a Image
type ImageId struct {
SubscriptionId string
ResourceGroupName string
ImageName string
}

// NewImageID returns a new ImageId struct
func NewImageID(subscriptionId string, resourceGroupName string, imageName string) ImageId {
return ImageId{
SubscriptionId: subscriptionId,
ResourceGroupName: resourceGroupName,
ImageName: imageName,
}
}

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

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

return &id, nil
}

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

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

return &id, nil
}

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

return nil
}

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

return
}

// ID returns the formatted Image ID
func (id ImageId) ID() string {
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.DevOpsInfrastructure/images/%s"
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ImageName)
}

// Segments returns a slice of Resource ID Segments which comprise this Image ID
func (id ImageId) 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("staticMicrosoftDevOpsInfrastructure", "Microsoft.DevOpsInfrastructure", "Microsoft.DevOpsInfrastructure"),
resourceids.StaticSegment("staticImages", "images", "images"),
resourceids.UserSpecifiedSegment("imageName", "imageValue"),
}
}

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

0 comments on commit 6654396

Please sign in to comment.