diff --git a/resource-manager/networkanalytics/2023-11-15/client.go b/resource-manager/networkanalytics/2023-11-15/client.go new file mode 100644 index 00000000000..5213c0f7e53 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/client.go @@ -0,0 +1,46 @@ +package v2023_11_15 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/networkanalytics/2023-11-15/dataproducts" + "github.com/hashicorp/go-azure-sdk/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs" + "github.com/hashicorp/go-azure-sdk/resource-manager/networkanalytics/2023-11-15/datatypes" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + DataProducts *dataproducts.DataProductsClient + DataProductsCatalogs *dataproductscatalogs.DataProductsCatalogsClient + DataTypes *datatypes.DataTypesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + dataProductsCatalogsClient, err := dataproductscatalogs.NewDataProductsCatalogsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataProductsCatalogs client: %+v", err) + } + configureFunc(dataProductsCatalogsClient.Client) + + dataProductsClient, err := dataproducts.NewDataProductsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataProducts client: %+v", err) + } + configureFunc(dataProductsClient.Client) + + dataTypesClient, err := datatypes.NewDataTypesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataTypes client: %+v", err) + } + configureFunc(dataTypesClient.Client) + + return &Client{ + DataProducts: dataProductsClient, + DataProductsCatalogs: dataProductsCatalogsClient, + DataTypes: dataTypesClient, + }, nil +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/README.md b/resource-manager/networkanalytics/2023-11-15/dataproducts/README.md new file mode 100644 index 00000000000..457afc5564c --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/README.md @@ -0,0 +1,218 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/networkanalytics/2023-11-15/dataproducts` Documentation + +The `dataproducts` SDK allows for interaction with the Azure Resource Manager Service `networkanalytics` (API Version `2023-11-15`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/networkanalytics/2023-11-15/dataproducts" +``` + + +### Client Initialization + +```go +client := dataproducts.NewDataProductsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataProductsClient.AddUserRole` + +```go +ctx := context.TODO() +id := dataproducts.NewDataProductID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue") + +payload := dataproducts.RoleAssignmentCommonProperties{ + // ... +} + + +read, err := client.AddUserRole(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataProductsClient.Create` + +```go +ctx := context.TODO() +id := dataproducts.NewDataProductID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue") + +payload := dataproducts.DataProduct{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataProductsClient.Delete` + +```go +ctx := context.TODO() +id := dataproducts.NewDataProductID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataProductsClient.GenerateStorageAccountSasToken` + +```go +ctx := context.TODO() +id := dataproducts.NewDataProductID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue") + +payload := dataproducts.AccountSas{ + // ... +} + + +read, err := client.GenerateStorageAccountSasToken(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataProductsClient.Get` + +```go +ctx := context.TODO() +id := dataproducts.NewDataProductID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue") + +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: `DataProductsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DataProductsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DataProductsClient.ListRolesAssignments` + +```go +ctx := context.TODO() +id := dataproducts.NewDataProductID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue") +var payload interface{} + +read, err := client.ListRolesAssignments(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataProductsClient.RemoveUserRole` + +```go +ctx := context.TODO() +id := dataproducts.NewDataProductID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue") + +payload := dataproducts.RoleAssignmentDetail{ + // ... +} + + +read, err := client.RemoveUserRole(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataProductsClient.RotateKey` + +```go +ctx := context.TODO() +id := dataproducts.NewDataProductID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue") + +payload := dataproducts.KeyVaultInfo{ + // ... +} + + +read, err := client.RotateKey(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataProductsClient.Update` + +```go +ctx := context.TODO() +id := dataproducts.NewDataProductID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue") + +payload := dataproducts.DataProductUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/client.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/client.go new file mode 100644 index 00000000000..387dcf72dfa --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/client.go @@ -0,0 +1,26 @@ +package dataproducts + +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 DataProductsClient struct { + Client *resourcemanager.Client +} + +func NewDataProductsClientWithBaseURI(sdkApi sdkEnv.Api) (*DataProductsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "dataproducts", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataProductsClient: %+v", err) + } + + return &DataProductsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/constants.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/constants.go new file mode 100644 index 00000000000..de9514b4345 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/constants.go @@ -0,0 +1,189 @@ +package dataproducts + +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 ControlState string + +const ( + ControlStateDisabled ControlState = "Disabled" + ControlStateEnabled ControlState = "Enabled" +) + +func PossibleValuesForControlState() []string { + return []string{ + string(ControlStateDisabled), + string(ControlStateEnabled), + } +} + +func (s *ControlState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseControlState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseControlState(input string) (*ControlState, error) { + vals := map[string]ControlState{ + "disabled": ControlStateDisabled, + "enabled": ControlStateEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ControlState(input) + return &out, nil +} + +type DataProductUserRole string + +const ( + DataProductUserRoleReader DataProductUserRole = "Reader" + DataProductUserRoleSensitiveReader DataProductUserRole = "SensitiveReader" +) + +func PossibleValuesForDataProductUserRole() []string { + return []string{ + string(DataProductUserRoleReader), + string(DataProductUserRoleSensitiveReader), + } +} + +func (s *DataProductUserRole) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataProductUserRole(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataProductUserRole(input string) (*DataProductUserRole, error) { + vals := map[string]DataProductUserRole{ + "reader": DataProductUserRoleReader, + "sensitivereader": DataProductUserRoleSensitiveReader, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataProductUserRole(input) + return &out, nil +} + +type DefaultAction string + +const ( + DefaultActionAllow DefaultAction = "Allow" + DefaultActionDeny DefaultAction = "Deny" +) + +func PossibleValuesForDefaultAction() []string { + return []string{ + string(DefaultActionAllow), + string(DefaultActionDeny), + } +} + +func (s *DefaultAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDefaultAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDefaultAction(input string) (*DefaultAction, error) { + vals := map[string]DefaultAction{ + "allow": DefaultActionAllow, + "deny": DefaultActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DefaultAction(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/id_dataproduct.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/id_dataproduct.go new file mode 100644 index 00000000000..eda77278218 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/id_dataproduct.go @@ -0,0 +1,130 @@ +package dataproducts + +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(&DataProductId{}) +} + +var _ resourceids.ResourceId = &DataProductId{} + +// DataProductId is a struct representing the Resource ID for a Data Product +type DataProductId struct { + SubscriptionId string + ResourceGroupName string + DataProductName string +} + +// NewDataProductID returns a new DataProductId struct +func NewDataProductID(subscriptionId string, resourceGroupName string, dataProductName string) DataProductId { + return DataProductId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DataProductName: dataProductName, + } +} + +// ParseDataProductID parses 'input' into a DataProductId +func ParseDataProductID(input string) (*DataProductId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataProductId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataProductId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataProductIDInsensitively parses 'input' case-insensitively into a DataProductId +// note: this method should only be used for API response data and not user input +func ParseDataProductIDInsensitively(input string) (*DataProductId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataProductId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataProductId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataProductId) 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.DataProductName, ok = input.Parsed["dataProductName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataProductName", input) + } + + return nil +} + +// ValidateDataProductID checks that 'input' can be parsed as a Data Product ID +func ValidateDataProductID(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 := ParseDataProductID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data Product ID +func (id DataProductId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkAnalytics/dataProducts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DataProductName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data Product ID +func (id DataProductId) 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("staticMicrosoftNetworkAnalytics", "Microsoft.NetworkAnalytics", "Microsoft.NetworkAnalytics"), + resourceids.StaticSegment("staticDataProducts", "dataProducts", "dataProducts"), + resourceids.UserSpecifiedSegment("dataProductName", "dataProductValue"), + } +} + +// String returns a human-readable description of this Data Product ID +func (id DataProductId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Data Product Name: %q", id.DataProductName), + } + return fmt.Sprintf("Data Product (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/id_dataproduct_test.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/id_dataproduct_test.go new file mode 100644 index 00000000000..9382095d98f --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/id_dataproduct_test.go @@ -0,0 +1,282 @@ +package dataproducts + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DataProductId{} + +func TestNewDataProductID(t *testing.T) { + id := NewDataProductID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.DataProductName != "dataProductValue" { + t.Fatalf("Expected %q but got %q for Segment 'DataProductName'", id.DataProductName, "dataProductValue") + } +} + +func TestFormatDataProductID(t *testing.T) { + actual := NewDataProductID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataProductID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataProductId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue", + Expected: &DataProductId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DataProductName: "dataProductValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataProductID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DataProductName != v.Expected.DataProductName { + t.Fatalf("Expected %q but got %q for DataProductName", v.Expected.DataProductName, actual.DataProductName) + } + + } +} + +func TestParseDataProductIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataProductId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkAnAlYtIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkAnAlYtIcS/dAtApRoDuCtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue", + Expected: &DataProductId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DataProductName: "dataProductValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkAnAlYtIcS/dAtApRoDuCtS/dAtApRoDuCtVaLuE", + Expected: &DataProductId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DataProductName: "dAtApRoDuCtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkAnAlYtIcS/dAtApRoDuCtS/dAtApRoDuCtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataProductIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DataProductName != v.Expected.DataProductName { + t.Fatalf("Expected %q but got %q for DataProductName", v.Expected.DataProductName, actual.DataProductName) + } + + } +} + +func TestSegmentsForDataProductId(t *testing.T) { + segments := DataProductId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataProductId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/method_adduserrole.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_adduserrole.go new file mode 100644 index 00000000000..f10a15fb4c7 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_adduserrole.go @@ -0,0 +1,59 @@ +package dataproducts + +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 AddUserRoleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RoleAssignmentDetail +} + +// AddUserRole ... +func (c DataProductsClient) AddUserRole(ctx context.Context, id DataProductId, input RoleAssignmentCommonProperties) (result AddUserRoleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/addUserRole", 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 RoleAssignmentDetail + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/method_create.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_create.go new file mode 100644 index 00000000000..54c6ddaa8fc --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_create.go @@ -0,0 +1,75 @@ +package dataproducts + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DataProduct +} + +// Create ... +func (c DataProductsClient) Create(ctx context.Context, id DataProductId, input DataProduct) (result CreateOperationResponse, 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c DataProductsClient) CreateThenPoll(ctx context.Context, id DataProductId, input DataProduct) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/method_delete.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_delete.go new file mode 100644 index 00000000000..4ac6d04e7a4 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_delete.go @@ -0,0 +1,70 @@ +package dataproducts + +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 DataProductsClient) Delete(ctx context.Context, id DataProductId) (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 DataProductsClient) DeleteThenPoll(ctx context.Context, id DataProductId) 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/resource-manager/networkanalytics/2023-11-15/dataproducts/method_generatestorageaccountsastoken.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_generatestorageaccountsastoken.go new file mode 100644 index 00000000000..5321c96c8ba --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_generatestorageaccountsastoken.go @@ -0,0 +1,59 @@ +package dataproducts + +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 GenerateStorageAccountSasTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *AccountSasToken +} + +// GenerateStorageAccountSasToken ... +func (c DataProductsClient) GenerateStorageAccountSasToken(ctx context.Context, id DataProductId, input AccountSas) (result GenerateStorageAccountSasTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/generateStorageAccountSasToken", 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 AccountSasToken + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/method_get.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_get.go new file mode 100644 index 00000000000..f91d0cb40c2 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_get.go @@ -0,0 +1,54 @@ +package dataproducts + +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 *DataProduct +} + +// Get ... +func (c DataProductsClient) Get(ctx context.Context, id DataProductId) (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 DataProduct + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/method_listbyresourcegroup.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_listbyresourcegroup.go new file mode 100644 index 00000000000..de26cb90057 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_listbyresourcegroup.go @@ -0,0 +1,93 @@ +package dataproducts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DataProduct +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []DataProduct +} + +// ListByResourceGroup ... +func (c DataProductsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkAnalytics/dataProducts", 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 *[]DataProduct `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c DataProductsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, DataProductOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DataProductsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate DataProductOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]DataProduct, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/method_listbysubscription.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_listbysubscription.go new file mode 100644 index 00000000000..d5b8bb92202 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_listbysubscription.go @@ -0,0 +1,93 @@ +package dataproducts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DataProduct +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []DataProduct +} + +// ListBySubscription ... +func (c DataProductsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkAnalytics/dataProducts", 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 *[]DataProduct `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c DataProductsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, DataProductOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DataProductsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DataProductOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]DataProduct, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/method_listrolesassignments.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_listrolesassignments.go new file mode 100644 index 00000000000..4d4d5cf2a5a --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_listrolesassignments.go @@ -0,0 +1,59 @@ +package dataproducts + +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 ListRolesAssignmentsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ListRoleAssignments +} + +// ListRolesAssignments ... +func (c DataProductsClient) ListRolesAssignments(ctx context.Context, id DataProductId, input interface{}) (result ListRolesAssignmentsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listRolesAssignments", 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 ListRoleAssignments + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/method_removeuserrole.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_removeuserrole.go new file mode 100644 index 00000000000..c601140c4c3 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_removeuserrole.go @@ -0,0 +1,51 @@ +package dataproducts + +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 RemoveUserRoleOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RemoveUserRole ... +func (c DataProductsClient) RemoveUserRole(ctx context.Context, id DataProductId, input RoleAssignmentDetail) (result RemoveUserRoleOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/removeUserRole", 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/resource-manager/networkanalytics/2023-11-15/dataproducts/method_rotatekey.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_rotatekey.go new file mode 100644 index 00000000000..20074a7cb0b --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_rotatekey.go @@ -0,0 +1,51 @@ +package dataproducts + +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 RotateKeyOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// RotateKey ... +func (c DataProductsClient) RotateKey(ctx context.Context, id DataProductId, input KeyVaultInfo) (result RotateKeyOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/rotateKey", 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/resource-manager/networkanalytics/2023-11-15/dataproducts/method_update.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_update.go new file mode 100644 index 00000000000..0d05af9c78b --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/method_update.go @@ -0,0 +1,75 @@ +package dataproducts + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DataProduct +} + +// Update ... +func (c DataProductsClient) Update(ctx context.Context, id DataProductId, input DataProductUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c DataProductsClient) UpdateThenPoll(ctx context.Context, id DataProductId, input DataProductUpdate) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_accountsas.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_accountsas.go new file mode 100644 index 00000000000..4baf1c4e782 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_accountsas.go @@ -0,0 +1,34 @@ +package dataproducts + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountSas struct { + ExpiryTimeStamp string `json:"expiryTimeStamp"` + IPAddress string `json:"ipAddress"` + StartTimeStamp string `json:"startTimeStamp"` +} + +func (o *AccountSas) GetExpiryTimeStampAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.ExpiryTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *AccountSas) SetExpiryTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTimeStamp = formatted +} + +func (o *AccountSas) GetStartTimeStampAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.StartTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *AccountSas) SetStartTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTimeStamp = formatted +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_accountsastoken.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_accountsastoken.go new file mode 100644 index 00000000000..1703574b115 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_accountsastoken.go @@ -0,0 +1,8 @@ +package dataproducts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AccountSasToken struct { + StorageAccountSasToken string `json:"storageAccountSasToken"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_consumptionendpointsproperties.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_consumptionendpointsproperties.go new file mode 100644 index 00000000000..58e330cb98b --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_consumptionendpointsproperties.go @@ -0,0 +1,13 @@ +package dataproducts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ConsumptionEndpointsProperties struct { + FileAccessResourceId *string `json:"fileAccessResourceId,omitempty"` + FileAccessUrl *string `json:"fileAccessUrl,omitempty"` + IngestionResourceId *string `json:"ingestionResourceId,omitempty"` + IngestionUrl *string `json:"ingestionUrl,omitempty"` + QueryResourceId *string `json:"queryResourceId,omitempty"` + QueryUrl *string `json:"queryUrl,omitempty"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_dataproduct.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_dataproduct.go new file mode 100644 index 00000000000..7ebfcfd1720 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_dataproduct.go @@ -0,0 +1,20 @@ +package dataproducts + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProduct struct { + Id *string `json:"id,omitempty"` + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties *DataProductProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_dataproductnetworkacls.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_dataproductnetworkacls.go new file mode 100644 index 00000000000..8f6cdadd1fb --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_dataproductnetworkacls.go @@ -0,0 +1,11 @@ +package dataproducts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProductNetworkAcls struct { + AllowedQueryIPRangeList []string `json:"allowedQueryIpRangeList"` + DefaultAction DefaultAction `json:"defaultAction"` + IPRules []IPRules `json:"ipRules"` + VirtualNetworkRule []VirtualNetworkRule `json:"virtualNetworkRule"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_dataproductproperties.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_dataproductproperties.go new file mode 100644 index 00000000000..d1521c1c995 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_dataproductproperties.go @@ -0,0 +1,27 @@ +package dataproducts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProductProperties struct { + AvailableMinorVersions *[]string `json:"availableMinorVersions,omitempty"` + ConsumptionEndpoints *ConsumptionEndpointsProperties `json:"consumptionEndpoints,omitempty"` + CurrentMinorVersion *string `json:"currentMinorVersion,omitempty"` + CustomerEncryptionKey *EncryptionKeyDetails `json:"customerEncryptionKey,omitempty"` + CustomerManagedKeyEncryptionEnabled *ControlState `json:"customerManagedKeyEncryptionEnabled,omitempty"` + Documentation *string `json:"documentation,omitempty"` + KeyVaultUrl *string `json:"keyVaultUrl,omitempty"` + MajorVersion string `json:"majorVersion"` + ManagedResourceGroupConfiguration *ManagedResourceGroupConfiguration `json:"managedResourceGroupConfiguration,omitempty"` + Networkacls *DataProductNetworkAcls `json:"networkacls,omitempty"` + Owners *[]string `json:"owners,omitempty"` + PrivateLinksEnabled *ControlState `json:"privateLinksEnabled,omitempty"` + Product string `json:"product"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *ControlState `json:"publicNetworkAccess,omitempty"` + Publisher string `json:"publisher"` + PurviewAccount *string `json:"purviewAccount,omitempty"` + PurviewCollection *string `json:"purviewCollection,omitempty"` + Redundancy *ControlState `json:"redundancy,omitempty"` + ResourceGuid *string `json:"resourceGuid,omitempty"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_dataproductupdate.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_dataproductupdate.go new file mode 100644 index 00000000000..a403bce6563 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_dataproductupdate.go @@ -0,0 +1,14 @@ +package dataproducts + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProductUpdate struct { + Identity *identity.SystemAndUserAssignedMap `json:"identity,omitempty"` + Properties *DataProductUpdateProperties `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_dataproductupdateproperties.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_dataproductupdateproperties.go new file mode 100644 index 00000000000..39d3b3d2234 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_dataproductupdateproperties.go @@ -0,0 +1,12 @@ +package dataproducts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProductUpdateProperties struct { + CurrentMinorVersion *string `json:"currentMinorVersion,omitempty"` + Owners *[]string `json:"owners,omitempty"` + PrivateLinksEnabled *ControlState `json:"privateLinksEnabled,omitempty"` + PurviewAccount *string `json:"purviewAccount,omitempty"` + PurviewCollection *string `json:"purviewCollection,omitempty"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_encryptionkeydetails.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_encryptionkeydetails.go new file mode 100644 index 00000000000..eea867b40ab --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_encryptionkeydetails.go @@ -0,0 +1,10 @@ +package dataproducts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionKeyDetails struct { + KeyName string `json:"keyName"` + KeyVaultUri string `json:"keyVaultUri"` + KeyVersion string `json:"keyVersion"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_iprules.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_iprules.go new file mode 100644 index 00000000000..900f41224ec --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_iprules.go @@ -0,0 +1,9 @@ +package dataproducts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IPRules struct { + Action string `json:"action"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_keyvaultinfo.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_keyvaultinfo.go new file mode 100644 index 00000000000..816c1cce981 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_keyvaultinfo.go @@ -0,0 +1,8 @@ +package dataproducts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KeyVaultInfo struct { + KeyVaultUrl string `json:"keyVaultUrl"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_listroleassignments.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_listroleassignments.go new file mode 100644 index 00000000000..dc818501e1e --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_listroleassignments.go @@ -0,0 +1,9 @@ +package dataproducts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListRoleAssignments struct { + Count int64 `json:"count"` + RoleAssignmentResponse []RoleAssignmentDetail `json:"roleAssignmentResponse"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_managedresourcegroupconfiguration.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_managedresourcegroupconfiguration.go new file mode 100644 index 00000000000..a7b872d8d36 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_managedresourcegroupconfiguration.go @@ -0,0 +1,9 @@ +package dataproducts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedResourceGroupConfiguration struct { + Location string `json:"location"` + Name string `json:"name"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_roleassignmentcommonproperties.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_roleassignmentcommonproperties.go new file mode 100644 index 00000000000..b293db1948c --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_roleassignmentcommonproperties.go @@ -0,0 +1,13 @@ +package dataproducts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoleAssignmentCommonProperties struct { + DataTypeScope []string `json:"dataTypeScope"` + PrincipalId string `json:"principalId"` + PrincipalType string `json:"principalType"` + Role DataProductUserRole `json:"role"` + RoleId string `json:"roleId"` + UserName string `json:"userName"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_roleassignmentdetail.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_roleassignmentdetail.go new file mode 100644 index 00000000000..c8994150184 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_roleassignmentdetail.go @@ -0,0 +1,14 @@ +package dataproducts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RoleAssignmentDetail struct { + DataTypeScope []string `json:"dataTypeScope"` + PrincipalId string `json:"principalId"` + PrincipalType string `json:"principalType"` + Role DataProductUserRole `json:"role"` + RoleAssignmentId string `json:"roleAssignmentId"` + RoleId string `json:"roleId"` + UserName string `json:"userName"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/model_virtualnetworkrule.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_virtualnetworkrule.go new file mode 100644 index 00000000000..e9a91cfe882 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/model_virtualnetworkrule.go @@ -0,0 +1,10 @@ +package dataproducts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualNetworkRule struct { + Action *string `json:"action,omitempty"` + Id string `json:"id"` + State *string `json:"state,omitempty"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/predicates.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/predicates.go new file mode 100644 index 00000000000..4e56cbc0ce9 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/predicates.go @@ -0,0 +1,32 @@ +package dataproducts + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProductOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p DataProductOperationPredicate) Matches(input DataProduct) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproducts/version.go b/resource-manager/networkanalytics/2023-11-15/dataproducts/version.go new file mode 100644 index 00000000000..7b27ad6996c --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproducts/version.go @@ -0,0 +1,12 @@ +package dataproducts + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-11-15" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/dataproducts/%s", defaultApiVersion) +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/README.md b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/README.md new file mode 100644 index 00000000000..e96ed595fd5 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/README.md @@ -0,0 +1,71 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs` Documentation + +The `dataproductscatalogs` SDK allows for interaction with the Azure Resource Manager Service `networkanalytics` (API Version `2023-11-15`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs" +``` + + +### Client Initialization + +```go +client := dataproductscatalogs.NewDataProductsCatalogsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataProductsCatalogsClient.Get` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +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: `DataProductsCatalogsClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id)` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DataProductsCatalogsClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/client.go b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/client.go new file mode 100644 index 00000000000..588c4ca3519 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/client.go @@ -0,0 +1,26 @@ +package dataproductscatalogs + +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 DataProductsCatalogsClient struct { + Client *resourcemanager.Client +} + +func NewDataProductsCatalogsClientWithBaseURI(sdkApi sdkEnv.Api) (*DataProductsCatalogsClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "dataproductscatalogs", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataProductsCatalogsClient: %+v", err) + } + + return &DataProductsCatalogsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/constants.go b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/constants.go new file mode 100644 index 00000000000..0b945c9ac4f --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/constants.go @@ -0,0 +1,66 @@ +package dataproductscatalogs + +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 ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/method_get.go b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/method_get.go new file mode 100644 index 00000000000..3fa3d751462 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/method_get.go @@ -0,0 +1,56 @@ +package dataproductscatalogs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DataProductsCatalog +} + +// Get ... +func (c DataProductsCatalogsClient) Get(ctx context.Context, id commonids.ResourceGroupId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkAnalytics/dataProductsCatalogs/default", 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 DataProductsCatalog + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/method_listbyresourcegroup.go b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/method_listbyresourcegroup.go new file mode 100644 index 00000000000..5cf923e27dd --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/method_listbyresourcegroup.go @@ -0,0 +1,93 @@ +package dataproductscatalogs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DataProductsCatalog +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []DataProductsCatalog +} + +// ListByResourceGroup ... +func (c DataProductsCatalogsClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkAnalytics/dataProductsCatalogs", 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 *[]DataProductsCatalog `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByResourceGroupComplete retrieves all the results into a single object +func (c DataProductsCatalogsClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, DataProductsCatalogOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DataProductsCatalogsClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate DataProductsCatalogOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]DataProductsCatalog, 0) + + resp, err := c.ListByResourceGroup(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 = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/method_listbysubscription.go b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/method_listbysubscription.go new file mode 100644 index 00000000000..cae1173fda2 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/method_listbysubscription.go @@ -0,0 +1,93 @@ +package dataproductscatalogs + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DataProductsCatalog +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []DataProductsCatalog +} + +// ListBySubscription ... +func (c DataProductsCatalogsClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.NetworkAnalytics/dataProductsCatalogs", 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 *[]DataProductsCatalog `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c DataProductsCatalogsClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, DataProductsCatalogOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DataProductsCatalogsClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate DataProductsCatalogOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]DataProductsCatalog, 0) + + resp, err := c.ListBySubscription(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 = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/model_dataproductinformation.go b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/model_dataproductinformation.go new file mode 100644 index 00000000000..6d82e65380b --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/model_dataproductinformation.go @@ -0,0 +1,10 @@ +package dataproductscatalogs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProductInformation struct { + DataProductName string `json:"dataProductName"` + DataProductVersions []DataProductVersion `json:"dataProductVersions"` + Description string `json:"description"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/model_dataproductscatalog.go b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/model_dataproductscatalog.go new file mode 100644 index 00000000000..30fffd25fea --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/model_dataproductscatalog.go @@ -0,0 +1,16 @@ +package dataproductscatalogs + +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 DataProductsCatalog struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DataProductsCatalogProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/model_dataproductscatalogproperties.go b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/model_dataproductscatalogproperties.go new file mode 100644 index 00000000000..5918c7f68ed --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/model_dataproductscatalogproperties.go @@ -0,0 +1,9 @@ +package dataproductscatalogs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProductsCatalogProperties struct { + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + Publishers []PublisherInformation `json:"publishers"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/model_dataproductversion.go b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/model_dataproductversion.go new file mode 100644 index 00000000000..91ca664b275 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/model_dataproductversion.go @@ -0,0 +1,8 @@ +package dataproductscatalogs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProductVersion struct { + Version string `json:"version"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/model_publisherinformation.go b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/model_publisherinformation.go new file mode 100644 index 00000000000..b10e730a2fc --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/model_publisherinformation.go @@ -0,0 +1,9 @@ +package dataproductscatalogs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublisherInformation struct { + DataProducts []DataProductInformation `json:"dataProducts"` + PublisherName string `json:"publisherName"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/predicates.go b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/predicates.go new file mode 100644 index 00000000000..931e7251f7f --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/predicates.go @@ -0,0 +1,27 @@ +package dataproductscatalogs + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataProductsCatalogOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DataProductsCatalogOperationPredicate) Matches(input DataProductsCatalog) 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/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/version.go b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/version.go new file mode 100644 index 00000000000..47f04856ac9 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/dataproductscatalogs/version.go @@ -0,0 +1,12 @@ +package dataproductscatalogs + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-11-15" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/dataproductscatalogs/%s", defaultApiVersion) +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/README.md b/resource-manager/networkanalytics/2023-11-15/datatypes/README.md new file mode 100644 index 00000000000..e6ab52b4789 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/README.md @@ -0,0 +1,133 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/networkanalytics/2023-11-15/datatypes` Documentation + +The `datatypes` SDK allows for interaction with the Azure Resource Manager Service `networkanalytics` (API Version `2023-11-15`). + +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/networkanalytics/2023-11-15/datatypes" +``` + + +### Client Initialization + +```go +client := datatypes.NewDataTypesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataTypesClient.Create` + +```go +ctx := context.TODO() +id := datatypes.NewDataTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue", "dataTypeValue") + +payload := datatypes.DataType{ + // ... +} + + +if err := client.CreateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataTypesClient.Delete` + +```go +ctx := context.TODO() +id := datatypes.NewDataTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue", "dataTypeValue") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataTypesClient.DeleteData` + +```go +ctx := context.TODO() +id := datatypes.NewDataTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue", "dataTypeValue") +var payload interface{} + +if err := client.DeleteDataThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataTypesClient.GenerateStorageContainerSasToken` + +```go +ctx := context.TODO() +id := datatypes.NewDataTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue", "dataTypeValue") + +payload := datatypes.ContainerSaS{ + // ... +} + + +read, err := client.GenerateStorageContainerSasToken(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataTypesClient.Get` + +```go +ctx := context.TODO() +id := datatypes.NewDataTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue", "dataTypeValue") + +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: `DataTypesClient.ListByDataProduct` + +```go +ctx := context.TODO() +id := datatypes.NewDataProductID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue") + +// alternatively `client.ListByDataProduct(ctx, id)` can be used to do batched pagination +items, err := client.ListByDataProductComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DataTypesClient.Update` + +```go +ctx := context.TODO() +id := datatypes.NewDataTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue", "dataTypeValue") + +payload := datatypes.DataTypeUpdate{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/client.go b/resource-manager/networkanalytics/2023-11-15/datatypes/client.go new file mode 100644 index 00000000000..3cfa3a8eb35 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/client.go @@ -0,0 +1,26 @@ +package datatypes + +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 DataTypesClient struct { + Client *resourcemanager.Client +} + +func NewDataTypesClientWithBaseURI(sdkApi sdkEnv.Api) (*DataTypesClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "datatypes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataTypesClient: %+v", err) + } + + return &DataTypesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/constants.go b/resource-manager/networkanalytics/2023-11-15/datatypes/constants.go new file mode 100644 index 00000000000..5e181283940 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/constants.go @@ -0,0 +1,107 @@ +package datatypes + +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 DataTypeState string + +const ( + DataTypeStateRunning DataTypeState = "Running" + DataTypeStateStopped DataTypeState = "Stopped" +) + +func PossibleValuesForDataTypeState() []string { + return []string{ + string(DataTypeStateRunning), + string(DataTypeStateStopped), + } +} + +func (s *DataTypeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataTypeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataTypeState(input string) (*DataTypeState, error) { + vals := map[string]DataTypeState{ + "running": DataTypeStateRunning, + "stopped": DataTypeStateStopped, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataTypeState(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateAccepted), + string(ProvisioningStateCanceled), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateProvisioning), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "accepted": ProvisioningStateAccepted, + "canceled": ProvisioningStateCanceled, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "provisioning": ProvisioningStateProvisioning, + "succeeded": ProvisioningStateSucceeded, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/id_dataproduct.go b/resource-manager/networkanalytics/2023-11-15/datatypes/id_dataproduct.go new file mode 100644 index 00000000000..ba9fe2b3ec4 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/id_dataproduct.go @@ -0,0 +1,130 @@ +package datatypes + +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(&DataProductId{}) +} + +var _ resourceids.ResourceId = &DataProductId{} + +// DataProductId is a struct representing the Resource ID for a Data Product +type DataProductId struct { + SubscriptionId string + ResourceGroupName string + DataProductName string +} + +// NewDataProductID returns a new DataProductId struct +func NewDataProductID(subscriptionId string, resourceGroupName string, dataProductName string) DataProductId { + return DataProductId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DataProductName: dataProductName, + } +} + +// ParseDataProductID parses 'input' into a DataProductId +func ParseDataProductID(input string) (*DataProductId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataProductId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataProductId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataProductIDInsensitively parses 'input' case-insensitively into a DataProductId +// note: this method should only be used for API response data and not user input +func ParseDataProductIDInsensitively(input string) (*DataProductId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataProductId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataProductId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataProductId) 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.DataProductName, ok = input.Parsed["dataProductName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataProductName", input) + } + + return nil +} + +// ValidateDataProductID checks that 'input' can be parsed as a Data Product ID +func ValidateDataProductID(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 := ParseDataProductID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data Product ID +func (id DataProductId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkAnalytics/dataProducts/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DataProductName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data Product ID +func (id DataProductId) 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("staticMicrosoftNetworkAnalytics", "Microsoft.NetworkAnalytics", "Microsoft.NetworkAnalytics"), + resourceids.StaticSegment("staticDataProducts", "dataProducts", "dataProducts"), + resourceids.UserSpecifiedSegment("dataProductName", "dataProductValue"), + } +} + +// String returns a human-readable description of this Data Product ID +func (id DataProductId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Data Product Name: %q", id.DataProductName), + } + return fmt.Sprintf("Data Product (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/id_dataproduct_test.go b/resource-manager/networkanalytics/2023-11-15/datatypes/id_dataproduct_test.go new file mode 100644 index 00000000000..466ba3afb46 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/id_dataproduct_test.go @@ -0,0 +1,282 @@ +package datatypes + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DataProductId{} + +func TestNewDataProductID(t *testing.T) { + id := NewDataProductID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.DataProductName != "dataProductValue" { + t.Fatalf("Expected %q but got %q for Segment 'DataProductName'", id.DataProductName, "dataProductValue") + } +} + +func TestFormatDataProductID(t *testing.T) { + actual := NewDataProductID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataProductID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataProductId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue", + Expected: &DataProductId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DataProductName: "dataProductValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataProductID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DataProductName != v.Expected.DataProductName { + t.Fatalf("Expected %q but got %q for DataProductName", v.Expected.DataProductName, actual.DataProductName) + } + + } +} + +func TestParseDataProductIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataProductId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkAnAlYtIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkAnAlYtIcS/dAtApRoDuCtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue", + Expected: &DataProductId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DataProductName: "dataProductValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkAnAlYtIcS/dAtApRoDuCtS/dAtApRoDuCtVaLuE", + Expected: &DataProductId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DataProductName: "dAtApRoDuCtVaLuE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkAnAlYtIcS/dAtApRoDuCtS/dAtApRoDuCtVaLuE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataProductIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DataProductName != v.Expected.DataProductName { + t.Fatalf("Expected %q but got %q for DataProductName", v.Expected.DataProductName, actual.DataProductName) + } + + } +} + +func TestSegmentsForDataProductId(t *testing.T) { + segments := DataProductId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataProductId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/id_datatype.go b/resource-manager/networkanalytics/2023-11-15/datatypes/id_datatype.go new file mode 100644 index 00000000000..5b64cc1f316 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/id_datatype.go @@ -0,0 +1,139 @@ +package datatypes + +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(&DataTypeId{}) +} + +var _ resourceids.ResourceId = &DataTypeId{} + +// DataTypeId is a struct representing the Resource ID for a Data Type +type DataTypeId struct { + SubscriptionId string + ResourceGroupName string + DataProductName string + DataTypeName string +} + +// NewDataTypeID returns a new DataTypeId struct +func NewDataTypeID(subscriptionId string, resourceGroupName string, dataProductName string, dataTypeName string) DataTypeId { + return DataTypeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + DataProductName: dataProductName, + DataTypeName: dataTypeName, + } +} + +// ParseDataTypeID parses 'input' into a DataTypeId +func ParseDataTypeID(input string) (*DataTypeId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataTypeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataTypeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataTypeIDInsensitively parses 'input' case-insensitively into a DataTypeId +// note: this method should only be used for API response data and not user input +func ParseDataTypeIDInsensitively(input string) (*DataTypeId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataTypeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataTypeId{} + if err := id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataTypeId) 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.DataProductName, ok = input.Parsed["dataProductName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataProductName", input) + } + + if id.DataTypeName, ok = input.Parsed["dataTypeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataTypeName", input) + } + + return nil +} + +// ValidateDataTypeID checks that 'input' can be parsed as a Data Type ID +func ValidateDataTypeID(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 := ParseDataTypeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data Type ID +func (id DataTypeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.NetworkAnalytics/dataProducts/%s/dataTypes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.DataProductName, id.DataTypeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data Type ID +func (id DataTypeId) 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("staticMicrosoftNetworkAnalytics", "Microsoft.NetworkAnalytics", "Microsoft.NetworkAnalytics"), + resourceids.StaticSegment("staticDataProducts", "dataProducts", "dataProducts"), + resourceids.UserSpecifiedSegment("dataProductName", "dataProductValue"), + resourceids.StaticSegment("staticDataTypes", "dataTypes", "dataTypes"), + resourceids.UserSpecifiedSegment("dataTypeName", "dataTypeValue"), + } +} + +// String returns a human-readable description of this Data Type ID +func (id DataTypeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Data Product Name: %q", id.DataProductName), + fmt.Sprintf("Data Type Name: %q", id.DataTypeName), + } + return fmt.Sprintf("Data Type (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/id_datatype_test.go b/resource-manager/networkanalytics/2023-11-15/datatypes/id_datatype_test.go new file mode 100644 index 00000000000..4a335dc84bd --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/id_datatype_test.go @@ -0,0 +1,327 @@ +package datatypes + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DataTypeId{} + +func TestNewDataTypeID(t *testing.T) { + id := NewDataTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue", "dataTypeValue") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.DataProductName != "dataProductValue" { + t.Fatalf("Expected %q but got %q for Segment 'DataProductName'", id.DataProductName, "dataProductValue") + } + + if id.DataTypeName != "dataTypeValue" { + t.Fatalf("Expected %q but got %q for Segment 'DataTypeName'", id.DataTypeName, "dataTypeValue") + } +} + +func TestFormatDataTypeID(t *testing.T) { + actual := NewDataTypeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "dataProductValue", "dataTypeValue").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue/dataTypes/dataTypeValue" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataTypeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataTypeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue/dataTypes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue/dataTypes/dataTypeValue", + Expected: &DataTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DataProductName: "dataProductValue", + DataTypeName: "dataTypeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue/dataTypes/dataTypeValue/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataTypeID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DataProductName != v.Expected.DataProductName { + t.Fatalf("Expected %q but got %q for DataProductName", v.Expected.DataProductName, actual.DataProductName) + } + + if actual.DataTypeName != v.Expected.DataTypeName { + t.Fatalf("Expected %q but got %q for DataTypeName", v.Expected.DataTypeName, actual.DataTypeName) + } + + } +} + +func TestParseDataTypeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataTypeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkAnAlYtIcS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkAnAlYtIcS/dAtApRoDuCtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkAnAlYtIcS/dAtApRoDuCtS/dAtApRoDuCtVaLuE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue/dataTypes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkAnAlYtIcS/dAtApRoDuCtS/dAtApRoDuCtVaLuE/dAtAtYpEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue/dataTypes/dataTypeValue", + Expected: &DataTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + DataProductName: "dataProductValue", + DataTypeName: "dataTypeValue", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.NetworkAnalytics/dataProducts/dataProductValue/dataTypes/dataTypeValue/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkAnAlYtIcS/dAtApRoDuCtS/dAtApRoDuCtVaLuE/dAtAtYpEs/dAtAtYpEvAlUe", + Expected: &DataTypeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + DataProductName: "dAtApRoDuCtVaLuE", + DataTypeName: "dAtAtYpEvAlUe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.nEtWoRkAnAlYtIcS/dAtApRoDuCtS/dAtApRoDuCtVaLuE/dAtAtYpEs/dAtAtYpEvAlUe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataTypeIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.DataProductName != v.Expected.DataProductName { + t.Fatalf("Expected %q but got %q for DataProductName", v.Expected.DataProductName, actual.DataProductName) + } + + if actual.DataTypeName != v.Expected.DataTypeName { + t.Fatalf("Expected %q but got %q for DataTypeName", v.Expected.DataTypeName, actual.DataTypeName) + } + + } +} + +func TestSegmentsForDataTypeId(t *testing.T) { + segments := DataTypeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataTypeId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/method_create.go b/resource-manager/networkanalytics/2023-11-15/datatypes/method_create.go new file mode 100644 index 00000000000..452a12e422a --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/method_create.go @@ -0,0 +1,75 @@ +package datatypes + +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 CreateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DataType +} + +// Create ... +func (c DataTypesClient) Create(ctx context.Context, id DataTypeId, input DataType) (result CreateOperationResponse, 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateThenPoll performs Create then polls until it's completed +func (c DataTypesClient) CreateThenPoll(ctx context.Context, id DataTypeId, input DataType) error { + result, err := c.Create(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Create: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Create: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/method_delete.go b/resource-manager/networkanalytics/2023-11-15/datatypes/method_delete.go new file mode 100644 index 00000000000..2b9b79a291b --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/method_delete.go @@ -0,0 +1,70 @@ +package datatypes + +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 DataTypesClient) Delete(ctx context.Context, id DataTypeId) (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 DataTypesClient) DeleteThenPoll(ctx context.Context, id DataTypeId) 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/resource-manager/networkanalytics/2023-11-15/datatypes/method_deletedata.go b/resource-manager/networkanalytics/2023-11-15/datatypes/method_deletedata.go new file mode 100644 index 00000000000..b657696a059 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/method_deletedata.go @@ -0,0 +1,74 @@ +package datatypes + +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 DeleteDataOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// DeleteData ... +func (c DataTypesClient) DeleteData(ctx context.Context, id DataTypeId, input interface{}) (result DeleteDataOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/deleteData", 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 + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteDataThenPoll performs DeleteData then polls until it's completed +func (c DataTypesClient) DeleteDataThenPoll(ctx context.Context, id DataTypeId, input interface{}) error { + result, err := c.DeleteData(ctx, id, input) + if err != nil { + return fmt.Errorf("performing DeleteData: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after DeleteData: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/method_generatestoragecontainersastoken.go b/resource-manager/networkanalytics/2023-11-15/datatypes/method_generatestoragecontainersastoken.go new file mode 100644 index 00000000000..05ec07d90cd --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/method_generatestoragecontainersastoken.go @@ -0,0 +1,59 @@ +package datatypes + +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 GenerateStorageContainerSasTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ContainerSasToken +} + +// GenerateStorageContainerSasToken ... +func (c DataTypesClient) GenerateStorageContainerSasToken(ctx context.Context, id DataTypeId, input ContainerSaS) (result GenerateStorageContainerSasTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/generateStorageContainerSasToken", 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 ContainerSasToken + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/method_get.go b/resource-manager/networkanalytics/2023-11-15/datatypes/method_get.go new file mode 100644 index 00000000000..7f428664dd6 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/method_get.go @@ -0,0 +1,54 @@ +package datatypes + +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 *DataType +} + +// Get ... +func (c DataTypesClient) Get(ctx context.Context, id DataTypeId) (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 DataType + result.Model = &model + + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/method_listbydataproduct.go b/resource-manager/networkanalytics/2023-11-15/datatypes/method_listbydataproduct.go new file mode 100644 index 00000000000..1f1d2ce61c5 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/method_listbydataproduct.go @@ -0,0 +1,92 @@ +package datatypes + +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 ListByDataProductOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DataType +} + +type ListByDataProductCompleteResult struct { + LatestHttpResponse *http.Response + Items []DataType +} + +// ListByDataProduct ... +func (c DataTypesClient) ListByDataProduct(ctx context.Context, id DataProductId) (result ListByDataProductOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/dataTypes", 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 *[]DataType `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListByDataProductComplete retrieves all the results into a single object +func (c DataTypesClient) ListByDataProductComplete(ctx context.Context, id DataProductId) (ListByDataProductCompleteResult, error) { + return c.ListByDataProductCompleteMatchingPredicate(ctx, id, DataTypeOperationPredicate{}) +} + +// ListByDataProductCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DataTypesClient) ListByDataProductCompleteMatchingPredicate(ctx context.Context, id DataProductId, predicate DataTypeOperationPredicate) (result ListByDataProductCompleteResult, err error) { + items := make([]DataType, 0) + + resp, err := c.ListByDataProduct(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 = ListByDataProductCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/method_update.go b/resource-manager/networkanalytics/2023-11-15/datatypes/method_update.go new file mode 100644 index 00000000000..1053836a911 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/method_update.go @@ -0,0 +1,75 @@ +package datatypes + +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 UpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DataType +} + +// Update ... +func (c DataTypesClient) Update(ctx context.Context, id DataTypeId, input DataTypeUpdate) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// UpdateThenPoll performs Update then polls until it's completed +func (c DataTypesClient) UpdateThenPoll(ctx context.Context, id DataTypeId, input DataTypeUpdate) error { + result, err := c.Update(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Update: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Update: %+v", err) + } + + return nil +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/model_containersas.go b/resource-manager/networkanalytics/2023-11-15/datatypes/model_containersas.go new file mode 100644 index 00000000000..1f8bda212af --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/model_containersas.go @@ -0,0 +1,34 @@ +package datatypes + +import ( + "time" + + "github.com/hashicorp/go-azure-helpers/lang/dates" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerSaS struct { + ExpiryTimeStamp string `json:"expiryTimeStamp"` + IPAddress string `json:"ipAddress"` + StartTimeStamp string `json:"startTimeStamp"` +} + +func (o *ContainerSaS) GetExpiryTimeStampAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.ExpiryTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *ContainerSaS) SetExpiryTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTimeStamp = formatted +} + +func (o *ContainerSaS) GetStartTimeStampAsTime() (*time.Time, error) { + return dates.ParseAsFormat(&o.StartTimeStamp, "2006-01-02T15:04:05Z07:00") +} + +func (o *ContainerSaS) SetStartTimeStampAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.StartTimeStamp = formatted +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/model_containersastoken.go b/resource-manager/networkanalytics/2023-11-15/datatypes/model_containersastoken.go new file mode 100644 index 00000000000..bcac1fd0a59 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/model_containersastoken.go @@ -0,0 +1,8 @@ +package datatypes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerSasToken struct { + StorageContainerSasToken string `json:"storageContainerSasToken"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/model_datatype.go b/resource-manager/networkanalytics/2023-11-15/datatypes/model_datatype.go new file mode 100644 index 00000000000..2dd08074a44 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/model_datatype.go @@ -0,0 +1,16 @@ +package datatypes + +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 DataType struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties *DataTypeProperties `json:"properties,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/model_datatypeproperties.go b/resource-manager/networkanalytics/2023-11-15/datatypes/model_datatypeproperties.go new file mode 100644 index 00000000000..93ff6804541 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/model_datatypeproperties.go @@ -0,0 +1,14 @@ +package datatypes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTypeProperties struct { + DatabaseCacheRetention *int64 `json:"databaseCacheRetention,omitempty"` + DatabaseRetention *int64 `json:"databaseRetention,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + State *DataTypeState `json:"state,omitempty"` + StateReason *string `json:"stateReason,omitempty"` + StorageOutputRetention *int64 `json:"storageOutputRetention,omitempty"` + VisualizationUrl *string `json:"visualizationUrl,omitempty"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/model_datatypeupdate.go b/resource-manager/networkanalytics/2023-11-15/datatypes/model_datatypeupdate.go new file mode 100644 index 00000000000..57df4e7f39e --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/model_datatypeupdate.go @@ -0,0 +1,8 @@ +package datatypes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTypeUpdate struct { + Properties *DataTypeUpdateProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/model_datatypeupdateproperties.go b/resource-manager/networkanalytics/2023-11-15/datatypes/model_datatypeupdateproperties.go new file mode 100644 index 00000000000..0876197dc80 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/model_datatypeupdateproperties.go @@ -0,0 +1,11 @@ +package datatypes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTypeUpdateProperties struct { + DatabaseCacheRetention *int64 `json:"databaseCacheRetention,omitempty"` + DatabaseRetention *int64 `json:"databaseRetention,omitempty"` + State *DataTypeState `json:"state,omitempty"` + StorageOutputRetention *int64 `json:"storageOutputRetention,omitempty"` +} diff --git a/resource-manager/networkanalytics/2023-11-15/datatypes/predicates.go b/resource-manager/networkanalytics/2023-11-15/datatypes/predicates.go new file mode 100644 index 00000000000..e651d8f8290 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/predicates.go @@ -0,0 +1,27 @@ +package datatypes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataTypeOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DataTypeOperationPredicate) Matches(input DataType) 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/resource-manager/networkanalytics/2023-11-15/datatypes/version.go b/resource-manager/networkanalytics/2023-11-15/datatypes/version.go new file mode 100644 index 00000000000..ed3af6483d4 --- /dev/null +++ b/resource-manager/networkanalytics/2023-11-15/datatypes/version.go @@ -0,0 +1,12 @@ +package datatypes + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2023-11-15" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/datatypes/%s", defaultApiVersion) +}