Skip to content

Commit

Permalink
Merge pull request hashicorp#930 from hashicorp/auto-pr/850a7844
Browse files Browse the repository at this point in the history
Auto PR: Regenerating the Go SDK (a8cc23d)
  • Loading branch information
tombuildsstuff authored Mar 18, 2024
2 parents 42af722 + a8cc23d commit 99eaf06
Show file tree
Hide file tree
Showing 1,422 changed files with 108,289 additions and 0 deletions.
38 changes: 38 additions & 0 deletions resource-manager/newrelic/2024-03-01/accounts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

## `github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2024-03-01/accounts` Documentation

The `accounts` SDK allows for interaction with the Azure Resource Manager Service `newrelic` (API Version `2024-03-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/newrelic/2024-03-01/accounts"
```


### Client Initialization

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


### Example Usage: `AccountsClient.List`

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

// alternatively `client.List(ctx, id, accounts.DefaultListOperationOptions())` can be used to do batched pagination
items, err := client.ListComplete(ctx, id, accounts.DefaultListOperationOptions())
if err != nil {
// handle the error
}
for _, item := range items {
// do something
}
```
26 changes: 26 additions & 0 deletions resource-manager/newrelic/2024-03-01/accounts/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package accounts

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

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

return &AccountsClient{
Client: client,
}, nil
}
124 changes: 124 additions & 0 deletions resource-manager/newrelic/2024-03-01/accounts/method_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package accounts

import (
"context"
"fmt"
"net/http"

"github.com/hashicorp/go-azure-helpers/resourcemanager/commonids"
"github.com/hashicorp/go-azure-sdk/sdk/client"
"github.com/hashicorp/go-azure-sdk/sdk/odata"
)

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type ListOperationResponse struct {
HttpResponse *http.Response
OData *odata.OData
Model *[]AccountResource
}

type ListCompleteResult struct {
LatestHttpResponse *http.Response
Items []AccountResource
}

type ListOperationOptions struct {
Location *string
UserEmail *string
}

func DefaultListOperationOptions() ListOperationOptions {
return ListOperationOptions{}
}

func (o ListOperationOptions) ToHeaders() *client.Headers {
out := client.Headers{}

return &out
}

func (o ListOperationOptions) ToOData() *odata.Query {
out := odata.Query{}
return &out
}

func (o ListOperationOptions) ToQuery() *client.QueryParams {
out := client.QueryParams{}
if o.Location != nil {
out.Append("location", fmt.Sprintf("%v", *o.Location))
}
if o.UserEmail != nil {
out.Append("userEmail", fmt.Sprintf("%v", *o.UserEmail))
}
return &out
}

// List ...
func (c AccountsClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, err error) {
opts := client.RequestOptions{
ContentType: "application/json; charset=utf-8",
ExpectedStatusCodes: []int{
http.StatusOK,
},
HttpMethod: http.MethodGet,
Path: fmt.Sprintf("%s/providers/NewRelic.Observability/accounts", id.ID()),
OptionsObject: options,
}

req, err := c.Client.NewRequest(ctx, opts)
if err != nil {
return
}

var resp *client.Response
resp, err = req.ExecutePaged(ctx)
if resp != nil {
result.OData = resp.OData
result.HttpResponse = resp.Response
}
if err != nil {
return
}

var values struct {
Values *[]AccountResource `json:"value"`
}
if err = resp.Unmarshal(&values); err != nil {
return
}

result.Model = values.Values

return
}

// ListComplete retrieves all the results into a single object
func (c AccountsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) {
return c.ListCompleteMatchingPredicate(ctx, id, options, AccountResourceOperationPredicate{})
}

// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate
func (c AccountsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate AccountResourceOperationPredicate) (result ListCompleteResult, err error) {
items := make([]AccountResource, 0)

resp, err := c.List(ctx, id, options)
if err != nil {
err = fmt.Errorf("loading results: %+v", err)
return
}
if resp.Model != nil {
for _, v := range *resp.Model {
if predicate.Matches(v) {
items = append(items, v)
}
}
}

result = ListCompleteResult{
LatestHttpResponse: resp.HttpResponse,
Items: items,
}
return
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package accounts

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type AccountProperties struct {
AccountId *string `json:"accountId,omitempty"`
AccountName *string `json:"accountName,omitempty"`
OrganizationId *string `json:"organizationId,omitempty"`
Region *string `json:"region,omitempty"`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package accounts

import (
"github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata"
)

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type AccountResource struct {
Id *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Properties *AccountProperties `json:"properties,omitempty"`
SystemData *systemdata.SystemData `json:"systemData,omitempty"`
Type *string `json:"type,omitempty"`
}
27 changes: 27 additions & 0 deletions resource-manager/newrelic/2024-03-01/accounts/predicates.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package accounts

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

type AccountResourceOperationPredicate struct {
Id *string
Name *string
Type *string
}

func (p AccountResourceOperationPredicate) Matches(input AccountResource) bool {

if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) {
return false
}

if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) {
return false
}

if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) {
return false
}

return true
}
12 changes: 12 additions & 0 deletions resource-manager/newrelic/2024-03-01/accounts/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package accounts

import "fmt"

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.

const defaultApiVersion = "2024-03-01"

func userAgent() string {
return fmt.Sprintf("hashicorp/go-azure-sdk/accounts/%s", defaultApiVersion)
}
91 changes: 91 additions & 0 deletions resource-manager/newrelic/2024-03-01/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package v2024_03_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/newrelic/2024-03-01/accounts"
"github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2024-03-01/connectedresources"
"github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2024-03-01/linkedresources"
"github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2024-03-01/monitoredsubscriptions"
"github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2024-03-01/monitors"
"github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2024-03-01/organizations"
"github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2024-03-01/plan"
"github.com/hashicorp/go-azure-sdk/resource-manager/newrelic/2024-03-01/tagrules"
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager"
sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments"
)

type Client struct {
Accounts *accounts.AccountsClient
ConnectedResources *connectedresources.ConnectedResourcesClient
LinkedResources *linkedresources.LinkedResourcesClient
MonitoredSubscriptions *monitoredsubscriptions.MonitoredSubscriptionsClient
Monitors *monitors.MonitorsClient
Organizations *organizations.OrganizationsClient
Plan *plan.PlanClient
TagRules *tagrules.TagRulesClient
}

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

connectedResourcesClient, err := connectedresources.NewConnectedResourcesClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building ConnectedResources client: %+v", err)
}
configureFunc(connectedResourcesClient.Client)

linkedResourcesClient, err := linkedresources.NewLinkedResourcesClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building LinkedResources client: %+v", err)
}
configureFunc(linkedResourcesClient.Client)

monitoredSubscriptionsClient, err := monitoredsubscriptions.NewMonitoredSubscriptionsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building MonitoredSubscriptions client: %+v", err)
}
configureFunc(monitoredSubscriptionsClient.Client)

monitorsClient, err := monitors.NewMonitorsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Monitors client: %+v", err)
}
configureFunc(monitorsClient.Client)

organizationsClient, err := organizations.NewOrganizationsClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Organizations client: %+v", err)
}
configureFunc(organizationsClient.Client)

planClient, err := plan.NewPlanClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building Plan client: %+v", err)
}
configureFunc(planClient.Client)

tagRulesClient, err := tagrules.NewTagRulesClientWithBaseURI(sdkApi)
if err != nil {
return nil, fmt.Errorf("building TagRules client: %+v", err)
}
configureFunc(tagRulesClient.Client)

return &Client{
Accounts: accountsClient,
ConnectedResources: connectedResourcesClient,
LinkedResources: linkedResourcesClient,
MonitoredSubscriptions: monitoredSubscriptionsClient,
Monitors: monitorsClient,
Organizations: organizationsClient,
Plan: planClient,
TagRules: tagRulesClient,
}, nil
}
Loading

0 comments on commit 99eaf06

Please sign in to comment.