Skip to content

Commit

Permalink
Updating based on a53fbbbb
Browse files Browse the repository at this point in the history
  • Loading branch information
hc-github-team-tf-azure committed Feb 26, 2024
1 parent a0da4e2 commit ab253a4
Show file tree
Hide file tree
Showing 1,045 changed files with 14,023 additions and 9,440 deletions.
7 changes: 4 additions & 3 deletions resource-manager/advisor/2020-01-01/configurations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ if model := read.Model; model != nil {
ctx := context.TODO()
id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group")

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import (
type ListByResourceGroupOperationResponse struct {
HttpResponse *http.Response
OData *odata.OData
Model *ConfigurationListResult
Model *[]ConfigData
}

type ListByResourceGroupCompleteResult struct {
LatestHttpResponse *http.Response
Items []ConfigData
}

// ListByResourceGroup ...
Expand All @@ -36,7 +41,7 @@ func (c ConfigurationsClient) ListByResourceGroup(ctx context.Context, id common
}

var resp *client.Response
resp, err = req.Execute(ctx)
resp, err = req.ExecutePaged(ctx)
if resp != nil {
result.OData = resp.OData
result.HttpResponse = resp.Response
Expand All @@ -45,12 +50,43 @@ func (c ConfigurationsClient) ListByResourceGroup(ctx context.Context, id common
return
}

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

result.Model = values.Values

if err = resp.Unmarshal(result.Model); err != nil {
return
}

// ListByResourceGroupComplete retrieves all the results into a single object
func (c ConfigurationsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) {
return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ConfigDataOperationPredicate{})
}

// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate
func (c ConfigurationsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ConfigDataOperationPredicate) (result ListByResourceGroupCompleteResult, err error) {
items := make([]ConfigData, 0)

resp, err := c.ListByResourceGroup(ctx, id)
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 = ListByResourceGroupCompleteResult{
LatestHttpResponse: resp.HttpResponse,
Items: items,
}
return
}
7 changes: 4 additions & 3 deletions resource-manager/advisor/2022-10-01/configurations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ if model := read.Model; model != nil {
ctx := context.TODO()
id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group")

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import (
type ListByResourceGroupOperationResponse struct {
HttpResponse *http.Response
OData *odata.OData
Model *ConfigurationListResult
Model *[]ConfigData
}

type ListByResourceGroupCompleteResult struct {
LatestHttpResponse *http.Response
Items []ConfigData
}

// ListByResourceGroup ...
Expand All @@ -36,7 +41,7 @@ func (c ConfigurationsClient) ListByResourceGroup(ctx context.Context, id common
}

var resp *client.Response
resp, err = req.Execute(ctx)
resp, err = req.ExecutePaged(ctx)
if resp != nil {
result.OData = resp.OData
result.HttpResponse = resp.Response
Expand All @@ -45,12 +50,43 @@ func (c ConfigurationsClient) ListByResourceGroup(ctx context.Context, id common
return
}

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

result.Model = values.Values

if err = resp.Unmarshal(result.Model); err != nil {
return
}

// ListByResourceGroupComplete retrieves all the results into a single object
func (c ConfigurationsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) {
return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ConfigDataOperationPredicate{})
}

// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate
func (c ConfigurationsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ConfigDataOperationPredicate) (result ListByResourceGroupCompleteResult, err error) {
items := make([]ConfigData, 0)

resp, err := c.ListByResourceGroup(ctx, id)
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 = ListByResourceGroupCompleteResult{
LatestHttpResponse: resp.HttpResponse,
Items: items,
}
return
}
7 changes: 4 additions & 3 deletions resource-manager/advisor/2023-01-01/configurations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ if model := read.Model; model != nil {
ctx := context.TODO()
id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group")

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import (
type ListByResourceGroupOperationResponse struct {
HttpResponse *http.Response
OData *odata.OData
Model *ConfigurationListResult
Model *[]ConfigData
}

type ListByResourceGroupCompleteResult struct {
LatestHttpResponse *http.Response
Items []ConfigData
}

// ListByResourceGroup ...
Expand All @@ -36,7 +41,7 @@ func (c ConfigurationsClient) ListByResourceGroup(ctx context.Context, id common
}

var resp *client.Response
resp, err = req.Execute(ctx)
resp, err = req.ExecutePaged(ctx)
if resp != nil {
result.OData = resp.OData
result.HttpResponse = resp.Response
Expand All @@ -45,12 +50,43 @@ func (c ConfigurationsClient) ListByResourceGroup(ctx context.Context, id common
return
}

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

result.Model = values.Values

if err = resp.Unmarshal(result.Model); err != nil {
return
}

// ListByResourceGroupComplete retrieves all the results into a single object
func (c ConfigurationsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) {
return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, ConfigDataOperationPredicate{})
}

// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate
func (c ConfigurationsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate ConfigDataOperationPredicate) (result ListByResourceGroupCompleteResult, err error) {
items := make([]ConfigData, 0)

resp, err := c.ListByResourceGroup(ctx, id)
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 = ListByResourceGroupCompleteResult{
LatestHttpResponse: resp.HttpResponse,
Items: items,
}
return
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,12 @@ if model := read.Model; model != nil {
ctx := context.TODO()
id := apioperationpolicy.NewOperationID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceValue", "apiIdValue", "operationIdValue")

read, err := client.ListByOperation(ctx, id)
// alternatively `client.ListByOperation(ctx, id)` can be used to do batched pagination
items, err := client.ListByOperationComplete(ctx, id)
if err != nil {
// handle the error
}
if model := read.Model; model != nil {
// do something with the model/response object
for _, item := range items {
// do something
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import (
type ListByOperationOperationResponse struct {
HttpResponse *http.Response
OData *odata.OData
Model *PolicyCollection
Model *[]PolicyContract
}

type ListByOperationCompleteResult struct {
LatestHttpResponse *http.Response
Items []PolicyContract
}

// ListByOperation ...
Expand All @@ -35,7 +40,7 @@ func (c ApiOperationPolicyClient) ListByOperation(ctx context.Context, id Operat
}

var resp *client.Response
resp, err = req.Execute(ctx)
resp, err = req.ExecutePaged(ctx)
if resp != nil {
result.OData = resp.OData
result.HttpResponse = resp.Response
Expand All @@ -44,12 +49,43 @@ func (c ApiOperationPolicyClient) ListByOperation(ctx context.Context, id Operat
return
}

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

result.Model = values.Values

if err = resp.Unmarshal(result.Model); err != nil {
return
}

// ListByOperationComplete retrieves all the results into a single object
func (c ApiOperationPolicyClient) ListByOperationComplete(ctx context.Context, id OperationId) (ListByOperationCompleteResult, error) {
return c.ListByOperationCompleteMatchingPredicate(ctx, id, PolicyContractOperationPredicate{})
}

// ListByOperationCompleteMatchingPredicate retrieves all the results and then applies the predicate
func (c ApiOperationPolicyClient) ListByOperationCompleteMatchingPredicate(ctx context.Context, id OperationId, predicate PolicyContractOperationPredicate) (result ListByOperationCompleteResult, err error) {
items := make([]PolicyContract, 0)

resp, err := c.ListByOperation(ctx, id)
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 = ListByOperationCompleteResult{
LatestHttpResponse: resp.HttpResponse,
Items: items,
}
return
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package apioperationpolicy

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

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

func (p PolicyContractOperationPredicate) Matches(input PolicyContract) 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
}
Loading

0 comments on commit ab253a4

Please sign in to comment.