Skip to content

Commit

Permalink
Updating based on e29bbb4a
Browse files Browse the repository at this point in the history
  • Loading branch information
hc-github-team-tf-azure committed Feb 27, 2024
1 parent 7642acc commit c58fb27
Show file tree
Hide file tree
Showing 644 changed files with 6,472 additions and 4,358 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,12 @@ for _, item := range items {
ctx := context.TODO()
id := policyfragment.NewPolicyFragmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceValue", "policyFragmentValue")

read, err := client.ListReferences(ctx, id, policyfragment.DefaultListReferencesOperationOptions())
// alternatively `client.ListReferences(ctx, id, policyfragment.DefaultListReferencesOperationOptions())` can be used to do batched pagination
items, err := client.ListReferencesComplete(ctx, id, policyfragment.DefaultListReferencesOperationOptions())
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 ListReferencesOperationResponse struct {
HttpResponse *http.Response
OData *odata.OData
Model *ResourceCollection
Model *[]Resource
}

type ListReferencesCompleteResult struct {
LatestHttpResponse *http.Response
Items []Resource
}

type ListReferencesOperationOptions struct {
Expand Down Expand Up @@ -67,7 +72,7 @@ func (c PolicyFragmentClient) ListReferences(ctx context.Context, id PolicyFragm
}

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 @@ -76,12 +81,43 @@ func (c PolicyFragmentClient) ListReferences(ctx context.Context, id PolicyFragm
return
}

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

result.Model = values.Values

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

// ListReferencesComplete retrieves all the results into a single object
func (c PolicyFragmentClient) ListReferencesComplete(ctx context.Context, id PolicyFragmentId, options ListReferencesOperationOptions) (ListReferencesCompleteResult, error) {
return c.ListReferencesCompleteMatchingPredicate(ctx, id, options, ResourceOperationPredicate{})
}

// ListReferencesCompleteMatchingPredicate retrieves all the results and then applies the predicate
func (c PolicyFragmentClient) ListReferencesCompleteMatchingPredicate(ctx context.Context, id PolicyFragmentId, options ListReferencesOperationOptions, predicate ResourceOperationPredicate) (result ListReferencesCompleteResult, err error) {
items := make([]Resource, 0)

resp, err := c.ListReferences(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 = ListReferencesCompleteResult{
LatestHttpResponse: resp.HttpResponse,
Items: items,
}
return
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,26 @@ func (p PolicyFragmentContractOperationPredicate) Matches(input PolicyFragmentCo

return true
}

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

func (p ResourceOperationPredicate) Matches(input Resource) 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
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,13 @@ for _, item := range items {
ctx := context.TODO()
id := policyfragment.NewPolicyFragmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceValue", "policyFragmentValue")

read, err := client.ListReferences(ctx, id, policyfragment.DefaultListReferencesOperationOptions())
// alternatively `client.ListReferences(ctx, id, policyfragment.DefaultListReferencesOperationOptions())` can be used to do batched pagination
items, err := client.ListReferencesComplete(ctx, id, policyfragment.DefaultListReferencesOperationOptions())
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 Expand Up @@ -206,11 +207,12 @@ for _, item := range items {
ctx := context.TODO()
id := policyfragment.NewWorkspacePolicyFragmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceValue", "workspaceIdValue", "policyFragmentValue")

read, err := client.WorkspacePolicyFragmentListReferences(ctx, id, policyfragment.DefaultWorkspacePolicyFragmentListReferencesOperationOptions())
// alternatively `client.WorkspacePolicyFragmentListReferences(ctx, id, policyfragment.DefaultWorkspacePolicyFragmentListReferencesOperationOptions())` can be used to do batched pagination
items, err := client.WorkspacePolicyFragmentListReferencesComplete(ctx, id, policyfragment.DefaultWorkspacePolicyFragmentListReferencesOperationOptions())
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 ListReferencesOperationResponse struct {
HttpResponse *http.Response
OData *odata.OData
Model *ResourceCollection
Model *[]Resource
}

type ListReferencesCompleteResult struct {
LatestHttpResponse *http.Response
Items []Resource
}

type ListReferencesOperationOptions struct {
Expand Down Expand Up @@ -67,7 +72,7 @@ func (c PolicyFragmentClient) ListReferences(ctx context.Context, id PolicyFragm
}

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 @@ -76,12 +81,43 @@ func (c PolicyFragmentClient) ListReferences(ctx context.Context, id PolicyFragm
return
}

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

result.Model = values.Values

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

// ListReferencesComplete retrieves all the results into a single object
func (c PolicyFragmentClient) ListReferencesComplete(ctx context.Context, id PolicyFragmentId, options ListReferencesOperationOptions) (ListReferencesCompleteResult, error) {
return c.ListReferencesCompleteMatchingPredicate(ctx, id, options, ResourceOperationPredicate{})
}

// ListReferencesCompleteMatchingPredicate retrieves all the results and then applies the predicate
func (c PolicyFragmentClient) ListReferencesCompleteMatchingPredicate(ctx context.Context, id PolicyFragmentId, options ListReferencesOperationOptions, predicate ResourceOperationPredicate) (result ListReferencesCompleteResult, err error) {
items := make([]Resource, 0)

resp, err := c.ListReferences(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 = ListReferencesCompleteResult{
LatestHttpResponse: resp.HttpResponse,
Items: items,
}
return
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import (
type WorkspacePolicyFragmentListReferencesOperationResponse struct {
HttpResponse *http.Response
OData *odata.OData
Model *ResourceCollection
Model *[]Resource
}

type WorkspacePolicyFragmentListReferencesCompleteResult struct {
LatestHttpResponse *http.Response
Items []Resource
}

type WorkspacePolicyFragmentListReferencesOperationOptions struct {
Expand Down Expand Up @@ -67,7 +72,7 @@ func (c PolicyFragmentClient) WorkspacePolicyFragmentListReferences(ctx context.
}

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 @@ -76,12 +81,43 @@ func (c PolicyFragmentClient) WorkspacePolicyFragmentListReferences(ctx context.
return
}

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

result.Model = values.Values

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

// WorkspacePolicyFragmentListReferencesComplete retrieves all the results into a single object
func (c PolicyFragmentClient) WorkspacePolicyFragmentListReferencesComplete(ctx context.Context, id WorkspacePolicyFragmentId, options WorkspacePolicyFragmentListReferencesOperationOptions) (WorkspacePolicyFragmentListReferencesCompleteResult, error) {
return c.WorkspacePolicyFragmentListReferencesCompleteMatchingPredicate(ctx, id, options, ResourceOperationPredicate{})
}

// WorkspacePolicyFragmentListReferencesCompleteMatchingPredicate retrieves all the results and then applies the predicate
func (c PolicyFragmentClient) WorkspacePolicyFragmentListReferencesCompleteMatchingPredicate(ctx context.Context, id WorkspacePolicyFragmentId, options WorkspacePolicyFragmentListReferencesOperationOptions, predicate ResourceOperationPredicate) (result WorkspacePolicyFragmentListReferencesCompleteResult, err error) {
items := make([]Resource, 0)

resp, err := c.WorkspacePolicyFragmentListReferences(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 = WorkspacePolicyFragmentListReferencesCompleteResult{
LatestHttpResponse: resp.HttpResponse,
Items: items,
}
return
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,26 @@ func (p PolicyFragmentContractOperationPredicate) Matches(input PolicyFragmentCo

return true
}

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

func (p ResourceOperationPredicate) Matches(input Resource) 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
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,13 @@ for _, item := range items {
ctx := context.TODO()
id := policyfragment.NewPolicyFragmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceValue", "policyFragmentValue")

read, err := client.ListReferences(ctx, id, policyfragment.DefaultListReferencesOperationOptions())
// alternatively `client.ListReferences(ctx, id, policyfragment.DefaultListReferencesOperationOptions())` can be used to do batched pagination
items, err := client.ListReferencesComplete(ctx, id, policyfragment.DefaultListReferencesOperationOptions())
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 Expand Up @@ -206,11 +207,12 @@ for _, item := range items {
ctx := context.TODO()
id := policyfragment.NewWorkspacePolicyFragmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "serviceValue", "workspaceIdValue", "policyFragmentValue")

read, err := client.WorkspacePolicyFragmentListReferences(ctx, id, policyfragment.DefaultWorkspacePolicyFragmentListReferencesOperationOptions())
// alternatively `client.WorkspacePolicyFragmentListReferences(ctx, id, policyfragment.DefaultWorkspacePolicyFragmentListReferencesOperationOptions())` can be used to do batched pagination
items, err := client.WorkspacePolicyFragmentListReferencesComplete(ctx, id, policyfragment.DefaultWorkspacePolicyFragmentListReferencesOperationOptions())
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
}
```
Loading

0 comments on commit c58fb27

Please sign in to comment.