Skip to content

Commit 29557cb

Browse files
authored
Merge pull request #1145 from hashicorp/auto-pr/4d862f147
Auto PR: Regenerating the Go SDK (77f3cc9)
2 parents 3e57c83 + 77f3cc9 commit 29557cb

File tree

263 files changed

+17337
-56
lines changed

Some content is hidden

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

263 files changed

+17337
-56
lines changed

resource-manager/datadog/2023-01-01/createresource/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ if model := read.Model; model != nil {
4343
ctx := context.TODO()
4444
id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012")
4545

46-
read, err := client.CreationSupportedList(ctx, id, createresource.DefaultCreationSupportedListOperationOptions())
46+
// alternatively `client.CreationSupportedList(ctx, id, createresource.DefaultCreationSupportedListOperationOptions())` can be used to do batched pagination
47+
items, err := client.CreationSupportedListComplete(ctx, id, createresource.DefaultCreationSupportedListOperationOptions())
4748
if err != nil {
4849
// handle the error
4950
}
50-
if model := read.Model; model != nil {
51-
// do something with the model/response object
51+
for _, item := range items {
52+
// do something
5253
}
5354
```

resource-manager/datadog/2023-01-01/createresource/method_creationsupportedlist.go

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ import (
1616
type CreationSupportedListOperationResponse struct {
1717
HttpResponse *http.Response
1818
OData *odata.OData
19-
Model *CreateResourceSupportedResponseList
19+
Model *[]CreateResourceSupportedResponse
20+
}
21+
22+
type CreationSupportedListCompleteResult struct {
23+
LatestHttpResponse *http.Response
24+
Items []CreateResourceSupportedResponse
2025
}
2126

2227
type CreationSupportedListOperationOptions struct {
@@ -47,6 +52,18 @@ func (o CreationSupportedListOperationOptions) ToQuery() *client.QueryParams {
4752
return &out
4853
}
4954

55+
type CreationSupportedListCustomPager struct {
56+
NextLink *odata.Link `json:"nextLink"`
57+
}
58+
59+
func (p *CreationSupportedListCustomPager) NextPageLink() *odata.Link {
60+
defer func() {
61+
p.NextLink = nil
62+
}()
63+
64+
return p.NextLink
65+
}
66+
5067
// CreationSupportedList ...
5168
func (c CreateResourceClient) CreationSupportedList(ctx context.Context, id commonids.SubscriptionId, options CreationSupportedListOperationOptions) (result CreationSupportedListOperationResponse, err error) {
5269
opts := client.RequestOptions{
@@ -56,6 +73,7 @@ func (c CreateResourceClient) CreationSupportedList(ctx context.Context, id comm
5673
},
5774
HttpMethod: http.MethodGet,
5875
OptionsObject: options,
76+
Pager: &CreationSupportedListCustomPager{},
5977
Path: fmt.Sprintf("%s/providers/Microsoft.Datadog/subscriptionStatuses", id.ID()),
6078
}
6179

@@ -65,7 +83,7 @@ func (c CreateResourceClient) CreationSupportedList(ctx context.Context, id comm
6583
}
6684

6785
var resp *client.Response
68-
resp, err = req.Execute(ctx)
86+
resp, err = req.ExecutePaged(ctx)
6987
if resp != nil {
7088
result.OData = resp.OData
7189
result.HttpResponse = resp.Response
@@ -74,11 +92,44 @@ func (c CreateResourceClient) CreationSupportedList(ctx context.Context, id comm
7492
return
7593
}
7694

77-
var model CreateResourceSupportedResponseList
78-
result.Model = &model
79-
if err = resp.Unmarshal(result.Model); err != nil {
95+
var values struct {
96+
Values *[]CreateResourceSupportedResponse `json:"value"`
97+
}
98+
if err = resp.Unmarshal(&values); err != nil {
8099
return
81100
}
82101

102+
result.Model = values.Values
103+
104+
return
105+
}
106+
107+
// CreationSupportedListComplete retrieves all the results into a single object
108+
func (c CreateResourceClient) CreationSupportedListComplete(ctx context.Context, id commonids.SubscriptionId, options CreationSupportedListOperationOptions) (CreationSupportedListCompleteResult, error) {
109+
return c.CreationSupportedListCompleteMatchingPredicate(ctx, id, options, CreateResourceSupportedResponseOperationPredicate{})
110+
}
111+
112+
// CreationSupportedListCompleteMatchingPredicate retrieves all the results and then applies the predicate
113+
func (c CreateResourceClient) CreationSupportedListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options CreationSupportedListOperationOptions, predicate CreateResourceSupportedResponseOperationPredicate) (result CreationSupportedListCompleteResult, err error) {
114+
items := make([]CreateResourceSupportedResponse, 0)
115+
116+
resp, err := c.CreationSupportedList(ctx, id, options)
117+
if err != nil {
118+
result.LatestHttpResponse = resp.HttpResponse
119+
err = fmt.Errorf("loading results: %+v", err)
120+
return
121+
}
122+
if resp.Model != nil {
123+
for _, v := range *resp.Model {
124+
if predicate.Matches(v) {
125+
items = append(items, v)
126+
}
127+
}
128+
}
129+
130+
result = CreationSupportedListCompleteResult{
131+
LatestHttpResponse: resp.HttpResponse,
132+
Items: items,
133+
}
83134
return
84135
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package createresource
2+
3+
// Copyright (c) Microsoft Corporation. All rights reserved.
4+
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.
5+
6+
type CreateResourceSupportedResponseOperationPredicate struct {
7+
}
8+
9+
func (p CreateResourceSupportedResponseOperationPredicate) Matches(input CreateResourceSupportedResponse) bool {
10+
11+
return true
12+
}

resource-manager/datadog/2023-01-01/monitoredsubscriptions/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,13 @@ if model := read.Model; model != nil {
7171
ctx := context.TODO()
7272
id := monitoredsubscriptions.NewMonitorID("12345678-1234-9876-4563-123456789012", "example-resource-group", "monitorName")
7373

74-
read, err := client.List(ctx, id)
74+
// alternatively `client.List(ctx, id)` can be used to do batched pagination
75+
items, err := client.ListComplete(ctx, id)
7576
if err != nil {
7677
// handle the error
7778
}
78-
if model := read.Model; model != nil {
79-
// do something with the model/response object
79+
for _, item := range items {
80+
// do something
8081
}
8182
```
8283

resource-manager/datadog/2023-01-01/monitoredsubscriptions/method_list.go

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,24 @@ import (
1515
type ListOperationResponse struct {
1616
HttpResponse *http.Response
1717
OData *odata.OData
18-
Model *MonitoredSubscriptionPropertiesList
18+
Model *[]MonitoredSubscriptionProperties
19+
}
20+
21+
type ListCompleteResult struct {
22+
LatestHttpResponse *http.Response
23+
Items []MonitoredSubscriptionProperties
24+
}
25+
26+
type ListCustomPager struct {
27+
NextLink *odata.Link `json:"nextLink"`
28+
}
29+
30+
func (p *ListCustomPager) NextPageLink() *odata.Link {
31+
defer func() {
32+
p.NextLink = nil
33+
}()
34+
35+
return p.NextLink
1936
}
2037

2138
// List ...
@@ -26,6 +43,7 @@ func (c MonitoredSubscriptionsClient) List(ctx context.Context, id MonitorId) (r
2643
http.StatusOK,
2744
},
2845
HttpMethod: http.MethodGet,
46+
Pager: &ListCustomPager{},
2947
Path: fmt.Sprintf("%s/monitoredSubscriptions", id.ID()),
3048
}
3149

@@ -35,7 +53,7 @@ func (c MonitoredSubscriptionsClient) List(ctx context.Context, id MonitorId) (r
3553
}
3654

3755
var resp *client.Response
38-
resp, err = req.Execute(ctx)
56+
resp, err = req.ExecutePaged(ctx)
3957
if resp != nil {
4058
result.OData = resp.OData
4159
result.HttpResponse = resp.Response
@@ -44,11 +62,44 @@ func (c MonitoredSubscriptionsClient) List(ctx context.Context, id MonitorId) (r
4462
return
4563
}
4664

47-
var model MonitoredSubscriptionPropertiesList
48-
result.Model = &model
49-
if err = resp.Unmarshal(result.Model); err != nil {
65+
var values struct {
66+
Values *[]MonitoredSubscriptionProperties `json:"value"`
67+
}
68+
if err = resp.Unmarshal(&values); err != nil {
5069
return
5170
}
5271

72+
result.Model = values.Values
73+
74+
return
75+
}
76+
77+
// ListComplete retrieves all the results into a single object
78+
func (c MonitoredSubscriptionsClient) ListComplete(ctx context.Context, id MonitorId) (ListCompleteResult, error) {
79+
return c.ListCompleteMatchingPredicate(ctx, id, MonitoredSubscriptionPropertiesOperationPredicate{})
80+
}
81+
82+
// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate
83+
func (c MonitoredSubscriptionsClient) ListCompleteMatchingPredicate(ctx context.Context, id MonitorId, predicate MonitoredSubscriptionPropertiesOperationPredicate) (result ListCompleteResult, err error) {
84+
items := make([]MonitoredSubscriptionProperties, 0)
85+
86+
resp, err := c.List(ctx, id)
87+
if err != nil {
88+
result.LatestHttpResponse = resp.HttpResponse
89+
err = fmt.Errorf("loading results: %+v", err)
90+
return
91+
}
92+
if resp.Model != nil {
93+
for _, v := range *resp.Model {
94+
if predicate.Matches(v) {
95+
items = append(items, v)
96+
}
97+
}
98+
}
99+
100+
result = ListCompleteResult{
101+
LatestHttpResponse: resp.HttpResponse,
102+
Items: items,
103+
}
53104
return
54105
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package monitoredsubscriptions
2+
3+
// Copyright (c) Microsoft Corporation. All rights reserved.
4+
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.
5+
6+
type MonitoredSubscriptionPropertiesOperationPredicate struct {
7+
Id *string
8+
Name *string
9+
Type *string
10+
}
11+
12+
func (p MonitoredSubscriptionPropertiesOperationPredicate) Matches(input MonitoredSubscriptionProperties) bool {
13+
14+
if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) {
15+
return false
16+
}
17+
18+
if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) {
19+
return false
20+
}
21+
22+
if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) {
23+
return false
24+
}
25+
26+
return true
27+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
## `github.com/hashicorp/go-azure-sdk/resource-manager/datadog/2023-10-20/agreements` Documentation
3+
4+
The `agreements` SDK allows for interaction with Azure Resource Manager `datadog` (API Version `2023-10-20`).
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-helpers/resourcemanager/commonids"
12+
import "github.com/hashicorp/go-azure-sdk/resource-manager/datadog/2023-10-20/agreements"
13+
```
14+
15+
16+
### Client Initialization
17+
18+
```go
19+
client := agreements.NewAgreementsClientWithBaseURI("https://management.azure.com")
20+
client.Client.Authorizer = authorizer
21+
```
22+
23+
24+
### Example Usage: `AgreementsClient.MarketplaceAgreementsCreateOrUpdate`
25+
26+
```go
27+
ctx := context.TODO()
28+
id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012")
29+
30+
payload := agreements.DatadogAgreementResource{
31+
// ...
32+
}
33+
34+
35+
read, err := client.MarketplaceAgreementsCreateOrUpdate(ctx, id, payload)
36+
if err != nil {
37+
// handle the error
38+
}
39+
if model := read.Model; model != nil {
40+
// do something with the model/response object
41+
}
42+
```
43+
44+
45+
### Example Usage: `AgreementsClient.MarketplaceAgreementsList`
46+
47+
```go
48+
ctx := context.TODO()
49+
id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012")
50+
51+
// alternatively `client.MarketplaceAgreementsList(ctx, id)` can be used to do batched pagination
52+
items, err := client.MarketplaceAgreementsListComplete(ctx, id)
53+
if err != nil {
54+
// handle the error
55+
}
56+
for _, item := range items {
57+
// do something
58+
}
59+
```
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package agreements
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 AgreementsClient struct {
14+
Client *resourcemanager.Client
15+
}
16+
17+
func NewAgreementsClientWithBaseURI(sdkApi sdkEnv.Api) (*AgreementsClient, error) {
18+
client, err := resourcemanager.NewClient(sdkApi, "agreements", defaultApiVersion)
19+
if err != nil {
20+
return nil, fmt.Errorf("instantiating AgreementsClient: %+v", err)
21+
}
22+
23+
return &AgreementsClient{
24+
Client: client,
25+
}, nil
26+
}

0 commit comments

Comments
 (0)