Skip to content

Commit 5bcba23

Browse files
author
hc-github-team-tf-azure
committed
Updating based on 2786afc07
1 parent 3e57c83 commit 5bcba23

36 files changed

+880
-46
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+
}

resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_sapodplinkedservicetypeproperties.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type SapOdpLinkedServiceTypeProperties struct {
1818
Password SecretBase `json:"password"`
1919
Server *string `json:"server,omitempty"`
2020
SncLibraryPath *string `json:"sncLibraryPath,omitempty"`
21-
SncMode *string `json:"sncMode,omitempty"`
21+
SncMode *bool `json:"sncMode,omitempty"`
2222
SncMyName *string `json:"sncMyName,omitempty"`
2323
SncPartnerName *string `json:"sncPartnerName,omitempty"`
2424
SncQop *string `json:"sncQop,omitempty"`
@@ -41,7 +41,7 @@ func (s *SapOdpLinkedServiceTypeProperties) UnmarshalJSON(bytes []byte) error {
4141
MessageServerService *string `json:"messageServerService,omitempty"`
4242
Server *string `json:"server,omitempty"`
4343
SncLibraryPath *string `json:"sncLibraryPath,omitempty"`
44-
SncMode *string `json:"sncMode,omitempty"`
44+
SncMode *bool `json:"sncMode,omitempty"`
4545
SncMyName *string `json:"sncMyName,omitempty"`
4646
SncPartnerName *string `json:"sncPartnerName,omitempty"`
4747
SncQop *string `json:"sncQop,omitempty"`

resource-manager/datafactory/2018-06-01/dataflowdebugsession/model_saptablelinkedservicetypeproperties.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type SapTableLinkedServiceTypeProperties struct {
1818
Password SecretBase `json:"password"`
1919
Server *string `json:"server,omitempty"`
2020
SncLibraryPath *string `json:"sncLibraryPath,omitempty"`
21-
SncMode *string `json:"sncMode,omitempty"`
21+
SncMode *bool `json:"sncMode,omitempty"`
2222
SncMyName *string `json:"sncMyName,omitempty"`
2323
SncPartnerName *string `json:"sncPartnerName,omitempty"`
2424
SncQop *string `json:"sncQop,omitempty"`
@@ -39,7 +39,7 @@ func (s *SapTableLinkedServiceTypeProperties) UnmarshalJSON(bytes []byte) error
3939
MessageServerService *string `json:"messageServerService,omitempty"`
4040
Server *string `json:"server,omitempty"`
4141
SncLibraryPath *string `json:"sncLibraryPath,omitempty"`
42-
SncMode *string `json:"sncMode,omitempty"`
42+
SncMode *bool `json:"sncMode,omitempty"`
4343
SncMyName *string `json:"sncMyName,omitempty"`
4444
SncPartnerName *string `json:"sncPartnerName,omitempty"`
4545
SncQop *string `json:"sncQop,omitempty"`

resource-manager/datafactory/2018-06-01/linkedservices/model_sapodplinkedservicetypeproperties.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type SapOdpLinkedServiceTypeProperties struct {
1818
Password SecretBase `json:"password"`
1919
Server *string `json:"server,omitempty"`
2020
SncLibraryPath *string `json:"sncLibraryPath,omitempty"`
21-
SncMode *string `json:"sncMode,omitempty"`
21+
SncMode *bool `json:"sncMode,omitempty"`
2222
SncMyName *string `json:"sncMyName,omitempty"`
2323
SncPartnerName *string `json:"sncPartnerName,omitempty"`
2424
SncQop *string `json:"sncQop,omitempty"`
@@ -41,7 +41,7 @@ func (s *SapOdpLinkedServiceTypeProperties) UnmarshalJSON(bytes []byte) error {
4141
MessageServerService *string `json:"messageServerService,omitempty"`
4242
Server *string `json:"server,omitempty"`
4343
SncLibraryPath *string `json:"sncLibraryPath,omitempty"`
44-
SncMode *string `json:"sncMode,omitempty"`
44+
SncMode *bool `json:"sncMode,omitempty"`
4545
SncMyName *string `json:"sncMyName,omitempty"`
4646
SncPartnerName *string `json:"sncPartnerName,omitempty"`
4747
SncQop *string `json:"sncQop,omitempty"`

resource-manager/datafactory/2018-06-01/linkedservices/model_saptablelinkedservicetypeproperties.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type SapTableLinkedServiceTypeProperties struct {
1818
Password SecretBase `json:"password"`
1919
Server *string `json:"server,omitempty"`
2020
SncLibraryPath *string `json:"sncLibraryPath,omitempty"`
21-
SncMode *string `json:"sncMode,omitempty"`
21+
SncMode *bool `json:"sncMode,omitempty"`
2222
SncMyName *string `json:"sncMyName,omitempty"`
2323
SncPartnerName *string `json:"sncPartnerName,omitempty"`
2424
SncQop *string `json:"sncQop,omitempty"`
@@ -39,7 +39,7 @@ func (s *SapTableLinkedServiceTypeProperties) UnmarshalJSON(bytes []byte) error
3939
MessageServerService *string `json:"messageServerService,omitempty"`
4040
Server *string `json:"server,omitempty"`
4141
SncLibraryPath *string `json:"sncLibraryPath,omitempty"`
42-
SncMode *string `json:"sncMode,omitempty"`
42+
SncMode *bool `json:"sncMode,omitempty"`
4343
SncMyName *string `json:"sncMyName,omitempty"`
4444
SncPartnerName *string `json:"sncPartnerName,omitempty"`
4545
SncQop *string `json:"sncQop,omitempty"`

0 commit comments

Comments
 (0)