From 6b6730bcf750c38f2fe59584258191a8e0a76fcc Mon Sep 17 00:00:00 2001 From: "Yun Liu (from Dev Box)" Date: Thu, 14 Nov 2024 14:25:10 +0800 Subject: [PATCH 1/9] Add new resource `azurerm_cognitive_account_rai_policy` --- internal/services/cognitive/client/client.go | 10 + .../cognitive_account_rai_policy_resource.go | 425 ++++++++++++++++++ ...nitive_account_rai_policy_resource_test.go | 155 +++++++ internal/services/cognitive/registration.go | 1 + .../2024-10-01/raiblocklists/README.md | 186 ++++++++ .../2024-10-01/raiblocklists/client.go | 26 ++ .../2024-10-01/raiblocklists/id_account.go | 130 ++++++ .../raiblocklists/id_raiblocklist.go | 139 ++++++ .../raiblocklists/id_raiblocklistitem.go | 148 ++++++ .../raiblocklists/method_createorupdate.go | 58 +++ .../2024-10-01/raiblocklists/method_delete.go | 70 +++ .../2024-10-01/raiblocklists/method_get.go | 53 +++ .../2024-10-01/raiblocklists/method_list.go | 105 +++++ .../method_raiblocklistitemsbatchadd.go | 58 +++ .../method_raiblocklistitemsbatchdelete.go | 51 +++ .../method_raiblocklistitemscreateorupdate.go | 58 +++ .../method_raiblocklistitemsdelete.go | 70 +++ .../method_raiblocklistitemsget.go | 53 +++ .../method_raiblocklistitemslist.go | 105 +++++ .../raiblocklists/model_raiblocklist.go | 18 + .../raiblocklists/model_raiblocklistitem.go | 18 + .../model_raiblocklistitembulkrequest.go | 9 + .../model_raiblocklistitemproperties.go | 9 + .../model_raiblocklistproperties.go | 8 + .../2024-10-01/raiblocklists/predicates.go | 60 +++ .../2024-10-01/raiblocklists/version.go | 10 + .../2024-10-01/raicontentfilters/README.md | 53 +++ .../2024-10-01/raicontentfilters/client.go | 26 ++ .../2024-10-01/raicontentfilters/constants.go | 51 +++ .../raicontentfilters/id_location.go | 121 +++++ .../raicontentfilters/id_raicontentfilter.go | 130 ++++++ .../raicontentfilters/method_get.go | 53 +++ .../raicontentfilters/method_list.go | 105 +++++ .../model_raicontentfilter.go | 11 + .../model_raicontentfilterproperties.go | 10 + .../raicontentfilters/predicates.go | 27 ++ .../2024-10-01/raicontentfilters/version.go | 10 + .../2024-10-01/raipolicies/README.md | 86 ++++ .../2024-10-01/raipolicies/client.go | 26 ++ .../2024-10-01/raipolicies/constants.go | 183 ++++++++ .../2024-10-01/raipolicies/id_account.go | 130 ++++++ .../2024-10-01/raipolicies/id_raipolicy.go | 139 ++++++ .../raipolicies/method_createorupdate.go | 58 +++ .../2024-10-01/raipolicies/method_delete.go | 70 +++ .../2024-10-01/raipolicies/method_get.go | 53 +++ .../2024-10-01/raipolicies/method_list.go | 105 +++++ .../model_customblocklistconfig.go | 10 + .../2024-10-01/raipolicies/model_raipolicy.go | 18 + .../model_raipolicycontentfilter.go | 12 + .../raipolicies/model_raipolicyproperties.go | 12 + .../2024-10-01/raipolicies/predicates.go | 32 ++ .../2024-10-01/raipolicies/version.go | 10 + vendor/modules.txt | 3 + ...cognitive_account_rai_policy.html.markdown | 112 +++++ 54 files changed, 3689 insertions(+) create mode 100644 internal/services/cognitive/cognitive_account_rai_policy_resource.go create mode 100644 internal/services/cognitive/cognitive_account_rai_policy_resource_test.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_account.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklistitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_list.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchadd.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchdelete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemscreateorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsdelete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsget.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitembulkrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitemproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_location.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_raicontentfilter.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_list.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilter.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilterproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/version.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/id_account.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/id_raipolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_list.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_customblocklistconfig.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_raipolicy.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_raipolicycontentfilter.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_raipolicyproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/version.go create mode 100644 website/docs/r/cognitive_account_rai_policy.html.markdown diff --git a/internal/services/cognitive/client/client.go b/internal/services/cognitive/client/client.go index e9692f5de8ff..96349c9f9282 100644 --- a/internal/services/cognitive/client/client.go +++ b/internal/services/cognitive/client/client.go @@ -8,12 +8,14 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/cognitiveservicesaccounts" "github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/deployments" + "github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) type Client struct { AccountsClient *cognitiveservicesaccounts.CognitiveServicesAccountsClient DeploymentsClient *deployments.DeploymentsClient + RaiPoliciesClient *raipolicies.RaiPoliciesClient } func NewClient(o *common.ClientOptions) (*Client, error) { @@ -28,8 +30,16 @@ func NewClient(o *common.ClientOptions) (*Client, error) { return nil, fmt.Errorf("building Deployments client: %+v", err) } o.Configure(deploymentsClient.Client, o.Authorizers.ResourceManager) + + raiPoliciesClient, err := raipolicies.NewRaiPoliciesClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building RaiPolicies client: %+v", err) + } + o.Configure(raiPoliciesClient.Client, o.Authorizers.ResourceManager) + return &Client{ AccountsClient: accountsClient, DeploymentsClient: deploymentsClient, + RaiPoliciesClient: raiPoliciesClient, }, nil } diff --git a/internal/services/cognitive/cognitive_account_rai_policy_resource.go b/internal/services/cognitive/cognitive_account_rai_policy_resource.go new file mode 100644 index 000000000000..5a87849d95bd --- /dev/null +++ b/internal/services/cognitive/cognitive_account_rai_policy_resource.go @@ -0,0 +1,425 @@ +package cognitive + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies" + "github.com/hashicorp/terraform-provider-azurerm/internal/locks" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +var _ sdk.ResourceWithUpdate = &CognitiveAccountRaiPolicyResource{} + +type CognitiveAccountRaiPolicyResource struct{} + +type AccountRaiPolicyContentFilter struct { + Name string `tfschema:"name"` + FilterEnabled bool `tfschema:"filter_enabled"` + BlockEnabled bool `tfschema:"block_enabled"` + SeverityThreshold string `tfschema:"severity_threshold"` + Source string `tfschema:"source"` +} + +type AccountRaiPolicyCustomBlock struct { + Name string `tfschema:"name"` + BlockEnabled bool `tfschema:"block_enabled"` + Source string `tfschema:"source"` +} + +type AccountRaiPolicyResourceModel struct { + Name string `tfschema:"name"` + AccountId string `tfschema:"cognitive_account_id"` + BasePolicyName string `tfschema:"base_policy_name"` + ContentFilter []AccountRaiPolicyContentFilter `tfschema:"content_filter"` + CustomBlockList []AccountRaiPolicyCustomBlock `tfschema:"custom_blocklist"` + Mode string `tfschema:"mode"` + Tags map[string]string `tfschema:"tags"` + Type string `tfschema:"type"` +} + +func (r CognitiveAccountRaiPolicyResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "cognitive_account_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: raipolicies.ValidateAccountID, + }, + + "base_policy_name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "content_filter": { + Type: pluginsdk.TypeList, + Required: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + "filter_enabled": { + Type: pluginsdk.TypeBool, + Required: true, + }, + "block_enabled": { + Type: pluginsdk.TypeBool, + Required: true, + }, + "severity_threshold": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(raipolicies.PossibleValuesForContentLevel(), false), + }, + "source": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(raipolicies.PossibleValuesForRaiPolicyContentSource(), false), + }, + }, + }, + }, + + "custom_blocklist": { + Type: pluginsdk.TypeList, + Optional: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + "block_enabled": { + Type: pluginsdk.TypeBool, + Required: true, + }, + "source": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice(raipolicies.PossibleValuesForRaiPolicyContentSource(), false), + }, + }, + }, + }, + + "mode": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice(raipolicies.PossibleValuesForRaiPolicyMode(), false), + }, + + "tags": commonschema.Tags(), + } +} + +func (r CognitiveAccountRaiPolicyResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "type": { + Type: pluginsdk.TypeString, + Computed: true, + }, + } +} + +func (r CognitiveAccountRaiPolicyResource) ModelObject() interface{} { + return &AccountRaiPolicyResourceModel{} +} + +func (r CognitiveAccountRaiPolicyResource) ResourceType() string { + return "azurerm_cognitive_account_rai_policy" +} + +func (r CognitiveAccountRaiPolicyResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Cognitive.RaiPoliciesClient + subscriptionId := metadata.Client.Account.SubscriptionId + + var model AccountRaiPolicyResourceModel + if err := metadata.Decode(&model); err != nil { + return err + } + + cognitiveAccountId, err := raipolicies.ParseAccountID(model.AccountId) + if err != nil { + return err + } + + id := raipolicies.NewRaiPolicyID(subscriptionId, cognitiveAccountId.ResourceGroupName, cognitiveAccountId.AccountName, model.Name) + existing, err := client.Get(ctx, id) + if err != nil && !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) + } + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + locks.ByID(cognitiveAccountId.ID()) + defer locks.UnlockByID(cognitiveAccountId.ID()) + + raiPolicy := raipolicies.RaiPolicy{ + Name: pointer.To(model.Name), + Properties: &raipolicies.RaiPolicyProperties{ + BasePolicyName: pointer.To(model.BasePolicyName), + Mode: pointer.To(raipolicies.RaiPolicyMode(model.Mode)), + }, + Tags: pointer.To(model.Tags), + } + + if contentFilters, err := expandRaiPolicyContentFilters(model.ContentFilter); err != nil { + return err + } else { + raiPolicy.Properties.ContentFilters = contentFilters + } + + if customBlockLists, err := expandCustomBlockLists(model.CustomBlockList); err != nil { + return err + } else { + raiPolicy.Properties.CustomBlocklists = customBlockLists + } + + if _, err := client.CreateOrUpdate(ctx, id, raiPolicy); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + + return nil + }, + } +} + +func (r CognitiveAccountRaiPolicyResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Cognitive.RaiPoliciesClient + + id, err := raipolicies.ParseRaiPolicyID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + cognitiveAccountId := raipolicies.NewAccountID(id.SubscriptionId, id.ResourceGroupName, id.AccountName) + + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(id) + } + return fmt.Errorf("retrieving %s: %+v", id, err) + } + + state := AccountRaiPolicyResourceModel{} + + if model := resp.Model; model != nil { + state.Name = pointer.From(model.Name) + state.AccountId = cognitiveAccountId.ID() + state.Tags = pointer.From(model.Tags) + + if props := model.Properties; props != nil { + state.BasePolicyName = pointer.From(props.BasePolicyName) + state.Mode = string(pointer.From(props.Mode)) + state.Type = string(pointer.From(props.Type)) + + if err, contentFilters := flattenRaiPolicyContentFilters(props.ContentFilters); err != nil { + return err + } else { + state.ContentFilter = contentFilters + } + + if err, customBlockLists := flattenRaiCustomBlockLists(props.CustomBlocklists); err != nil { + return err + } else { + state.CustomBlockList = customBlockLists + } + } + } + + return metadata.Encode(&state) + }, + } +} + +func (r CognitiveAccountRaiPolicyResource) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Cognitive.RaiPoliciesClient + + id, err := raipolicies.ParseRaiPolicyID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + var model AccountRaiPolicyResourceModel + if err := metadata.Decode(&model); err != nil { + return err + } + + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(id) + } + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + cognitiveAccountId := raipolicies.NewAccountID(id.SubscriptionId, id.ResourceGroupName, id.AccountName) + + locks.ByID(cognitiveAccountId.ID()) + defer locks.UnlockByID(cognitiveAccountId.ID()) + + props := resp.Model + + if metadata.ResourceData.HasChange("content_filter") { + if contentFilters, err := expandRaiPolicyContentFilters(model.ContentFilter); err != nil { + return err + } else { + props.Properties.ContentFilters = contentFilters + } + } + + if metadata.ResourceData.HasChange("custom_blocklist") { + if customBlockLists, err := expandCustomBlockLists(model.CustomBlockList); err != nil { + return err + } else { + props.Properties.CustomBlocklists = customBlockLists + } + } + + if metadata.ResourceData.HasChange("mode") { + props.Properties.Mode = pointer.To(raipolicies.RaiPolicyMode(model.Mode)) + } + + if metadata.ResourceData.HasChange("tags") { + props.Tags = pointer.To(model.Tags) + } + + if _, err := client.CreateOrUpdate(ctx, *id, *props); err != nil { + return fmt.Errorf("updating %s: %+v", id, err) + } + + return nil + }, + } +} + +func (r CognitiveAccountRaiPolicyResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Cognitive.RaiPoliciesClient + + id, err := raipolicies.ParseRaiPolicyID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + cognitiveAccountId := raipolicies.NewAccountID(id.SubscriptionId, id.ResourceGroupName, id.AccountName) + + locks.ByID(cognitiveAccountId.ID()) + defer locks.UnlockByID(cognitiveAccountId.ID()) + + if err := client.DeleteThenPoll(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", id, err) + } + + return nil + }, + } +} + +func (r CognitiveAccountRaiPolicyResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return raipolicies.ValidateRaiPolicyID +} + +func expandRaiPolicyContentFilters(filters []AccountRaiPolicyContentFilter) (*[]raipolicies.RaiPolicyContentFilter, error) { + if filters == nil { + return nil, nil + } + + var contentFilters []raipolicies.RaiPolicyContentFilter + for _, filter := range filters { + contentFilters = append(contentFilters, raipolicies.RaiPolicyContentFilter{ + Name: pointer.To(filter.Name), + Enabled: pointer.To(filter.FilterEnabled), + Blocking: pointer.To(filter.BlockEnabled), + SeverityThreshold: pointer.To(raipolicies.ContentLevel(filter.SeverityThreshold)), + Source: pointer.To(raipolicies.RaiPolicyContentSource(filter.Source)), + }) + } + return &contentFilters, nil +} + +func expandCustomBlockLists(list []AccountRaiPolicyCustomBlock) (*[]raipolicies.CustomBlocklistConfig, error) { + if list == nil { + return nil, nil + } + + var customBlockLists []raipolicies.CustomBlocklistConfig + for _, block := range list { + customBlockLists = append(customBlockLists, raipolicies.CustomBlocklistConfig{ + BlocklistName: pointer.To(block.Name), + Blocking: pointer.To(block.BlockEnabled), + Source: pointer.To(raipolicies.RaiPolicyContentSource(block.Source)), + }) + } + return &customBlockLists, nil +} + +func flattenRaiCustomBlockLists(blocklists *[]raipolicies.CustomBlocklistConfig) (error, []AccountRaiPolicyCustomBlock) { + if blocklists == nil { + return nil, nil + } + + var customBlockLists []AccountRaiPolicyCustomBlock + + for _, block := range *blocklists { + customBlockLists = append(customBlockLists, AccountRaiPolicyCustomBlock{ + Name: pointer.From(block.BlocklistName), + BlockEnabled: pointer.From(block.Blocking), + Source: string(pointer.From(block.Source)), + }) + } + return nil, customBlockLists +} + +func flattenRaiPolicyContentFilters(filters *[]raipolicies.RaiPolicyContentFilter) (error, []AccountRaiPolicyContentFilter) { + if filters == nil { + return nil, nil + } + + var contentFilters []AccountRaiPolicyContentFilter + for _, filter := range *filters { + contentFilters = append(contentFilters, AccountRaiPolicyContentFilter{ + Name: pointer.From(filter.Name), + FilterEnabled: pointer.From(filter.Enabled), + BlockEnabled: pointer.From(filter.Blocking), + SeverityThreshold: string(pointer.From(filter.SeverityThreshold)), + Source: string(pointer.From(filter.Source)), + }) + } + return nil, contentFilters +} diff --git a/internal/services/cognitive/cognitive_account_rai_policy_resource_test.go b/internal/services/cognitive/cognitive_account_rai_policy_resource_test.go new file mode 100644 index 000000000000..d78ded7f29e2 --- /dev/null +++ b/internal/services/cognitive/cognitive_account_rai_policy_resource_test.go @@ -0,0 +1,155 @@ +package cognitive_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" +) + +type RaiPolicyTestResource struct{} + +func TestCognitiveAccountRaiPolicy_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_cognitive_account_rai_policy", "test") + r := RaiPolicyTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + data.ApplyStep(r.basicConfig, r), + data.ImportStep(), + }) +} + +func TestCognitiveAccountRaiPolicy_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_cognitive_account_rai_policy", "test") + r := RaiPolicyTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + data.ApplyStep(r.basicConfig, r), + data.RequiresImportErrorStep(r.requiresImportConfig), + }) +} + +func TestCognitiveAccountRaiPolicy_complete(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_cognitive_account_rai_policy", "test") + r := RaiPolicyTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + data.ApplyStep(r.completeConfig, r), + data.ImportStep(), + data.ApplyStep(r.basicConfig, r), + data.ImportStep(), + data.ApplyStep(r.completeConfig, r), + data.ImportStep(), + }) +} + +func (r RaiPolicyTestResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := raipolicies.ParseRaiPolicyID(state.ID) + if err != nil { + return nil, err + } + + resp, err := client.Cognitive.RaiPoliciesClient.Get(ctx, *id) + if err != nil { + return nil, fmt.Errorf("retrieving %s: %+v", *id, err) + } + + return pointer.To(resp.Model != nil), nil +} + +func (r RaiPolicyTestResource) basicConfig(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-cognitive-%d" + location = "%s" +} + +resource "azurerm_cognitive_account" "test" { + name = "acctestcogacc-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + kind = "OpenAI" + sku_name = "S0" +} + +resource "azurerm_cognitive_account_rai_policy" "test" { + name = "acctestraip-%s" + cognitive_account_id = azurerm_cognitive_account.test.id + base_policy_name = "Microsoft.Default" + content_filter { + name = "Hate" + filter_enabled = true + block_enabled = true + severity_threshold = "High" + source = "Prompt" + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomString) +} + +func (r RaiPolicyTestResource) completeConfig(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-cognitive-%d" + location = "%s" +} + +resource "azurerm_cognitive_account" "test" { + name = "acctestcogacc-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + kind = "OpenAI" + sku_name = "S0" +} + +resource "azurerm_cognitive_account_rai_policy" "test" { + name = "acctestraip-%s" + cognitive_account_id = azurerm_cognitive_account.test.id + base_policy_name = "Microsoft.Default" + content_filter { + name = "Hate" + filter_enabled = true + block_enabled = true + severity_threshold = "High" + source = "Prompt" + } + mode = "Asynchronous_filter" + tags = { + Environment = "Test" + } +} +`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomString) +} + +func (r RaiPolicyTestResource) requiresImportConfig(data acceptance.TestData) string { + template := r.basicConfig(data) + return fmt.Sprintf(` +%s + +resource "azurerm_cognitive_account_rai_policy" "import" { + name = azurerm_cognitive_account_rai_policy.test.name + cognitive_account_id = azurerm_cognitive_account.test.id + base_policy_name = azurerm_cognitive_account_rai_policy.test.base_policy_name + content_filter { + name = "Hate" + filter_enabled = true + block_enabled = true + severity_threshold = "High" + source = "Prompt" + } +} +`, template) +} diff --git a/internal/services/cognitive/registration.go b/internal/services/cognitive/registration.go index 5c3cd5d03c5a..57ae5719c0a5 100644 --- a/internal/services/cognitive/registration.go +++ b/internal/services/cognitive/registration.go @@ -56,5 +56,6 @@ func (r Registration) Resources() []sdk.Resource { return []sdk.Resource{ AzureAIServicesResource{}, CognitiveDeploymentResource{}, + CognitiveAccountRaiPolicyResource{}, } } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/README.md new file mode 100644 index 000000000000..d0fc2d949ba4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/README.md @@ -0,0 +1,186 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists` Documentation + +The `raiblocklists` SDK allows for interaction with Azure Resource Manager `cognitive` (API Version `2024-10-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-sdk/resource-manager/cognitive/2024-10-01/raiblocklists" +``` + + +### Client Initialization + +```go +client := raiblocklists.NewRaiBlocklistsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RaiBlocklistsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") + +payload := raiblocklists.RaiBlocklist{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RaiBlocklistsClient.Delete` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RaiBlocklistsClient.Get` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") + +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: `RaiBlocklistsClient.List` + +```go +ctx := context.TODO() +id := raiblocklists.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsBatchAdd` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") +var payload []RaiBlocklistItemBulkRequest + +read, err := client.RaiBlocklistItemsBatchAdd(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsBatchDelete` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") +var payload interface{} + +read, err := client.RaiBlocklistItemsBatchDelete(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsCreateOrUpdate` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName", "raiBlocklistItemName") + +payload := raiblocklists.RaiBlocklistItem{ + // ... +} + + +read, err := client.RaiBlocklistItemsCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsDelete` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName", "raiBlocklistItemName") + +if err := client.RaiBlocklistItemsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsGet` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName", "raiBlocklistItemName") + +read, err := client.RaiBlocklistItemsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsList` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") + +// alternatively `client.RaiBlocklistItemsList(ctx, id)` can be used to do batched pagination +items, err := client.RaiBlocklistItemsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/client.go new file mode 100644 index 000000000000..8721ad1960a9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/client.go @@ -0,0 +1,26 @@ +package raiblocklists + +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 RaiBlocklistsClient struct { + Client *resourcemanager.Client +} + +func NewRaiBlocklistsClientWithBaseURI(sdkApi sdkEnv.Api) (*RaiBlocklistsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "raiblocklists", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RaiBlocklistsClient: %+v", err) + } + + return &RaiBlocklistsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_account.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_account.go new file mode 100644 index 000000000000..eadf6b999b86 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_account.go @@ -0,0 +1,130 @@ +package raiblocklists + +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(&AccountId{}) +} + +var _ resourceids.ResourceId = &AccountId{} + +// AccountId is a struct representing the Resource ID for a Account +type AccountId struct { + SubscriptionId string + ResourceGroupName string + AccountName string +} + +// NewAccountID returns a new AccountId struct +func NewAccountID(subscriptionId string, resourceGroupName string, accountName string) AccountId { + return AccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AccountName: accountName, + } +} + +// ParseAccountID parses 'input' into a AccountId +func ParseAccountID(input string) (*AccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAccountIDInsensitively parses 'input' case-insensitively into a AccountId +// note: this method should only be used for API response data and not user input +func ParseAccountIDInsensitively(input string) (*AccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AccountName, ok = input.Parsed["accountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) + } + + return nil +} + +// ValidateAccountID checks that 'input' can be parsed as a Account ID +func ValidateAccountID(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 := ParseAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Account ID +func (id AccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CognitiveServices/accounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Account ID +func (id AccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCognitiveServices", "Microsoft.CognitiveServices", "Microsoft.CognitiveServices"), + resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), + resourceids.UserSpecifiedSegment("accountName", "accountName"), + } +} + +// String returns a human-readable description of this Account ID +func (id AccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Account Name: %q", id.AccountName), + } + return fmt.Sprintf("Account (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklist.go new file mode 100644 index 000000000000..70ef2a3f25fd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklist.go @@ -0,0 +1,139 @@ +package raiblocklists + +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(&RaiBlocklistId{}) +} + +var _ resourceids.ResourceId = &RaiBlocklistId{} + +// RaiBlocklistId is a struct representing the Resource ID for a Rai Blocklist +type RaiBlocklistId struct { + SubscriptionId string + ResourceGroupName string + AccountName string + RaiBlocklistName string +} + +// NewRaiBlocklistID returns a new RaiBlocklistId struct +func NewRaiBlocklistID(subscriptionId string, resourceGroupName string, accountName string, raiBlocklistName string) RaiBlocklistId { + return RaiBlocklistId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AccountName: accountName, + RaiBlocklistName: raiBlocklistName, + } +} + +// ParseRaiBlocklistID parses 'input' into a RaiBlocklistId +func ParseRaiBlocklistID(input string) (*RaiBlocklistId, error) { + parser := resourceids.NewParserFromResourceIdType(&RaiBlocklistId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RaiBlocklistId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRaiBlocklistIDInsensitively parses 'input' case-insensitively into a RaiBlocklistId +// note: this method should only be used for API response data and not user input +func ParseRaiBlocklistIDInsensitively(input string) (*RaiBlocklistId, error) { + parser := resourceids.NewParserFromResourceIdType(&RaiBlocklistId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RaiBlocklistId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RaiBlocklistId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AccountName, ok = input.Parsed["accountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) + } + + if id.RaiBlocklistName, ok = input.Parsed["raiBlocklistName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "raiBlocklistName", input) + } + + return nil +} + +// ValidateRaiBlocklistID checks that 'input' can be parsed as a Rai Blocklist ID +func ValidateRaiBlocklistID(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 := ParseRaiBlocklistID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rai Blocklist ID +func (id RaiBlocklistId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CognitiveServices/accounts/%s/raiBlocklists/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AccountName, id.RaiBlocklistName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rai Blocklist ID +func (id RaiBlocklistId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCognitiveServices", "Microsoft.CognitiveServices", "Microsoft.CognitiveServices"), + resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), + resourceids.UserSpecifiedSegment("accountName", "accountName"), + resourceids.StaticSegment("staticRaiBlocklists", "raiBlocklists", "raiBlocklists"), + resourceids.UserSpecifiedSegment("raiBlocklistName", "raiBlocklistName"), + } +} + +// String returns a human-readable description of this Rai Blocklist ID +func (id RaiBlocklistId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Account Name: %q", id.AccountName), + fmt.Sprintf("Rai Blocklist Name: %q", id.RaiBlocklistName), + } + return fmt.Sprintf("Rai Blocklist (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklistitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklistitem.go new file mode 100644 index 000000000000..642b218519cc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklistitem.go @@ -0,0 +1,148 @@ +package raiblocklists + +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(&RaiBlocklistItemId{}) +} + +var _ resourceids.ResourceId = &RaiBlocklistItemId{} + +// RaiBlocklistItemId is a struct representing the Resource ID for a Rai Blocklist Item +type RaiBlocklistItemId struct { + SubscriptionId string + ResourceGroupName string + AccountName string + RaiBlocklistName string + RaiBlocklistItemName string +} + +// NewRaiBlocklistItemID returns a new RaiBlocklistItemId struct +func NewRaiBlocklistItemID(subscriptionId string, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemName string) RaiBlocklistItemId { + return RaiBlocklistItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AccountName: accountName, + RaiBlocklistName: raiBlocklistName, + RaiBlocklistItemName: raiBlocklistItemName, + } +} + +// ParseRaiBlocklistItemID parses 'input' into a RaiBlocklistItemId +func ParseRaiBlocklistItemID(input string) (*RaiBlocklistItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&RaiBlocklistItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RaiBlocklistItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRaiBlocklistItemIDInsensitively parses 'input' case-insensitively into a RaiBlocklistItemId +// note: this method should only be used for API response data and not user input +func ParseRaiBlocklistItemIDInsensitively(input string) (*RaiBlocklistItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&RaiBlocklistItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RaiBlocklistItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RaiBlocklistItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AccountName, ok = input.Parsed["accountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) + } + + if id.RaiBlocklistName, ok = input.Parsed["raiBlocklistName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "raiBlocklistName", input) + } + + if id.RaiBlocklistItemName, ok = input.Parsed["raiBlocklistItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "raiBlocklistItemName", input) + } + + return nil +} + +// ValidateRaiBlocklistItemID checks that 'input' can be parsed as a Rai Blocklist Item ID +func ValidateRaiBlocklistItemID(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 := ParseRaiBlocklistItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rai Blocklist Item ID +func (id RaiBlocklistItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CognitiveServices/accounts/%s/raiBlocklists/%s/raiBlocklistItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AccountName, id.RaiBlocklistName, id.RaiBlocklistItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rai Blocklist Item ID +func (id RaiBlocklistItemId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCognitiveServices", "Microsoft.CognitiveServices", "Microsoft.CognitiveServices"), + resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), + resourceids.UserSpecifiedSegment("accountName", "accountName"), + resourceids.StaticSegment("staticRaiBlocklists", "raiBlocklists", "raiBlocklists"), + resourceids.UserSpecifiedSegment("raiBlocklistName", "raiBlocklistName"), + resourceids.StaticSegment("staticRaiBlocklistItems", "raiBlocklistItems", "raiBlocklistItems"), + resourceids.UserSpecifiedSegment("raiBlocklistItemName", "raiBlocklistItemName"), + } +} + +// String returns a human-readable description of this Rai Blocklist Item ID +func (id RaiBlocklistItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Account Name: %q", id.AccountName), + fmt.Sprintf("Rai Blocklist Name: %q", id.RaiBlocklistName), + fmt.Sprintf("Rai Blocklist Item Name: %q", id.RaiBlocklistItemName), + } + return fmt.Sprintf("Rai Blocklist Item (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_createorupdate.go new file mode 100644 index 000000000000..a6b788f2ab6d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_createorupdate.go @@ -0,0 +1,58 @@ +package raiblocklists + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RaiBlocklist +} + +// CreateOrUpdate ... +func (c RaiBlocklistsClient) CreateOrUpdate(ctx context.Context, id RaiBlocklistId, input RaiBlocklist) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + 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 RaiBlocklist + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_delete.go new file mode 100644 index 000000000000..621e422780ff --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_delete.go @@ -0,0 +1,70 @@ +package raiblocklists + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c RaiBlocklistsClient) Delete(ctx context.Context, id RaiBlocklistId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c RaiBlocklistsClient) DeleteThenPoll(ctx context.Context, id RaiBlocklistId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_get.go new file mode 100644 index 000000000000..277a3c8997eb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_get.go @@ -0,0 +1,53 @@ +package raiblocklists + +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 *RaiBlocklist +} + +// Get ... +func (c RaiBlocklistsClient) Get(ctx context.Context, id RaiBlocklistId) (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 RaiBlocklist + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_list.go new file mode 100644 index 000000000000..ea9724913f5d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_list.go @@ -0,0 +1,105 @@ +package raiblocklists + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RaiBlocklist +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RaiBlocklist +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c RaiBlocklistsClient) List(ctx context.Context, id AccountId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/raiBlocklists", 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 *[]RaiBlocklist `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 RaiBlocklistsClient) ListComplete(ctx context.Context, id AccountId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RaiBlocklistOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RaiBlocklistsClient) ListCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate RaiBlocklistOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RaiBlocklist, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchadd.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchadd.go new file mode 100644 index 000000000000..1a7e886a20f2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchadd.go @@ -0,0 +1,58 @@ +package raiblocklists + +import ( + "context" + "fmt" + "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 RaiBlocklistItemsBatchAddOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RaiBlocklist +} + +// RaiBlocklistItemsBatchAdd ... +func (c RaiBlocklistsClient) RaiBlocklistItemsBatchAdd(ctx context.Context, id RaiBlocklistId, input []RaiBlocklistItemBulkRequest) (result RaiBlocklistItemsBatchAddOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/addRaiBlocklistItems", 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 RaiBlocklist + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchdelete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchdelete.go new file mode 100644 index 000000000000..b8313577f4c7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchdelete.go @@ -0,0 +1,51 @@ +package raiblocklists + +import ( + "context" + "fmt" + "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 RaiBlocklistItemsBatchDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RaiBlocklistItemsBatchDelete ... +func (c RaiBlocklistsClient) RaiBlocklistItemsBatchDelete(ctx context.Context, id RaiBlocklistId, input interface{}) (result RaiBlocklistItemsBatchDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deleteRaiBlocklistItems", 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 + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemscreateorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemscreateorupdate.go new file mode 100644 index 000000000000..5caeb001e7c7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemscreateorupdate.go @@ -0,0 +1,58 @@ +package raiblocklists + +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 RaiBlocklistItemsCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RaiBlocklistItem +} + +// RaiBlocklistItemsCreateOrUpdate ... +func (c RaiBlocklistsClient) RaiBlocklistItemsCreateOrUpdate(ctx context.Context, id RaiBlocklistItemId, input RaiBlocklistItem) (result RaiBlocklistItemsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + 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 RaiBlocklistItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsdelete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsdelete.go new file mode 100644 index 000000000000..b832a825b546 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsdelete.go @@ -0,0 +1,70 @@ +package raiblocklists + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 RaiBlocklistItemsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RaiBlocklistItemsDelete ... +func (c RaiBlocklistsClient) RaiBlocklistItemsDelete(ctx context.Context, id RaiBlocklistItemId) (result RaiBlocklistItemsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RaiBlocklistItemsDeleteThenPoll performs RaiBlocklistItemsDelete then polls until it's completed +func (c RaiBlocklistsClient) RaiBlocklistItemsDeleteThenPoll(ctx context.Context, id RaiBlocklistItemId) error { + result, err := c.RaiBlocklistItemsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RaiBlocklistItemsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RaiBlocklistItemsDelete: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsget.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsget.go new file mode 100644 index 000000000000..390fcc14f820 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsget.go @@ -0,0 +1,53 @@ +package raiblocklists + +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 RaiBlocklistItemsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RaiBlocklistItem +} + +// RaiBlocklistItemsGet ... +func (c RaiBlocklistsClient) RaiBlocklistItemsGet(ctx context.Context, id RaiBlocklistItemId) (result RaiBlocklistItemsGetOperationResponse, 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 RaiBlocklistItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemslist.go new file mode 100644 index 000000000000..15c228ce07a4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemslist.go @@ -0,0 +1,105 @@ +package raiblocklists + +import ( + "context" + "fmt" + "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 RaiBlocklistItemsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RaiBlocklistItem +} + +type RaiBlocklistItemsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RaiBlocklistItem +} + +type RaiBlocklistItemsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RaiBlocklistItemsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RaiBlocklistItemsList ... +func (c RaiBlocklistsClient) RaiBlocklistItemsList(ctx context.Context, id RaiBlocklistId) (result RaiBlocklistItemsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &RaiBlocklistItemsListCustomPager{}, + Path: fmt.Sprintf("%s/raiBlocklistItems", 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 *[]RaiBlocklistItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RaiBlocklistItemsListComplete retrieves all the results into a single object +func (c RaiBlocklistsClient) RaiBlocklistItemsListComplete(ctx context.Context, id RaiBlocklistId) (RaiBlocklistItemsListCompleteResult, error) { + return c.RaiBlocklistItemsListCompleteMatchingPredicate(ctx, id, RaiBlocklistItemOperationPredicate{}) +} + +// RaiBlocklistItemsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RaiBlocklistsClient) RaiBlocklistItemsListCompleteMatchingPredicate(ctx context.Context, id RaiBlocklistId, predicate RaiBlocklistItemOperationPredicate) (result RaiBlocklistItemsListCompleteResult, err error) { + items := make([]RaiBlocklistItem, 0) + + resp, err := c.RaiBlocklistItemsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = RaiBlocklistItemsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklist.go new file mode 100644 index 000000000000..8be491a1b59b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklist.go @@ -0,0 +1,18 @@ +package raiblocklists + +import ( + "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 RaiBlocklist struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RaiBlocklistProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitem.go new file mode 100644 index 000000000000..98bd2267f965 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitem.go @@ -0,0 +1,18 @@ +package raiblocklists + +import ( + "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 RaiBlocklistItem struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RaiBlocklistItemProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitembulkrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitembulkrequest.go new file mode 100644 index 000000000000..7f7ac1e1e3c3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitembulkrequest.go @@ -0,0 +1,9 @@ +package raiblocklists + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RaiBlocklistItemBulkRequest struct { + Name *string `json:"name,omitempty"` + Properties *RaiBlocklistItemProperties `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitemproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitemproperties.go new file mode 100644 index 000000000000..f6b4e7ca37a6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitemproperties.go @@ -0,0 +1,9 @@ +package raiblocklists + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RaiBlocklistItemProperties struct { + IsRegex *bool `json:"isRegex,omitempty"` + Pattern *string `json:"pattern,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistproperties.go new file mode 100644 index 000000000000..816f9b75e266 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistproperties.go @@ -0,0 +1,8 @@ +package raiblocklists + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RaiBlocklistProperties struct { + Description *string `json:"description,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/predicates.go new file mode 100644 index 000000000000..a317e1c7318b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/predicates.go @@ -0,0 +1,60 @@ +package raiblocklists + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RaiBlocklistOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p RaiBlocklistOperationPredicate) Matches(input RaiBlocklist) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + 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 +} + +type RaiBlocklistItemOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p RaiBlocklistItemOperationPredicate) Matches(input RaiBlocklistItem) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/version.go new file mode 100644 index 000000000000..cc4c248b7f4a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/version.go @@ -0,0 +1,10 @@ +package raiblocklists + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/raiblocklists/2024-10-01" +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/README.md new file mode 100644 index 000000000000..7e211cb271c8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters` Documentation + +The `raicontentfilters` SDK allows for interaction with Azure Resource Manager `cognitive` (API Version `2024-10-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-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters" +``` + + +### Client Initialization + +```go +client := raicontentfilters.NewRaiContentFiltersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RaiContentFiltersClient.Get` + +```go +ctx := context.TODO() +id := raicontentfilters.NewRaiContentFilterID("12345678-1234-9876-4563-123456789012", "locationName", "raiContentFilterName") + +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: `RaiContentFiltersClient.List` + +```go +ctx := context.TODO() +id := raicontentfilters.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/client.go new file mode 100644 index 000000000000..63dbeff0cfdd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/client.go @@ -0,0 +1,26 @@ +package raicontentfilters + +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 RaiContentFiltersClient struct { + Client *resourcemanager.Client +} + +func NewRaiContentFiltersClientWithBaseURI(sdkApi sdkEnv.Api) (*RaiContentFiltersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "raicontentfilters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RaiContentFiltersClient: %+v", err) + } + + return &RaiContentFiltersClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/constants.go new file mode 100644 index 000000000000..68418b1081bf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/constants.go @@ -0,0 +1,51 @@ +package raicontentfilters + +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 RaiPolicyContentSource string + +const ( + RaiPolicyContentSourceCompletion RaiPolicyContentSource = "Completion" + RaiPolicyContentSourcePrompt RaiPolicyContentSource = "Prompt" +) + +func PossibleValuesForRaiPolicyContentSource() []string { + return []string{ + string(RaiPolicyContentSourceCompletion), + string(RaiPolicyContentSourcePrompt), + } +} + +func (s *RaiPolicyContentSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRaiPolicyContentSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRaiPolicyContentSource(input string) (*RaiPolicyContentSource, error) { + vals := map[string]RaiPolicyContentSource{ + "completion": RaiPolicyContentSourceCompletion, + "prompt": RaiPolicyContentSourcePrompt, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RaiPolicyContentSource(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_location.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_location.go new file mode 100644 index 000000000000..3dfb920179ae --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_location.go @@ -0,0 +1,121 @@ +package raicontentfilters + +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(&LocationId{}) +} + +var _ resourceids.ResourceId = &LocationId{} + +// LocationId is a struct representing the Resource ID for a Location +type LocationId struct { + SubscriptionId string + LocationName string +} + +// NewLocationID returns a new LocationId struct +func NewLocationID(subscriptionId string, locationName string) LocationId { + return LocationId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + } +} + +// ParseLocationID parses 'input' into a LocationId +func ParseLocationID(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId +// note: this method should only be used for API response data and not user input +func ParseLocationIDInsensitively(input string) (*LocationId, error) { + parser := resourceids.NewParserFromResourceIdType(&LocationId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := LocationId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + return nil +} + +// ValidateLocationID checks that 'input' can be parsed as a Location ID +func ValidateLocationID(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 := ParseLocationID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Location ID +func (id LocationId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.CognitiveServices/locations/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Location ID +func (id LocationId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCognitiveServices", "Microsoft.CognitiveServices", "Microsoft.CognitiveServices"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + } +} + +// String returns a human-readable description of this Location ID +func (id LocationId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + } + return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_raicontentfilter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_raicontentfilter.go new file mode 100644 index 000000000000..0494a52b88e6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_raicontentfilter.go @@ -0,0 +1,130 @@ +package raicontentfilters + +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(&RaiContentFilterId{}) +} + +var _ resourceids.ResourceId = &RaiContentFilterId{} + +// RaiContentFilterId is a struct representing the Resource ID for a Rai Content Filter +type RaiContentFilterId struct { + SubscriptionId string + LocationName string + RaiContentFilterName string +} + +// NewRaiContentFilterID returns a new RaiContentFilterId struct +func NewRaiContentFilterID(subscriptionId string, locationName string, raiContentFilterName string) RaiContentFilterId { + return RaiContentFilterId{ + SubscriptionId: subscriptionId, + LocationName: locationName, + RaiContentFilterName: raiContentFilterName, + } +} + +// ParseRaiContentFilterID parses 'input' into a RaiContentFilterId +func ParseRaiContentFilterID(input string) (*RaiContentFilterId, error) { + parser := resourceids.NewParserFromResourceIdType(&RaiContentFilterId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RaiContentFilterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRaiContentFilterIDInsensitively parses 'input' case-insensitively into a RaiContentFilterId +// note: this method should only be used for API response data and not user input +func ParseRaiContentFilterIDInsensitively(input string) (*RaiContentFilterId, error) { + parser := resourceids.NewParserFromResourceIdType(&RaiContentFilterId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RaiContentFilterId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RaiContentFilterId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.LocationName, ok = input.Parsed["locationName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) + } + + if id.RaiContentFilterName, ok = input.Parsed["raiContentFilterName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "raiContentFilterName", input) + } + + return nil +} + +// ValidateRaiContentFilterID checks that 'input' can be parsed as a Rai Content Filter ID +func ValidateRaiContentFilterID(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 := ParseRaiContentFilterID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rai Content Filter ID +func (id RaiContentFilterId) ID() string { + fmtString := "/subscriptions/%s/providers/Microsoft.CognitiveServices/locations/%s/raiContentFilters/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.RaiContentFilterName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rai Content Filter ID +func (id RaiContentFilterId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCognitiveServices", "Microsoft.CognitiveServices", "Microsoft.CognitiveServices"), + resourceids.StaticSegment("staticLocations", "locations", "locations"), + resourceids.UserSpecifiedSegment("locationName", "locationName"), + resourceids.StaticSegment("staticRaiContentFilters", "raiContentFilters", "raiContentFilters"), + resourceids.UserSpecifiedSegment("raiContentFilterName", "raiContentFilterName"), + } +} + +// String returns a human-readable description of this Rai Content Filter ID +func (id RaiContentFilterId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Location Name: %q", id.LocationName), + fmt.Sprintf("Rai Content Filter Name: %q", id.RaiContentFilterName), + } + return fmt.Sprintf("Rai Content Filter (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_get.go new file mode 100644 index 000000000000..92a989a8f085 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_get.go @@ -0,0 +1,53 @@ +package raicontentfilters + +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 *RaiContentFilter +} + +// Get ... +func (c RaiContentFiltersClient) Get(ctx context.Context, id RaiContentFilterId) (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 RaiContentFilter + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_list.go new file mode 100644 index 000000000000..0760eeeeb371 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_list.go @@ -0,0 +1,105 @@ +package raicontentfilters + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RaiContentFilter +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RaiContentFilter +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c RaiContentFiltersClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/raiContentFilters", 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 *[]RaiContentFilter `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 RaiContentFiltersClient) ListComplete(ctx context.Context, id LocationId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RaiContentFilterOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RaiContentFiltersClient) ListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate RaiContentFilterOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RaiContentFilter, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilter.go new file mode 100644 index 000000000000..1f2adebacaba --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilter.go @@ -0,0 +1,11 @@ +package raicontentfilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RaiContentFilter struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RaiContentFilterProperties `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilterproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilterproperties.go new file mode 100644 index 000000000000..116e39cdd8bc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilterproperties.go @@ -0,0 +1,10 @@ +package raicontentfilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RaiContentFilterProperties struct { + IsMultiLevelFilter *bool `json:"isMultiLevelFilter,omitempty"` + Name *string `json:"name,omitempty"` + Source *RaiPolicyContentSource `json:"source,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/predicates.go new file mode 100644 index 000000000000..994f2fa9ea89 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/predicates.go @@ -0,0 +1,27 @@ +package raicontentfilters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RaiContentFilterOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p RaiContentFilterOperationPredicate) Matches(input RaiContentFilter) 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/version.go new file mode 100644 index 000000000000..c83eb0666831 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/version.go @@ -0,0 +1,10 @@ +package raicontentfilters + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/raicontentfilters/2024-10-01" +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/README.md new file mode 100644 index 000000000000..3202b2c9afa4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/README.md @@ -0,0 +1,86 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies` Documentation + +The `raipolicies` SDK allows for interaction with Azure Resource Manager `cognitive` (API Version `2024-10-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-sdk/resource-manager/cognitive/2024-10-01/raipolicies" +``` + + +### Client Initialization + +```go +client := raipolicies.NewRaiPoliciesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RaiPoliciesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := raipolicies.NewRaiPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiPolicyName") + +payload := raipolicies.RaiPolicy{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RaiPoliciesClient.Delete` + +```go +ctx := context.TODO() +id := raipolicies.NewRaiPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiPolicyName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RaiPoliciesClient.Get` + +```go +ctx := context.TODO() +id := raipolicies.NewRaiPolicyID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiPolicyName") + +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: `RaiPoliciesClient.List` + +```go +ctx := context.TODO() +id := raipolicies.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/client.go new file mode 100644 index 000000000000..7503f70f6570 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/client.go @@ -0,0 +1,26 @@ +package raipolicies + +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 RaiPoliciesClient struct { + Client *resourcemanager.Client +} + +func NewRaiPoliciesClientWithBaseURI(sdkApi sdkEnv.Api) (*RaiPoliciesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "raipolicies", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RaiPoliciesClient: %+v", err) + } + + return &RaiPoliciesClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/constants.go new file mode 100644 index 000000000000..528ea7cc654e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/constants.go @@ -0,0 +1,183 @@ +package raipolicies + +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 ContentLevel string + +const ( + ContentLevelHigh ContentLevel = "High" + ContentLevelLow ContentLevel = "Low" + ContentLevelMedium ContentLevel = "Medium" +) + +func PossibleValuesForContentLevel() []string { + return []string{ + string(ContentLevelHigh), + string(ContentLevelLow), + string(ContentLevelMedium), + } +} + +func (s *ContentLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContentLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseContentLevel(input string) (*ContentLevel, error) { + vals := map[string]ContentLevel{ + "high": ContentLevelHigh, + "low": ContentLevelLow, + "medium": ContentLevelMedium, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContentLevel(input) + return &out, nil +} + +type RaiPolicyContentSource string + +const ( + RaiPolicyContentSourceCompletion RaiPolicyContentSource = "Completion" + RaiPolicyContentSourcePrompt RaiPolicyContentSource = "Prompt" +) + +func PossibleValuesForRaiPolicyContentSource() []string { + return []string{ + string(RaiPolicyContentSourceCompletion), + string(RaiPolicyContentSourcePrompt), + } +} + +func (s *RaiPolicyContentSource) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRaiPolicyContentSource(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRaiPolicyContentSource(input string) (*RaiPolicyContentSource, error) { + vals := map[string]RaiPolicyContentSource{ + "completion": RaiPolicyContentSourceCompletion, + "prompt": RaiPolicyContentSourcePrompt, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RaiPolicyContentSource(input) + return &out, nil +} + +type RaiPolicyMode string + +const ( + RaiPolicyModeAsynchronousFilter RaiPolicyMode = "Asynchronous_filter" + RaiPolicyModeBlocking RaiPolicyMode = "Blocking" + RaiPolicyModeDefault RaiPolicyMode = "Default" + RaiPolicyModeDeferred RaiPolicyMode = "Deferred" +) + +func PossibleValuesForRaiPolicyMode() []string { + return []string{ + string(RaiPolicyModeAsynchronousFilter), + string(RaiPolicyModeBlocking), + string(RaiPolicyModeDefault), + string(RaiPolicyModeDeferred), + } +} + +func (s *RaiPolicyMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRaiPolicyMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRaiPolicyMode(input string) (*RaiPolicyMode, error) { + vals := map[string]RaiPolicyMode{ + "asynchronous_filter": RaiPolicyModeAsynchronousFilter, + "blocking": RaiPolicyModeBlocking, + "default": RaiPolicyModeDefault, + "deferred": RaiPolicyModeDeferred, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RaiPolicyMode(input) + return &out, nil +} + +type RaiPolicyType string + +const ( + RaiPolicyTypeSystemManaged RaiPolicyType = "SystemManaged" + RaiPolicyTypeUserManaged RaiPolicyType = "UserManaged" +) + +func PossibleValuesForRaiPolicyType() []string { + return []string{ + string(RaiPolicyTypeSystemManaged), + string(RaiPolicyTypeUserManaged), + } +} + +func (s *RaiPolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRaiPolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRaiPolicyType(input string) (*RaiPolicyType, error) { + vals := map[string]RaiPolicyType{ + "systemmanaged": RaiPolicyTypeSystemManaged, + "usermanaged": RaiPolicyTypeUserManaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RaiPolicyType(input) + return &out, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/id_account.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/id_account.go new file mode 100644 index 000000000000..460748c4e41d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/id_account.go @@ -0,0 +1,130 @@ +package raipolicies + +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(&AccountId{}) +} + +var _ resourceids.ResourceId = &AccountId{} + +// AccountId is a struct representing the Resource ID for a Account +type AccountId struct { + SubscriptionId string + ResourceGroupName string + AccountName string +} + +// NewAccountID returns a new AccountId struct +func NewAccountID(subscriptionId string, resourceGroupName string, accountName string) AccountId { + return AccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AccountName: accountName, + } +} + +// ParseAccountID parses 'input' into a AccountId +func ParseAccountID(input string) (*AccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAccountIDInsensitively parses 'input' case-insensitively into a AccountId +// note: this method should only be used for API response data and not user input +func ParseAccountIDInsensitively(input string) (*AccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AccountName, ok = input.Parsed["accountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) + } + + return nil +} + +// ValidateAccountID checks that 'input' can be parsed as a Account ID +func ValidateAccountID(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 := ParseAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Account ID +func (id AccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CognitiveServices/accounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Account ID +func (id AccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCognitiveServices", "Microsoft.CognitiveServices", "Microsoft.CognitiveServices"), + resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), + resourceids.UserSpecifiedSegment("accountName", "accountName"), + } +} + +// String returns a human-readable description of this Account ID +func (id AccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Account Name: %q", id.AccountName), + } + return fmt.Sprintf("Account (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/id_raipolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/id_raipolicy.go new file mode 100644 index 000000000000..9447722fe0d8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/id_raipolicy.go @@ -0,0 +1,139 @@ +package raipolicies + +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(&RaiPolicyId{}) +} + +var _ resourceids.ResourceId = &RaiPolicyId{} + +// RaiPolicyId is a struct representing the Resource ID for a Rai Policy +type RaiPolicyId struct { + SubscriptionId string + ResourceGroupName string + AccountName string + RaiPolicyName string +} + +// NewRaiPolicyID returns a new RaiPolicyId struct +func NewRaiPolicyID(subscriptionId string, resourceGroupName string, accountName string, raiPolicyName string) RaiPolicyId { + return RaiPolicyId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AccountName: accountName, + RaiPolicyName: raiPolicyName, + } +} + +// ParseRaiPolicyID parses 'input' into a RaiPolicyId +func ParseRaiPolicyID(input string) (*RaiPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&RaiPolicyId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RaiPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRaiPolicyIDInsensitively parses 'input' case-insensitively into a RaiPolicyId +// note: this method should only be used for API response data and not user input +func ParseRaiPolicyIDInsensitively(input string) (*RaiPolicyId, error) { + parser := resourceids.NewParserFromResourceIdType(&RaiPolicyId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RaiPolicyId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RaiPolicyId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AccountName, ok = input.Parsed["accountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) + } + + if id.RaiPolicyName, ok = input.Parsed["raiPolicyName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "raiPolicyName", input) + } + + return nil +} + +// ValidateRaiPolicyID checks that 'input' can be parsed as a Rai Policy ID +func ValidateRaiPolicyID(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 := ParseRaiPolicyID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rai Policy ID +func (id RaiPolicyId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CognitiveServices/accounts/%s/raiPolicies/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AccountName, id.RaiPolicyName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rai Policy ID +func (id RaiPolicyId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCognitiveServices", "Microsoft.CognitiveServices", "Microsoft.CognitiveServices"), + resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), + resourceids.UserSpecifiedSegment("accountName", "accountName"), + resourceids.StaticSegment("staticRaiPolicies", "raiPolicies", "raiPolicies"), + resourceids.UserSpecifiedSegment("raiPolicyName", "raiPolicyName"), + } +} + +// String returns a human-readable description of this Rai Policy ID +func (id RaiPolicyId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Account Name: %q", id.AccountName), + fmt.Sprintf("Rai Policy Name: %q", id.RaiPolicyName), + } + return fmt.Sprintf("Rai Policy (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_createorupdate.go new file mode 100644 index 000000000000..f462d012d822 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_createorupdate.go @@ -0,0 +1,58 @@ +package raipolicies + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RaiPolicy +} + +// CreateOrUpdate ... +func (c RaiPoliciesClient) CreateOrUpdate(ctx context.Context, id RaiPolicyId, input RaiPolicy) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + 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 RaiPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_delete.go new file mode 100644 index 000000000000..fdb2a53c9321 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_delete.go @@ -0,0 +1,70 @@ +package raipolicies + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c RaiPoliciesClient) Delete(ctx context.Context, id RaiPolicyId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c RaiPoliciesClient) DeleteThenPoll(ctx context.Context, id RaiPolicyId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_get.go new file mode 100644 index 000000000000..3770891a82fb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_get.go @@ -0,0 +1,53 @@ +package raipolicies + +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 *RaiPolicy +} + +// Get ... +func (c RaiPoliciesClient) Get(ctx context.Context, id RaiPolicyId) (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 RaiPolicy + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_list.go new file mode 100644 index 000000000000..932a5025f0eb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/method_list.go @@ -0,0 +1,105 @@ +package raipolicies + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RaiPolicy +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RaiPolicy +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c RaiPoliciesClient) List(ctx context.Context, id AccountId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/raiPolicies", 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 *[]RaiPolicy `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 RaiPoliciesClient) ListComplete(ctx context.Context, id AccountId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RaiPolicyOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RaiPoliciesClient) ListCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate RaiPolicyOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RaiPolicy, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_customblocklistconfig.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_customblocklistconfig.go new file mode 100644 index 000000000000..0fe7b2a6641b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_customblocklistconfig.go @@ -0,0 +1,10 @@ +package raipolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomBlocklistConfig struct { + Blocking *bool `json:"blocking,omitempty"` + BlocklistName *string `json:"blocklistName,omitempty"` + Source *RaiPolicyContentSource `json:"source,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_raipolicy.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_raipolicy.go new file mode 100644 index 000000000000..b373a9fdc22c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_raipolicy.go @@ -0,0 +1,18 @@ +package raipolicies + +import ( + "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 RaiPolicy struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RaiPolicyProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_raipolicycontentfilter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_raipolicycontentfilter.go new file mode 100644 index 000000000000..d5984e730bab --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_raipolicycontentfilter.go @@ -0,0 +1,12 @@ +package raipolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RaiPolicyContentFilter struct { + Blocking *bool `json:"blocking,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + Name *string `json:"name,omitempty"` + SeverityThreshold *ContentLevel `json:"severityThreshold,omitempty"` + Source *RaiPolicyContentSource `json:"source,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_raipolicyproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_raipolicyproperties.go new file mode 100644 index 000000000000..31f7dbcb3bae --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/model_raipolicyproperties.go @@ -0,0 +1,12 @@ +package raipolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RaiPolicyProperties struct { + BasePolicyName *string `json:"basePolicyName,omitempty"` + ContentFilters *[]RaiPolicyContentFilter `json:"contentFilters,omitempty"` + CustomBlocklists *[]CustomBlocklistConfig `json:"customBlocklists,omitempty"` + Mode *RaiPolicyMode `json:"mode,omitempty"` + Type *RaiPolicyType `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/predicates.go new file mode 100644 index 000000000000..4f56bb41f17f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/predicates.go @@ -0,0 +1,32 @@ +package raipolicies + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RaiPolicyOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p RaiPolicyOperationPredicate) Matches(input RaiPolicy) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/version.go new file mode 100644 index 000000000000..777f0458d62e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies/version.go @@ -0,0 +1,10 @@ +package raipolicies + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/raipolicies/2024-10-01" +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 17d269b35a92..1d6745e5a337 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -320,6 +320,9 @@ github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-previe github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/cognitiveservicesaccounts github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/deployments +github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists +github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters +github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/communicationservices github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/emailservices diff --git a/website/docs/r/cognitive_account_rai_policy.html.markdown b/website/docs/r/cognitive_account_rai_policy.html.markdown new file mode 100644 index 000000000000..4a2967b4be4a --- /dev/null +++ b/website/docs/r/cognitive_account_rai_policy.html.markdown @@ -0,0 +1,112 @@ +--- +subcategory: "Cognitive Services" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_cognitive_account_rai_policy" +description: |- + Manages a Cognitive Services Account RAI Policy. +--- + +# azurerm_cognitive_account + +Manages a Cognitive Services Account RAI Policy. + +## Example Usage + +```hcl +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "East US" +} + +resource "azurerm_cognitive_account" "example" { + name = "example-account" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + kind = "OpenAI" + sku_name = "S0" +} + +resource "azurerm_cognitive_account_rai_policy" "example" { + name = "example-rai-policy" + cognitive_account_id = azurerm_cognitive_account.example.id + base_policy_name = "Microsoft.Default" + content_filter { + name = "Hate" + filter_enabled = true + block_enabled = true + severity_threshold = "High" + source = "Prompt" + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) The name of the Cognitive Service Account RAI Policy. Changing this forces a new resource to be created. + +* `cognitive_account_id` - (Required) The ID of the Cognitive Service Account to which this RAI Policy should be associated. Changing this forces a new resource to be created. + +* `base_policy_name` - (Required) The name of the base policy to use for this RAI Policy. Changing this forces a new resource to be created. + +* `content_filter` - (Required) A `content_filter` block as defined below. + +* `custom_blocklist` - (Optional) A `custom_blocklist` block as defined below. + +* `mode` - (Optional) The mode of the RAI Policy. Possible values are `Default`, `Deferred`, `Blocking` or `Asynchronous_filter`. + +* `tags` - (Optional) A mapping of tags to assign to the resource. + +--- + +A `content_filter` block supports the following: + +* `name` - (Required) The name of the content filter. + +* `filter_enabled` - (Required) Whether the filter is enabled. Possible values are `true` or `false`. + +* `block_enabled` - (Required) Whether the filter should block content. Possible values are `true` or `false`. + +* `severity_threshold` - (Required) The severity threshold for the filter. Possible values are `Low`, `Medium` or `High`. + +* `source` - (Required) Content source to apply the content filter. Possible values are `Prompt` or `Completion`. + +--- + +A `custom_blocklist` block supports the following: + +* `name` - (Required) The name of the custom blocklist. + +* `block_enabled` - (Required) Whether the custom blocklist should block content. Possible values are `true` or `false`. + +* `source` - (Required) Content source to apply the content filter. Possible values are `Prompt` or `Completion`. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Cognitive Service Account RAI Policy. + +* `type` - The type of the Cognitive Service Account RAI Policy. Possible values are `SystemManaged` or `UserManaged`. + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Cognitive Service Account. +* `update` - (Defaults to 30 minutes) Used when updating the Cognitive Service Account. +* `read` - (Defaults to 5 minutes) Used when retrieving the Cognitive Service Account. +* `delete` - (Defaults to 30 minutes) Used when deleting the Cognitive Service Account. + +## Import + +Cognitive Service Account RAI Policies can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_cognitive_account_rai_policy.policy1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.CognitiveServices/accounts/account1/raiPolicies/policy1 +``` From 87122c532ec2915bb02dbcd3b3e737297b0e27ed Mon Sep 17 00:00:00 2001 From: "Yun Liu (from Dev Box)" Date: Thu, 14 Nov 2024 16:02:25 +0800 Subject: [PATCH 2/9] Optimize code and dependancies for RAI policy --- .../cognitive_account_rai_policy_resource.go | 69 ++----- .../2024-10-01/raiblocklists/README.md | 186 ------------------ .../2024-10-01/raiblocklists/client.go | 26 --- .../2024-10-01/raiblocklists/id_account.go | 130 ------------ .../raiblocklists/id_raiblocklist.go | 139 ------------- .../raiblocklists/id_raiblocklistitem.go | 148 -------------- .../raiblocklists/method_createorupdate.go | 58 ------ .../2024-10-01/raiblocklists/method_delete.go | 70 ------- .../2024-10-01/raiblocklists/method_get.go | 53 ----- .../2024-10-01/raiblocklists/method_list.go | 105 ---------- .../method_raiblocklistitemsbatchadd.go | 58 ------ .../method_raiblocklistitemsbatchdelete.go | 51 ----- .../method_raiblocklistitemscreateorupdate.go | 58 ------ .../method_raiblocklistitemsdelete.go | 70 ------- .../method_raiblocklistitemsget.go | 53 ----- .../method_raiblocklistitemslist.go | 105 ---------- .../raiblocklists/model_raiblocklist.go | 18 -- .../raiblocklists/model_raiblocklistitem.go | 18 -- .../model_raiblocklistitembulkrequest.go | 9 - .../model_raiblocklistitemproperties.go | 9 - .../model_raiblocklistproperties.go | 8 - .../2024-10-01/raiblocklists/predicates.go | 60 ------ .../2024-10-01/raiblocklists/version.go | 10 - .../2024-10-01/raicontentfilters/README.md | 53 ----- .../2024-10-01/raicontentfilters/client.go | 26 --- .../2024-10-01/raicontentfilters/constants.go | 51 ----- .../raicontentfilters/id_location.go | 121 ------------ .../raicontentfilters/id_raicontentfilter.go | 130 ------------ .../raicontentfilters/method_get.go | 53 ----- .../raicontentfilters/method_list.go | 105 ---------- .../model_raicontentfilter.go | 11 -- .../model_raicontentfilterproperties.go | 10 - .../raicontentfilters/predicates.go | 27 --- .../2024-10-01/raicontentfilters/version.go | 10 - vendor/modules.txt | 2 - 35 files changed, 20 insertions(+), 2090 deletions(-) delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/README.md delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/client.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_account.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklist.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklistitem.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_createorupdate.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_delete.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_get.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_list.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchadd.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchdelete.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemscreateorupdate.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsdelete.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsget.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemslist.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklist.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitem.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitembulkrequest.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitemproperties.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistproperties.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/predicates.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/version.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/README.md delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/client.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/constants.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_location.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_raicontentfilter.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_get.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_list.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilter.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilterproperties.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/predicates.go delete mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/version.go diff --git a/internal/services/cognitive/cognitive_account_rai_policy_resource.go b/internal/services/cognitive/cognitive_account_rai_policy_resource.go index 5a87849d95bd..00870eedce25 100644 --- a/internal/services/cognitive/cognitive_account_rai_policy_resource.go +++ b/internal/services/cognitive/cognitive_account_rai_policy_resource.go @@ -181,24 +181,14 @@ func (r CognitiveAccountRaiPolicyResource) Create() sdk.ResourceFunc { raiPolicy := raipolicies.RaiPolicy{ Name: pointer.To(model.Name), Properties: &raipolicies.RaiPolicyProperties{ - BasePolicyName: pointer.To(model.BasePolicyName), - Mode: pointer.To(raipolicies.RaiPolicyMode(model.Mode)), + BasePolicyName: pointer.To(model.BasePolicyName), + ContentFilters: expandRaiPolicyContentFilters(model.ContentFilter), + CustomBlocklists: expandCustomBlockLists(model.CustomBlockList), + Mode: pointer.To(raipolicies.RaiPolicyMode(model.Mode)), }, Tags: pointer.To(model.Tags), } - if contentFilters, err := expandRaiPolicyContentFilters(model.ContentFilter); err != nil { - return err - } else { - raiPolicy.Properties.ContentFilters = contentFilters - } - - if customBlockLists, err := expandCustomBlockLists(model.CustomBlockList); err != nil { - return err - } else { - raiPolicy.Properties.CustomBlocklists = customBlockLists - } - if _, err := client.CreateOrUpdate(ctx, id, raiPolicy); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } @@ -240,20 +230,10 @@ func (r CognitiveAccountRaiPolicyResource) Read() sdk.ResourceFunc { if props := model.Properties; props != nil { state.BasePolicyName = pointer.From(props.BasePolicyName) + state.ContentFilter = flattenRaiPolicyContentFilters(props.ContentFilters) + state.CustomBlockList = flattenRaiCustomBlockLists(props.CustomBlocklists) state.Mode = string(pointer.From(props.Mode)) state.Type = string(pointer.From(props.Type)) - - if err, contentFilters := flattenRaiPolicyContentFilters(props.ContentFilters); err != nil { - return err - } else { - state.ContentFilter = contentFilters - } - - if err, customBlockLists := flattenRaiCustomBlockLists(props.CustomBlocklists); err != nil { - return err - } else { - state.CustomBlockList = customBlockLists - } } } @@ -294,19 +274,11 @@ func (r CognitiveAccountRaiPolicyResource) Update() sdk.ResourceFunc { props := resp.Model if metadata.ResourceData.HasChange("content_filter") { - if contentFilters, err := expandRaiPolicyContentFilters(model.ContentFilter); err != nil { - return err - } else { - props.Properties.ContentFilters = contentFilters - } + props.Properties.ContentFilters = expandRaiPolicyContentFilters(model.ContentFilter) } if metadata.ResourceData.HasChange("custom_blocklist") { - if customBlockLists, err := expandCustomBlockLists(model.CustomBlockList); err != nil { - return err - } else { - props.Properties.CustomBlocklists = customBlockLists - } + props.Properties.CustomBlocklists = expandCustomBlockLists(model.CustomBlockList) } if metadata.ResourceData.HasChange("mode") { @@ -355,9 +327,9 @@ func (r CognitiveAccountRaiPolicyResource) IDValidationFunc() pluginsdk.SchemaVa return raipolicies.ValidateRaiPolicyID } -func expandRaiPolicyContentFilters(filters []AccountRaiPolicyContentFilter) (*[]raipolicies.RaiPolicyContentFilter, error) { +func expandRaiPolicyContentFilters(filters []AccountRaiPolicyContentFilter) *[]raipolicies.RaiPolicyContentFilter { if filters == nil { - return nil, nil + return nil } var contentFilters []raipolicies.RaiPolicyContentFilter @@ -370,12 +342,12 @@ func expandRaiPolicyContentFilters(filters []AccountRaiPolicyContentFilter) (*[] Source: pointer.To(raipolicies.RaiPolicyContentSource(filter.Source)), }) } - return &contentFilters, nil + return &contentFilters } -func expandCustomBlockLists(list []AccountRaiPolicyCustomBlock) (*[]raipolicies.CustomBlocklistConfig, error) { +func expandCustomBlockLists(list []AccountRaiPolicyCustomBlock) *[]raipolicies.CustomBlocklistConfig { if list == nil { - return nil, nil + return nil } var customBlockLists []raipolicies.CustomBlocklistConfig @@ -386,16 +358,15 @@ func expandCustomBlockLists(list []AccountRaiPolicyCustomBlock) (*[]raipolicies. Source: pointer.To(raipolicies.RaiPolicyContentSource(block.Source)), }) } - return &customBlockLists, nil + return &customBlockLists } -func flattenRaiCustomBlockLists(blocklists *[]raipolicies.CustomBlocklistConfig) (error, []AccountRaiPolicyCustomBlock) { +func flattenRaiCustomBlockLists(blocklists *[]raipolicies.CustomBlocklistConfig) []AccountRaiPolicyCustomBlock { if blocklists == nil { - return nil, nil + return nil } var customBlockLists []AccountRaiPolicyCustomBlock - for _, block := range *blocklists { customBlockLists = append(customBlockLists, AccountRaiPolicyCustomBlock{ Name: pointer.From(block.BlocklistName), @@ -403,12 +374,12 @@ func flattenRaiCustomBlockLists(blocklists *[]raipolicies.CustomBlocklistConfig) Source: string(pointer.From(block.Source)), }) } - return nil, customBlockLists + return customBlockLists } -func flattenRaiPolicyContentFilters(filters *[]raipolicies.RaiPolicyContentFilter) (error, []AccountRaiPolicyContentFilter) { +func flattenRaiPolicyContentFilters(filters *[]raipolicies.RaiPolicyContentFilter) []AccountRaiPolicyContentFilter { if filters == nil { - return nil, nil + return nil } var contentFilters []AccountRaiPolicyContentFilter @@ -421,5 +392,5 @@ func flattenRaiPolicyContentFilters(filters *[]raipolicies.RaiPolicyContentFilte Source: string(pointer.From(filter.Source)), }) } - return nil, contentFilters + return contentFilters } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/README.md deleted file mode 100644 index d0fc2d949ba4..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/README.md +++ /dev/null @@ -1,186 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists` Documentation - -The `raiblocklists` SDK allows for interaction with Azure Resource Manager `cognitive` (API Version `2024-10-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-sdk/resource-manager/cognitive/2024-10-01/raiblocklists" -``` - - -### Client Initialization - -```go -client := raiblocklists.NewRaiBlocklistsClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `RaiBlocklistsClient.CreateOrUpdate` - -```go -ctx := context.TODO() -id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") - -payload := raiblocklists.RaiBlocklist{ - // ... -} - - -read, err := client.CreateOrUpdate(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `RaiBlocklistsClient.Delete` - -```go -ctx := context.TODO() -id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") - -if err := client.DeleteThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `RaiBlocklistsClient.Get` - -```go -ctx := context.TODO() -id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") - -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: `RaiBlocklistsClient.List` - -```go -ctx := context.TODO() -id := raiblocklists.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName") - -// alternatively `client.List(ctx, id)` can be used to do batched pagination -items, err := client.ListComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` - - -### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsBatchAdd` - -```go -ctx := context.TODO() -id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") -var payload []RaiBlocklistItemBulkRequest - -read, err := client.RaiBlocklistItemsBatchAdd(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsBatchDelete` - -```go -ctx := context.TODO() -id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") -var payload interface{} - -read, err := client.RaiBlocklistItemsBatchDelete(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsCreateOrUpdate` - -```go -ctx := context.TODO() -id := raiblocklists.NewRaiBlocklistItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName", "raiBlocklistItemName") - -payload := raiblocklists.RaiBlocklistItem{ - // ... -} - - -read, err := client.RaiBlocklistItemsCreateOrUpdate(ctx, id, payload) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsDelete` - -```go -ctx := context.TODO() -id := raiblocklists.NewRaiBlocklistItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName", "raiBlocklistItemName") - -if err := client.RaiBlocklistItemsDeleteThenPoll(ctx, id); err != nil { - // handle the error -} -``` - - -### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsGet` - -```go -ctx := context.TODO() -id := raiblocklists.NewRaiBlocklistItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName", "raiBlocklistItemName") - -read, err := client.RaiBlocklistItemsGet(ctx, id) -if err != nil { - // handle the error -} -if model := read.Model; model != nil { - // do something with the model/response object -} -``` - - -### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsList` - -```go -ctx := context.TODO() -id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") - -// alternatively `client.RaiBlocklistItemsList(ctx, id)` can be used to do batched pagination -items, err := client.RaiBlocklistItemsListComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/client.go deleted file mode 100644 index 8721ad1960a9..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/client.go +++ /dev/null @@ -1,26 +0,0 @@ -package raiblocklists - -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 RaiBlocklistsClient struct { - Client *resourcemanager.Client -} - -func NewRaiBlocklistsClientWithBaseURI(sdkApi sdkEnv.Api) (*RaiBlocklistsClient, error) { - client, err := resourcemanager.NewClient(sdkApi, "raiblocklists", defaultApiVersion) - if err != nil { - return nil, fmt.Errorf("instantiating RaiBlocklistsClient: %+v", err) - } - - return &RaiBlocklistsClient{ - Client: client, - }, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_account.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_account.go deleted file mode 100644 index eadf6b999b86..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_account.go +++ /dev/null @@ -1,130 +0,0 @@ -package raiblocklists - -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(&AccountId{}) -} - -var _ resourceids.ResourceId = &AccountId{} - -// AccountId is a struct representing the Resource ID for a Account -type AccountId struct { - SubscriptionId string - ResourceGroupName string - AccountName string -} - -// NewAccountID returns a new AccountId struct -func NewAccountID(subscriptionId string, resourceGroupName string, accountName string) AccountId { - return AccountId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - AccountName: accountName, - } -} - -// ParseAccountID parses 'input' into a AccountId -func ParseAccountID(input string) (*AccountId, error) { - parser := resourceids.NewParserFromResourceIdType(&AccountId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := AccountId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseAccountIDInsensitively parses 'input' case-insensitively into a AccountId -// note: this method should only be used for API response data and not user input -func ParseAccountIDInsensitively(input string) (*AccountId, error) { - parser := resourceids.NewParserFromResourceIdType(&AccountId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := AccountId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *AccountId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.AccountName, ok = input.Parsed["accountName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) - } - - return nil -} - -// ValidateAccountID checks that 'input' can be parsed as a Account ID -func ValidateAccountID(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 := ParseAccountID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Account ID -func (id AccountId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CognitiveServices/accounts/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AccountName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Account ID -func (id AccountId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftCognitiveServices", "Microsoft.CognitiveServices", "Microsoft.CognitiveServices"), - resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), - resourceids.UserSpecifiedSegment("accountName", "accountName"), - } -} - -// String returns a human-readable description of this Account ID -func (id AccountId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Account Name: %q", id.AccountName), - } - return fmt.Sprintf("Account (%s)", strings.Join(components, "\n")) -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklist.go deleted file mode 100644 index 70ef2a3f25fd..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklist.go +++ /dev/null @@ -1,139 +0,0 @@ -package raiblocklists - -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(&RaiBlocklistId{}) -} - -var _ resourceids.ResourceId = &RaiBlocklistId{} - -// RaiBlocklistId is a struct representing the Resource ID for a Rai Blocklist -type RaiBlocklistId struct { - SubscriptionId string - ResourceGroupName string - AccountName string - RaiBlocklistName string -} - -// NewRaiBlocklistID returns a new RaiBlocklistId struct -func NewRaiBlocklistID(subscriptionId string, resourceGroupName string, accountName string, raiBlocklistName string) RaiBlocklistId { - return RaiBlocklistId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - AccountName: accountName, - RaiBlocklistName: raiBlocklistName, - } -} - -// ParseRaiBlocklistID parses 'input' into a RaiBlocklistId -func ParseRaiBlocklistID(input string) (*RaiBlocklistId, error) { - parser := resourceids.NewParserFromResourceIdType(&RaiBlocklistId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := RaiBlocklistId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseRaiBlocklistIDInsensitively parses 'input' case-insensitively into a RaiBlocklistId -// note: this method should only be used for API response data and not user input -func ParseRaiBlocklistIDInsensitively(input string) (*RaiBlocklistId, error) { - parser := resourceids.NewParserFromResourceIdType(&RaiBlocklistId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := RaiBlocklistId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *RaiBlocklistId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.AccountName, ok = input.Parsed["accountName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) - } - - if id.RaiBlocklistName, ok = input.Parsed["raiBlocklistName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "raiBlocklistName", input) - } - - return nil -} - -// ValidateRaiBlocklistID checks that 'input' can be parsed as a Rai Blocklist ID -func ValidateRaiBlocklistID(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 := ParseRaiBlocklistID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Rai Blocklist ID -func (id RaiBlocklistId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CognitiveServices/accounts/%s/raiBlocklists/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AccountName, id.RaiBlocklistName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Rai Blocklist ID -func (id RaiBlocklistId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftCognitiveServices", "Microsoft.CognitiveServices", "Microsoft.CognitiveServices"), - resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), - resourceids.UserSpecifiedSegment("accountName", "accountName"), - resourceids.StaticSegment("staticRaiBlocklists", "raiBlocklists", "raiBlocklists"), - resourceids.UserSpecifiedSegment("raiBlocklistName", "raiBlocklistName"), - } -} - -// String returns a human-readable description of this Rai Blocklist ID -func (id RaiBlocklistId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Account Name: %q", id.AccountName), - fmt.Sprintf("Rai Blocklist Name: %q", id.RaiBlocklistName), - } - return fmt.Sprintf("Rai Blocklist (%s)", strings.Join(components, "\n")) -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklistitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklistitem.go deleted file mode 100644 index 642b218519cc..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklistitem.go +++ /dev/null @@ -1,148 +0,0 @@ -package raiblocklists - -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(&RaiBlocklistItemId{}) -} - -var _ resourceids.ResourceId = &RaiBlocklistItemId{} - -// RaiBlocklistItemId is a struct representing the Resource ID for a Rai Blocklist Item -type RaiBlocklistItemId struct { - SubscriptionId string - ResourceGroupName string - AccountName string - RaiBlocklistName string - RaiBlocklistItemName string -} - -// NewRaiBlocklistItemID returns a new RaiBlocklistItemId struct -func NewRaiBlocklistItemID(subscriptionId string, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemName string) RaiBlocklistItemId { - return RaiBlocklistItemId{ - SubscriptionId: subscriptionId, - ResourceGroupName: resourceGroupName, - AccountName: accountName, - RaiBlocklistName: raiBlocklistName, - RaiBlocklistItemName: raiBlocklistItemName, - } -} - -// ParseRaiBlocklistItemID parses 'input' into a RaiBlocklistItemId -func ParseRaiBlocklistItemID(input string) (*RaiBlocklistItemId, error) { - parser := resourceids.NewParserFromResourceIdType(&RaiBlocklistItemId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := RaiBlocklistItemId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseRaiBlocklistItemIDInsensitively parses 'input' case-insensitively into a RaiBlocklistItemId -// note: this method should only be used for API response data and not user input -func ParseRaiBlocklistItemIDInsensitively(input string) (*RaiBlocklistItemId, error) { - parser := resourceids.NewParserFromResourceIdType(&RaiBlocklistItemId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := RaiBlocklistItemId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *RaiBlocklistItemId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) - } - - if id.AccountName, ok = input.Parsed["accountName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) - } - - if id.RaiBlocklistName, ok = input.Parsed["raiBlocklistName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "raiBlocklistName", input) - } - - if id.RaiBlocklistItemName, ok = input.Parsed["raiBlocklistItemName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "raiBlocklistItemName", input) - } - - return nil -} - -// ValidateRaiBlocklistItemID checks that 'input' can be parsed as a Rai Blocklist Item ID -func ValidateRaiBlocklistItemID(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 := ParseRaiBlocklistItemID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Rai Blocklist Item ID -func (id RaiBlocklistItemId) ID() string { - fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CognitiveServices/accounts/%s/raiBlocklists/%s/raiBlocklistItems/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AccountName, id.RaiBlocklistName, id.RaiBlocklistItemName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Rai Blocklist Item ID -func (id RaiBlocklistItemId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), - resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftCognitiveServices", "Microsoft.CognitiveServices", "Microsoft.CognitiveServices"), - resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), - resourceids.UserSpecifiedSegment("accountName", "accountName"), - resourceids.StaticSegment("staticRaiBlocklists", "raiBlocklists", "raiBlocklists"), - resourceids.UserSpecifiedSegment("raiBlocklistName", "raiBlocklistName"), - resourceids.StaticSegment("staticRaiBlocklistItems", "raiBlocklistItems", "raiBlocklistItems"), - resourceids.UserSpecifiedSegment("raiBlocklistItemName", "raiBlocklistItemName"), - } -} - -// String returns a human-readable description of this Rai Blocklist Item ID -func (id RaiBlocklistItemId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Account Name: %q", id.AccountName), - fmt.Sprintf("Rai Blocklist Name: %q", id.RaiBlocklistName), - fmt.Sprintf("Rai Blocklist Item Name: %q", id.RaiBlocklistItemName), - } - return fmt.Sprintf("Rai Blocklist Item (%s)", strings.Join(components, "\n")) -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_createorupdate.go deleted file mode 100644 index a6b788f2ab6d..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_createorupdate.go +++ /dev/null @@ -1,58 +0,0 @@ -package raiblocklists - -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 CreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *RaiBlocklist -} - -// CreateOrUpdate ... -func (c RaiBlocklistsClient) CreateOrUpdate(ctx context.Context, id RaiBlocklistId, input RaiBlocklist) (result CreateOrUpdateOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusCreated, - http.StatusOK, - }, - 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 RaiBlocklist - result.Model = &model - if err = resp.Unmarshal(result.Model); err != nil { - return - } - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_delete.go deleted file mode 100644 index 621e422780ff..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_delete.go +++ /dev/null @@ -1,70 +0,0 @@ -package raiblocklists - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" - "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" - "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 { - Poller pollers.Poller - HttpResponse *http.Response - OData *odata.OData -} - -// Delete ... -func (c RaiBlocklistsClient) Delete(ctx context.Context, id RaiBlocklistId) (result DeleteOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusAccepted, - http.StatusNoContent, - }, - 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 - } - - result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) - if err != nil { - return - } - - return -} - -// DeleteThenPoll performs Delete then polls until it's completed -func (c RaiBlocklistsClient) DeleteThenPoll(ctx context.Context, id RaiBlocklistId) error { - result, err := c.Delete(ctx, id) - if err != nil { - return fmt.Errorf("performing Delete: %+v", err) - } - - if err := result.Poller.PollUntilDone(ctx); err != nil { - return fmt.Errorf("polling after Delete: %+v", err) - } - - return nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_get.go deleted file mode 100644 index 277a3c8997eb..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_get.go +++ /dev/null @@ -1,53 +0,0 @@ -package raiblocklists - -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 *RaiBlocklist -} - -// Get ... -func (c RaiBlocklistsClient) Get(ctx context.Context, id RaiBlocklistId) (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 RaiBlocklist - result.Model = &model - if err = resp.Unmarshal(result.Model); err != nil { - return - } - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_list.go deleted file mode 100644 index ea9724913f5d..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_list.go +++ /dev/null @@ -1,105 +0,0 @@ -package raiblocklists - -import ( - "context" - "fmt" - "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 ListOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *[]RaiBlocklist -} - -type ListCompleteResult struct { - LatestHttpResponse *http.Response - Items []RaiBlocklist -} - -type ListCustomPager struct { - NextLink *odata.Link `json:"nextLink"` -} - -func (p *ListCustomPager) NextPageLink() *odata.Link { - defer func() { - p.NextLink = nil - }() - - return p.NextLink -} - -// List ... -func (c RaiBlocklistsClient) List(ctx context.Context, id AccountId) (result ListOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodGet, - Pager: &ListCustomPager{}, - Path: fmt.Sprintf("%s/raiBlocklists", 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 *[]RaiBlocklist `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 RaiBlocklistsClient) ListComplete(ctx context.Context, id AccountId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, RaiBlocklistOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c RaiBlocklistsClient) ListCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate RaiBlocklistOperationPredicate) (result ListCompleteResult, err error) { - items := make([]RaiBlocklist, 0) - - resp, err := c.List(ctx, id) - if err != nil { - result.LatestHttpResponse = resp.HttpResponse - 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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchadd.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchadd.go deleted file mode 100644 index 1a7e886a20f2..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchadd.go +++ /dev/null @@ -1,58 +0,0 @@ -package raiblocklists - -import ( - "context" - "fmt" - "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 RaiBlocklistItemsBatchAddOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *RaiBlocklist -} - -// RaiBlocklistItemsBatchAdd ... -func (c RaiBlocklistsClient) RaiBlocklistItemsBatchAdd(ctx context.Context, id RaiBlocklistId, input []RaiBlocklistItemBulkRequest) (result RaiBlocklistItemsBatchAddOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodPost, - Path: fmt.Sprintf("%s/addRaiBlocklistItems", 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 RaiBlocklist - result.Model = &model - if err = resp.Unmarshal(result.Model); err != nil { - return - } - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchdelete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchdelete.go deleted file mode 100644 index b8313577f4c7..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchdelete.go +++ /dev/null @@ -1,51 +0,0 @@ -package raiblocklists - -import ( - "context" - "fmt" - "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 RaiBlocklistItemsBatchDeleteOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData -} - -// RaiBlocklistItemsBatchDelete ... -func (c RaiBlocklistsClient) RaiBlocklistItemsBatchDelete(ctx context.Context, id RaiBlocklistId, input interface{}) (result RaiBlocklistItemsBatchDeleteOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusNoContent, - }, - HttpMethod: http.MethodPost, - Path: fmt.Sprintf("%s/deleteRaiBlocklistItems", 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 - } - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemscreateorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemscreateorupdate.go deleted file mode 100644 index 5caeb001e7c7..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemscreateorupdate.go +++ /dev/null @@ -1,58 +0,0 @@ -package raiblocklists - -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 RaiBlocklistItemsCreateOrUpdateOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *RaiBlocklistItem -} - -// RaiBlocklistItemsCreateOrUpdate ... -func (c RaiBlocklistsClient) RaiBlocklistItemsCreateOrUpdate(ctx context.Context, id RaiBlocklistItemId, input RaiBlocklistItem) (result RaiBlocklistItemsCreateOrUpdateOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusCreated, - http.StatusOK, - }, - 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 RaiBlocklistItem - result.Model = &model - if err = resp.Unmarshal(result.Model); err != nil { - return - } - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsdelete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsdelete.go deleted file mode 100644 index b832a825b546..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsdelete.go +++ /dev/null @@ -1,70 +0,0 @@ -package raiblocklists - -import ( - "context" - "fmt" - "net/http" - - "github.com/hashicorp/go-azure-sdk/sdk/client" - "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" - "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" - "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 RaiBlocklistItemsDeleteOperationResponse struct { - Poller pollers.Poller - HttpResponse *http.Response - OData *odata.OData -} - -// RaiBlocklistItemsDelete ... -func (c RaiBlocklistsClient) RaiBlocklistItemsDelete(ctx context.Context, id RaiBlocklistItemId) (result RaiBlocklistItemsDeleteOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusAccepted, - http.StatusNoContent, - }, - 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 - } - - result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) - if err != nil { - return - } - - return -} - -// RaiBlocklistItemsDeleteThenPoll performs RaiBlocklistItemsDelete then polls until it's completed -func (c RaiBlocklistsClient) RaiBlocklistItemsDeleteThenPoll(ctx context.Context, id RaiBlocklistItemId) error { - result, err := c.RaiBlocklistItemsDelete(ctx, id) - if err != nil { - return fmt.Errorf("performing RaiBlocklistItemsDelete: %+v", err) - } - - if err := result.Poller.PollUntilDone(ctx); err != nil { - return fmt.Errorf("polling after RaiBlocklistItemsDelete: %+v", err) - } - - return nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsget.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsget.go deleted file mode 100644 index 390fcc14f820..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsget.go +++ /dev/null @@ -1,53 +0,0 @@ -package raiblocklists - -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 RaiBlocklistItemsGetOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *RaiBlocklistItem -} - -// RaiBlocklistItemsGet ... -func (c RaiBlocklistsClient) RaiBlocklistItemsGet(ctx context.Context, id RaiBlocklistItemId) (result RaiBlocklistItemsGetOperationResponse, 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 RaiBlocklistItem - result.Model = &model - if err = resp.Unmarshal(result.Model); err != nil { - return - } - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemslist.go deleted file mode 100644 index 15c228ce07a4..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemslist.go +++ /dev/null @@ -1,105 +0,0 @@ -package raiblocklists - -import ( - "context" - "fmt" - "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 RaiBlocklistItemsListOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *[]RaiBlocklistItem -} - -type RaiBlocklistItemsListCompleteResult struct { - LatestHttpResponse *http.Response - Items []RaiBlocklistItem -} - -type RaiBlocklistItemsListCustomPager struct { - NextLink *odata.Link `json:"nextLink"` -} - -func (p *RaiBlocklistItemsListCustomPager) NextPageLink() *odata.Link { - defer func() { - p.NextLink = nil - }() - - return p.NextLink -} - -// RaiBlocklistItemsList ... -func (c RaiBlocklistsClient) RaiBlocklistItemsList(ctx context.Context, id RaiBlocklistId) (result RaiBlocklistItemsListOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodGet, - Pager: &RaiBlocklistItemsListCustomPager{}, - Path: fmt.Sprintf("%s/raiBlocklistItems", 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 *[]RaiBlocklistItem `json:"value"` - } - if err = resp.Unmarshal(&values); err != nil { - return - } - - result.Model = values.Values - - return -} - -// RaiBlocklistItemsListComplete retrieves all the results into a single object -func (c RaiBlocklistsClient) RaiBlocklistItemsListComplete(ctx context.Context, id RaiBlocklistId) (RaiBlocklistItemsListCompleteResult, error) { - return c.RaiBlocklistItemsListCompleteMatchingPredicate(ctx, id, RaiBlocklistItemOperationPredicate{}) -} - -// RaiBlocklistItemsListCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c RaiBlocklistsClient) RaiBlocklistItemsListCompleteMatchingPredicate(ctx context.Context, id RaiBlocklistId, predicate RaiBlocklistItemOperationPredicate) (result RaiBlocklistItemsListCompleteResult, err error) { - items := make([]RaiBlocklistItem, 0) - - resp, err := c.RaiBlocklistItemsList(ctx, id) - if err != nil { - result.LatestHttpResponse = resp.HttpResponse - 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 = RaiBlocklistItemsListCompleteResult{ - LatestHttpResponse: resp.HttpResponse, - Items: items, - } - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklist.go deleted file mode 100644 index 8be491a1b59b..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklist.go +++ /dev/null @@ -1,18 +0,0 @@ -package raiblocklists - -import ( - "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 RaiBlocklist struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *RaiBlocklistProperties `json:"properties,omitempty"` - SystemData *systemdata.SystemData `json:"systemData,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitem.go deleted file mode 100644 index 98bd2267f965..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitem.go +++ /dev/null @@ -1,18 +0,0 @@ -package raiblocklists - -import ( - "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 RaiBlocklistItem struct { - Etag *string `json:"etag,omitempty"` - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *RaiBlocklistItemProperties `json:"properties,omitempty"` - SystemData *systemdata.SystemData `json:"systemData,omitempty"` - Tags *map[string]string `json:"tags,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitembulkrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitembulkrequest.go deleted file mode 100644 index 7f7ac1e1e3c3..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitembulkrequest.go +++ /dev/null @@ -1,9 +0,0 @@ -package raiblocklists - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RaiBlocklistItemBulkRequest struct { - Name *string `json:"name,omitempty"` - Properties *RaiBlocklistItemProperties `json:"properties,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitemproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitemproperties.go deleted file mode 100644 index f6b4e7ca37a6..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitemproperties.go +++ /dev/null @@ -1,9 +0,0 @@ -package raiblocklists - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RaiBlocklistItemProperties struct { - IsRegex *bool `json:"isRegex,omitempty"` - Pattern *string `json:"pattern,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistproperties.go deleted file mode 100644 index 816f9b75e266..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistproperties.go +++ /dev/null @@ -1,8 +0,0 @@ -package raiblocklists - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RaiBlocklistProperties struct { - Description *string `json:"description,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/predicates.go deleted file mode 100644 index a317e1c7318b..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/predicates.go +++ /dev/null @@ -1,60 +0,0 @@ -package raiblocklists - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RaiBlocklistOperationPredicate struct { - Etag *string - Id *string - Name *string - Type *string -} - -func (p RaiBlocklistOperationPredicate) Matches(input RaiBlocklist) bool { - - if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { - return false - } - - 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 -} - -type RaiBlocklistItemOperationPredicate struct { - Etag *string - Id *string - Name *string - Type *string -} - -func (p RaiBlocklistItemOperationPredicate) Matches(input RaiBlocklistItem) bool { - - if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { - return false - } - - 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 -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/version.go deleted file mode 100644 index cc4c248b7f4a..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/version.go +++ /dev/null @@ -1,10 +0,0 @@ -package raiblocklists - -// 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-10-01" - -func userAgent() string { - return "hashicorp/go-azure-sdk/raiblocklists/2024-10-01" -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/README.md deleted file mode 100644 index 7e211cb271c8..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/README.md +++ /dev/null @@ -1,53 +0,0 @@ - -## `github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters` Documentation - -The `raicontentfilters` SDK allows for interaction with Azure Resource Manager `cognitive` (API Version `2024-10-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-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters" -``` - - -### Client Initialization - -```go -client := raicontentfilters.NewRaiContentFiltersClientWithBaseURI("https://management.azure.com") -client.Client.Authorizer = authorizer -``` - - -### Example Usage: `RaiContentFiltersClient.Get` - -```go -ctx := context.TODO() -id := raicontentfilters.NewRaiContentFilterID("12345678-1234-9876-4563-123456789012", "locationName", "raiContentFilterName") - -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: `RaiContentFiltersClient.List` - -```go -ctx := context.TODO() -id := raicontentfilters.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") - -// alternatively `client.List(ctx, id)` can be used to do batched pagination -items, err := client.ListComplete(ctx, id) -if err != nil { - // handle the error -} -for _, item := range items { - // do something -} -``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/client.go deleted file mode 100644 index 63dbeff0cfdd..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/client.go +++ /dev/null @@ -1,26 +0,0 @@ -package raicontentfilters - -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 RaiContentFiltersClient struct { - Client *resourcemanager.Client -} - -func NewRaiContentFiltersClientWithBaseURI(sdkApi sdkEnv.Api) (*RaiContentFiltersClient, error) { - client, err := resourcemanager.NewClient(sdkApi, "raicontentfilters", defaultApiVersion) - if err != nil { - return nil, fmt.Errorf("instantiating RaiContentFiltersClient: %+v", err) - } - - return &RaiContentFiltersClient{ - Client: client, - }, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/constants.go deleted file mode 100644 index 68418b1081bf..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/constants.go +++ /dev/null @@ -1,51 +0,0 @@ -package raicontentfilters - -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 RaiPolicyContentSource string - -const ( - RaiPolicyContentSourceCompletion RaiPolicyContentSource = "Completion" - RaiPolicyContentSourcePrompt RaiPolicyContentSource = "Prompt" -) - -func PossibleValuesForRaiPolicyContentSource() []string { - return []string{ - string(RaiPolicyContentSourceCompletion), - string(RaiPolicyContentSourcePrompt), - } -} - -func (s *RaiPolicyContentSource) UnmarshalJSON(bytes []byte) error { - var decoded string - if err := json.Unmarshal(bytes, &decoded); err != nil { - return fmt.Errorf("unmarshaling: %+v", err) - } - out, err := parseRaiPolicyContentSource(decoded) - if err != nil { - return fmt.Errorf("parsing %q: %+v", decoded, err) - } - *s = *out - return nil -} - -func parseRaiPolicyContentSource(input string) (*RaiPolicyContentSource, error) { - vals := map[string]RaiPolicyContentSource{ - "completion": RaiPolicyContentSourceCompletion, - "prompt": RaiPolicyContentSourcePrompt, - } - if v, ok := vals[strings.ToLower(input)]; ok { - return &v, nil - } - - // otherwise presume it's an undefined value and best-effort it - out := RaiPolicyContentSource(input) - return &out, nil -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_location.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_location.go deleted file mode 100644 index 3dfb920179ae..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_location.go +++ /dev/null @@ -1,121 +0,0 @@ -package raicontentfilters - -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(&LocationId{}) -} - -var _ resourceids.ResourceId = &LocationId{} - -// LocationId is a struct representing the Resource ID for a Location -type LocationId struct { - SubscriptionId string - LocationName string -} - -// NewLocationID returns a new LocationId struct -func NewLocationID(subscriptionId string, locationName string) LocationId { - return LocationId{ - SubscriptionId: subscriptionId, - LocationName: locationName, - } -} - -// ParseLocationID parses 'input' into a LocationId -func ParseLocationID(input string) (*LocationId, error) { - parser := resourceids.NewParserFromResourceIdType(&LocationId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := LocationId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseLocationIDInsensitively parses 'input' case-insensitively into a LocationId -// note: this method should only be used for API response data and not user input -func ParseLocationIDInsensitively(input string) (*LocationId, error) { - parser := resourceids.NewParserFromResourceIdType(&LocationId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := LocationId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *LocationId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.LocationName, ok = input.Parsed["locationName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) - } - - return nil -} - -// ValidateLocationID checks that 'input' can be parsed as a Location ID -func ValidateLocationID(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 := ParseLocationID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Location ID -func (id LocationId) ID() string { - fmtString := "/subscriptions/%s/providers/Microsoft.CognitiveServices/locations/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Location ID -func (id LocationId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftCognitiveServices", "Microsoft.CognitiveServices", "Microsoft.CognitiveServices"), - resourceids.StaticSegment("staticLocations", "locations", "locations"), - resourceids.UserSpecifiedSegment("locationName", "locationName"), - } -} - -// String returns a human-readable description of this Location ID -func (id LocationId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Location Name: %q", id.LocationName), - } - return fmt.Sprintf("Location (%s)", strings.Join(components, "\n")) -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_raicontentfilter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_raicontentfilter.go deleted file mode 100644 index 0494a52b88e6..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/id_raicontentfilter.go +++ /dev/null @@ -1,130 +0,0 @@ -package raicontentfilters - -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(&RaiContentFilterId{}) -} - -var _ resourceids.ResourceId = &RaiContentFilterId{} - -// RaiContentFilterId is a struct representing the Resource ID for a Rai Content Filter -type RaiContentFilterId struct { - SubscriptionId string - LocationName string - RaiContentFilterName string -} - -// NewRaiContentFilterID returns a new RaiContentFilterId struct -func NewRaiContentFilterID(subscriptionId string, locationName string, raiContentFilterName string) RaiContentFilterId { - return RaiContentFilterId{ - SubscriptionId: subscriptionId, - LocationName: locationName, - RaiContentFilterName: raiContentFilterName, - } -} - -// ParseRaiContentFilterID parses 'input' into a RaiContentFilterId -func ParseRaiContentFilterID(input string) (*RaiContentFilterId, error) { - parser := resourceids.NewParserFromResourceIdType(&RaiContentFilterId{}) - parsed, err := parser.Parse(input, false) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := RaiContentFilterId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -// ParseRaiContentFilterIDInsensitively parses 'input' case-insensitively into a RaiContentFilterId -// note: this method should only be used for API response data and not user input -func ParseRaiContentFilterIDInsensitively(input string) (*RaiContentFilterId, error) { - parser := resourceids.NewParserFromResourceIdType(&RaiContentFilterId{}) - parsed, err := parser.Parse(input, true) - if err != nil { - return nil, fmt.Errorf("parsing %q: %+v", input, err) - } - - id := RaiContentFilterId{} - if err = id.FromParseResult(*parsed); err != nil { - return nil, err - } - - return &id, nil -} - -func (id *RaiContentFilterId) FromParseResult(input resourceids.ParseResult) error { - var ok bool - - if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) - } - - if id.LocationName, ok = input.Parsed["locationName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "locationName", input) - } - - if id.RaiContentFilterName, ok = input.Parsed["raiContentFilterName"]; !ok { - return resourceids.NewSegmentNotSpecifiedError(id, "raiContentFilterName", input) - } - - return nil -} - -// ValidateRaiContentFilterID checks that 'input' can be parsed as a Rai Content Filter ID -func ValidateRaiContentFilterID(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 := ParseRaiContentFilterID(v); err != nil { - errors = append(errors, err) - } - - return -} - -// ID returns the formatted Rai Content Filter ID -func (id RaiContentFilterId) ID() string { - fmtString := "/subscriptions/%s/providers/Microsoft.CognitiveServices/locations/%s/raiContentFilters/%s" - return fmt.Sprintf(fmtString, id.SubscriptionId, id.LocationName, id.RaiContentFilterName) -} - -// Segments returns a slice of Resource ID Segments which comprise this Rai Content Filter ID -func (id RaiContentFilterId) Segments() []resourceids.Segment { - return []resourceids.Segment{ - resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), - resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), - resourceids.StaticSegment("staticProviders", "providers", "providers"), - resourceids.ResourceProviderSegment("staticMicrosoftCognitiveServices", "Microsoft.CognitiveServices", "Microsoft.CognitiveServices"), - resourceids.StaticSegment("staticLocations", "locations", "locations"), - resourceids.UserSpecifiedSegment("locationName", "locationName"), - resourceids.StaticSegment("staticRaiContentFilters", "raiContentFilters", "raiContentFilters"), - resourceids.UserSpecifiedSegment("raiContentFilterName", "raiContentFilterName"), - } -} - -// String returns a human-readable description of this Rai Content Filter ID -func (id RaiContentFilterId) String() string { - components := []string{ - fmt.Sprintf("Subscription: %q", id.SubscriptionId), - fmt.Sprintf("Location Name: %q", id.LocationName), - fmt.Sprintf("Rai Content Filter Name: %q", id.RaiContentFilterName), - } - return fmt.Sprintf("Rai Content Filter (%s)", strings.Join(components, "\n")) -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_get.go deleted file mode 100644 index 92a989a8f085..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_get.go +++ /dev/null @@ -1,53 +0,0 @@ -package raicontentfilters - -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 *RaiContentFilter -} - -// Get ... -func (c RaiContentFiltersClient) Get(ctx context.Context, id RaiContentFilterId) (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 RaiContentFilter - result.Model = &model - if err = resp.Unmarshal(result.Model); err != nil { - return - } - - return -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_list.go deleted file mode 100644 index 0760eeeeb371..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/method_list.go +++ /dev/null @@ -1,105 +0,0 @@ -package raicontentfilters - -import ( - "context" - "fmt" - "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 ListOperationResponse struct { - HttpResponse *http.Response - OData *odata.OData - Model *[]RaiContentFilter -} - -type ListCompleteResult struct { - LatestHttpResponse *http.Response - Items []RaiContentFilter -} - -type ListCustomPager struct { - NextLink *odata.Link `json:"nextLink"` -} - -func (p *ListCustomPager) NextPageLink() *odata.Link { - defer func() { - p.NextLink = nil - }() - - return p.NextLink -} - -// List ... -func (c RaiContentFiltersClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { - opts := client.RequestOptions{ - ContentType: "application/json; charset=utf-8", - ExpectedStatusCodes: []int{ - http.StatusOK, - }, - HttpMethod: http.MethodGet, - Pager: &ListCustomPager{}, - Path: fmt.Sprintf("%s/raiContentFilters", 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 *[]RaiContentFilter `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 RaiContentFiltersClient) ListComplete(ctx context.Context, id LocationId) (ListCompleteResult, error) { - return c.ListCompleteMatchingPredicate(ctx, id, RaiContentFilterOperationPredicate{}) -} - -// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate -func (c RaiContentFiltersClient) ListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate RaiContentFilterOperationPredicate) (result ListCompleteResult, err error) { - items := make([]RaiContentFilter, 0) - - resp, err := c.List(ctx, id) - if err != nil { - result.LatestHttpResponse = resp.HttpResponse - 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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilter.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilter.go deleted file mode 100644 index 1f2adebacaba..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilter.go +++ /dev/null @@ -1,11 +0,0 @@ -package raicontentfilters - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RaiContentFilter struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Properties *RaiContentFilterProperties `json:"properties,omitempty"` - Type *string `json:"type,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilterproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilterproperties.go deleted file mode 100644 index 116e39cdd8bc..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/model_raicontentfilterproperties.go +++ /dev/null @@ -1,10 +0,0 @@ -package raicontentfilters - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RaiContentFilterProperties struct { - IsMultiLevelFilter *bool `json:"isMultiLevelFilter,omitempty"` - Name *string `json:"name,omitempty"` - Source *RaiPolicyContentSource `json:"source,omitempty"` -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/predicates.go deleted file mode 100644 index 994f2fa9ea89..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/predicates.go +++ /dev/null @@ -1,27 +0,0 @@ -package raicontentfilters - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See NOTICE.txt in the project root for license information. - -type RaiContentFilterOperationPredicate struct { - Id *string - Name *string - Type *string -} - -func (p RaiContentFilterOperationPredicate) Matches(input RaiContentFilter) 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 -} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/version.go deleted file mode 100644 index c83eb0666831..000000000000 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters/version.go +++ /dev/null @@ -1,10 +0,0 @@ -package raicontentfilters - -// 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-10-01" - -func userAgent() string { - return "hashicorp/go-azure-sdk/raicontentfilters/2024-10-01" -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 1d6745e5a337..9e6a316c050b 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -320,8 +320,6 @@ github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-previe github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/cognitiveservicesaccounts github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/deployments -github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists -github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raicontentfilters github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/communicationservices github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains From 536d6703d93fbd7a313e9cc791e832f7a1776cbd Mon Sep 17 00:00:00 2001 From: "Yun Liu (from Dev Box)" Date: Thu, 14 Nov 2024 17:29:31 +0800 Subject: [PATCH 3/9] Resolve golint issues by pre-allocation --- .../cognitive/cognitive_account_rai_policy_resource.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/services/cognitive/cognitive_account_rai_policy_resource.go b/internal/services/cognitive/cognitive_account_rai_policy_resource.go index 00870eedce25..6df5f2ceb1e3 100644 --- a/internal/services/cognitive/cognitive_account_rai_policy_resource.go +++ b/internal/services/cognitive/cognitive_account_rai_policy_resource.go @@ -332,7 +332,7 @@ func expandRaiPolicyContentFilters(filters []AccountRaiPolicyContentFilter) *[]r return nil } - var contentFilters []raipolicies.RaiPolicyContentFilter + contentFilters := make([]raipolicies.RaiPolicyContentFilter, 0, len(filters)) for _, filter := range filters { contentFilters = append(contentFilters, raipolicies.RaiPolicyContentFilter{ Name: pointer.To(filter.Name), @@ -350,7 +350,7 @@ func expandCustomBlockLists(list []AccountRaiPolicyCustomBlock) *[]raipolicies.C return nil } - var customBlockLists []raipolicies.CustomBlocklistConfig + customBlockLists := make([]raipolicies.CustomBlocklistConfig, 0, len(list)) for _, block := range list { customBlockLists = append(customBlockLists, raipolicies.CustomBlocklistConfig{ BlocklistName: pointer.To(block.Name), @@ -366,7 +366,7 @@ func flattenRaiCustomBlockLists(blocklists *[]raipolicies.CustomBlocklistConfig) return nil } - var customBlockLists []AccountRaiPolicyCustomBlock + customBlockLists := make([]AccountRaiPolicyCustomBlock, 0, len(*blocklists)) for _, block := range *blocklists { customBlockLists = append(customBlockLists, AccountRaiPolicyCustomBlock{ Name: pointer.From(block.BlocklistName), @@ -382,7 +382,7 @@ func flattenRaiPolicyContentFilters(filters *[]raipolicies.RaiPolicyContentFilte return nil } - var contentFilters []AccountRaiPolicyContentFilter + contentFilters := make([]AccountRaiPolicyContentFilter, 0, len(*filters)) for _, filter := range *filters { contentFilters = append(contentFilters, AccountRaiPolicyContentFilter{ Name: pointer.From(filter.Name), From 91404ee28d519331b3e68b5acc9086000d1add7b Mon Sep 17 00:00:00 2001 From: Yun Liu Date: Tue, 10 Dec 2024 10:39:23 +0800 Subject: [PATCH 4/9] Apply suggestions from code review Co-authored-by: stephybun --- internal/services/cognitive/client/client.go | 2 +- .../cognitive_account_rai_policy_resource.go | 33 +++++++++---------- ...nitive_account_rai_policy_resource_test.go | 2 +- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/internal/services/cognitive/client/client.go b/internal/services/cognitive/client/client.go index 96349c9f9282..55408b710680 100644 --- a/internal/services/cognitive/client/client.go +++ b/internal/services/cognitive/client/client.go @@ -33,7 +33,7 @@ func NewClient(o *common.ClientOptions) (*Client, error) { raiPoliciesClient, err := raipolicies.NewRaiPoliciesClientWithBaseURI(o.Environment.ResourceManager) if err != nil { - return nil, fmt.Errorf("building RaiPolicies client: %+v", err) + return nil, fmt.Errorf("building Rai Policies client: %+v", err) } o.Configure(raiPoliciesClient.Client, o.Authorizers.ResourceManager) diff --git a/internal/services/cognitive/cognitive_account_rai_policy_resource.go b/internal/services/cognitive/cognitive_account_rai_policy_resource.go index 6df5f2ceb1e3..5faf3cbf0fc8 100644 --- a/internal/services/cognitive/cognitive_account_rai_policy_resource.go +++ b/internal/services/cognitive/cognitive_account_rai_policy_resource.go @@ -41,7 +41,6 @@ type AccountRaiPolicyResourceModel struct { CustomBlockList []AccountRaiPolicyCustomBlock `tfschema:"custom_blocklist"` Mode string `tfschema:"mode"` Tags map[string]string `tfschema:"tags"` - Type string `tfschema:"type"` } func (r CognitiveAccountRaiPolicyResource) Arguments() map[string]*pluginsdk.Schema { @@ -134,10 +133,6 @@ func (r CognitiveAccountRaiPolicyResource) Arguments() map[string]*pluginsdk.Sch func (r CognitiveAccountRaiPolicyResource) Attributes() map[string]*pluginsdk.Schema { return map[string]*pluginsdk.Schema{ - "type": { - Type: pluginsdk.TypeString, - Computed: true, - }, } } @@ -158,7 +153,7 @@ func (r CognitiveAccountRaiPolicyResource) Create() sdk.ResourceFunc { var model AccountRaiPolicyResourceModel if err := metadata.Decode(&model); err != nil { - return err + return fmt.Errorf("decoding: %+v", err) } cognitiveAccountId, err := raipolicies.ParseAccountID(model.AccountId) @@ -168,8 +163,10 @@ func (r CognitiveAccountRaiPolicyResource) Create() sdk.ResourceFunc { id := raipolicies.NewRaiPolicyID(subscriptionId, cognitiveAccountId.ResourceGroupName, cognitiveAccountId.AccountName, model.Name) existing, err := client.Get(ctx, id) - if err != nil && !response.WasNotFound(existing.HttpResponse) { - return fmt.Errorf("checking for presence of existing %s: %+v", id, err) + if err != nil { + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) + } } if !response.WasNotFound(existing.HttpResponse) { return metadata.ResourceRequiresImport(r.ResourceType(), id) @@ -221,11 +218,12 @@ func (r CognitiveAccountRaiPolicyResource) Read() sdk.ResourceFunc { return fmt.Errorf("retrieving %s: %+v", id, err) } - state := AccountRaiPolicyResourceModel{} + state := AccountRaiPolicyResourceModel{ + Name: id.Name, + AccountId: cognitiveAccountId.ID(), + } if model := resp.Model; model != nil { - state.Name = pointer.From(model.Name) - state.AccountId = cognitiveAccountId.ID() state.Tags = pointer.From(model.Tags) if props := model.Properties; props != nil { @@ -260,9 +258,6 @@ func (r CognitiveAccountRaiPolicyResource) Update() sdk.ResourceFunc { resp, err := client.Get(ctx, *id) if err != nil { - if response.WasNotFound(resp.HttpResponse) { - return metadata.MarkAsGone(id) - } return fmt.Errorf("retrieving %s: %+v", *id, err) } @@ -362,11 +357,12 @@ func expandCustomBlockLists(list []AccountRaiPolicyCustomBlock) *[]raipolicies.C } func flattenRaiCustomBlockLists(blocklists *[]raipolicies.CustomBlocklistConfig) []AccountRaiPolicyCustomBlock { + customBlockLists := make([]AccountRaiPolicyCustomBlock, 0) if blocklists == nil { - return nil + return customBlockLists } - customBlockLists := make([]AccountRaiPolicyCustomBlock, 0, len(*blocklists)) + for _, block := range *blocklists { customBlockLists = append(customBlockLists, AccountRaiPolicyCustomBlock{ Name: pointer.From(block.BlocklistName), @@ -378,11 +374,12 @@ func flattenRaiCustomBlockLists(blocklists *[]raipolicies.CustomBlocklistConfig) } func flattenRaiPolicyContentFilters(filters *[]raipolicies.RaiPolicyContentFilter) []AccountRaiPolicyContentFilter { + contentFilters := make([]AccountRaiPolicyContentFilter, 0) if filters == nil { - return nil + return contentFilters } - contentFilters := make([]AccountRaiPolicyContentFilter, 0, len(*filters)) + for _, filter := range *filters { contentFilters = append(contentFilters, AccountRaiPolicyContentFilter{ Name: pointer.From(filter.Name), diff --git a/internal/services/cognitive/cognitive_account_rai_policy_resource_test.go b/internal/services/cognitive/cognitive_account_rai_policy_resource_test.go index d78ded7f29e2..a573a6fc848e 100644 --- a/internal/services/cognitive/cognitive_account_rai_policy_resource_test.go +++ b/internal/services/cognitive/cognitive_account_rai_policy_resource_test.go @@ -62,7 +62,7 @@ func (r RaiPolicyTestResource) Exists(ctx context.Context, client *clients.Clien return pointer.To(resp.Model != nil), nil } -func (r RaiPolicyTestResource) basicConfig(data acceptance.TestData) string { +func (r RaiPolicyTestResource) basic(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} From cace0c9a74153442b1dd111962094e24f656f859 Mon Sep 17 00:00:00 2001 From: "Yun Liu (from Dev Box)" Date: Tue, 10 Dec 2024 14:30:43 +0800 Subject: [PATCH 5/9] Update according to review comment. --- .../cognitive_account_rai_policy_resource.go | 44 +++++++++------- ...nitive_account_rai_policy_resource_test.go | 50 +++++++++++++++---- internal/services/cognitive/registration.go | 2 +- ...cognitive_account_rai_policy.html.markdown | 13 ++--- 4 files changed, 75 insertions(+), 34 deletions(-) diff --git a/internal/services/cognitive/cognitive_account_rai_policy_resource.go b/internal/services/cognitive/cognitive_account_rai_policy_resource.go index 5faf3cbf0fc8..b25ca42e394d 100644 --- a/internal/services/cognitive/cognitive_account_rai_policy_resource.go +++ b/internal/services/cognitive/cognitive_account_rai_policy_resource.go @@ -132,8 +132,7 @@ func (r CognitiveAccountRaiPolicyResource) Arguments() map[string]*pluginsdk.Sch } func (r CognitiveAccountRaiPolicyResource) Attributes() map[string]*pluginsdk.Schema { - return map[string]*pluginsdk.Schema{ - } + return map[string]*pluginsdk.Schema{} } func (r CognitiveAccountRaiPolicyResource) ModelObject() interface{} { @@ -178,14 +177,20 @@ func (r CognitiveAccountRaiPolicyResource) Create() sdk.ResourceFunc { raiPolicy := raipolicies.RaiPolicy{ Name: pointer.To(model.Name), Properties: &raipolicies.RaiPolicyProperties{ - BasePolicyName: pointer.To(model.BasePolicyName), - ContentFilters: expandRaiPolicyContentFilters(model.ContentFilter), - CustomBlocklists: expandCustomBlockLists(model.CustomBlockList), - Mode: pointer.To(raipolicies.RaiPolicyMode(model.Mode)), + BasePolicyName: pointer.To(model.BasePolicyName), + ContentFilters: expandRaiPolicyContentFilters(model.ContentFilter), }, Tags: pointer.To(model.Tags), } + if model.CustomBlockList != nil { + raiPolicy.Properties.CustomBlocklists = expandCustomBlockLists(model.CustomBlockList) + } + + if model.Mode != "" { + raiPolicy.Properties.Mode = pointer.To(raipolicies.RaiPolicyMode(model.Mode)) + } + if _, err := client.CreateOrUpdate(ctx, id, raiPolicy); err != nil { return fmt.Errorf("creating %s: %+v", id, err) } @@ -219,7 +224,7 @@ func (r CognitiveAccountRaiPolicyResource) Read() sdk.ResourceFunc { } state := AccountRaiPolicyResourceModel{ - Name: id.Name, + Name: id.RaiPolicyName, AccountId: cognitiveAccountId.ID(), } @@ -231,7 +236,6 @@ func (r CognitiveAccountRaiPolicyResource) Read() sdk.ResourceFunc { state.ContentFilter = flattenRaiPolicyContentFilters(props.ContentFilters) state.CustomBlockList = flattenRaiCustomBlockLists(props.CustomBlocklists) state.Mode = string(pointer.From(props.Mode)) - state.Type = string(pointer.From(props.Type)) } } @@ -256,35 +260,43 @@ func (r CognitiveAccountRaiPolicyResource) Update() sdk.ResourceFunc { return err } - resp, err := client.Get(ctx, *id) + existing, err := client.Get(ctx, *id) if err != nil { return fmt.Errorf("retrieving %s: %+v", *id, err) } + if existing.Model == nil { + return fmt.Errorf("retrieving %s: `model` was nil", id) + } + + if existing.Model.Properties == nil { + return fmt.Errorf("retrieving %s: `properties` was nil", id) + } + cognitiveAccountId := raipolicies.NewAccountID(id.SubscriptionId, id.ResourceGroupName, id.AccountName) locks.ByID(cognitiveAccountId.ID()) defer locks.UnlockByID(cognitiveAccountId.ID()) - props := resp.Model + payload := existing.Model if metadata.ResourceData.HasChange("content_filter") { - props.Properties.ContentFilters = expandRaiPolicyContentFilters(model.ContentFilter) + payload.Properties.ContentFilters = expandRaiPolicyContentFilters(model.ContentFilter) } if metadata.ResourceData.HasChange("custom_blocklist") { - props.Properties.CustomBlocklists = expandCustomBlockLists(model.CustomBlockList) + payload.Properties.CustomBlocklists = expandCustomBlockLists(model.CustomBlockList) } if metadata.ResourceData.HasChange("mode") { - props.Properties.Mode = pointer.To(raipolicies.RaiPolicyMode(model.Mode)) + payload.Properties.Mode = pointer.To(raipolicies.RaiPolicyMode(model.Mode)) } if metadata.ResourceData.HasChange("tags") { - props.Tags = pointer.To(model.Tags) + payload.Tags = pointer.To(model.Tags) } - if _, err := client.CreateOrUpdate(ctx, *id, *props); err != nil { + if _, err := client.CreateOrUpdate(ctx, *id, *payload); err != nil { return fmt.Errorf("updating %s: %+v", id, err) } @@ -362,7 +374,6 @@ func flattenRaiCustomBlockLists(blocklists *[]raipolicies.CustomBlocklistConfig) return customBlockLists } - for _, block := range *blocklists { customBlockLists = append(customBlockLists, AccountRaiPolicyCustomBlock{ Name: pointer.From(block.BlocklistName), @@ -379,7 +390,6 @@ func flattenRaiPolicyContentFilters(filters *[]raipolicies.RaiPolicyContentFilte return contentFilters } - for _, filter := range *filters { contentFilters = append(contentFilters, AccountRaiPolicyContentFilter{ Name: pointer.From(filter.Name), diff --git a/internal/services/cognitive/cognitive_account_rai_policy_resource_test.go b/internal/services/cognitive/cognitive_account_rai_policy_resource_test.go index a573a6fc848e..8dd8a07169d1 100644 --- a/internal/services/cognitive/cognitive_account_rai_policy_resource_test.go +++ b/internal/services/cognitive/cognitive_account_rai_policy_resource_test.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies" "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" "github.com/hashicorp/terraform-provider-azurerm/internal/clients" "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" ) @@ -19,7 +20,12 @@ func TestCognitiveAccountRaiPolicy_basic(t *testing.T) { r := RaiPolicyTestResource{} data.ResourceTest(t, r, []acceptance.TestStep{ - data.ApplyStep(r.basicConfig, r), + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, data.ImportStep(), }) } @@ -29,21 +35,45 @@ func TestCognitiveAccountRaiPolicy_requiresImport(t *testing.T) { r := RaiPolicyTestResource{} data.ResourceTest(t, r, []acceptance.TestStep{ - data.ApplyStep(r.basicConfig, r), - data.RequiresImportErrorStep(r.requiresImportConfig), + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + { + Config: r.requiresImport(data), + ExpectError: acceptance.RequiresImportError("azurerm_cognitive_account_rai_policy"), + }, }) } -func TestCognitiveAccountRaiPolicy_complete(t *testing.T) { +func TestCognitiveAccountRaiPolicy_update(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_cognitive_account_rai_policy", "test") r := RaiPolicyTestResource{} data.ResourceTest(t, r, []acceptance.TestStep{ - data.ApplyStep(r.completeConfig, r), + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, data.ImportStep(), - data.ApplyStep(r.basicConfig, r), + { + Config: r.complete(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("mode").HasValue("Asynchronous_filter"), + ), + }, data.ImportStep(), - data.ApplyStep(r.completeConfig, r), + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, data.ImportStep(), }) } @@ -96,7 +126,7 @@ resource "azurerm_cognitive_account_rai_policy" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomString) } -func (r RaiPolicyTestResource) completeConfig(data acceptance.TestData) string { +func (r RaiPolicyTestResource) complete(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} @@ -134,8 +164,8 @@ resource "azurerm_cognitive_account_rai_policy" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomString) } -func (r RaiPolicyTestResource) requiresImportConfig(data acceptance.TestData) string { - template := r.basicConfig(data) +func (r RaiPolicyTestResource) requiresImport(data acceptance.TestData) string { + template := r.basic(data) return fmt.Sprintf(` %s diff --git a/internal/services/cognitive/registration.go b/internal/services/cognitive/registration.go index 57ae5719c0a5..07b10f380208 100644 --- a/internal/services/cognitive/registration.go +++ b/internal/services/cognitive/registration.go @@ -55,7 +55,7 @@ func (r Registration) DataSources() []sdk.DataSource { func (r Registration) Resources() []sdk.Resource { return []sdk.Resource{ AzureAIServicesResource{}, - CognitiveDeploymentResource{}, CognitiveAccountRaiPolicyResource{}, + CognitiveDeploymentResource{}, } } diff --git a/website/docs/r/cognitive_account_rai_policy.html.markdown b/website/docs/r/cognitive_account_rai_policy.html.markdown index 4a2967b4be4a..3779b75eff1b 100644 --- a/website/docs/r/cognitive_account_rai_policy.html.markdown +++ b/website/docs/r/cognitive_account_rai_policy.html.markdown @@ -92,16 +92,17 @@ In addition to the Arguments listed above - the following Attributes are exporte * `id` - The ID of the Cognitive Service Account RAI Policy. -* `type` - The type of the Cognitive Service Account RAI Policy. Possible values are `SystemManaged` or `UserManaged`. - ## Timeouts The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: -* `create` - (Defaults to 30 minutes) Used when creating the Cognitive Service Account. -* `update` - (Defaults to 30 minutes) Used when updating the Cognitive Service Account. -* `read` - (Defaults to 5 minutes) Used when retrieving the Cognitive Service Account. -* `delete` - (Defaults to 30 minutes) Used when deleting the Cognitive Service Account. +* `create` - (Defaults to 30 minutes) Used when creating the Cognitive Service Account RAI Policy. + +* `update` - (Defaults to 30 minutes) Used when updating the Cognitive Service Account RAI Policy. + +* `read` - (Defaults to 5 minutes) Used when retrieving the Cognitive Service Account RAI Policy. + +* `delete` - (Defaults to 30 minutes) Used when deleting the Cognitive Service Account RAI Policy. ## Import From 8913a7a73f70495ade718a82c029ac01770ffb69 Mon Sep 17 00:00:00 2001 From: "Yun Liu (from Dev Box)" Date: Wed, 11 Dec 2024 13:36:29 +0800 Subject: [PATCH 6/9] Change custom_blocklist.name to custom_blocklist.id --- .../cognitive_account_rai_policy_resource.go | 20 +- .../2024-10-01/raiblocklists/README.md | 186 ++++++++++++++++++ .../2024-10-01/raiblocklists/client.go | 26 +++ .../2024-10-01/raiblocklists/id_account.go | 130 ++++++++++++ .../raiblocklists/id_raiblocklist.go | 139 +++++++++++++ .../raiblocklists/id_raiblocklistitem.go | 148 ++++++++++++++ .../raiblocklists/method_createorupdate.go | 58 ++++++ .../2024-10-01/raiblocklists/method_delete.go | 70 +++++++ .../2024-10-01/raiblocklists/method_get.go | 53 +++++ .../2024-10-01/raiblocklists/method_list.go | 105 ++++++++++ .../method_raiblocklistitemsbatchadd.go | 58 ++++++ .../method_raiblocklistitemsbatchdelete.go | 51 +++++ .../method_raiblocklistitemscreateorupdate.go | 58 ++++++ .../method_raiblocklistitemsdelete.go | 70 +++++++ .../method_raiblocklistitemsget.go | 53 +++++ .../method_raiblocklistitemslist.go | 105 ++++++++++ .../raiblocklists/model_raiblocklist.go | 18 ++ .../raiblocklists/model_raiblocklistitem.go | 18 ++ .../model_raiblocklistitembulkrequest.go | 9 + .../model_raiblocklistitemproperties.go | 9 + .../model_raiblocklistproperties.go | 8 + .../2024-10-01/raiblocklists/predicates.go | 60 ++++++ .../2024-10-01/raiblocklists/version.go | 10 + vendor/modules.txt | 1 + ...cognitive_account_rai_policy.html.markdown | 2 +- 25 files changed, 1457 insertions(+), 8 deletions(-) create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_account.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklistitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_createorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_delete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_get.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_list.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchadd.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchdelete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemscreateorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsdelete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsget.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemslist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitem.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitembulkrequest.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitemproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistproperties.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/version.go diff --git a/internal/services/cognitive/cognitive_account_rai_policy_resource.go b/internal/services/cognitive/cognitive_account_rai_policy_resource.go index b25ca42e394d..8730cdb964ec 100644 --- a/internal/services/cognitive/cognitive_account_rai_policy_resource.go +++ b/internal/services/cognitive/cognitive_account_rai_policy_resource.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists" "github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" @@ -28,7 +29,7 @@ type AccountRaiPolicyContentFilter struct { } type AccountRaiPolicyCustomBlock struct { - Name string `tfschema:"name"` + Id string `tfschema:"id"` BlockEnabled bool `tfschema:"block_enabled"` Source string `tfschema:"source"` } @@ -103,10 +104,10 @@ func (r CognitiveAccountRaiPolicyResource) Arguments() map[string]*pluginsdk.Sch Optional: true, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ - "name": { + "id": { Type: pluginsdk.TypeString, Required: true, - ValidateFunc: validation.StringIsNotEmpty, + ValidateFunc: raiblocklists.ValidateRaiBlocklistID, }, "block_enabled": { Type: pluginsdk.TypeBool, @@ -234,7 +235,7 @@ func (r CognitiveAccountRaiPolicyResource) Read() sdk.ResourceFunc { if props := model.Properties; props != nil { state.BasePolicyName = pointer.From(props.BasePolicyName) state.ContentFilter = flattenRaiPolicyContentFilters(props.ContentFilters) - state.CustomBlockList = flattenRaiCustomBlockLists(props.CustomBlocklists) + state.CustomBlockList = flattenRaiCustomBlockLists(props.CustomBlocklists, cognitiveAccountId) state.Mode = string(pointer.From(props.Mode)) } } @@ -359,8 +360,13 @@ func expandCustomBlockLists(list []AccountRaiPolicyCustomBlock) *[]raipolicies.C customBlockLists := make([]raipolicies.CustomBlocklistConfig, 0, len(list)) for _, block := range list { + customBlockId, err := raiblocklists.ParseRaiBlocklistID(block.Id) + if err != nil { + continue + } + customBlockLists = append(customBlockLists, raipolicies.CustomBlocklistConfig{ - BlocklistName: pointer.To(block.Name), + BlocklistName: pointer.To(customBlockId.RaiBlocklistName), Blocking: pointer.To(block.BlockEnabled), Source: pointer.To(raipolicies.RaiPolicyContentSource(block.Source)), }) @@ -368,7 +374,7 @@ func expandCustomBlockLists(list []AccountRaiPolicyCustomBlock) *[]raipolicies.C return &customBlockLists } -func flattenRaiCustomBlockLists(blocklists *[]raipolicies.CustomBlocklistConfig) []AccountRaiPolicyCustomBlock { +func flattenRaiCustomBlockLists(blocklists *[]raipolicies.CustomBlocklistConfig, accountId raipolicies.AccountId) []AccountRaiPolicyCustomBlock { customBlockLists := make([]AccountRaiPolicyCustomBlock, 0) if blocklists == nil { return customBlockLists @@ -376,7 +382,7 @@ func flattenRaiCustomBlockLists(blocklists *[]raipolicies.CustomBlocklistConfig) for _, block := range *blocklists { customBlockLists = append(customBlockLists, AccountRaiPolicyCustomBlock{ - Name: pointer.From(block.BlocklistName), + Id: raiblocklists.NewRaiBlocklistID(accountId.SubscriptionId, accountId.ResourceGroupName, accountId.AccountName, *block.BlocklistName).ID(), BlockEnabled: pointer.From(block.Blocking), Source: string(pointer.From(block.Source)), }) diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/README.md new file mode 100644 index 000000000000..d0fc2d949ba4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/README.md @@ -0,0 +1,186 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists` Documentation + +The `raiblocklists` SDK allows for interaction with Azure Resource Manager `cognitive` (API Version `2024-10-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-sdk/resource-manager/cognitive/2024-10-01/raiblocklists" +``` + + +### Client Initialization + +```go +client := raiblocklists.NewRaiBlocklistsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RaiBlocklistsClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") + +payload := raiblocklists.RaiBlocklist{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RaiBlocklistsClient.Delete` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RaiBlocklistsClient.Get` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") + +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: `RaiBlocklistsClient.List` + +```go +ctx := context.TODO() +id := raiblocklists.NewAccountID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName") + +// alternatively `client.List(ctx, id)` can be used to do batched pagination +items, err := client.ListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsBatchAdd` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") +var payload []RaiBlocklistItemBulkRequest + +read, err := client.RaiBlocklistItemsBatchAdd(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsBatchDelete` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") +var payload interface{} + +read, err := client.RaiBlocklistItemsBatchDelete(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsCreateOrUpdate` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName", "raiBlocklistItemName") + +payload := raiblocklists.RaiBlocklistItem{ + // ... +} + + +read, err := client.RaiBlocklistItemsCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsDelete` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName", "raiBlocklistItemName") + +if err := client.RaiBlocklistItemsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsGet` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistItemID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName", "raiBlocklistItemName") + +read, err := client.RaiBlocklistItemsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RaiBlocklistsClient.RaiBlocklistItemsList` + +```go +ctx := context.TODO() +id := raiblocklists.NewRaiBlocklistID("12345678-1234-9876-4563-123456789012", "example-resource-group", "accountName", "raiBlocklistName") + +// alternatively `client.RaiBlocklistItemsList(ctx, id)` can be used to do batched pagination +items, err := client.RaiBlocklistItemsListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/client.go new file mode 100644 index 000000000000..8721ad1960a9 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/client.go @@ -0,0 +1,26 @@ +package raiblocklists + +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 RaiBlocklistsClient struct { + Client *resourcemanager.Client +} + +func NewRaiBlocklistsClientWithBaseURI(sdkApi sdkEnv.Api) (*RaiBlocklistsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "raiblocklists", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RaiBlocklistsClient: %+v", err) + } + + return &RaiBlocklistsClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_account.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_account.go new file mode 100644 index 000000000000..eadf6b999b86 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_account.go @@ -0,0 +1,130 @@ +package raiblocklists + +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(&AccountId{}) +} + +var _ resourceids.ResourceId = &AccountId{} + +// AccountId is a struct representing the Resource ID for a Account +type AccountId struct { + SubscriptionId string + ResourceGroupName string + AccountName string +} + +// NewAccountID returns a new AccountId struct +func NewAccountID(subscriptionId string, resourceGroupName string, accountName string) AccountId { + return AccountId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AccountName: accountName, + } +} + +// ParseAccountID parses 'input' into a AccountId +func ParseAccountID(input string) (*AccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccountId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseAccountIDInsensitively parses 'input' case-insensitively into a AccountId +// note: this method should only be used for API response data and not user input +func ParseAccountIDInsensitively(input string) (*AccountId, error) { + parser := resourceids.NewParserFromResourceIdType(&AccountId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := AccountId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *AccountId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AccountName, ok = input.Parsed["accountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) + } + + return nil +} + +// ValidateAccountID checks that 'input' can be parsed as a Account ID +func ValidateAccountID(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 := ParseAccountID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Account ID +func (id AccountId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CognitiveServices/accounts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AccountName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Account ID +func (id AccountId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCognitiveServices", "Microsoft.CognitiveServices", "Microsoft.CognitiveServices"), + resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), + resourceids.UserSpecifiedSegment("accountName", "accountName"), + } +} + +// String returns a human-readable description of this Account ID +func (id AccountId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Account Name: %q", id.AccountName), + } + return fmt.Sprintf("Account (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklist.go new file mode 100644 index 000000000000..70ef2a3f25fd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklist.go @@ -0,0 +1,139 @@ +package raiblocklists + +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(&RaiBlocklistId{}) +} + +var _ resourceids.ResourceId = &RaiBlocklistId{} + +// RaiBlocklistId is a struct representing the Resource ID for a Rai Blocklist +type RaiBlocklistId struct { + SubscriptionId string + ResourceGroupName string + AccountName string + RaiBlocklistName string +} + +// NewRaiBlocklistID returns a new RaiBlocklistId struct +func NewRaiBlocklistID(subscriptionId string, resourceGroupName string, accountName string, raiBlocklistName string) RaiBlocklistId { + return RaiBlocklistId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AccountName: accountName, + RaiBlocklistName: raiBlocklistName, + } +} + +// ParseRaiBlocklistID parses 'input' into a RaiBlocklistId +func ParseRaiBlocklistID(input string) (*RaiBlocklistId, error) { + parser := resourceids.NewParserFromResourceIdType(&RaiBlocklistId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RaiBlocklistId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRaiBlocklistIDInsensitively parses 'input' case-insensitively into a RaiBlocklistId +// note: this method should only be used for API response data and not user input +func ParseRaiBlocklistIDInsensitively(input string) (*RaiBlocklistId, error) { + parser := resourceids.NewParserFromResourceIdType(&RaiBlocklistId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RaiBlocklistId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RaiBlocklistId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AccountName, ok = input.Parsed["accountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) + } + + if id.RaiBlocklistName, ok = input.Parsed["raiBlocklistName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "raiBlocklistName", input) + } + + return nil +} + +// ValidateRaiBlocklistID checks that 'input' can be parsed as a Rai Blocklist ID +func ValidateRaiBlocklistID(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 := ParseRaiBlocklistID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rai Blocklist ID +func (id RaiBlocklistId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CognitiveServices/accounts/%s/raiBlocklists/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AccountName, id.RaiBlocklistName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rai Blocklist ID +func (id RaiBlocklistId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCognitiveServices", "Microsoft.CognitiveServices", "Microsoft.CognitiveServices"), + resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), + resourceids.UserSpecifiedSegment("accountName", "accountName"), + resourceids.StaticSegment("staticRaiBlocklists", "raiBlocklists", "raiBlocklists"), + resourceids.UserSpecifiedSegment("raiBlocklistName", "raiBlocklistName"), + } +} + +// String returns a human-readable description of this Rai Blocklist ID +func (id RaiBlocklistId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Account Name: %q", id.AccountName), + fmt.Sprintf("Rai Blocklist Name: %q", id.RaiBlocklistName), + } + return fmt.Sprintf("Rai Blocklist (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklistitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklistitem.go new file mode 100644 index 000000000000..642b218519cc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/id_raiblocklistitem.go @@ -0,0 +1,148 @@ +package raiblocklists + +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(&RaiBlocklistItemId{}) +} + +var _ resourceids.ResourceId = &RaiBlocklistItemId{} + +// RaiBlocklistItemId is a struct representing the Resource ID for a Rai Blocklist Item +type RaiBlocklistItemId struct { + SubscriptionId string + ResourceGroupName string + AccountName string + RaiBlocklistName string + RaiBlocklistItemName string +} + +// NewRaiBlocklistItemID returns a new RaiBlocklistItemId struct +func NewRaiBlocklistItemID(subscriptionId string, resourceGroupName string, accountName string, raiBlocklistName string, raiBlocklistItemName string) RaiBlocklistItemId { + return RaiBlocklistItemId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + AccountName: accountName, + RaiBlocklistName: raiBlocklistName, + RaiBlocklistItemName: raiBlocklistItemName, + } +} + +// ParseRaiBlocklistItemID parses 'input' into a RaiBlocklistItemId +func ParseRaiBlocklistItemID(input string) (*RaiBlocklistItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&RaiBlocklistItemId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RaiBlocklistItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRaiBlocklistItemIDInsensitively parses 'input' case-insensitively into a RaiBlocklistItemId +// note: this method should only be used for API response data and not user input +func ParseRaiBlocklistItemIDInsensitively(input string) (*RaiBlocklistItemId, error) { + parser := resourceids.NewParserFromResourceIdType(&RaiBlocklistItemId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RaiBlocklistItemId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RaiBlocklistItemId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.AccountName, ok = input.Parsed["accountName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "accountName", input) + } + + if id.RaiBlocklistName, ok = input.Parsed["raiBlocklistName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "raiBlocklistName", input) + } + + if id.RaiBlocklistItemName, ok = input.Parsed["raiBlocklistItemName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "raiBlocklistItemName", input) + } + + return nil +} + +// ValidateRaiBlocklistItemID checks that 'input' can be parsed as a Rai Blocklist Item ID +func ValidateRaiBlocklistItemID(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 := ParseRaiBlocklistItemID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Rai Blocklist Item ID +func (id RaiBlocklistItemId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.CognitiveServices/accounts/%s/raiBlocklists/%s/raiBlocklistItems/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.AccountName, id.RaiBlocklistName, id.RaiBlocklistItemName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Rai Blocklist Item ID +func (id RaiBlocklistItemId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftCognitiveServices", "Microsoft.CognitiveServices", "Microsoft.CognitiveServices"), + resourceids.StaticSegment("staticAccounts", "accounts", "accounts"), + resourceids.UserSpecifiedSegment("accountName", "accountName"), + resourceids.StaticSegment("staticRaiBlocklists", "raiBlocklists", "raiBlocklists"), + resourceids.UserSpecifiedSegment("raiBlocklistName", "raiBlocklistName"), + resourceids.StaticSegment("staticRaiBlocklistItems", "raiBlocklistItems", "raiBlocklistItems"), + resourceids.UserSpecifiedSegment("raiBlocklistItemName", "raiBlocklistItemName"), + } +} + +// String returns a human-readable description of this Rai Blocklist Item ID +func (id RaiBlocklistItemId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Account Name: %q", id.AccountName), + fmt.Sprintf("Rai Blocklist Name: %q", id.RaiBlocklistName), + fmt.Sprintf("Rai Blocklist Item Name: %q", id.RaiBlocklistItemName), + } + return fmt.Sprintf("Rai Blocklist Item (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_createorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_createorupdate.go new file mode 100644 index 000000000000..a6b788f2ab6d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_createorupdate.go @@ -0,0 +1,58 @@ +package raiblocklists + +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 CreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RaiBlocklist +} + +// CreateOrUpdate ... +func (c RaiBlocklistsClient) CreateOrUpdate(ctx context.Context, id RaiBlocklistId, input RaiBlocklist) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + 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 RaiBlocklist + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_delete.go new file mode 100644 index 000000000000..621e422780ff --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_delete.go @@ -0,0 +1,70 @@ +package raiblocklists + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c RaiBlocklistsClient) Delete(ctx context.Context, id RaiBlocklistId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c RaiBlocklistsClient) DeleteThenPoll(ctx context.Context, id RaiBlocklistId) error { + result, err := c.Delete(ctx, id) + if err != nil { + return fmt.Errorf("performing Delete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Delete: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_get.go new file mode 100644 index 000000000000..277a3c8997eb --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_get.go @@ -0,0 +1,53 @@ +package raiblocklists + +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 *RaiBlocklist +} + +// Get ... +func (c RaiBlocklistsClient) Get(ctx context.Context, id RaiBlocklistId) (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 RaiBlocklist + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_list.go new file mode 100644 index 000000000000..ea9724913f5d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_list.go @@ -0,0 +1,105 @@ +package raiblocklists + +import ( + "context" + "fmt" + "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 ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RaiBlocklist +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RaiBlocklist +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c RaiBlocklistsClient) List(ctx context.Context, id AccountId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/raiBlocklists", 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 *[]RaiBlocklist `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 RaiBlocklistsClient) ListComplete(ctx context.Context, id AccountId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, RaiBlocklistOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RaiBlocklistsClient) ListCompleteMatchingPredicate(ctx context.Context, id AccountId, predicate RaiBlocklistOperationPredicate) (result ListCompleteResult, err error) { + items := make([]RaiBlocklist, 0) + + resp, err := c.List(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchadd.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchadd.go new file mode 100644 index 000000000000..1a7e886a20f2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchadd.go @@ -0,0 +1,58 @@ +package raiblocklists + +import ( + "context" + "fmt" + "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 RaiBlocklistItemsBatchAddOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RaiBlocklist +} + +// RaiBlocklistItemsBatchAdd ... +func (c RaiBlocklistsClient) RaiBlocklistItemsBatchAdd(ctx context.Context, id RaiBlocklistId, input []RaiBlocklistItemBulkRequest) (result RaiBlocklistItemsBatchAddOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/addRaiBlocklistItems", 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 RaiBlocklist + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchdelete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchdelete.go new file mode 100644 index 000000000000..b8313577f4c7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsbatchdelete.go @@ -0,0 +1,51 @@ +package raiblocklists + +import ( + "context" + "fmt" + "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 RaiBlocklistItemsBatchDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RaiBlocklistItemsBatchDelete ... +func (c RaiBlocklistsClient) RaiBlocklistItemsBatchDelete(ctx context.Context, id RaiBlocklistId, input interface{}) (result RaiBlocklistItemsBatchDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deleteRaiBlocklistItems", 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 + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemscreateorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemscreateorupdate.go new file mode 100644 index 000000000000..5caeb001e7c7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemscreateorupdate.go @@ -0,0 +1,58 @@ +package raiblocklists + +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 RaiBlocklistItemsCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RaiBlocklistItem +} + +// RaiBlocklistItemsCreateOrUpdate ... +func (c RaiBlocklistsClient) RaiBlocklistItemsCreateOrUpdate(ctx context.Context, id RaiBlocklistItemId, input RaiBlocklistItem) (result RaiBlocklistItemsCreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + 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 RaiBlocklistItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsdelete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsdelete.go new file mode 100644 index 000000000000..b832a825b546 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsdelete.go @@ -0,0 +1,70 @@ +package raiblocklists + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "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 RaiBlocklistItemsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RaiBlocklistItemsDelete ... +func (c RaiBlocklistsClient) RaiBlocklistItemsDelete(ctx context.Context, id RaiBlocklistItemId) (result RaiBlocklistItemsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RaiBlocklistItemsDeleteThenPoll performs RaiBlocklistItemsDelete then polls until it's completed +func (c RaiBlocklistsClient) RaiBlocklistItemsDeleteThenPoll(ctx context.Context, id RaiBlocklistItemId) error { + result, err := c.RaiBlocklistItemsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RaiBlocklistItemsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RaiBlocklistItemsDelete: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsget.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsget.go new file mode 100644 index 000000000000..390fcc14f820 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemsget.go @@ -0,0 +1,53 @@ +package raiblocklists + +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 RaiBlocklistItemsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RaiBlocklistItem +} + +// RaiBlocklistItemsGet ... +func (c RaiBlocklistsClient) RaiBlocklistItemsGet(ctx context.Context, id RaiBlocklistItemId) (result RaiBlocklistItemsGetOperationResponse, 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 RaiBlocklistItem + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemslist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemslist.go new file mode 100644 index 000000000000..15c228ce07a4 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/method_raiblocklistitemslist.go @@ -0,0 +1,105 @@ +package raiblocklists + +import ( + "context" + "fmt" + "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 RaiBlocklistItemsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RaiBlocklistItem +} + +type RaiBlocklistItemsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RaiBlocklistItem +} + +type RaiBlocklistItemsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RaiBlocklistItemsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RaiBlocklistItemsList ... +func (c RaiBlocklistsClient) RaiBlocklistItemsList(ctx context.Context, id RaiBlocklistId) (result RaiBlocklistItemsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &RaiBlocklistItemsListCustomPager{}, + Path: fmt.Sprintf("%s/raiBlocklistItems", 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 *[]RaiBlocklistItem `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RaiBlocklistItemsListComplete retrieves all the results into a single object +func (c RaiBlocklistsClient) RaiBlocklistItemsListComplete(ctx context.Context, id RaiBlocklistId) (RaiBlocklistItemsListCompleteResult, error) { + return c.RaiBlocklistItemsListCompleteMatchingPredicate(ctx, id, RaiBlocklistItemOperationPredicate{}) +} + +// RaiBlocklistItemsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RaiBlocklistsClient) RaiBlocklistItemsListCompleteMatchingPredicate(ctx context.Context, id RaiBlocklistId, predicate RaiBlocklistItemOperationPredicate) (result RaiBlocklistItemsListCompleteResult, err error) { + items := make([]RaiBlocklistItem, 0) + + resp, err := c.RaiBlocklistItemsList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + 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 = RaiBlocklistItemsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklist.go new file mode 100644 index 000000000000..8be491a1b59b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklist.go @@ -0,0 +1,18 @@ +package raiblocklists + +import ( + "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 RaiBlocklist struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RaiBlocklistProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitem.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitem.go new file mode 100644 index 000000000000..98bd2267f965 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitem.go @@ -0,0 +1,18 @@ +package raiblocklists + +import ( + "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 RaiBlocklistItem struct { + Etag *string `json:"etag,omitempty"` + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *RaiBlocklistItemProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitembulkrequest.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitembulkrequest.go new file mode 100644 index 000000000000..7f7ac1e1e3c3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitembulkrequest.go @@ -0,0 +1,9 @@ +package raiblocklists + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RaiBlocklistItemBulkRequest struct { + Name *string `json:"name,omitempty"` + Properties *RaiBlocklistItemProperties `json:"properties,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitemproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitemproperties.go new file mode 100644 index 000000000000..f6b4e7ca37a6 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistitemproperties.go @@ -0,0 +1,9 @@ +package raiblocklists + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RaiBlocklistItemProperties struct { + IsRegex *bool `json:"isRegex,omitempty"` + Pattern *string `json:"pattern,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistproperties.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistproperties.go new file mode 100644 index 000000000000..816f9b75e266 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/model_raiblocklistproperties.go @@ -0,0 +1,8 @@ +package raiblocklists + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RaiBlocklistProperties struct { + Description *string `json:"description,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/predicates.go new file mode 100644 index 000000000000..a317e1c7318b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/predicates.go @@ -0,0 +1,60 @@ +package raiblocklists + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RaiBlocklistOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p RaiBlocklistOperationPredicate) Matches(input RaiBlocklist) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + 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 +} + +type RaiBlocklistItemOperationPredicate struct { + Etag *string + Id *string + Name *string + Type *string +} + +func (p RaiBlocklistItemOperationPredicate) Matches(input RaiBlocklistItem) bool { + + if p.Etag != nil && (input.Etag == nil || *p.Etag != *input.Etag) { + return false + } + + 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 +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/version.go new file mode 100644 index 000000000000..cc4c248b7f4a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists/version.go @@ -0,0 +1,10 @@ +package raiblocklists + +// 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-10-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/raiblocklists/2024-10-01" +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 9e6a316c050b..9569e3999cde 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -320,6 +320,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-previe github.com/hashicorp/go-azure-sdk/resource-manager/codesigning/2024-09-30-preview/codesigningaccounts github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/cognitiveservicesaccounts github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/deployments +github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/communicationservices github.com/hashicorp/go-azure-sdk/resource-manager/communication/2023-03-31/domains diff --git a/website/docs/r/cognitive_account_rai_policy.html.markdown b/website/docs/r/cognitive_account_rai_policy.html.markdown index 3779b75eff1b..275ddd68dfad 100644 --- a/website/docs/r/cognitive_account_rai_policy.html.markdown +++ b/website/docs/r/cognitive_account_rai_policy.html.markdown @@ -80,7 +80,7 @@ A `content_filter` block supports the following: A `custom_blocklist` block supports the following: -* `name` - (Required) The name of the custom blocklist. +* `id` - (Required) The ARM resource ID of the custom blocklist. * `block_enabled` - (Required) Whether the custom blocklist should block content. Possible values are `true` or `false`. From c18d7cc77975a2c239ad46c1740ec9ee943f211f Mon Sep 17 00:00:00 2001 From: "Yun Liu (from Dev Box)" Date: Wed, 11 Dec 2024 14:45:01 +0800 Subject: [PATCH 7/9] Rename custom_blocklist.id to custom_blocklist.rai_blocklist_id as suggested --- .../cognitive/cognitive_account_rai_policy_resource.go | 4 ++-- website/docs/r/cognitive_account_rai_policy.html.markdown | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/services/cognitive/cognitive_account_rai_policy_resource.go b/internal/services/cognitive/cognitive_account_rai_policy_resource.go index 8730cdb964ec..df95c1009a28 100644 --- a/internal/services/cognitive/cognitive_account_rai_policy_resource.go +++ b/internal/services/cognitive/cognitive_account_rai_policy_resource.go @@ -29,7 +29,7 @@ type AccountRaiPolicyContentFilter struct { } type AccountRaiPolicyCustomBlock struct { - Id string `tfschema:"id"` + Id string `tfschema:"rai_blocklist_id"` BlockEnabled bool `tfschema:"block_enabled"` Source string `tfschema:"source"` } @@ -104,7 +104,7 @@ func (r CognitiveAccountRaiPolicyResource) Arguments() map[string]*pluginsdk.Sch Optional: true, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ - "id": { + "rai_blocklist_id": { Type: pluginsdk.TypeString, Required: true, ValidateFunc: raiblocklists.ValidateRaiBlocklistID, diff --git a/website/docs/r/cognitive_account_rai_policy.html.markdown b/website/docs/r/cognitive_account_rai_policy.html.markdown index 275ddd68dfad..63da29c5ff2a 100644 --- a/website/docs/r/cognitive_account_rai_policy.html.markdown +++ b/website/docs/r/cognitive_account_rai_policy.html.markdown @@ -80,7 +80,7 @@ A `content_filter` block supports the following: A `custom_blocklist` block supports the following: -* `id` - (Required) The ARM resource ID of the custom blocklist. +* `rai_blocklist_id` - (Required) The ARM resource ID of the custom blocklist. * `block_enabled` - (Required) Whether the custom blocklist should block content. Possible values are `true` or `false`. From 1629e594536cca81ca4fb92694f3eb58812abc52 Mon Sep 17 00:00:00 2001 From: "Yun Liu (from Dev Box)" Date: Tue, 17 Dec 2024 13:10:48 +0800 Subject: [PATCH 8/9] Remove custom_blocklist from the RAI Policy resource --- .../cognitive_account_rai_policy_resource.go | 83 ++----------------- ...nitive_account_rai_policy_resource_test.go | 2 + ...cognitive_account_rai_policy.html.markdown | 12 --- 3 files changed, 8 insertions(+), 89 deletions(-) diff --git a/internal/services/cognitive/cognitive_account_rai_policy_resource.go b/internal/services/cognitive/cognitive_account_rai_policy_resource.go index df95c1009a28..a6a90cc736d5 100644 --- a/internal/services/cognitive/cognitive_account_rai_policy_resource.go +++ b/internal/services/cognitive/cognitive_account_rai_policy_resource.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/go-azure-helpers/lang/pointer" "github.com/hashicorp/go-azure-helpers/lang/response" "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" - "github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raiblocklists" "github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2024-10-01/raipolicies" "github.com/hashicorp/terraform-provider-azurerm/internal/locks" "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" @@ -35,13 +34,12 @@ type AccountRaiPolicyCustomBlock struct { } type AccountRaiPolicyResourceModel struct { - Name string `tfschema:"name"` - AccountId string `tfschema:"cognitive_account_id"` - BasePolicyName string `tfschema:"base_policy_name"` - ContentFilter []AccountRaiPolicyContentFilter `tfschema:"content_filter"` - CustomBlockList []AccountRaiPolicyCustomBlock `tfschema:"custom_blocklist"` - Mode string `tfschema:"mode"` - Tags map[string]string `tfschema:"tags"` + Name string `tfschema:"name"` + AccountId string `tfschema:"cognitive_account_id"` + BasePolicyName string `tfschema:"base_policy_name"` + ContentFilter []AccountRaiPolicyContentFilter `tfschema:"content_filter"` + Mode string `tfschema:"mode"` + Tags map[string]string `tfschema:"tags"` } func (r CognitiveAccountRaiPolicyResource) Arguments() map[string]*pluginsdk.Schema { @@ -99,29 +97,6 @@ func (r CognitiveAccountRaiPolicyResource) Arguments() map[string]*pluginsdk.Sch }, }, - "custom_blocklist": { - Type: pluginsdk.TypeList, - Optional: true, - Elem: &pluginsdk.Resource{ - Schema: map[string]*pluginsdk.Schema{ - "rai_blocklist_id": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: raiblocklists.ValidateRaiBlocklistID, - }, - "block_enabled": { - Type: pluginsdk.TypeBool, - Required: true, - }, - "source": { - Type: pluginsdk.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(raipolicies.PossibleValuesForRaiPolicyContentSource(), false), - }, - }, - }, - }, - "mode": { Type: pluginsdk.TypeString, Optional: true, @@ -184,10 +159,6 @@ func (r CognitiveAccountRaiPolicyResource) Create() sdk.ResourceFunc { Tags: pointer.To(model.Tags), } - if model.CustomBlockList != nil { - raiPolicy.Properties.CustomBlocklists = expandCustomBlockLists(model.CustomBlockList) - } - if model.Mode != "" { raiPolicy.Properties.Mode = pointer.To(raipolicies.RaiPolicyMode(model.Mode)) } @@ -235,7 +206,6 @@ func (r CognitiveAccountRaiPolicyResource) Read() sdk.ResourceFunc { if props := model.Properties; props != nil { state.BasePolicyName = pointer.From(props.BasePolicyName) state.ContentFilter = flattenRaiPolicyContentFilters(props.ContentFilters) - state.CustomBlockList = flattenRaiCustomBlockLists(props.CustomBlocklists, cognitiveAccountId) state.Mode = string(pointer.From(props.Mode)) } } @@ -285,10 +255,6 @@ func (r CognitiveAccountRaiPolicyResource) Update() sdk.ResourceFunc { payload.Properties.ContentFilters = expandRaiPolicyContentFilters(model.ContentFilter) } - if metadata.ResourceData.HasChange("custom_blocklist") { - payload.Properties.CustomBlocklists = expandCustomBlockLists(model.CustomBlockList) - } - if metadata.ResourceData.HasChange("mode") { payload.Properties.Mode = pointer.To(raipolicies.RaiPolicyMode(model.Mode)) } @@ -353,43 +319,6 @@ func expandRaiPolicyContentFilters(filters []AccountRaiPolicyContentFilter) *[]r return &contentFilters } -func expandCustomBlockLists(list []AccountRaiPolicyCustomBlock) *[]raipolicies.CustomBlocklistConfig { - if list == nil { - return nil - } - - customBlockLists := make([]raipolicies.CustomBlocklistConfig, 0, len(list)) - for _, block := range list { - customBlockId, err := raiblocklists.ParseRaiBlocklistID(block.Id) - if err != nil { - continue - } - - customBlockLists = append(customBlockLists, raipolicies.CustomBlocklistConfig{ - BlocklistName: pointer.To(customBlockId.RaiBlocklistName), - Blocking: pointer.To(block.BlockEnabled), - Source: pointer.To(raipolicies.RaiPolicyContentSource(block.Source)), - }) - } - return &customBlockLists -} - -func flattenRaiCustomBlockLists(blocklists *[]raipolicies.CustomBlocklistConfig, accountId raipolicies.AccountId) []AccountRaiPolicyCustomBlock { - customBlockLists := make([]AccountRaiPolicyCustomBlock, 0) - if blocklists == nil { - return customBlockLists - } - - for _, block := range *blocklists { - customBlockLists = append(customBlockLists, AccountRaiPolicyCustomBlock{ - Id: raiblocklists.NewRaiBlocklistID(accountId.SubscriptionId, accountId.ResourceGroupName, accountId.AccountName, *block.BlocklistName).ID(), - BlockEnabled: pointer.From(block.Blocking), - Source: string(pointer.From(block.Source)), - }) - } - return customBlockLists -} - func flattenRaiPolicyContentFilters(filters *[]raipolicies.RaiPolicyContentFilter) []AccountRaiPolicyContentFilter { contentFilters := make([]AccountRaiPolicyContentFilter, 0) if filters == nil { diff --git a/internal/services/cognitive/cognitive_account_rai_policy_resource_test.go b/internal/services/cognitive/cognitive_account_rai_policy_resource_test.go index 8dd8a07169d1..7084e8d5cc78 100644 --- a/internal/services/cognitive/cognitive_account_rai_policy_resource_test.go +++ b/internal/services/cognitive/cognitive_account_rai_policy_resource_test.go @@ -149,6 +149,7 @@ resource "azurerm_cognitive_account_rai_policy" "test" { name = "acctestraip-%s" cognitive_account_id = azurerm_cognitive_account.test.id base_policy_name = "Microsoft.Default" + content_filter { name = "Hate" filter_enabled = true @@ -156,6 +157,7 @@ resource "azurerm_cognitive_account_rai_policy" "test" { severity_threshold = "High" source = "Prompt" } + mode = "Asynchronous_filter" tags = { Environment = "Test" diff --git a/website/docs/r/cognitive_account_rai_policy.html.markdown b/website/docs/r/cognitive_account_rai_policy.html.markdown index 63da29c5ff2a..4ac442848758 100644 --- a/website/docs/r/cognitive_account_rai_policy.html.markdown +++ b/website/docs/r/cognitive_account_rai_policy.html.markdown @@ -56,8 +56,6 @@ The following arguments are supported: * `content_filter` - (Required) A `content_filter` block as defined below. -* `custom_blocklist` - (Optional) A `custom_blocklist` block as defined below. - * `mode` - (Optional) The mode of the RAI Policy. Possible values are `Default`, `Deferred`, `Blocking` or `Asynchronous_filter`. * `tags` - (Optional) A mapping of tags to assign to the resource. @@ -76,16 +74,6 @@ A `content_filter` block supports the following: * `source` - (Required) Content source to apply the content filter. Possible values are `Prompt` or `Completion`. ---- - -A `custom_blocklist` block supports the following: - -* `rai_blocklist_id` - (Required) The ARM resource ID of the custom blocklist. - -* `block_enabled` - (Required) Whether the custom blocklist should block content. Possible values are `true` or `false`. - -* `source` - (Required) Content source to apply the content filter. Possible values are `Prompt` or `Completion`. - ## Attributes Reference In addition to the Arguments listed above - the following Attributes are exported: From 6dbb70fbe69dce29747c157262438f7afc92d033 Mon Sep 17 00:00:00 2001 From: "Yun Liu (from Dev Box)" Date: Tue, 17 Dec 2024 13:27:18 +0800 Subject: [PATCH 9/9] Resolve lint issue --- internal/services/cognitive/client/client.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/services/cognitive/client/client.go b/internal/services/cognitive/client/client.go index 1ca3632e77d6..6a4e456dbeb7 100644 --- a/internal/services/cognitive/client/client.go +++ b/internal/services/cognitive/client/client.go @@ -14,10 +14,10 @@ import ( ) type Client struct { - AccountsClient *cognitiveservicesaccounts.CognitiveServicesAccountsClient - DeploymentsClient *deployments.DeploymentsClient + AccountsClient *cognitiveservicesaccounts.CognitiveServicesAccountsClient + DeploymentsClient *deployments.DeploymentsClient RaiBlocklistsClient *raiblocklists.RaiBlocklistsClient - RaiPoliciesClient *raipolicies.RaiPoliciesClient + RaiPoliciesClient *raipolicies.RaiPoliciesClient } func NewClient(o *common.ClientOptions) (*Client, error) { @@ -39,7 +39,6 @@ func NewClient(o *common.ClientOptions) (*Client, error) { } o.Configure(raiPoliciesClient.Client, o.Authorizers.ResourceManager) - raiBlobklistsClient, err := raiblocklists.NewRaiBlocklistsClientWithBaseURI(o.Environment.ResourceManager) if err != nil { return nil, fmt.Errorf("building Rai Blocklists client: %+v", err) @@ -50,6 +49,6 @@ func NewClient(o *common.ClientOptions) (*Client, error) { AccountsClient: accountsClient, DeploymentsClient: deploymentsClient, RaiBlocklistsClient: raiBlobklistsClient, - RaiPoliciesClient: raiPoliciesClient, + RaiPoliciesClient: raiPoliciesClient, }, nil }