-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #700 from hashicorp/auto-pr/bda7a28c1
Auto PR: Regenerating the Go SDK (2234dc0)
- Loading branch information
Showing
21 changed files
with
1,180 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
resource-manager/authorization/2022-05-01-preview/client.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package v2022_05_01_preview | ||
|
||
// 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/authorization/2022-05-01-preview/permissions" | ||
"github.com/hashicorp/go-azure-sdk/resource-manager/authorization/2022-05-01-preview/roledefinitions" | ||
"github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" | ||
sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" | ||
) | ||
|
||
type Client struct { | ||
Permissions *permissions.PermissionsClient | ||
RoleDefinitions *roledefinitions.RoleDefinitionsClient | ||
} | ||
|
||
func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { | ||
permissionsClient, err := permissions.NewPermissionsClientWithBaseURI(sdkApi) | ||
if err != nil { | ||
return nil, fmt.Errorf("building Permissions client: %+v", err) | ||
} | ||
configureFunc(permissionsClient.Client) | ||
|
||
roleDefinitionsClient, err := roledefinitions.NewRoleDefinitionsClientWithBaseURI(sdkApi) | ||
if err != nil { | ||
return nil, fmt.Errorf("building RoleDefinitions client: %+v", err) | ||
} | ||
configureFunc(roleDefinitionsClient.Client) | ||
|
||
return &Client{ | ||
Permissions: permissionsClient, | ||
RoleDefinitions: roleDefinitionsClient, | ||
}, nil | ||
} |
54 changes: 54 additions & 0 deletions
54
resource-manager/authorization/2022-05-01-preview/permissions/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
## `github.com/hashicorp/go-azure-sdk/resource-manager/authorization/2022-05-01-preview/permissions` Documentation | ||
|
||
The `permissions` SDK allows for interaction with the Azure Resource Manager Service `authorization` (API Version `2022-05-01-preview`). | ||
|
||
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-sdk/resource-manager/authorization/2022-05-01-preview/permissions" | ||
``` | ||
|
||
|
||
### Client Initialization | ||
|
||
```go | ||
client := permissions.NewPermissionsClientWithBaseURI("https://management.azure.com") | ||
client.Client.Authorizer = authorizer | ||
``` | ||
|
||
|
||
### Example Usage: `PermissionsClient.ListForResource` | ||
|
||
```go | ||
ctx := context.TODO() | ||
id := permissions.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") | ||
|
||
// alternatively `client.ListForResource(ctx, id)` can be used to do batched pagination | ||
items, err := client.ListForResourceComplete(ctx, id) | ||
if err != nil { | ||
// handle the error | ||
} | ||
for _, item := range items { | ||
// do something | ||
} | ||
``` | ||
|
||
|
||
### Example Usage: `PermissionsClient.ListForResourceGroup` | ||
|
||
```go | ||
ctx := context.TODO() | ||
id := permissions.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") | ||
|
||
// alternatively `client.ListForResourceGroup(ctx, id)` can be used to do batched pagination | ||
items, err := client.ListForResourceGroupComplete(ctx, id) | ||
if err != nil { | ||
// handle the error | ||
} | ||
for _, item := range items { | ||
// do something | ||
} | ||
``` |
26 changes: 26 additions & 0 deletions
26
resource-manager/authorization/2022-05-01-preview/permissions/client.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package permissions | ||
|
||
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 PermissionsClient struct { | ||
Client *resourcemanager.Client | ||
} | ||
|
||
func NewPermissionsClientWithBaseURI(sdkApi sdkEnv.Api) (*PermissionsClient, error) { | ||
client, err := resourcemanager.NewResourceManagerClient(sdkApi, "permissions", defaultApiVersion) | ||
if err != nil { | ||
return nil, fmt.Errorf("instantiating PermissionsClient: %+v", err) | ||
} | ||
|
||
return &PermissionsClient{ | ||
Client: client, | ||
}, nil | ||
} |
90 changes: 90 additions & 0 deletions
90
resource-manager/authorization/2022-05-01-preview/permissions/method_listforresource.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package permissions | ||
|
||
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 ListForResourceOperationResponse struct { | ||
HttpResponse *http.Response | ||
OData *odata.OData | ||
Model *[]Permission | ||
} | ||
|
||
type ListForResourceCompleteResult struct { | ||
Items []Permission | ||
} | ||
|
||
// ListForResource ... | ||
func (c PermissionsClient) ListForResource(ctx context.Context, id commonids.ScopeId) (result ListForResourceOperationResponse, err error) { | ||
opts := client.RequestOptions{ | ||
ContentType: "application/json; charset=utf-8", | ||
ExpectedStatusCodes: []int{ | ||
http.StatusOK, | ||
}, | ||
HttpMethod: http.MethodGet, | ||
Path: fmt.Sprintf("%s/providers/Microsoft.Authorization/permissions", id.ID()), | ||
} | ||
|
||
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 *[]Permission `json:"value"` | ||
} | ||
if err = resp.Unmarshal(&values); err != nil { | ||
return | ||
} | ||
|
||
result.Model = values.Values | ||
|
||
return | ||
} | ||
|
||
// ListForResourceComplete retrieves all the results into a single object | ||
func (c PermissionsClient) ListForResourceComplete(ctx context.Context, id commonids.ScopeId) (ListForResourceCompleteResult, error) { | ||
return c.ListForResourceCompleteMatchingPredicate(ctx, id, PermissionOperationPredicate{}) | ||
} | ||
|
||
// ListForResourceCompleteMatchingPredicate retrieves all the results and then applies the predicate | ||
func (c PermissionsClient) ListForResourceCompleteMatchingPredicate(ctx context.Context, id commonids.ScopeId, predicate PermissionOperationPredicate) (result ListForResourceCompleteResult, err error) { | ||
items := make([]Permission, 0) | ||
|
||
resp, err := c.ListForResource(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 = ListForResourceCompleteResult{ | ||
Items: items, | ||
} | ||
return | ||
} |
90 changes: 90 additions & 0 deletions
90
resource-manager/authorization/2022-05-01-preview/permissions/method_listforresourcegroup.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package permissions | ||
|
||
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 ListForResourceGroupOperationResponse struct { | ||
HttpResponse *http.Response | ||
OData *odata.OData | ||
Model *[]Permission | ||
} | ||
|
||
type ListForResourceGroupCompleteResult struct { | ||
Items []Permission | ||
} | ||
|
||
// ListForResourceGroup ... | ||
func (c PermissionsClient) ListForResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListForResourceGroupOperationResponse, err error) { | ||
opts := client.RequestOptions{ | ||
ContentType: "application/json; charset=utf-8", | ||
ExpectedStatusCodes: []int{ | ||
http.StatusOK, | ||
}, | ||
HttpMethod: http.MethodGet, | ||
Path: fmt.Sprintf("%s/providers/Microsoft.Authorization/permissions", id.ID()), | ||
} | ||
|
||
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 *[]Permission `json:"value"` | ||
} | ||
if err = resp.Unmarshal(&values); err != nil { | ||
return | ||
} | ||
|
||
result.Model = values.Values | ||
|
||
return | ||
} | ||
|
||
// ListForResourceGroupComplete retrieves all the results into a single object | ||
func (c PermissionsClient) ListForResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListForResourceGroupCompleteResult, error) { | ||
return c.ListForResourceGroupCompleteMatchingPredicate(ctx, id, PermissionOperationPredicate{}) | ||
} | ||
|
||
// ListForResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate | ||
func (c PermissionsClient) ListForResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate PermissionOperationPredicate) (result ListForResourceGroupCompleteResult, err error) { | ||
items := make([]Permission, 0) | ||
|
||
resp, err := c.ListForResourceGroup(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 = ListForResourceGroupCompleteResult{ | ||
Items: items, | ||
} | ||
return | ||
} |
13 changes: 13 additions & 0 deletions
13
resource-manager/authorization/2022-05-01-preview/permissions/model_permission.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package permissions | ||
|
||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See NOTICE.txt in the project root for license information. | ||
|
||
type Permission struct { | ||
Actions *[]string `json:"actions,omitempty"` | ||
Condition *string `json:"condition,omitempty"` | ||
ConditionVersion *string `json:"conditionVersion,omitempty"` | ||
DataActions *[]string `json:"dataActions,omitempty"` | ||
NotActions *[]string `json:"notActions,omitempty"` | ||
NotDataActions *[]string `json:"notDataActions,omitempty"` | ||
} |
22 changes: 22 additions & 0 deletions
22
resource-manager/authorization/2022-05-01-preview/permissions/predicates.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package permissions | ||
|
||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See NOTICE.txt in the project root for license information. | ||
|
||
type PermissionOperationPredicate struct { | ||
Condition *string | ||
ConditionVersion *string | ||
} | ||
|
||
func (p PermissionOperationPredicate) Matches(input Permission) bool { | ||
|
||
if p.Condition != nil && (input.Condition == nil || *p.Condition != *input.Condition) { | ||
return false | ||
} | ||
|
||
if p.ConditionVersion != nil && (input.ConditionVersion == nil || *p.ConditionVersion != *input.ConditionVersion) { | ||
return false | ||
} | ||
|
||
return true | ||
} |
12 changes: 12 additions & 0 deletions
12
resource-manager/authorization/2022-05-01-preview/permissions/version.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package permissions | ||
|
||
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 = "2022-05-01-preview" | ||
|
||
func userAgent() string { | ||
return fmt.Sprintf("hashicorp/go-azure-sdk/permissions/%s", defaultApiVersion) | ||
} |
Oops, something went wrong.