From 7861ea0515e6dac3dfab9860c53eee0932fd392f Mon Sep 17 00:00:00 2001 From: hc-github-team-tf-azure <> Date: Tue, 16 Apr 2024 06:12:24 +0000 Subject: [PATCH] Updating based on 6e5cf5d2 --- .../resources/2024-04-01/client.go | 28 +++ .../2024-04-01/policyassignments/README.md | 237 ++++++++++++++++++ .../2024-04-01/policyassignments/client.go | 26 ++ .../2024-04-01/policyassignments/constants.go | 136 ++++++++++ .../id_policyassignmentid.go | 109 ++++++++ .../id_policyassignmentid_test.go | 147 +++++++++++ .../id_scopedpolicyassignment.go | 120 +++++++++ .../id_scopedpolicyassignment_test.go | 222 ++++++++++++++++ .../policyassignments/method_create.go | 58 +++++ .../policyassignments/method_createbyid.go | 58 +++++ .../policyassignments/method_delete.go | 55 ++++ .../policyassignments/method_deletebyid.go | 55 ++++ .../policyassignments/method_get.go | 54 ++++ .../policyassignments/method_getbyid.go | 54 ++++ .../policyassignments/method_list.go | 124 +++++++++ .../method_listformanagementgroup.go | 124 +++++++++ .../method_listforresource.go | 124 +++++++++ .../method_listforresourcegroup.go | 124 +++++++++ .../policyassignments/method_update.go | 58 +++++ .../policyassignments/method_updatebyid.go | 58 +++++ .../model_noncompliancemessage.go | 9 + .../policyassignments/model_override.go | 10 + .../model_parametervaluesvalue.go | 8 + .../model_policyassignment.go | 19 ++ .../model_policyassignmentproperties.go | 19 ++ .../model_policyassignmentupdate.go | 14 ++ .../model_policyassignmentupdateproperties.go | 9 + .../model_resourceselector.go | 9 + .../policyassignments/model_selector.go | 10 + .../policyassignments/predicates.go | 32 +++ .../2024-04-01/policyassignments/version.go | 12 + 31 files changed, 2122 insertions(+) create mode 100644 resource-manager/resources/2024-04-01/client.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/README.md create mode 100644 resource-manager/resources/2024-04-01/policyassignments/client.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/constants.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/id_policyassignmentid.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/id_policyassignmentid_test.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/id_scopedpolicyassignment.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/id_scopedpolicyassignment_test.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/method_create.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/method_createbyid.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/method_delete.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/method_deletebyid.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/method_get.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/method_getbyid.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/method_list.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/method_listformanagementgroup.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/method_listforresource.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/method_listforresourcegroup.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/method_update.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/method_updatebyid.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/model_noncompliancemessage.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/model_override.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/model_parametervaluesvalue.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/model_policyassignment.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentproperties.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentupdate.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentupdateproperties.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/model_resourceselector.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/model_selector.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/predicates.go create mode 100644 resource-manager/resources/2024-04-01/policyassignments/version.go diff --git a/resource-manager/resources/2024-04-01/client.go b/resource-manager/resources/2024-04-01/client.go new file mode 100644 index 00000000000..18712d7101d --- /dev/null +++ b/resource-manager/resources/2024-04-01/client.go @@ -0,0 +1,28 @@ +package v2024_04_01 + +// 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/resources/2024-04-01/policyassignments" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + PolicyAssignments *policyassignments.PolicyAssignmentsClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + policyAssignmentsClient, err := policyassignments.NewPolicyAssignmentsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PolicyAssignments client: %+v", err) + } + configureFunc(policyAssignmentsClient.Client) + + return &Client{ + PolicyAssignments: policyAssignmentsClient, + }, nil +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/README.md b/resource-manager/resources/2024-04-01/policyassignments/README.md new file mode 100644 index 00000000000..032bcec408e --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/README.md @@ -0,0 +1,237 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/resources/2024-04-01/policyassignments` Documentation + +The `policyassignments` SDK allows for interaction with the Azure Resource Manager Service `resources` (API Version `2024-04-01`). + +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-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2024-04-01/policyassignments" +``` + + +### Client Initialization + +```go +client := policyassignments.NewPolicyAssignmentsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PolicyAssignmentsClient.Create` + +```go +ctx := context.TODO() +id := policyassignments.NewScopedPolicyAssignmentID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "policyAssignmentValue") + +payload := policyassignments.PolicyAssignment{ + // ... +} + + +read, err := client.Create(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyAssignmentsClient.CreateById` + +```go +ctx := context.TODO() +id := policyassignments.NewPolicyAssignmentIdID("policyAssignmentIdValue") + +payload := policyassignments.PolicyAssignment{ + // ... +} + + +read, err := client.CreateById(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyAssignmentsClient.Delete` + +```go +ctx := context.TODO() +id := policyassignments.NewScopedPolicyAssignmentID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "policyAssignmentValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyAssignmentsClient.DeleteById` + +```go +ctx := context.TODO() +id := policyassignments.NewPolicyAssignmentIdID("policyAssignmentIdValue") + +read, err := client.DeleteById(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyAssignmentsClient.Get` + +```go +ctx := context.TODO() +id := policyassignments.NewScopedPolicyAssignmentID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "policyAssignmentValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyAssignmentsClient.GetById` + +```go +ctx := context.TODO() +id := policyassignments.NewPolicyAssignmentIdID("policyAssignmentIdValue") + +read, err := client.GetById(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyAssignmentsClient.List` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.List(ctx, id, policyassignments.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, policyassignments.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyAssignmentsClient.ListForManagementGroup` + +```go +ctx := context.TODO() +id := commonids.NewManagementGroupID("groupIdValue") + +// alternatively `client.ListForManagementGroup(ctx, id, policyassignments.DefaultListForManagementGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListForManagementGroupComplete(ctx, id, policyassignments.DefaultListForManagementGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyAssignmentsClient.ListForResource` + +```go +ctx := context.TODO() +id := commonids.NewScopeID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + +// alternatively `client.ListForResource(ctx, id, policyassignments.DefaultListForResourceOperationOptions())` can be used to do batched pagination +items, err := client.ListForResourceComplete(ctx, id, policyassignments.DefaultListForResourceOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyAssignmentsClient.ListForResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListForResourceGroup(ctx, id, policyassignments.DefaultListForResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListForResourceGroupComplete(ctx, id, policyassignments.DefaultListForResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `PolicyAssignmentsClient.Update` + +```go +ctx := context.TODO() +id := policyassignments.NewScopedPolicyAssignmentID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "policyAssignmentValue") + +payload := policyassignments.PolicyAssignmentUpdate{ + // ... +} + + +read, err := client.Update(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `PolicyAssignmentsClient.UpdateById` + +```go +ctx := context.TODO() +id := policyassignments.NewPolicyAssignmentIdID("policyAssignmentIdValue") + +payload := policyassignments.PolicyAssignmentUpdate{ + // ... +} + + +read, err := client.UpdateById(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/resources/2024-04-01/policyassignments/client.go b/resource-manager/resources/2024-04-01/policyassignments/client.go new file mode 100644 index 00000000000..8e17cddc4c7 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/client.go @@ -0,0 +1,26 @@ +package policyassignments + +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 PolicyAssignmentsClient struct { + Client *resourcemanager.Client +} + +func NewPolicyAssignmentsClientWithBaseURI(sdkApi sdkEnv.Api) (*PolicyAssignmentsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "policyassignments", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating PolicyAssignmentsClient: %+v", err) + } + + return &PolicyAssignmentsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/constants.go b/resource-manager/resources/2024-04-01/policyassignments/constants.go new file mode 100644 index 00000000000..15d2935dcd7 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/constants.go @@ -0,0 +1,136 @@ +package policyassignments + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnforcementMode string + +const ( + EnforcementModeDefault EnforcementMode = "Default" + EnforcementModeDoNotEnforce EnforcementMode = "DoNotEnforce" +) + +func PossibleValuesForEnforcementMode() []string { + return []string{ + string(EnforcementModeDefault), + string(EnforcementModeDoNotEnforce), + } +} + +func (s *EnforcementMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnforcementMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnforcementMode(input string) (*EnforcementMode, error) { + vals := map[string]EnforcementMode{ + "default": EnforcementModeDefault, + "donotenforce": EnforcementModeDoNotEnforce, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnforcementMode(input) + return &out, nil +} + +type OverrideKind string + +const ( + OverrideKindPolicyEffect OverrideKind = "policyEffect" +) + +func PossibleValuesForOverrideKind() []string { + return []string{ + string(OverrideKindPolicyEffect), + } +} + +func (s *OverrideKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOverrideKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOverrideKind(input string) (*OverrideKind, error) { + vals := map[string]OverrideKind{ + "policyeffect": OverrideKindPolicyEffect, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OverrideKind(input) + return &out, nil +} + +type SelectorKind string + +const ( + SelectorKindPolicyDefinitionReferenceId SelectorKind = "policyDefinitionReferenceId" + SelectorKindResourceLocation SelectorKind = "resourceLocation" + SelectorKindResourceType SelectorKind = "resourceType" + SelectorKindResourceWithoutLocation SelectorKind = "resourceWithoutLocation" +) + +func PossibleValuesForSelectorKind() []string { + return []string{ + string(SelectorKindPolicyDefinitionReferenceId), + string(SelectorKindResourceLocation), + string(SelectorKindResourceType), + string(SelectorKindResourceWithoutLocation), + } +} + +func (s *SelectorKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSelectorKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSelectorKind(input string) (*SelectorKind, error) { + vals := map[string]SelectorKind{ + "policydefinitionreferenceid": SelectorKindPolicyDefinitionReferenceId, + "resourcelocation": SelectorKindResourceLocation, + "resourcetype": SelectorKindResourceType, + "resourcewithoutlocation": SelectorKindResourceWithoutLocation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SelectorKind(input) + return &out, nil +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/id_policyassignmentid.go b/resource-manager/resources/2024-04-01/policyassignments/id_policyassignmentid.go new file mode 100644 index 00000000000..dd4c7ddf9b7 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/id_policyassignmentid.go @@ -0,0 +1,109 @@ +package policyassignments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&PolicyAssignmentIdId{}) +} + +var _ resourceids.ResourceId = &PolicyAssignmentIdId{} + +// PolicyAssignmentIdId is a struct representing the Resource ID for a Policy Assignment Id +type PolicyAssignmentIdId struct { + PolicyAssignmentId string +} + +// NewPolicyAssignmentIdID returns a new PolicyAssignmentIdId struct +func NewPolicyAssignmentIdID(policyAssignmentId string) PolicyAssignmentIdId { + return PolicyAssignmentIdId{ + PolicyAssignmentId: policyAssignmentId, + } +} + +// ParsePolicyAssignmentIdID parses 'input' into a PolicyAssignmentIdId +func ParsePolicyAssignmentIdID(input string) (*PolicyAssignmentIdId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyAssignmentIdId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyAssignmentIdId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParsePolicyAssignmentIdIDInsensitively parses 'input' case-insensitively into a PolicyAssignmentIdId +// note: this method should only be used for API response data and not user input +func ParsePolicyAssignmentIdIDInsensitively(input string) (*PolicyAssignmentIdId, error) { + parser := resourceids.NewParserFromResourceIdType(&PolicyAssignmentIdId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := PolicyAssignmentIdId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *PolicyAssignmentIdId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.PolicyAssignmentId, ok = input.Parsed["policyAssignmentId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyAssignmentId", input) + } + + return nil +} + +// ValidatePolicyAssignmentIdID checks that 'input' can be parsed as a Policy Assignment Id ID +func ValidatePolicyAssignmentIdID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParsePolicyAssignmentIdID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Policy Assignment Id ID +func (id PolicyAssignmentIdId) ID() string { + fmtString := "/%s" + return fmt.Sprintf(fmtString, id.PolicyAssignmentId) +} + +// Segments returns a slice of Resource ID Segments which comprise this Policy Assignment Id ID +func (id PolicyAssignmentIdId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.UserSpecifiedSegment("policyAssignmentId", "policyAssignmentIdValue"), + } +} + +// String returns a human-readable description of this Policy Assignment Id ID +func (id PolicyAssignmentIdId) String() string { + components := []string{ + fmt.Sprintf("Policy Assignment: %q", id.PolicyAssignmentId), + } + return fmt.Sprintf("Policy Assignment Id (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/id_policyassignmentid_test.go b/resource-manager/resources/2024-04-01/policyassignments/id_policyassignmentid_test.go new file mode 100644 index 00000000000..604fe6149ad --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/id_policyassignmentid_test.go @@ -0,0 +1,147 @@ +package policyassignments + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &PolicyAssignmentIdId{} + +func TestNewPolicyAssignmentIdID(t *testing.T) { + id := NewPolicyAssignmentIdID("policyAssignmentIdValue") + + if id.PolicyAssignmentId != "policyAssignmentIdValue" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyAssignmentId'", id.PolicyAssignmentId, "policyAssignmentIdValue") + } +} + +func TestFormatPolicyAssignmentIdID(t *testing.T) { + actual := NewPolicyAssignmentIdID("policyAssignmentIdValue").ID() + expected := "/policyAssignmentIdValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParsePolicyAssignmentIdID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyAssignmentIdId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Valid URI + Input: "/policyAssignmentIdValue", + Expected: &PolicyAssignmentIdId{ + PolicyAssignmentId: "policyAssignmentIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/policyAssignmentIdValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyAssignmentIdID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicyAssignmentId != v.Expected.PolicyAssignmentId { + t.Fatalf("Expected %q but got %q for PolicyAssignmentId", v.Expected.PolicyAssignmentId, actual.PolicyAssignmentId) + } + + } +} + +func TestParsePolicyAssignmentIdIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *PolicyAssignmentIdId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Valid URI + Input: "/policyAssignmentIdValue", + Expected: &PolicyAssignmentIdId{ + PolicyAssignmentId: "policyAssignmentIdValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/policyAssignmentIdValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/pOlIcYaSsIgNmEnTiDvAlUe", + Expected: &PolicyAssignmentIdId{ + PolicyAssignmentId: "pOlIcYaSsIgNmEnTiDvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/pOlIcYaSsIgNmEnTiDvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParsePolicyAssignmentIdIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.PolicyAssignmentId != v.Expected.PolicyAssignmentId { + t.Fatalf("Expected %q but got %q for PolicyAssignmentId", v.Expected.PolicyAssignmentId, actual.PolicyAssignmentId) + } + + } +} + +func TestSegmentsForPolicyAssignmentIdId(t *testing.T) { + segments := PolicyAssignmentIdId{}.Segments() + if len(segments) == 0 { + t.Fatalf("PolicyAssignmentIdId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/id_scopedpolicyassignment.go b/resource-manager/resources/2024-04-01/policyassignments/id_scopedpolicyassignment.go new file mode 100644 index 00000000000..2ed810504d2 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/id_scopedpolicyassignment.go @@ -0,0 +1,120 @@ +package policyassignments + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ScopedPolicyAssignmentId{}) +} + +var _ resourceids.ResourceId = &ScopedPolicyAssignmentId{} + +// ScopedPolicyAssignmentId is a struct representing the Resource ID for a Scoped Policy Assignment +type ScopedPolicyAssignmentId struct { + Scope string + PolicyAssignmentName string +} + +// NewScopedPolicyAssignmentID returns a new ScopedPolicyAssignmentId struct +func NewScopedPolicyAssignmentID(scope string, policyAssignmentName string) ScopedPolicyAssignmentId { + return ScopedPolicyAssignmentId{ + Scope: scope, + PolicyAssignmentName: policyAssignmentName, + } +} + +// ParseScopedPolicyAssignmentID parses 'input' into a ScopedPolicyAssignmentId +func ParseScopedPolicyAssignmentID(input string) (*ScopedPolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopedPolicyAssignmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopedPolicyAssignmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseScopedPolicyAssignmentIDInsensitively parses 'input' case-insensitively into a ScopedPolicyAssignmentId +// note: this method should only be used for API response data and not user input +func ParseScopedPolicyAssignmentIDInsensitively(input string) (*ScopedPolicyAssignmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScopedPolicyAssignmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScopedPolicyAssignmentId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ScopedPolicyAssignmentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.Scope, ok = input.Parsed["scope"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "scope", input) + } + + if id.PolicyAssignmentName, ok = input.Parsed["policyAssignmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "policyAssignmentName", input) + } + + return nil +} + +// ValidateScopedPolicyAssignmentID checks that 'input' can be parsed as a Scoped Policy Assignment ID +func ValidateScopedPolicyAssignmentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseScopedPolicyAssignmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Scoped Policy Assignment ID +func (id ScopedPolicyAssignmentId) ID() string { + fmtString := "/%s/providers/Microsoft.Authorization/policyAssignments/%s" + return fmt.Sprintf(fmtString, strings.TrimPrefix(id.Scope, "/"), id.PolicyAssignmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Scoped Policy Assignment ID +func (id ScopedPolicyAssignmentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.ScopeSegment("scope", "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticPolicyAssignments", "policyAssignments", "policyAssignments"), + resourceids.UserSpecifiedSegment("policyAssignmentName", "policyAssignmentValue"), + } +} + +// String returns a human-readable description of this Scoped Policy Assignment ID +func (id ScopedPolicyAssignmentId) String() string { + components := []string{ + fmt.Sprintf("Scope: %q", id.Scope), + fmt.Sprintf("Policy Assignment Name: %q", id.PolicyAssignmentName), + } + return fmt.Sprintf("Scoped Policy Assignment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/id_scopedpolicyassignment_test.go b/resource-manager/resources/2024-04-01/policyassignments/id_scopedpolicyassignment_test.go new file mode 100644 index 00000000000..30d20edc8cc --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/id_scopedpolicyassignment_test.go @@ -0,0 +1,222 @@ +package policyassignments + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ScopedPolicyAssignmentId{} + +func TestNewScopedPolicyAssignmentID(t *testing.T) { + id := NewScopedPolicyAssignmentID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "policyAssignmentValue") + + if id.Scope != "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'Scope'", id.Scope, "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group") + } + + if id.PolicyAssignmentName != "policyAssignmentValue" { + t.Fatalf("Expected %q but got %q for Segment 'PolicyAssignmentName'", id.PolicyAssignmentName, "policyAssignmentValue") + } +} + +func TestFormatScopedPolicyAssignmentID(t *testing.T) { + actual := NewScopedPolicyAssignmentID("/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", "policyAssignmentValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseScopedPolicyAssignmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopedPolicyAssignmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentValue", + Expected: &ScopedPolicyAssignmentId{ + Scope: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + PolicyAssignmentName: "policyAssignmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopedPolicyAssignmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.Scope != v.Expected.Scope { + t.Fatalf("Expected %q but got %q for Scope", v.Expected.Scope, actual.Scope) + } + + if actual.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestParseScopedPolicyAssignmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScopedPolicyAssignmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization/policyAssignments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentValue", + Expected: &ScopedPolicyAssignmentId{ + Scope: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group", + PolicyAssignmentName: "policyAssignmentValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/some-resource-group/providers/Microsoft.Authorization/policyAssignments/policyAssignmentValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTvAlUe", + Expected: &ScopedPolicyAssignmentId{ + Scope: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp", + PolicyAssignmentName: "pOlIcYaSsIgNmEnTvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/sOmE-ReSoUrCe-gRoUp/pRoViDeRs/mIcRoSoFt.aUtHoRiZaTiOn/pOlIcYaSsIgNmEnTs/pOlIcYaSsIgNmEnTvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScopedPolicyAssignmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.Scope != v.Expected.Scope { + t.Fatalf("Expected %q but got %q for Scope", v.Expected.Scope, actual.Scope) + } + + if actual.PolicyAssignmentName != v.Expected.PolicyAssignmentName { + t.Fatalf("Expected %q but got %q for PolicyAssignmentName", v.Expected.PolicyAssignmentName, actual.PolicyAssignmentName) + } + + } +} + +func TestSegmentsForScopedPolicyAssignmentId(t *testing.T) { + segments := ScopedPolicyAssignmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ScopedPolicyAssignmentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/method_create.go b/resource-manager/resources/2024-04-01/policyassignments/method_create.go new file mode 100644 index 00000000000..a532f7d9a19 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/method_create.go @@ -0,0 +1,58 @@ +package policyassignments + +import ( + "context" + "net/http" + + "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 CreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyAssignment +} + +// Create ... +func (c PolicyAssignmentsClient) Create(ctx context.Context, id ScopedPolicyAssignmentId, input PolicyAssignment) (result CreateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PolicyAssignment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/method_createbyid.go b/resource-manager/resources/2024-04-01/policyassignments/method_createbyid.go new file mode 100644 index 00000000000..674d24a20ae --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/method_createbyid.go @@ -0,0 +1,58 @@ +package policyassignments + +import ( + "context" + "net/http" + + "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 CreateByIdOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyAssignment +} + +// CreateById ... +func (c PolicyAssignmentsClient) CreateById(ctx context.Context, id PolicyAssignmentIdId, input PolicyAssignment) (result CreateByIdOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PolicyAssignment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/method_delete.go b/resource-manager/resources/2024-04-01/policyassignments/method_delete.go new file mode 100644 index 00000000000..34fe8c30441 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/method_delete.go @@ -0,0 +1,55 @@ +package policyassignments + +import ( + "context" + "net/http" + + "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 DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyAssignment +} + +// Delete ... +func (c PolicyAssignmentsClient) Delete(ctx context.Context, id ScopedPolicyAssignmentId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PolicyAssignment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/method_deletebyid.go b/resource-manager/resources/2024-04-01/policyassignments/method_deletebyid.go new file mode 100644 index 00000000000..ef64fb62032 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/method_deletebyid.go @@ -0,0 +1,55 @@ +package policyassignments + +import ( + "context" + "net/http" + + "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 DeleteByIdOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyAssignment +} + +// DeleteById ... +func (c PolicyAssignmentsClient) DeleteById(ctx context.Context, id PolicyAssignmentIdId) (result DeleteByIdOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PolicyAssignment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/method_get.go b/resource-manager/resources/2024-04-01/policyassignments/method_get.go new file mode 100644 index 00000000000..9e8e5bbce83 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/method_get.go @@ -0,0 +1,54 @@ +package policyassignments + +import ( + "context" + "net/http" + + "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 GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyAssignment +} + +// Get ... +func (c PolicyAssignmentsClient) Get(ctx context.Context, id ScopedPolicyAssignmentId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PolicyAssignment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/method_getbyid.go b/resource-manager/resources/2024-04-01/policyassignments/method_getbyid.go new file mode 100644 index 00000000000..8f0a663b93d --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/method_getbyid.go @@ -0,0 +1,54 @@ +package policyassignments + +import ( + "context" + "net/http" + + "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 GetByIdOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyAssignment +} + +// GetById ... +func (c PolicyAssignmentsClient) GetById(ctx context.Context, id PolicyAssignmentIdId) (result GetByIdOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PolicyAssignment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/method_list.go b/resource-manager/resources/2024-04-01/policyassignments/method_list.go new file mode 100644 index 00000000000..6da10909dce --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/method_list.go @@ -0,0 +1,124 @@ +package policyassignments + +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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyAssignment +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyAssignment +} + +type ListOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// List ... +func (c PolicyAssignmentsClient) List(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (result ListOperationResponse, 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/policyAssignments", id.ID()), + OptionsObject: options, + } + + 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 *[]PolicyAssignment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListComplete retrieves all the results into a single object +func (c PolicyAssignmentsClient) ListComplete(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, PolicyAssignmentOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyAssignmentsClient) ListCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListOperationOptions, predicate PolicyAssignmentOperationPredicate) (result ListCompleteResult, err error) { + items := make([]PolicyAssignment, 0) + + resp, err := c.List(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 = ListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/method_listformanagementgroup.go b/resource-manager/resources/2024-04-01/policyassignments/method_listformanagementgroup.go new file mode 100644 index 00000000000..06cd5c52adc --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/method_listformanagementgroup.go @@ -0,0 +1,124 @@ +package policyassignments + +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 ListForManagementGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]PolicyAssignment +} + +type ListForManagementGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyAssignment +} + +type ListForManagementGroupOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListForManagementGroupOperationOptions() ListForManagementGroupOperationOptions { + return ListForManagementGroupOperationOptions{} +} + +func (o ListForManagementGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListForManagementGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListForManagementGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListForManagementGroup ... +func (c PolicyAssignmentsClient) ListForManagementGroup(ctx context.Context, id commonids.ManagementGroupId, options ListForManagementGroupOperationOptions) (result ListForManagementGroupOperationResponse, 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/policyAssignments", id.ID()), + OptionsObject: options, + } + + 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 *[]PolicyAssignment `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListForManagementGroupComplete retrieves all the results into a single object +func (c PolicyAssignmentsClient) ListForManagementGroupComplete(ctx context.Context, id commonids.ManagementGroupId, options ListForManagementGroupOperationOptions) (ListForManagementGroupCompleteResult, error) { + return c.ListForManagementGroupCompleteMatchingPredicate(ctx, id, options, PolicyAssignmentOperationPredicate{}) +} + +// ListForManagementGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyAssignmentsClient) ListForManagementGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ManagementGroupId, options ListForManagementGroupOperationOptions, predicate PolicyAssignmentOperationPredicate) (result ListForManagementGroupCompleteResult, err error) { + items := make([]PolicyAssignment, 0) + + resp, err := c.ListForManagementGroup(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 = ListForManagementGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/method_listforresource.go b/resource-manager/resources/2024-04-01/policyassignments/method_listforresource.go new file mode 100644 index 00000000000..be396473df0 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/method_listforresource.go @@ -0,0 +1,124 @@ +package policyassignments + +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 *[]PolicyAssignment +} + +type ListForResourceCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyAssignment +} + +type ListForResourceOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListForResourceOperationOptions() ListForResourceOperationOptions { + return ListForResourceOperationOptions{} +} + +func (o ListForResourceOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListForResourceOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListForResourceOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListForResource ... +func (c PolicyAssignmentsClient) ListForResource(ctx context.Context, id commonids.ScopeId, options ListForResourceOperationOptions) (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/policyAssignments", id.ID()), + OptionsObject: options, + } + + 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 *[]PolicyAssignment `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 PolicyAssignmentsClient) ListForResourceComplete(ctx context.Context, id commonids.ScopeId, options ListForResourceOperationOptions) (ListForResourceCompleteResult, error) { + return c.ListForResourceCompleteMatchingPredicate(ctx, id, options, PolicyAssignmentOperationPredicate{}) +} + +// ListForResourceCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyAssignmentsClient) ListForResourceCompleteMatchingPredicate(ctx context.Context, id commonids.ScopeId, options ListForResourceOperationOptions, predicate PolicyAssignmentOperationPredicate) (result ListForResourceCompleteResult, err error) { + items := make([]PolicyAssignment, 0) + + resp, err := c.ListForResource(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 = ListForResourceCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/method_listforresourcegroup.go b/resource-manager/resources/2024-04-01/policyassignments/method_listforresourcegroup.go new file mode 100644 index 00000000000..bb3bd6a3086 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/method_listforresourcegroup.go @@ -0,0 +1,124 @@ +package policyassignments + +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 *[]PolicyAssignment +} + +type ListForResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []PolicyAssignment +} + +type ListForResourceGroupOperationOptions struct { + Filter *string + Top *int64 +} + +func DefaultListForResourceGroupOperationOptions() ListForResourceGroupOperationOptions { + return ListForResourceGroupOperationOptions{} +} + +func (o ListForResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListForResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + return &out +} + +func (o ListForResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Filter != nil { + out.Append("$filter", fmt.Sprintf("%v", *o.Filter)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +// ListForResourceGroup ... +func (c PolicyAssignmentsClient) ListForResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListForResourceGroupOperationOptions) (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/policyAssignments", id.ID()), + OptionsObject: options, + } + + 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 *[]PolicyAssignment `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 PolicyAssignmentsClient) ListForResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListForResourceGroupOperationOptions) (ListForResourceGroupCompleteResult, error) { + return c.ListForResourceGroupCompleteMatchingPredicate(ctx, id, options, PolicyAssignmentOperationPredicate{}) +} + +// ListForResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c PolicyAssignmentsClient) ListForResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListForResourceGroupOperationOptions, predicate PolicyAssignmentOperationPredicate) (result ListForResourceGroupCompleteResult, err error) { + items := make([]PolicyAssignment, 0) + + resp, err := c.ListForResourceGroup(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 = ListForResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/method_update.go b/resource-manager/resources/2024-04-01/policyassignments/method_update.go new file mode 100644 index 00000000000..196a096f894 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/method_update.go @@ -0,0 +1,58 @@ +package policyassignments + +import ( + "context" + "net/http" + + "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 UpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyAssignment +} + +// Update ... +func (c PolicyAssignmentsClient) Update(ctx context.Context, id ScopedPolicyAssignmentId, input PolicyAssignmentUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PolicyAssignment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/method_updatebyid.go b/resource-manager/resources/2024-04-01/policyassignments/method_updatebyid.go new file mode 100644 index 00000000000..840a25a0f98 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/method_updatebyid.go @@ -0,0 +1,58 @@ +package policyassignments + +import ( + "context" + "net/http" + + "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 UpdateByIdOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PolicyAssignment +} + +// UpdateById ... +func (c PolicyAssignmentsClient) UpdateById(ctx context.Context, id PolicyAssignmentIdId, input PolicyAssignmentUpdate) (result UpdateByIdOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PolicyAssignment + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/model_noncompliancemessage.go b/resource-manager/resources/2024-04-01/policyassignments/model_noncompliancemessage.go new file mode 100644 index 00000000000..1a110b58070 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/model_noncompliancemessage.go @@ -0,0 +1,9 @@ +package policyassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NonComplianceMessage struct { + Message string `json:"message"` + PolicyDefinitionReferenceId *string `json:"policyDefinitionReferenceId,omitempty"` +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/model_override.go b/resource-manager/resources/2024-04-01/policyassignments/model_override.go new file mode 100644 index 00000000000..d189ffc2881 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/model_override.go @@ -0,0 +1,10 @@ +package policyassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Override struct { + Kind *OverrideKind `json:"kind,omitempty"` + Selectors *[]Selector `json:"selectors,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/model_parametervaluesvalue.go b/resource-manager/resources/2024-04-01/policyassignments/model_parametervaluesvalue.go new file mode 100644 index 00000000000..6c83cf1cdaa --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/model_parametervaluesvalue.go @@ -0,0 +1,8 @@ +package policyassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ParameterValuesValue struct { + Value *interface{} `json:"value,omitempty"` +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/model_policyassignment.go b/resource-manager/resources/2024-04-01/policyassignments/model_policyassignment.go new file mode 100644 index 00000000000..abe79336cd7 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/model_policyassignment.go @@ -0,0 +1,19 @@ +package policyassignments + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyAssignment struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PolicyAssignmentProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentproperties.go b/resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentproperties.go new file mode 100644 index 00000000000..1495651d2da --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentproperties.go @@ -0,0 +1,19 @@ +package policyassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyAssignmentProperties struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + EnforcementMode *EnforcementMode `json:"enforcementMode,omitempty"` + IsSystemPolicy *bool `json:"isSystemPolicy,omitempty"` + Metadata *interface{} `json:"metadata,omitempty"` + NonComplianceMessages *[]NonComplianceMessage `json:"nonComplianceMessages,omitempty"` + NotScopes *[]string `json:"notScopes,omitempty"` + Overrides *[]Override `json:"overrides,omitempty"` + Parameters *map[string]ParameterValuesValue `json:"parameters,omitempty"` + PolicyDefinitionId *string `json:"policyDefinitionId,omitempty"` + ResourceSelectors *[]ResourceSelector `json:"resourceSelectors,omitempty"` + Scope *string `json:"scope,omitempty"` +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentupdate.go b/resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentupdate.go new file mode 100644 index 00000000000..46e84124dde --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentupdate.go @@ -0,0 +1,14 @@ +package policyassignments + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyAssignmentUpdate struct { + Identity *identity.SystemOrUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Properties *PolicyAssignmentUpdateProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentupdateproperties.go b/resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentupdateproperties.go new file mode 100644 index 00000000000..e122904bc8c --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/model_policyassignmentupdateproperties.go @@ -0,0 +1,9 @@ +package policyassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyAssignmentUpdateProperties struct { + Overrides *[]Override `json:"overrides,omitempty"` + ResourceSelectors *[]ResourceSelector `json:"resourceSelectors,omitempty"` +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/model_resourceselector.go b/resource-manager/resources/2024-04-01/policyassignments/model_resourceselector.go new file mode 100644 index 00000000000..128a6ba0295 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/model_resourceselector.go @@ -0,0 +1,9 @@ +package policyassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceSelector struct { + Name *string `json:"name,omitempty"` + Selectors *[]Selector `json:"selectors,omitempty"` +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/model_selector.go b/resource-manager/resources/2024-04-01/policyassignments/model_selector.go new file mode 100644 index 00000000000..918246f2a8a --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/model_selector.go @@ -0,0 +1,10 @@ +package policyassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Selector struct { + In *[]string `json:"in,omitempty"` + Kind *SelectorKind `json:"kind,omitempty"` + NotIn *[]string `json:"notIn,omitempty"` +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/predicates.go b/resource-manager/resources/2024-04-01/policyassignments/predicates.go new file mode 100644 index 00000000000..93f39469c95 --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/predicates.go @@ -0,0 +1,32 @@ +package policyassignments + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PolicyAssignmentOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p PolicyAssignmentOperationPredicate) Matches(input PolicyAssignment) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + 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 +} diff --git a/resource-manager/resources/2024-04-01/policyassignments/version.go b/resource-manager/resources/2024-04-01/policyassignments/version.go new file mode 100644 index 00000000000..063ed4111da --- /dev/null +++ b/resource-manager/resources/2024-04-01/policyassignments/version.go @@ -0,0 +1,12 @@ +package policyassignments + +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 = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/policyassignments/%s", defaultApiVersion) +}