diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/CHANGELOG.md b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/CHANGELOG.md new file mode 100644 index 000000000000..72a6099fae49 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 0.1.0 (2023-11-24) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkanalytics/armnetworkanalytics` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/LICENSE.txt b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/README.md b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/README.md new file mode 100644 index 000000000000..2f309ff29ce0 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/README.md @@ -0,0 +1,92 @@ +# Azure Networkanalytics Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkanalytics/armnetworkanalytics)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkanalytics/armnetworkanalytics) + +The `armnetworkanalytics` module provides operations for working with Azure Networkanalytics. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/networkanalytics/armnetworkanalytics) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Networkanalytics module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkanalytics/armnetworkanalytics +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Networkanalytics. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Client Factory + +Azure Networkanalytics module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := armnetworkanalytics.NewClientFactory(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := armnetworkanalytics.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewDataProductsClient() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Networkanalytics` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/autorest.md b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/autorest.md new file mode 100644 index 000000000000..3236e070ec37 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 +tag: package-2023-11-15 +``` \ No newline at end of file diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/build.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/build.go new file mode 100644 index 000000000000..fc222c0fe729 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/build.go @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file enables 'go generate' to regenerate this specific SDK +//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/networkanalytics/armnetworkanalytics + +package armnetworkanalytics diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/ci.yml b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/ci.yml new file mode 100644 index 000000000000..484ba66becca --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/networkanalytics/armnetworkanalytics/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/networkanalytics/armnetworkanalytics/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/networkanalytics/armnetworkanalytics' diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/client_factory.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/client_factory.go new file mode 100644 index 000000000000..39968accc35e --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/client_factory.go @@ -0,0 +1,62 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnetworkanalytics + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +// NewDataProductsCatalogsClient creates a new instance of DataProductsCatalogsClient. +func (c *ClientFactory) NewDataProductsCatalogsClient() *DataProductsCatalogsClient { + subClient, _ := NewDataProductsCatalogsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewDataProductsClient creates a new instance of DataProductsClient. +func (c *ClientFactory) NewDataProductsClient() *DataProductsClient { + subClient, _ := NewDataProductsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewDataTypesClient creates a new instance of DataTypesClient. +func (c *ClientFactory) NewDataTypesClient() *DataTypesClient { + subClient, _ := NewDataTypesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/constants.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/constants.go new file mode 100644 index 000000000000..f682f9e50043 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/constants.go @@ -0,0 +1,193 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnetworkanalytics + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkanalytics/armnetworkanalytics" + moduleVersion = "v0.1.0" +) + +// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// ControlState - The data type state +type ControlState string + +const ( + // ControlStateDisabled - Field to disable a setting. + ControlStateDisabled ControlState = "Disabled" + // ControlStateEnabled - Field to enable a setting. + ControlStateEnabled ControlState = "Enabled" +) + +// PossibleControlStateValues returns the possible values for the ControlState const type. +func PossibleControlStateValues() []ControlState { + return []ControlState{ + ControlStateDisabled, + ControlStateEnabled, + } +} + +// CreatedByType - The type of identity that created the resource. +type CreatedByType string + +const ( + CreatedByTypeApplication CreatedByType = "Application" + CreatedByTypeKey CreatedByType = "Key" + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// DataProductUserRole - The data type state +type DataProductUserRole string + +const ( + // DataProductUserRoleReader - Field to specify user of type Reader. + DataProductUserRoleReader DataProductUserRole = "Reader" + // DataProductUserRoleSensitiveReader - Field to specify user of type SensitiveReader. + // This user has privileged access to read sensitive data of a data product. + DataProductUserRoleSensitiveReader DataProductUserRole = "SensitiveReader" +) + +// PossibleDataProductUserRoleValues returns the possible values for the DataProductUserRole const type. +func PossibleDataProductUserRoleValues() []DataProductUserRole { + return []DataProductUserRole{ + DataProductUserRoleReader, + DataProductUserRoleSensitiveReader, + } +} + +// DataTypeState - The data type state +type DataTypeState string + +const ( + // DataTypeStateRunning - Field to specify running state. + DataTypeStateRunning DataTypeState = "Running" + // DataTypeStateStopped - Field to specify stopped state. + DataTypeStateStopped DataTypeState = "Stopped" +) + +// PossibleDataTypeStateValues returns the possible values for the DataTypeState const type. +func PossibleDataTypeStateValues() []DataTypeState { + return []DataTypeState{ + DataTypeStateRunning, + DataTypeStateStopped, + } +} + +// DefaultAction - Specifies the default action of allow or deny when no other rules match. +type DefaultAction string + +const ( + // DefaultActionAllow - Represents allow action. + DefaultActionAllow DefaultAction = "Allow" + // DefaultActionDeny - Represents deny action. + DefaultActionDeny DefaultAction = "Deny" +) + +// PossibleDefaultActionValues returns the possible values for the DefaultAction const type. +func PossibleDefaultActionValues() []DefaultAction { + return []DefaultAction{ + DefaultActionAllow, + DefaultActionDeny, + } +} + +// ManagedServiceIdentityType - Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned, UserAssigned" + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +// PossibleManagedServiceIdentityTypeValues returns the possible values for the ManagedServiceIdentityType const type. +func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { + return []ManagedServiceIdentityType{ + ManagedServiceIdentityTypeNone, + ManagedServiceIdentityTypeSystemAssigned, + ManagedServiceIdentityTypeSystemAssignedUserAssigned, + ManagedServiceIdentityTypeUserAssigned, + } +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// ProvisioningState - The status of the current operation. +type ProvisioningState string + +const ( + // ProvisioningStateAccepted - Represents an accepted operation. + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Represents a canceled operation. + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateDeleting - Represents an operation under deletion. + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Represents a failed operation. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateProvisioning - Represents a pending operation. + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded - Represents a succeeded operation. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - Represents a pending operation. + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateProvisioning, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/dataproducts_client.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/dataproducts_client.go new file mode 100644 index 000000000000..79c4fb732e13 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/dataproducts_client.go @@ -0,0 +1,786 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnetworkanalytics + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// DataProductsClient contains the methods for the DataProducts group. +// Don't use this type directly, use NewDataProductsClient() instead. +type DataProductsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDataProductsClient creates a new instance of DataProductsClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDataProductsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DataProductsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DataProductsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// AddUserRole - Assign role to the data product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - body - The content of the action request +// - options - DataProductsClientAddUserRoleOptions contains the optional parameters for the DataProductsClient.AddUserRole +// method. +func (client *DataProductsClient) AddUserRole(ctx context.Context, resourceGroupName string, dataProductName string, body RoleAssignmentCommonProperties, options *DataProductsClientAddUserRoleOptions) (DataProductsClientAddUserRoleResponse, error) { + var err error + const operationName = "DataProductsClient.AddUserRole" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.addUserRoleCreateRequest(ctx, resourceGroupName, dataProductName, body, options) + if err != nil { + return DataProductsClientAddUserRoleResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataProductsClientAddUserRoleResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DataProductsClientAddUserRoleResponse{}, err + } + resp, err := client.addUserRoleHandleResponse(httpResp) + return resp, err +} + +// addUserRoleCreateRequest creates the AddUserRole request. +func (client *DataProductsClient) addUserRoleCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, body RoleAssignmentCommonProperties, options *DataProductsClientAddUserRoleOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}/addUserRole" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// addUserRoleHandleResponse handles the AddUserRole response. +func (client *DataProductsClient) addUserRoleHandleResponse(resp *http.Response) (DataProductsClientAddUserRoleResponse, error) { + result := DataProductsClientAddUserRoleResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignmentDetail); err != nil { + return DataProductsClientAddUserRoleResponse{}, err + } + return result, nil +} + +// BeginCreate - Create data product resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - resource - Resource create parameters. +// - options - DataProductsClientBeginCreateOptions contains the optional parameters for the DataProductsClient.BeginCreate +// method. +func (client *DataProductsClient) BeginCreate(ctx context.Context, resourceGroupName string, dataProductName string, resource DataProduct, options *DataProductsClientBeginCreateOptions) (*runtime.Poller[DataProductsClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, dataProductName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DataProductsClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DataProductsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Create data product resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +func (client *DataProductsClient) create(ctx context.Context, resourceGroupName string, dataProductName string, resource DataProduct, options *DataProductsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "DataProductsClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceGroupName, dataProductName, resource, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *DataProductsClient) createCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, resource DataProduct, options *DataProductsClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete data product resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - options - DataProductsClientBeginDeleteOptions contains the optional parameters for the DataProductsClient.BeginDelete +// method. +func (client *DataProductsClient) BeginDelete(ctx context.Context, resourceGroupName string, dataProductName string, options *DataProductsClientBeginDeleteOptions) (*runtime.Poller[DataProductsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, dataProductName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DataProductsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DataProductsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete data product resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +func (client *DataProductsClient) deleteOperation(ctx context.Context, resourceGroupName string, dataProductName string, options *DataProductsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "DataProductsClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, dataProductName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DataProductsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, options *DataProductsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// GenerateStorageAccountSasToken - Generate sas token for storage account. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - body - The content of the action request +// - options - DataProductsClientGenerateStorageAccountSasTokenOptions contains the optional parameters for the DataProductsClient.GenerateStorageAccountSasToken +// method. +func (client *DataProductsClient) GenerateStorageAccountSasToken(ctx context.Context, resourceGroupName string, dataProductName string, body AccountSas, options *DataProductsClientGenerateStorageAccountSasTokenOptions) (DataProductsClientGenerateStorageAccountSasTokenResponse, error) { + var err error + const operationName = "DataProductsClient.GenerateStorageAccountSasToken" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.generateStorageAccountSasTokenCreateRequest(ctx, resourceGroupName, dataProductName, body, options) + if err != nil { + return DataProductsClientGenerateStorageAccountSasTokenResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataProductsClientGenerateStorageAccountSasTokenResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DataProductsClientGenerateStorageAccountSasTokenResponse{}, err + } + resp, err := client.generateStorageAccountSasTokenHandleResponse(httpResp) + return resp, err +} + +// generateStorageAccountSasTokenCreateRequest creates the GenerateStorageAccountSasToken request. +func (client *DataProductsClient) generateStorageAccountSasTokenCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, body AccountSas, options *DataProductsClientGenerateStorageAccountSasTokenOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}/generateStorageAccountSasToken" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// generateStorageAccountSasTokenHandleResponse handles the GenerateStorageAccountSasToken response. +func (client *DataProductsClient) generateStorageAccountSasTokenHandleResponse(resp *http.Response) (DataProductsClientGenerateStorageAccountSasTokenResponse, error) { + result := DataProductsClientGenerateStorageAccountSasTokenResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.AccountSasToken); err != nil { + return DataProductsClientGenerateStorageAccountSasTokenResponse{}, err + } + return result, nil +} + +// Get - Retrieve data product resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - options - DataProductsClientGetOptions contains the optional parameters for the DataProductsClient.Get method. +func (client *DataProductsClient) Get(ctx context.Context, resourceGroupName string, dataProductName string, options *DataProductsClientGetOptions) (DataProductsClientGetResponse, error) { + var err error + const operationName = "DataProductsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, dataProductName, options) + if err != nil { + return DataProductsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataProductsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DataProductsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *DataProductsClient) getCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, options *DataProductsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DataProductsClient) getHandleResponse(resp *http.Response) (DataProductsClientGetResponse, error) { + result := DataProductsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataProduct); err != nil { + return DataProductsClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List data products by resource group. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - DataProductsClientListByResourceGroupOptions contains the optional parameters for the DataProductsClient.NewListByResourceGroupPager +// method. +func (client *DataProductsClient) NewListByResourceGroupPager(resourceGroupName string, options *DataProductsClientListByResourceGroupOptions) *runtime.Pager[DataProductsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[DataProductsClientListByResourceGroupResponse]{ + More: func(page DataProductsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DataProductsClientListByResourceGroupResponse) (DataProductsClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DataProductsClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return DataProductsClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *DataProductsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DataProductsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *DataProductsClient) listByResourceGroupHandleResponse(resp *http.Response) (DataProductsClientListByResourceGroupResponse, error) { + result := DataProductsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataProductListResult); err != nil { + return DataProductsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List data products by subscription. +// +// Generated from API version 2023-11-15 +// - options - DataProductsClientListBySubscriptionOptions contains the optional parameters for the DataProductsClient.NewListBySubscriptionPager +// method. +func (client *DataProductsClient) NewListBySubscriptionPager(options *DataProductsClientListBySubscriptionOptions) *runtime.Pager[DataProductsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[DataProductsClientListBySubscriptionResponse]{ + More: func(page DataProductsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DataProductsClientListBySubscriptionResponse) (DataProductsClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DataProductsClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return DataProductsClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *DataProductsClient) listBySubscriptionCreateRequest(ctx context.Context, options *DataProductsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.NetworkAnalytics/dataProducts" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *DataProductsClient) listBySubscriptionHandleResponse(resp *http.Response) (DataProductsClientListBySubscriptionResponse, error) { + result := DataProductsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataProductListResult); err != nil { + return DataProductsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// ListRolesAssignments - List user roles associated with the data product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - body - The content of the action request +// - options - DataProductsClientListRolesAssignmentsOptions contains the optional parameters for the DataProductsClient.ListRolesAssignments +// method. +func (client *DataProductsClient) ListRolesAssignments(ctx context.Context, resourceGroupName string, dataProductName string, body any, options *DataProductsClientListRolesAssignmentsOptions) (DataProductsClientListRolesAssignmentsResponse, error) { + var err error + const operationName = "DataProductsClient.ListRolesAssignments" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listRolesAssignmentsCreateRequest(ctx, resourceGroupName, dataProductName, body, options) + if err != nil { + return DataProductsClientListRolesAssignmentsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataProductsClientListRolesAssignmentsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DataProductsClientListRolesAssignmentsResponse{}, err + } + resp, err := client.listRolesAssignmentsHandleResponse(httpResp) + return resp, err +} + +// listRolesAssignmentsCreateRequest creates the ListRolesAssignments request. +func (client *DataProductsClient) listRolesAssignmentsCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, body any, options *DataProductsClientListRolesAssignmentsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}/listRolesAssignments" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// listRolesAssignmentsHandleResponse handles the ListRolesAssignments response. +func (client *DataProductsClient) listRolesAssignmentsHandleResponse(resp *http.Response) (DataProductsClientListRolesAssignmentsResponse, error) { + result := DataProductsClientListRolesAssignmentsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ListRoleAssignments); err != nil { + return DataProductsClientListRolesAssignmentsResponse{}, err + } + return result, nil +} + +// RemoveUserRole - Remove role from the data product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - body - The content of the action request +// - options - DataProductsClientRemoveUserRoleOptions contains the optional parameters for the DataProductsClient.RemoveUserRole +// method. +func (client *DataProductsClient) RemoveUserRole(ctx context.Context, resourceGroupName string, dataProductName string, body RoleAssignmentDetail, options *DataProductsClientRemoveUserRoleOptions) (DataProductsClientRemoveUserRoleResponse, error) { + var err error + const operationName = "DataProductsClient.RemoveUserRole" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.removeUserRoleCreateRequest(ctx, resourceGroupName, dataProductName, body, options) + if err != nil { + return DataProductsClientRemoveUserRoleResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataProductsClientRemoveUserRoleResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return DataProductsClientRemoveUserRoleResponse{}, err + } + return DataProductsClientRemoveUserRoleResponse{}, nil +} + +// removeUserRoleCreateRequest creates the RemoveUserRole request. +func (client *DataProductsClient) removeUserRoleCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, body RoleAssignmentDetail, options *DataProductsClientRemoveUserRoleOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}/removeUserRole" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// RotateKey - Initiate key rotation on Data Product. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - body - The content of the action request +// - options - DataProductsClientRotateKeyOptions contains the optional parameters for the DataProductsClient.RotateKey method. +func (client *DataProductsClient) RotateKey(ctx context.Context, resourceGroupName string, dataProductName string, body KeyVaultInfo, options *DataProductsClientRotateKeyOptions) (DataProductsClientRotateKeyResponse, error) { + var err error + const operationName = "DataProductsClient.RotateKey" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.rotateKeyCreateRequest(ctx, resourceGroupName, dataProductName, body, options) + if err != nil { + return DataProductsClientRotateKeyResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataProductsClientRotateKeyResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return DataProductsClientRotateKeyResponse{}, err + } + return DataProductsClientRotateKeyResponse{}, nil +} + +// rotateKeyCreateRequest creates the RotateKey request. +func (client *DataProductsClient) rotateKeyCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, body KeyVaultInfo, options *DataProductsClientRotateKeyOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}/rotateKey" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// BeginUpdate - Update data product resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - properties - The resource properties to be updated. +// - options - DataProductsClientBeginUpdateOptions contains the optional parameters for the DataProductsClient.BeginUpdate +// method. +func (client *DataProductsClient) BeginUpdate(ctx context.Context, resourceGroupName string, dataProductName string, properties DataProductUpdate, options *DataProductsClientBeginUpdateOptions) (*runtime.Poller[DataProductsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, dataProductName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DataProductsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DataProductsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update data product resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +func (client *DataProductsClient) update(ctx context.Context, resourceGroupName string, dataProductName string, properties DataProductUpdate, options *DataProductsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "DataProductsClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, dataProductName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *DataProductsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, properties DataProductUpdate, options *DataProductsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/dataproducts_client_example_test.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/dataproducts_client_example_test.go new file mode 100644 index 000000000000..5eec44e83e05 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/dataproducts_client_example_test.go @@ -0,0 +1,1115 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armnetworkanalytics_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkanalytics/armnetworkanalytics" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_ListBySubscription_MaximumSet_Gen.json +func ExampleDataProductsClient_NewListBySubscriptionPager_dataProductsListBySubscriptionMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDataProductsClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DataProductListResult = armnetworkanalytics.DataProductListResult{ + // Value: []*armnetworkanalytics.DataProduct{ + // { + // Name: to.Ptr("dataproduct01"), + // Type: to.Ptr("Microsoft.NetworkAnalytics/DataProducts"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/DataProducts/dataproduct01"), + // SystemData: &armnetworkanalytics.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // CreatedBy: to.Ptr("abc@micros.com"), + // CreatedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // LastModifiedBy: to.Ptr("abc@micros.com"), + // LastModifiedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "userSpecifiedKeyName": to.Ptr("userSpecifiedKeyValue"), + // }, + // Identity: &armnetworkanalytics.ManagedServiceIdentity{ + // Type: to.Ptr(armnetworkanalytics.ManagedServiceIdentityType("IdentityType")), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // UserAssignedIdentities: map[string]*armnetworkanalytics.UserAssignedIdentity{ + // "key8474": &armnetworkanalytics.UserAssignedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armnetworkanalytics.DataProductProperties{ + // AvailableMinorVersions: []*string{ + // to.Ptr("1.0.1"), + // to.Ptr("1.0.2")}, + // ConsumptionEndpoints: &armnetworkanalytics.ConsumptionEndpointsProperties{ + // FileAccessResourceID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/storageResourceName"), + // FileAccessURL: to.Ptr("https://operatorinsightsstorageResourceName.blob.core.windows.net"), + // IngestionResourceID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/storageResourceName"), + // IngestionURL: to.Ptr("https://aoiingestionstorageResourceName.blob.core.windows.net"), + // QueryResourceID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Kusto/clusters/clusterName"), + // QueryURL: to.Ptr("https://opinsightsclusterName.regionName.kusto.windows.net"), + // }, + // CurrentMinorVersion: to.Ptr("1.0.1"), + // CustomerEncryptionKey: &armnetworkanalytics.EncryptionKeyDetails{ + // KeyName: to.Ptr("keyName"), + // KeyVaultURI: to.Ptr("https://KeyVault.vault.azure.net"), + // KeyVersion: to.Ptr("keyVersion"), + // }, + // CustomerManagedKeyEncryptionEnabled: to.Ptr(armnetworkanalytics.ControlStateEnabled), + // Documentation: to.Ptr("https://learn.microsoft.com/"), + // KeyVaultURL: to.Ptr("https://myKeyVault.vault.azure.net"), + // MajorVersion: to.Ptr("1.0.0"), + // ManagedResourceGroupConfiguration: &armnetworkanalytics.ManagedResourceGroupConfiguration{ + // Name: to.Ptr("managedResourceGroupName"), + // Location: to.Ptr("eastus"), + // }, + // Networkacls: &armnetworkanalytics.DataProductNetworkACLs{ + // AllowedQueryIPRangeList: []*string{ + // to.Ptr("1.1.1.1"), + // to.Ptr("1.1.1.2")}, + // DefaultAction: to.Ptr(armnetworkanalytics.DefaultActionAllow), + // IPRules: []*armnetworkanalytics.IPRules{ + // { + // Action: to.Ptr("Allow"), + // Value: to.Ptr("1.1.1.1"), + // }}, + // VirtualNetworkRule: []*armnetworkanalytics.VirtualNetworkRule{ + // { + // Action: to.Ptr("Allow"), + // ID: to.Ptr("/subscriptions/subscriptionId/resourcegroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/subnets/subnetName"), + // State: to.Ptr("Succeeded"), + // }}, + // }, + // Owners: []*string{ + // to.Ptr("abc@micros.com")}, + // PrivateLinksEnabled: to.Ptr(armnetworkanalytics.ControlStateDisabled), + // Product: to.Ptr("MCC"), + // ProvisioningState: to.Ptr(armnetworkanalytics.ProvisioningStateSucceeded), + // PublicNetworkAccess: to.Ptr(armnetworkanalytics.ControlStateEnabled), + // Publisher: to.Ptr("Microsoft"), + // PurviewAccount: to.Ptr("testpurview"), + // PurviewCollection: to.Ptr("134567890"), + // Redundancy: to.Ptr(armnetworkanalytics.ControlStateDisabled), + // ResourceGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_ListBySubscription_MinimumSet_Gen.json +func ExampleDataProductsClient_NewListBySubscriptionPager_dataProductsListBySubscriptionMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDataProductsClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DataProductListResult = armnetworkanalytics.DataProductListResult{ + // Value: []*armnetworkanalytics.DataProduct{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/DataProducts/dataproduct01"), + // Location: to.Ptr("eastus"), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_ListByResourceGroup_MaximumSet_Gen.json +func ExampleDataProductsClient_NewListByResourceGroupPager_dataProductsListByResourceGroupMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDataProductsClient().NewListByResourceGroupPager("aoiresourceGroupName", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DataProductListResult = armnetworkanalytics.DataProductListResult{ + // Value: []*armnetworkanalytics.DataProduct{ + // { + // Name: to.Ptr("dataproduct01"), + // Type: to.Ptr("Microsoft.NetworkAnalytics/DataProducts"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/DataProducts/dataproduct01"), + // SystemData: &armnetworkanalytics.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // CreatedBy: to.Ptr("abc@micros.com"), + // CreatedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // LastModifiedBy: to.Ptr("abc@micros.com"), + // LastModifiedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "userSpecifiedKeyName": to.Ptr("userSpecifiedKeyValue"), + // }, + // Identity: &armnetworkanalytics.ManagedServiceIdentity{ + // Type: to.Ptr(armnetworkanalytics.ManagedServiceIdentityType("IdentityType")), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // UserAssignedIdentities: map[string]*armnetworkanalytics.UserAssignedIdentity{ + // "key8474": &armnetworkanalytics.UserAssignedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armnetworkanalytics.DataProductProperties{ + // AvailableMinorVersions: []*string{ + // to.Ptr("1.0.1"), + // to.Ptr("1.0.2")}, + // ConsumptionEndpoints: &armnetworkanalytics.ConsumptionEndpointsProperties{ + // FileAccessResourceID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/storageResourceName"), + // FileAccessURL: to.Ptr("https://operatorinsightsstorageResourceName.blob.core.windows.net"), + // IngestionResourceID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/storageResourceName"), + // IngestionURL: to.Ptr("https://aoiingestionstorageResourceName.blob.core.windows.net"), + // QueryResourceID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Kusto/clusters/clusterName"), + // QueryURL: to.Ptr("https://opinsightsclusterName.regionName.kusto.windows.net"), + // }, + // CurrentMinorVersion: to.Ptr("1.0.1"), + // CustomerEncryptionKey: &armnetworkanalytics.EncryptionKeyDetails{ + // KeyName: to.Ptr("keyName"), + // KeyVaultURI: to.Ptr("https://KeyVault.vault.azure.net"), + // KeyVersion: to.Ptr("keyVersion"), + // }, + // CustomerManagedKeyEncryptionEnabled: to.Ptr(armnetworkanalytics.ControlStateEnabled), + // Documentation: to.Ptr("https://learn.microsoft.com/"), + // KeyVaultURL: to.Ptr("https://myKeyVault.vault.azure.net"), + // MajorVersion: to.Ptr("1.0.0"), + // ManagedResourceGroupConfiguration: &armnetworkanalytics.ManagedResourceGroupConfiguration{ + // Name: to.Ptr("managedResourceGroupName"), + // Location: to.Ptr("eastus"), + // }, + // Networkacls: &armnetworkanalytics.DataProductNetworkACLs{ + // AllowedQueryIPRangeList: []*string{ + // to.Ptr("1.1.1.1"), + // to.Ptr("1.1.1.2")}, + // DefaultAction: to.Ptr(armnetworkanalytics.DefaultActionAllow), + // IPRules: []*armnetworkanalytics.IPRules{ + // { + // Action: to.Ptr("Allow"), + // Value: to.Ptr("1.1.1.1"), + // }}, + // VirtualNetworkRule: []*armnetworkanalytics.VirtualNetworkRule{ + // { + // Action: to.Ptr("Allow"), + // ID: to.Ptr("/subscriptions/subscriptionId/resourcegroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/subnets/subnetName"), + // State: to.Ptr("Succeeded"), + // }}, + // }, + // Owners: []*string{ + // to.Ptr("abc@micros.com")}, + // PrivateLinksEnabled: to.Ptr(armnetworkanalytics.ControlStateDisabled), + // Product: to.Ptr("MCC"), + // ProvisioningState: to.Ptr(armnetworkanalytics.ProvisioningStateSucceeded), + // PublicNetworkAccess: to.Ptr(armnetworkanalytics.ControlStateEnabled), + // Publisher: to.Ptr("Microsoft"), + // PurviewAccount: to.Ptr("testpurview"), + // PurviewCollection: to.Ptr("134567890"), + // Redundancy: to.Ptr(armnetworkanalytics.ControlStateDisabled), + // ResourceGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_ListByResourceGroup_MinimumSet_Gen.json +func ExampleDataProductsClient_NewListByResourceGroupPager_dataProductsListByResourceGroupMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDataProductsClient().NewListByResourceGroupPager("aoiresourceGroupName", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DataProductListResult = armnetworkanalytics.DataProductListResult{ + // Value: []*armnetworkanalytics.DataProduct{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/DataProducts/dataproduct01"), + // Location: to.Ptr("eastus"), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Get_MaximumSet_Gen.json +func ExampleDataProductsClient_Get_dataProductsGetMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDataProductsClient().Get(ctx, "aoiresourceGroupName", "dataproduct01", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataProduct = armnetworkanalytics.DataProduct{ + // Name: to.Ptr("dataproduct01"), + // Type: to.Ptr("Microsoft.NetworkAnalytics/DataProducts"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/DataProducts/dataproduct01"), + // SystemData: &armnetworkanalytics.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // CreatedBy: to.Ptr("abc@micros.com"), + // CreatedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // LastModifiedBy: to.Ptr("abc@micros.com"), + // LastModifiedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "userSpecifiedKeyName": to.Ptr("userSpecifiedKeyValue"), + // }, + // Identity: &armnetworkanalytics.ManagedServiceIdentity{ + // Type: to.Ptr(armnetworkanalytics.ManagedServiceIdentityType("IdentityType")), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // UserAssignedIdentities: map[string]*armnetworkanalytics.UserAssignedIdentity{ + // "key8474": &armnetworkanalytics.UserAssignedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armnetworkanalytics.DataProductProperties{ + // AvailableMinorVersions: []*string{ + // to.Ptr("1.0.1"), + // to.Ptr("1.0.2")}, + // ConsumptionEndpoints: &armnetworkanalytics.ConsumptionEndpointsProperties{ + // FileAccessResourceID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/storageResourceName"), + // FileAccessURL: to.Ptr("https://operatorinsightsstorageResourceName.blob.core.windows.net"), + // IngestionResourceID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/storageResourceName"), + // IngestionURL: to.Ptr("https://aoiingestionstorageResourceName.blob.core.windows.net"), + // QueryResourceID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Kusto/clusters/clusterName"), + // QueryURL: to.Ptr("https://opinsightsclusterName.regionName.kusto.windows.net"), + // }, + // CurrentMinorVersion: to.Ptr("1.0.1"), + // CustomerEncryptionKey: &armnetworkanalytics.EncryptionKeyDetails{ + // KeyName: to.Ptr("keyName"), + // KeyVaultURI: to.Ptr("https://KeyVault.vault.azure.net"), + // KeyVersion: to.Ptr("keyVersion"), + // }, + // CustomerManagedKeyEncryptionEnabled: to.Ptr(armnetworkanalytics.ControlStateEnabled), + // Documentation: to.Ptr("https://learn.microsoft.com/"), + // KeyVaultURL: to.Ptr("https://myKeyVault.vault.azure.net"), + // MajorVersion: to.Ptr("1.0.0"), + // ManagedResourceGroupConfiguration: &armnetworkanalytics.ManagedResourceGroupConfiguration{ + // Name: to.Ptr("managedResourceGroupName"), + // Location: to.Ptr("eastus"), + // }, + // Networkacls: &armnetworkanalytics.DataProductNetworkACLs{ + // AllowedQueryIPRangeList: []*string{ + // to.Ptr("1.1.1.1"), + // to.Ptr("1.1.1.2")}, + // DefaultAction: to.Ptr(armnetworkanalytics.DefaultActionAllow), + // IPRules: []*armnetworkanalytics.IPRules{ + // { + // Action: to.Ptr("Allow"), + // Value: to.Ptr("1.1.1.1"), + // }}, + // VirtualNetworkRule: []*armnetworkanalytics.VirtualNetworkRule{ + // { + // Action: to.Ptr("Allow"), + // ID: to.Ptr("/subscriptions/subscriptionId/resourcegroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/subnets/subnetName"), + // State: to.Ptr("Succeeded"), + // }}, + // }, + // Owners: []*string{ + // to.Ptr("abc@micros.com")}, + // PrivateLinksEnabled: to.Ptr(armnetworkanalytics.ControlStateDisabled), + // Product: to.Ptr("MCC"), + // ProvisioningState: to.Ptr(armnetworkanalytics.ProvisioningStateSucceeded), + // PublicNetworkAccess: to.Ptr(armnetworkanalytics.ControlStateEnabled), + // Publisher: to.Ptr("Microsoft"), + // PurviewAccount: to.Ptr("testpurview"), + // PurviewCollection: to.Ptr("134567890"), + // Redundancy: to.Ptr(armnetworkanalytics.ControlStateDisabled), + // ResourceGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Get_MinimumSet_Gen.json +func ExampleDataProductsClient_Get_dataProductsGetMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDataProductsClient().Get(ctx, "aoiresourceGroupName", "dataproduct01", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataProduct = armnetworkanalytics.DataProduct{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/DataProducts/dataproduct01"), + // Location: to.Ptr("eastus"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Create_MaximumSet_Gen.json +func ExampleDataProductsClient_BeginCreate_dataProductsCreateMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDataProductsClient().BeginCreate(ctx, "aoiresourceGroupName", "dataproduct01", armnetworkanalytics.DataProduct{ + Location: to.Ptr("eastus"), + Tags: map[string]*string{ + "userSpecifiedKeyName": to.Ptr("userSpecifiedKeyValue"), + }, + Identity: &armnetworkanalytics.ManagedServiceIdentity{ + Type: to.Ptr(armnetworkanalytics.ManagedServiceIdentityTypeUserAssigned), + UserAssignedIdentities: map[string]*armnetworkanalytics.UserAssignedIdentity{ + "/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {}, + }, + }, + Properties: &armnetworkanalytics.DataProductProperties{ + ConsumptionEndpoints: &armnetworkanalytics.ConsumptionEndpointsProperties{}, + CurrentMinorVersion: to.Ptr("1.0.1"), + CustomerEncryptionKey: &armnetworkanalytics.EncryptionKeyDetails{ + KeyName: to.Ptr("keyName"), + KeyVaultURI: to.Ptr("https://KeyVault.vault.azure.net"), + KeyVersion: to.Ptr("keyVersion"), + }, + CustomerManagedKeyEncryptionEnabled: to.Ptr(armnetworkanalytics.ControlStateEnabled), + MajorVersion: to.Ptr("1.0.0"), + ManagedResourceGroupConfiguration: &armnetworkanalytics.ManagedResourceGroupConfiguration{ + Name: to.Ptr("managedResourceGroupName"), + Location: to.Ptr("eastus"), + }, + Networkacls: &armnetworkanalytics.DataProductNetworkACLs{ + AllowedQueryIPRangeList: []*string{ + to.Ptr("1.1.1.1")}, + DefaultAction: to.Ptr(armnetworkanalytics.DefaultActionAllow), + IPRules: []*armnetworkanalytics.IPRules{ + { + Action: to.Ptr("Allow"), + Value: to.Ptr("1.1.1.1"), + }}, + VirtualNetworkRule: []*armnetworkanalytics.VirtualNetworkRule{ + { + Action: to.Ptr("Allow"), + ID: to.Ptr("/subscriptions/subscriptionId/resourcegroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/subnets/subnetName"), + State: to.Ptr(""), + }}, + }, + Owners: []*string{ + to.Ptr("abc@micros.com")}, + PrivateLinksEnabled: to.Ptr(armnetworkanalytics.ControlStateDisabled), + Product: to.Ptr("MCC"), + ProvisioningState: to.Ptr(armnetworkanalytics.ProvisioningStateSucceeded), + PublicNetworkAccess: to.Ptr(armnetworkanalytics.ControlStateEnabled), + Publisher: to.Ptr("Microsoft"), + PurviewAccount: to.Ptr("testpurview"), + PurviewCollection: to.Ptr("134567890"), + Redundancy: to.Ptr(armnetworkanalytics.ControlStateDisabled), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataProduct = armnetworkanalytics.DataProduct{ + // Name: to.Ptr("dataproduct01"), + // Type: to.Ptr("Microsoft.NetworkAnalytics/DataProducts"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/DataProducts/dataproduct01"), + // SystemData: &armnetworkanalytics.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // CreatedBy: to.Ptr("abc@micros.com"), + // CreatedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // LastModifiedBy: to.Ptr("abc@micros.com"), + // LastModifiedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "userSpecifiedKeyName": to.Ptr("userSpecifiedKeyValue"), + // }, + // Identity: &armnetworkanalytics.ManagedServiceIdentity{ + // Type: to.Ptr(armnetworkanalytics.ManagedServiceIdentityType("IdentityType")), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // UserAssignedIdentities: map[string]*armnetworkanalytics.UserAssignedIdentity{ + // "key8474": &armnetworkanalytics.UserAssignedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armnetworkanalytics.DataProductProperties{ + // AvailableMinorVersions: []*string{ + // to.Ptr("1.0.1"), + // to.Ptr("1.0.2")}, + // ConsumptionEndpoints: &armnetworkanalytics.ConsumptionEndpointsProperties{ + // FileAccessResourceID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/storageResourceName"), + // FileAccessURL: to.Ptr("https://operatorinsightsstorageResourceName.blob.core.windows.net"), + // IngestionResourceID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/storageResourceName"), + // IngestionURL: to.Ptr("https://aoiingestionstorageResourceName.blob.core.windows.net"), + // QueryResourceID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Kusto/clusters/clusterName"), + // QueryURL: to.Ptr("https://opinsightsclusterName.regionName.kusto.windows.net"), + // }, + // CurrentMinorVersion: to.Ptr("1.0.1"), + // CustomerEncryptionKey: &armnetworkanalytics.EncryptionKeyDetails{ + // KeyName: to.Ptr("keyName"), + // KeyVaultURI: to.Ptr("https://KeyVault.vault.azure.net"), + // KeyVersion: to.Ptr("keyVersion"), + // }, + // CustomerManagedKeyEncryptionEnabled: to.Ptr(armnetworkanalytics.ControlStateEnabled), + // Documentation: to.Ptr("https://learn.microsoft.com/"), + // KeyVaultURL: to.Ptr("https://myKeyVault.vault.azure.net"), + // MajorVersion: to.Ptr("1.0.0"), + // ManagedResourceGroupConfiguration: &armnetworkanalytics.ManagedResourceGroupConfiguration{ + // Name: to.Ptr("managedResourceGroupName"), + // Location: to.Ptr("eastus"), + // }, + // Networkacls: &armnetworkanalytics.DataProductNetworkACLs{ + // AllowedQueryIPRangeList: []*string{ + // to.Ptr("1.1.1.1"), + // to.Ptr("1.1.1.2")}, + // DefaultAction: to.Ptr(armnetworkanalytics.DefaultActionAllow), + // IPRules: []*armnetworkanalytics.IPRules{ + // { + // Action: to.Ptr("Allow"), + // Value: to.Ptr("1.1.1.1"), + // }}, + // VirtualNetworkRule: []*armnetworkanalytics.VirtualNetworkRule{ + // { + // Action: to.Ptr("Allow"), + // ID: to.Ptr("/subscriptions/subscriptionId/resourcegroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/subnets/subnetName"), + // State: to.Ptr("Succeeded"), + // }}, + // }, + // Owners: []*string{ + // to.Ptr("abc@micros.com")}, + // PrivateLinksEnabled: to.Ptr(armnetworkanalytics.ControlStateDisabled), + // Product: to.Ptr("MCC"), + // ProvisioningState: to.Ptr(armnetworkanalytics.ProvisioningStateSucceeded), + // PublicNetworkAccess: to.Ptr(armnetworkanalytics.ControlStateEnabled), + // Publisher: to.Ptr("Microsoft"), + // PurviewAccount: to.Ptr("testpurview"), + // PurviewCollection: to.Ptr("134567890"), + // Redundancy: to.Ptr(armnetworkanalytics.ControlStateDisabled), + // ResourceGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Create_MinimumSet_Gen.json +func ExampleDataProductsClient_BeginCreate_dataProductsCreateMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDataProductsClient().BeginCreate(ctx, "aoiresourceGroupName", "dataproduct01", armnetworkanalytics.DataProduct{ + Location: to.Ptr("eastus"), + Tags: map[string]*string{ + "userSpecifiedKeyName": to.Ptr("userSpecifiedKeyValue"), + }, + Properties: &armnetworkanalytics.DataProductProperties{ + MajorVersion: to.Ptr("1.0.0"), + Product: to.Ptr("MCC"), + Publisher: to.Ptr("Microsoft"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataProduct = armnetworkanalytics.DataProduct{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/DataProducts/dataproduct01"), + // Location: to.Ptr("eastus"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Update_MaximumSet_Gen.json +func ExampleDataProductsClient_BeginUpdate_dataProductsUpdateMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDataProductsClient().BeginUpdate(ctx, "aoiresourceGroupName", "dataproduct01", armnetworkanalytics.DataProductUpdate{ + Identity: &armnetworkanalytics.ManagedServiceIdentity{ + Type: to.Ptr(armnetworkanalytics.ManagedServiceIdentityTypeUserAssigned), + UserAssignedIdentities: map[string]*armnetworkanalytics.UserAssignedIdentity{ + "/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {}, + }, + }, + Properties: &armnetworkanalytics.DataProductUpdateProperties{ + CurrentMinorVersion: to.Ptr("1.0.1"), + Owners: []*string{ + to.Ptr("abc@micros.com"), + to.Ptr("def@micros.com")}, + PrivateLinksEnabled: to.Ptr(armnetworkanalytics.ControlStateDisabled), + PurviewAccount: to.Ptr("testpurview"), + PurviewCollection: to.Ptr("134567890"), + }, + Tags: map[string]*string{ + "userSpecifiedKeyName": to.Ptr("userSpecifiedKeyValue"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataProduct = armnetworkanalytics.DataProduct{ + // Name: to.Ptr("dataproduct01"), + // Type: to.Ptr("Microsoft.NetworkAnalytics/DataProducts"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/DataProducts/dataproduct01"), + // SystemData: &armnetworkanalytics.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // CreatedBy: to.Ptr("abc@micros.com"), + // CreatedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // LastModifiedBy: to.Ptr("abc@micros.com"), + // LastModifiedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // }, + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // "userSpecifiedKeyName": to.Ptr("userSpecifiedKeyValue"), + // }, + // Identity: &armnetworkanalytics.ManagedServiceIdentity{ + // Type: to.Ptr(armnetworkanalytics.ManagedServiceIdentityType("IdentityType")), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // TenantID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // UserAssignedIdentities: map[string]*armnetworkanalytics.UserAssignedIdentity{ + // "key8474": &armnetworkanalytics.UserAssignedIdentity{ + // ClientID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // PrincipalID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // }, + // }, + // Properties: &armnetworkanalytics.DataProductProperties{ + // AvailableMinorVersions: []*string{ + // to.Ptr("1.0.1"), + // to.Ptr("1.0.2")}, + // ConsumptionEndpoints: &armnetworkanalytics.ConsumptionEndpointsProperties{ + // FileAccessResourceID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/storageResourceName"), + // FileAccessURL: to.Ptr("https://operatorinsightsstorageResourceName.blob.core.windows.net"), + // IngestionResourceID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Storage/storageAccounts/storageResourceName"), + // IngestionURL: to.Ptr("https://aoiingestionstorageResourceName.blob.core.windows.net"), + // QueryResourceID: to.Ptr("/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.Kusto/clusters/clusterName"), + // QueryURL: to.Ptr("https://opinsightsclusterName.regionName.kusto.windows.net"), + // }, + // CurrentMinorVersion: to.Ptr("1.0.1"), + // CustomerEncryptionKey: &armnetworkanalytics.EncryptionKeyDetails{ + // KeyName: to.Ptr("keyName"), + // KeyVaultURI: to.Ptr("https://KeyVault.vault.azure.net"), + // KeyVersion: to.Ptr("keyVersion"), + // }, + // CustomerManagedKeyEncryptionEnabled: to.Ptr(armnetworkanalytics.ControlStateEnabled), + // Documentation: to.Ptr("https://learn.microsoft.com/"), + // KeyVaultURL: to.Ptr("https://myKeyVault.vault.azure.net"), + // MajorVersion: to.Ptr("1.0.0"), + // ManagedResourceGroupConfiguration: &armnetworkanalytics.ManagedResourceGroupConfiguration{ + // Name: to.Ptr("managedResourceGroupName"), + // Location: to.Ptr("eastus"), + // }, + // Networkacls: &armnetworkanalytics.DataProductNetworkACLs{ + // AllowedQueryIPRangeList: []*string{ + // to.Ptr("1.1.1.1"), + // to.Ptr("1.1.1.2")}, + // DefaultAction: to.Ptr(armnetworkanalytics.DefaultActionAllow), + // IPRules: []*armnetworkanalytics.IPRules{ + // { + // Action: to.Ptr("Allow"), + // Value: to.Ptr("1.1.1.1"), + // }}, + // VirtualNetworkRule: []*armnetworkanalytics.VirtualNetworkRule{ + // { + // Action: to.Ptr("Allow"), + // ID: to.Ptr("/subscriptions/subscriptionId/resourcegroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/subnets/subnetName"), + // State: to.Ptr("Succeeded"), + // }}, + // }, + // Owners: []*string{ + // to.Ptr("abc@micros.com"), + // to.Ptr("def@micros.com")}, + // PrivateLinksEnabled: to.Ptr(armnetworkanalytics.ControlStateDisabled), + // Product: to.Ptr("MCC"), + // ProvisioningState: to.Ptr(armnetworkanalytics.ProvisioningStateSucceeded), + // PublicNetworkAccess: to.Ptr(armnetworkanalytics.ControlStateEnabled), + // Publisher: to.Ptr("Microsoft"), + // PurviewAccount: to.Ptr("testpurview"), + // PurviewCollection: to.Ptr("134567890"), + // Redundancy: to.Ptr(armnetworkanalytics.ControlStateDisabled), + // ResourceGUID: to.Ptr("00000000-0000-0000-0000-000000000000"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Update_MinimumSet_Gen.json +func ExampleDataProductsClient_BeginUpdate_dataProductsUpdateMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDataProductsClient().BeginUpdate(ctx, "aoiresourceGroupName", "dataproduct01", armnetworkanalytics.DataProductUpdate{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataProduct = armnetworkanalytics.DataProduct{ + // Location: to.Ptr("jwlerdaudgxff"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Delete_MaximumSet_Gen.json +func ExampleDataProductsClient_BeginDelete_dataProductsDeleteMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDataProductsClient().BeginDelete(ctx, "aoiresourceGroupName", "dataproduct01", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Delete_MinimumSet_Gen.json +func ExampleDataProductsClient_BeginDelete_dataProductsDeleteMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDataProductsClient().BeginDelete(ctx, "aoiresourceGroupName", "dataproduct01", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_AddUserRole_MaximumSet_Gen.json +func ExampleDataProductsClient_AddUserRole_dataProductsAddUserRoleMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDataProductsClient().AddUserRole(ctx, "aoiresourceGroupName", "dataproduct01", armnetworkanalytics.RoleAssignmentCommonProperties{ + DataTypeScope: []*string{ + to.Ptr("scope")}, + PrincipalID: to.Ptr("00000000-0000-0000-0000-00000000000"), + PrincipalType: to.Ptr("User"), + Role: to.Ptr(armnetworkanalytics.DataProductUserRoleReader), + RoleID: to.Ptr("00000000-0000-0000-0000-00000000000"), + UserName: to.Ptr("UserName"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleAssignmentDetail = armnetworkanalytics.RoleAssignmentDetail{ + // DataTypeScope: []*string{ + // to.Ptr("scope")}, + // PrincipalID: to.Ptr("00000000-0000-0000-0000-00000000000"), + // PrincipalType: to.Ptr("User"), + // Role: to.Ptr(armnetworkanalytics.DataProductUserRoleReader), + // RoleAssignmentID: to.Ptr("00000000-0000-0000-0000-00000000000"), + // RoleID: to.Ptr("00000000-0000-0000-0000-00000000000"), + // UserName: to.Ptr("UserName"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_AddUserRole_MinimumSet_Gen.json +func ExampleDataProductsClient_AddUserRole_dataProductsAddUserRoleMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDataProductsClient().AddUserRole(ctx, "aoiresourceGroupName", "dataproduct01", armnetworkanalytics.RoleAssignmentCommonProperties{ + DataTypeScope: []*string{ + to.Ptr("scope")}, + PrincipalID: to.Ptr("00000000-0000-0000-0000-00000000000"), + PrincipalType: to.Ptr("User"), + Role: to.Ptr(armnetworkanalytics.DataProductUserRoleReader), + RoleID: to.Ptr("00000000-0000-0000-0000-00000000000"), + UserName: to.Ptr("userName"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.RoleAssignmentDetail = armnetworkanalytics.RoleAssignmentDetail{ + // DataTypeScope: []*string{ + // to.Ptr("scope")}, + // PrincipalID: to.Ptr("00000000-0000-0000-0000-00000000000"), + // PrincipalType: to.Ptr("User"), + // Role: to.Ptr(armnetworkanalytics.DataProductUserRoleReader), + // RoleAssignmentID: to.Ptr("00000000-0000-0000-0000-00000000000"), + // RoleID: to.Ptr("00000000-0000-0000-0000-00000000000"), + // UserName: to.Ptr("userName"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_GenerateStorageAccountSasToken_MaximumSet_Gen.json +func ExampleDataProductsClient_GenerateStorageAccountSasToken_dataProductsGenerateStorageAccountSasTokenMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDataProductsClient().GenerateStorageAccountSasToken(ctx, "aoiresourceGroupName", "dataproduct01", armnetworkanalytics.AccountSas{ + ExpiryTimeStamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-24T05:34:58.151Z"); return t }()), + IPAddress: to.Ptr("1.1.1.1"), + StartTimeStamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-24T05:34:58.151Z"); return t }()), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccountSasToken = armnetworkanalytics.AccountSasToken{ + // StorageAccountSasToken: to.Ptr("storageAccountSasToken"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_GenerateStorageAccountSasToken_MinimumSet_Gen.json +func ExampleDataProductsClient_GenerateStorageAccountSasToken_dataProductsGenerateStorageAccountSasTokenMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDataProductsClient().GenerateStorageAccountSasToken(ctx, "aoiresourceGroupName", "dataproduct01", armnetworkanalytics.AccountSas{ + ExpiryTimeStamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-24T05:35:17.051Z"); return t }()), + IPAddress: to.Ptr("1.1.1.1"), + StartTimeStamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-24T05:35:17.051Z"); return t }()), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.AccountSasToken = armnetworkanalytics.AccountSasToken{ + // StorageAccountSasToken: to.Ptr("storageAccountSasToken"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_ListRolesAssignments_MaximumSet_Gen.json +func ExampleDataProductsClient_ListRolesAssignments_dataProductsListRolesAssignmentsMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDataProductsClient().ListRolesAssignments(ctx, "aoiresourceGroupName", "dataproduct01", map[string]any{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ListRoleAssignments = armnetworkanalytics.ListRoleAssignments{ + // Count: to.Ptr[int32](1), + // RoleAssignmentResponse: []*armnetworkanalytics.RoleAssignmentDetail{ + // { + // DataTypeScope: []*string{ + // to.Ptr("scope")}, + // PrincipalID: to.Ptr("00000000-0000-0000-0000-00000000000"), + // PrincipalType: to.Ptr("User"), + // Role: to.Ptr(armnetworkanalytics.DataProductUserRoleReader), + // RoleAssignmentID: to.Ptr("00000000-0000-0000-0000-00000000000"), + // RoleID: to.Ptr("00000000-0000-0000-0000-00000000000"), + // UserName: to.Ptr("UserName"), + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_ListRolesAssignments_MinimumSet_Gen.json +func ExampleDataProductsClient_ListRolesAssignments_dataProductsListRolesAssignmentsMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDataProductsClient().ListRolesAssignments(ctx, "aoiresourceGroupName", "dataproduct01", map[string]any{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ListRoleAssignments = armnetworkanalytics.ListRoleAssignments{ + // Count: to.Ptr[int32](1), + // RoleAssignmentResponse: []*armnetworkanalytics.RoleAssignmentDetail{ + // { + // DataTypeScope: []*string{ + // to.Ptr("scope")}, + // PrincipalID: to.Ptr("00000000-0000-0000-0000-00000000000"), + // PrincipalType: to.Ptr("User"), + // Role: to.Ptr(armnetworkanalytics.DataProductUserRoleReader), + // RoleAssignmentID: to.Ptr("00000000-0000-0000-0000-00000000000"), + // RoleID: to.Ptr("00000000-0000-0000-0000-00000000000"), + // UserName: to.Ptr("UserName"), + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_RemoveUserRole_MaximumSet_Gen.json +func ExampleDataProductsClient_RemoveUserRole_dataProductsRemoveUserRoleMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewDataProductsClient().RemoveUserRole(ctx, "aoiresourceGroupName", "dataproduct01", armnetworkanalytics.RoleAssignmentDetail{ + DataTypeScope: []*string{ + to.Ptr("scope")}, + PrincipalID: to.Ptr("00000000-0000-0000-0000-00000000000"), + PrincipalType: to.Ptr("User"), + Role: to.Ptr(armnetworkanalytics.DataProductUserRoleReader), + RoleAssignmentID: to.Ptr("00000000-0000-0000-0000-00000000000"), + RoleID: to.Ptr("00000000-0000-0000-0000-00000000000"), + UserName: to.Ptr("UserName"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_RemoveUserRole_MinimumSet_Gen.json +func ExampleDataProductsClient_RemoveUserRole_dataProductsRemoveUserRoleMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewDataProductsClient().RemoveUserRole(ctx, "aoiresourceGroupName", "dataproduct01", armnetworkanalytics.RoleAssignmentDetail{ + DataTypeScope: []*string{ + to.Ptr("scope")}, + PrincipalID: to.Ptr("00000000-0000-0000-0000-00000000000"), + PrincipalType: to.Ptr("User"), + Role: to.Ptr(armnetworkanalytics.DataProductUserRoleReader), + RoleAssignmentID: to.Ptr("00000000-0000-0000-0000-00000000000"), + RoleID: to.Ptr("00000000-0000-0000-0000-00000000000"), + UserName: to.Ptr("UserName"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_RotateKey_MaximumSet_Gen.json +func ExampleDataProductsClient_RotateKey_dataProductsRotateKeyMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewDataProductsClient().RotateKey(ctx, "aoiresourceGroupName", "dataproduct01", armnetworkanalytics.KeyVaultInfo{ + KeyVaultURL: to.Ptr("https://myKeyVault.vault.azure.net"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_RotateKey_MinimumSet_Gen.json +func ExampleDataProductsClient_RotateKey_dataProductsRotateKeyMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewDataProductsClient().RotateKey(ctx, "aoiresourceGroupName", "dataproduct01", armnetworkanalytics.KeyVaultInfo{ + KeyVaultURL: to.Ptr("https://myKeyVault.vault.azure.net"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/dataproductscatalogs_client.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/dataproductscatalogs_client.go new file mode 100644 index 000000000000..16ca9629387b --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/dataproductscatalogs_client.go @@ -0,0 +1,219 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnetworkanalytics + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// DataProductsCatalogsClient contains the methods for the DataProductsCatalogs group. +// Don't use this type directly, use NewDataProductsCatalogsClient() instead. +type DataProductsCatalogsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDataProductsCatalogsClient creates a new instance of DataProductsCatalogsClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDataProductsCatalogsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DataProductsCatalogsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DataProductsCatalogsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Retrieve data type resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - DataProductsCatalogsClientGetOptions contains the optional parameters for the DataProductsCatalogsClient.Get +// method. +func (client *DataProductsCatalogsClient) Get(ctx context.Context, resourceGroupName string, options *DataProductsCatalogsClientGetOptions) (DataProductsCatalogsClientGetResponse, error) { + var err error + const operationName = "DataProductsCatalogsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, options) + if err != nil { + return DataProductsCatalogsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataProductsCatalogsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DataProductsCatalogsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *DataProductsCatalogsClient) getCreateRequest(ctx context.Context, resourceGroupName string, options *DataProductsCatalogsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProductsCatalogs/default" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DataProductsCatalogsClient) getHandleResponse(resp *http.Response) (DataProductsCatalogsClientGetResponse, error) { + result := DataProductsCatalogsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataProductsCatalog); err != nil { + return DataProductsCatalogsClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List data catalog by resource group. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - DataProductsCatalogsClientListByResourceGroupOptions contains the optional parameters for the DataProductsCatalogsClient.NewListByResourceGroupPager +// method. +func (client *DataProductsCatalogsClient) NewListByResourceGroupPager(resourceGroupName string, options *DataProductsCatalogsClientListByResourceGroupOptions) *runtime.Pager[DataProductsCatalogsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[DataProductsCatalogsClientListByResourceGroupResponse]{ + More: func(page DataProductsCatalogsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DataProductsCatalogsClientListByResourceGroupResponse) (DataProductsCatalogsClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DataProductsCatalogsClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return DataProductsCatalogsClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *DataProductsCatalogsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *DataProductsCatalogsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProductsCatalogs" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *DataProductsCatalogsClient) listByResourceGroupHandleResponse(resp *http.Response) (DataProductsCatalogsClientListByResourceGroupResponse, error) { + result := DataProductsCatalogsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataProductsCatalogListResult); err != nil { + return DataProductsCatalogsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List data catalog by subscription. +// +// Generated from API version 2023-11-15 +// - options - DataProductsCatalogsClientListBySubscriptionOptions contains the optional parameters for the DataProductsCatalogsClient.NewListBySubscriptionPager +// method. +func (client *DataProductsCatalogsClient) NewListBySubscriptionPager(options *DataProductsCatalogsClientListBySubscriptionOptions) *runtime.Pager[DataProductsCatalogsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[DataProductsCatalogsClientListBySubscriptionResponse]{ + More: func(page DataProductsCatalogsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DataProductsCatalogsClientListBySubscriptionResponse) (DataProductsCatalogsClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DataProductsCatalogsClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return DataProductsCatalogsClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *DataProductsCatalogsClient) listBySubscriptionCreateRequest(ctx context.Context, options *DataProductsCatalogsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.NetworkAnalytics/dataProductsCatalogs" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *DataProductsCatalogsClient) listBySubscriptionHandleResponse(resp *http.Response) (DataProductsCatalogsClientListBySubscriptionResponse, error) { + result := DataProductsCatalogsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataProductsCatalogListResult); err != nil { + return DataProductsCatalogsClientListBySubscriptionResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/dataproductscatalogs_client_example_test.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/dataproductscatalogs_client_example_test.go new file mode 100644 index 000000000000..e30eb3235cf9 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/dataproductscatalogs_client_example_test.go @@ -0,0 +1,266 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armnetworkanalytics_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkanalytics/armnetworkanalytics" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProductsCatalogs_ListBySubscription_MaximumSet_Gen.json +func ExampleDataProductsCatalogsClient_NewListBySubscriptionPager_dataProductsCatalogsListBySubscriptionMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDataProductsCatalogsClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DataProductsCatalogListResult = armnetworkanalytics.DataProductsCatalogListResult{ + // Value: []*armnetworkanalytics.DataProductsCatalog{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.NetworkAnalytics/dataProductsCatalogs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/dataProductsCatalogs/default"), + // SystemData: &armnetworkanalytics.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // CreatedBy: to.Ptr("abc@micros.com"), + // CreatedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // LastModifiedBy: to.Ptr("abc@micros.com"), + // LastModifiedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // }, + // Properties: &armnetworkanalytics.DataProductsCatalogProperties{ + // ProvisioningState: to.Ptr(armnetworkanalytics.ProvisioningStateSucceeded), + // Publishers: []*armnetworkanalytics.PublisherInformation{ + // { + // DataProducts: []*armnetworkanalytics.DataProductInformation{ + // { + // Description: to.Ptr("Official data product for Mobile Content Cloud."), + // DataProductName: to.Ptr("MCC"), + // DataProductVersions: []*armnetworkanalytics.DataProductVersion{ + // { + // Version: to.Ptr("1.0.0"), + // }}, + // }}, + // PublisherName: to.Ptr("Microsoft"), + // }}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProductsCatalogs_ListBySubscription_MinimumSet_Gen.json +func ExampleDataProductsCatalogsClient_NewListBySubscriptionPager_dataProductsCatalogsListBySubscriptionMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDataProductsCatalogsClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DataProductsCatalogListResult = armnetworkanalytics.DataProductsCatalogListResult{ + // Value: []*armnetworkanalytics.DataProductsCatalog{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/dataProductsCatalogs/default"), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProductsCatalogs_ListByResourceGroup_MaximumSet_Gen.json +func ExampleDataProductsCatalogsClient_NewListByResourceGroupPager_dataProductsCatalogsListByResourceGroupMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDataProductsCatalogsClient().NewListByResourceGroupPager("aoiresourceGroupName", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DataProductsCatalogListResult = armnetworkanalytics.DataProductsCatalogListResult{ + // Value: []*armnetworkanalytics.DataProductsCatalog{ + // { + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.NetworkAnalytics/dataProductsCatalogs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/dataProductsCatalogs/default"), + // SystemData: &armnetworkanalytics.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // CreatedBy: to.Ptr("abc@micros.com"), + // CreatedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // LastModifiedBy: to.Ptr("abc@micros.com"), + // LastModifiedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // }, + // Properties: &armnetworkanalytics.DataProductsCatalogProperties{ + // ProvisioningState: to.Ptr(armnetworkanalytics.ProvisioningStateSucceeded), + // Publishers: []*armnetworkanalytics.PublisherInformation{ + // { + // DataProducts: []*armnetworkanalytics.DataProductInformation{ + // { + // Description: to.Ptr("Official data product for Mobile Content Cloud."), + // DataProductName: to.Ptr("MCC"), + // DataProductVersions: []*armnetworkanalytics.DataProductVersion{ + // { + // Version: to.Ptr("1.0.0"), + // }}, + // }}, + // PublisherName: to.Ptr("Microsoft"), + // }}, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProductsCatalogs_ListByResourceGroup_MinimumSet_Gen.json +func ExampleDataProductsCatalogsClient_NewListByResourceGroupPager_dataProductsCatalogsListByResourceGroupMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDataProductsCatalogsClient().NewListByResourceGroupPager("aoiresourceGroupName", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DataProductsCatalogListResult = armnetworkanalytics.DataProductsCatalogListResult{ + // Value: []*armnetworkanalytics.DataProductsCatalog{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/dataProductsCatalogs/default"), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProductsCatalogs_Get_MaximumSet_Gen.json +func ExampleDataProductsCatalogsClient_Get_dataProductsCatalogsGetMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDataProductsCatalogsClient().Get(ctx, "aoiresourceGroupName", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataProductsCatalog = armnetworkanalytics.DataProductsCatalog{ + // Name: to.Ptr("default"), + // Type: to.Ptr("Microsoft.NetworkAnalytics/dataProductsCatalogs"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/dataProductsCatalogs/default"), + // SystemData: &armnetworkanalytics.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // CreatedBy: to.Ptr("abc@micros.com"), + // CreatedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // LastModifiedBy: to.Ptr("abc@micros.com"), + // LastModifiedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // }, + // Properties: &armnetworkanalytics.DataProductsCatalogProperties{ + // ProvisioningState: to.Ptr(armnetworkanalytics.ProvisioningStateSucceeded), + // Publishers: []*armnetworkanalytics.PublisherInformation{ + // { + // DataProducts: []*armnetworkanalytics.DataProductInformation{ + // { + // Description: to.Ptr("Official data product for Mobile Content Cloud."), + // DataProductName: to.Ptr("MCC"), + // DataProductVersions: []*armnetworkanalytics.DataProductVersion{ + // { + // Version: to.Ptr("1.0.0"), + // }}, + // }}, + // PublisherName: to.Ptr("Microsoft"), + // }}, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProductsCatalogs_Get_MinimumSet_Gen.json +func ExampleDataProductsCatalogsClient_Get_dataProductsCatalogsGetMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDataProductsCatalogsClient().Get(ctx, "aoiresourceGroupName", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataProductsCatalog = armnetworkanalytics.DataProductsCatalog{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/dataProductsCatalogs/default"), + // } +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/datatypes_client.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/datatypes_client.go new file mode 100644 index 000000000000..dd9a0f1db35e --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/datatypes_client.go @@ -0,0 +1,589 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnetworkanalytics + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// DataTypesClient contains the methods for the DataTypes group. +// Don't use this type directly, use NewDataTypesClient() instead. +type DataTypesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewDataTypesClient creates a new instance of DataTypesClient with the specified values. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewDataTypesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DataTypesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &DataTypesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreate - Create data type resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - dataTypeName - The data type name. +// - resource - Resource create parameters. +// - options - DataTypesClientBeginCreateOptions contains the optional parameters for the DataTypesClient.BeginCreate method. +func (client *DataTypesClient) BeginCreate(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, resource DataType, options *DataTypesClientBeginCreateOptions) (*runtime.Poller[DataTypesClientCreateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.create(ctx, resourceGroupName, dataProductName, dataTypeName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DataTypesClientCreateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DataTypesClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Create - Create data type resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +func (client *DataTypesClient) create(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, resource DataType, options *DataTypesClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "DataTypesClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createCreateRequest(ctx, resourceGroupName, dataProductName, dataTypeName, resource, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createCreateRequest creates the Create request. +func (client *DataTypesClient) createCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, resource DataType, options *DataTypesClientBeginCreateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}/dataTypes/{dataTypeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + if dataTypeName == "" { + return nil, errors.New("parameter dataTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataTypeName}", url.PathEscape(dataTypeName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete data type resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - dataTypeName - The data type name. +// - options - DataTypesClientBeginDeleteOptions contains the optional parameters for the DataTypesClient.BeginDelete method. +func (client *DataTypesClient) BeginDelete(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, options *DataTypesClientBeginDeleteOptions) (*runtime.Poller[DataTypesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, dataProductName, dataTypeName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DataTypesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DataTypesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete data type resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +func (client *DataTypesClient) deleteOperation(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, options *DataTypesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "DataTypesClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, dataProductName, dataTypeName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DataTypesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, options *DataTypesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}/dataTypes/{dataTypeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + if dataTypeName == "" { + return nil, errors.New("parameter dataTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataTypeName}", url.PathEscape(dataTypeName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginDeleteData - Delete data for data type. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - dataTypeName - The data type name. +// - body - The content of the action request +// - options - DataTypesClientBeginDeleteDataOptions contains the optional parameters for the DataTypesClient.BeginDeleteData +// method. +func (client *DataTypesClient) BeginDeleteData(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, body any, options *DataTypesClientBeginDeleteDataOptions) (*runtime.Poller[DataTypesClientDeleteDataResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteData(ctx, resourceGroupName, dataProductName, dataTypeName, body, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DataTypesClientDeleteDataResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DataTypesClientDeleteDataResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// DeleteData - Delete data for data type. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +func (client *DataTypesClient) deleteData(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, body any, options *DataTypesClientBeginDeleteDataOptions) (*http.Response, error) { + var err error + const operationName = "DataTypesClient.BeginDeleteData" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteDataCreateRequest(ctx, resourceGroupName, dataProductName, dataTypeName, body, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteDataCreateRequest creates the DeleteData request. +func (client *DataTypesClient) deleteDataCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, body any, options *DataTypesClientBeginDeleteDataOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}/dataTypes/{dataTypeName}/deleteData" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + if dataTypeName == "" { + return nil, errors.New("parameter dataTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataTypeName}", url.PathEscape(dataTypeName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// GenerateStorageContainerSasToken - Generate sas token for storage container. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - dataTypeName - The data type name. +// - body - The content of the action request +// - options - DataTypesClientGenerateStorageContainerSasTokenOptions contains the optional parameters for the DataTypesClient.GenerateStorageContainerSasToken +// method. +func (client *DataTypesClient) GenerateStorageContainerSasToken(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, body ContainerSaS, options *DataTypesClientGenerateStorageContainerSasTokenOptions) (DataTypesClientGenerateStorageContainerSasTokenResponse, error) { + var err error + const operationName = "DataTypesClient.GenerateStorageContainerSasToken" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.generateStorageContainerSasTokenCreateRequest(ctx, resourceGroupName, dataProductName, dataTypeName, body, options) + if err != nil { + return DataTypesClientGenerateStorageContainerSasTokenResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataTypesClientGenerateStorageContainerSasTokenResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DataTypesClientGenerateStorageContainerSasTokenResponse{}, err + } + resp, err := client.generateStorageContainerSasTokenHandleResponse(httpResp) + return resp, err +} + +// generateStorageContainerSasTokenCreateRequest creates the GenerateStorageContainerSasToken request. +func (client *DataTypesClient) generateStorageContainerSasTokenCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, body ContainerSaS, options *DataTypesClientGenerateStorageContainerSasTokenOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}/dataTypes/{dataTypeName}/generateStorageContainerSasToken" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + if dataTypeName == "" { + return nil, errors.New("parameter dataTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataTypeName}", url.PathEscape(dataTypeName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// generateStorageContainerSasTokenHandleResponse handles the GenerateStorageContainerSasToken response. +func (client *DataTypesClient) generateStorageContainerSasTokenHandleResponse(resp *http.Response) (DataTypesClientGenerateStorageContainerSasTokenResponse, error) { + result := DataTypesClientGenerateStorageContainerSasTokenResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ContainerSasToken); err != nil { + return DataTypesClientGenerateStorageContainerSasTokenResponse{}, err + } + return result, nil +} + +// Get - Retrieve data type resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - dataTypeName - The data type name. +// - options - DataTypesClientGetOptions contains the optional parameters for the DataTypesClient.Get method. +func (client *DataTypesClient) Get(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, options *DataTypesClientGetOptions) (DataTypesClientGetResponse, error) { + var err error + const operationName = "DataTypesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, dataProductName, dataTypeName, options) + if err != nil { + return DataTypesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return DataTypesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DataTypesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *DataTypesClient) getCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, options *DataTypesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}/dataTypes/{dataTypeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + if dataTypeName == "" { + return nil, errors.New("parameter dataTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataTypeName}", url.PathEscape(dataTypeName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DataTypesClient) getHandleResponse(resp *http.Response) (DataTypesClientGetResponse, error) { + result := DataTypesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataType); err != nil { + return DataTypesClientGetResponse{}, err + } + return result, nil +} + +// NewListByDataProductPager - List data type by parent resource. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - options - DataTypesClientListByDataProductOptions contains the optional parameters for the DataTypesClient.NewListByDataProductPager +// method. +func (client *DataTypesClient) NewListByDataProductPager(resourceGroupName string, dataProductName string, options *DataTypesClientListByDataProductOptions) *runtime.Pager[DataTypesClientListByDataProductResponse] { + return runtime.NewPager(runtime.PagingHandler[DataTypesClientListByDataProductResponse]{ + More: func(page DataTypesClientListByDataProductResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *DataTypesClientListByDataProductResponse) (DataTypesClientListByDataProductResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DataTypesClient.NewListByDataProductPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByDataProductCreateRequest(ctx, resourceGroupName, dataProductName, options) + }, nil) + if err != nil { + return DataTypesClientListByDataProductResponse{}, err + } + return client.listByDataProductHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByDataProductCreateRequest creates the ListByDataProduct request. +func (client *DataTypesClient) listByDataProductCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, options *DataTypesClientListByDataProductOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}/dataTypes" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByDataProductHandleResponse handles the ListByDataProduct response. +func (client *DataTypesClient) listByDataProductHandleResponse(resp *http.Response) (DataTypesClientListByDataProductResponse, error) { + result := DataTypesClientListByDataProductResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.DataTypeListResult); err != nil { + return DataTypesClientListByDataProductResponse{}, err + } + return result, nil +} + +// BeginUpdate - Update data type resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - dataProductName - The data product resource name +// - dataTypeName - The data type name. +// - properties - The resource properties to be updated. +// - options - DataTypesClientBeginUpdateOptions contains the optional parameters for the DataTypesClient.BeginUpdate method. +func (client *DataTypesClient) BeginUpdate(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, properties DataTypeUpdate, options *DataTypesClientBeginUpdateOptions) (*runtime.Poller[DataTypesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, dataProductName, dataTypeName, properties, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DataTypesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DataTypesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Update data type resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-15 +func (client *DataTypesClient) update(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, properties DataTypeUpdate, options *DataTypesClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "DataTypesClient.BeginUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, dataProductName, dataTypeName, properties, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateCreateRequest creates the Update request. +func (client *DataTypesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, properties DataTypeUpdate, options *DataTypesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NetworkAnalytics/dataProducts/{dataProductName}/dataTypes/{dataTypeName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if dataProductName == "" { + return nil, errors.New("parameter dataProductName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataProductName}", url.PathEscape(dataProductName)) + if dataTypeName == "" { + return nil, errors.New("parameter dataTypeName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{dataTypeName}", url.PathEscape(dataTypeName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/datatypes_client_example_test.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/datatypes_client_example_test.go new file mode 100644 index 000000000000..0b37a665ba1f --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/datatypes_client_example_test.go @@ -0,0 +1,464 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armnetworkanalytics_test + +import ( + "context" + "log" + + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkanalytics/armnetworkanalytics" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataTypes_ListByDataProduct_MaximumSet_Gen.json +func ExampleDataTypesClient_NewListByDataProductPager_dataTypesListByDataProductMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDataTypesClient().NewListByDataProductPager("aoiresourceGroupName", "dataproduct01", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DataTypeListResult = armnetworkanalytics.DataTypeListResult{ + // Value: []*armnetworkanalytics.DataType{ + // { + // Name: to.Ptr("datatypename"), + // Type: to.Ptr("Microsoft.NetworkAnalytics/DataProducts/DataTypes"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/dataProducts/dataproduct01/dataTypes/datatypename"), + // SystemData: &armnetworkanalytics.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // CreatedBy: to.Ptr("abc@micros.com"), + // CreatedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // LastModifiedBy: to.Ptr("abc@micros.com"), + // LastModifiedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // }, + // Properties: &armnetworkanalytics.DataTypeProperties{ + // DatabaseCacheRetention: to.Ptr[int32](23), + // DatabaseRetention: to.Ptr[int32](6), + // ProvisioningState: to.Ptr(armnetworkanalytics.ProvisioningStateSucceeded), + // State: to.Ptr(armnetworkanalytics.DataTypeState("STARTED")), + // StateReason: to.Ptr("state Reason"), + // StorageOutputRetention: to.Ptr[int32](27), + // VisualizationURL: to.Ptr("visualizationUrl"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataTypes_ListByDataProduct_MinimumSet_Gen.json +func ExampleDataTypesClient_NewListByDataProductPager_dataTypesListByDataProductMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewDataTypesClient().NewListByDataProductPager("aoiresourceGroupName", "dataproduct01", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.DataTypeListResult = armnetworkanalytics.DataTypeListResult{ + // Value: []*armnetworkanalytics.DataType{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/dataProducts/dataproduct01/dataTypes/datatypename"), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataTypes_Get_MaximumSet_Gen.json +func ExampleDataTypesClient_Get_dataTypesGetMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDataTypesClient().Get(ctx, "aoiresourceGroupName", "dataproduct01", "datatypename", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataType = armnetworkanalytics.DataType{ + // Name: to.Ptr("datatypename"), + // Type: to.Ptr("Microsoft.NetworkAnalytics/DataProducts/DataTypes"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/dataProducts/dataproduct01/dataTypes/datatypename"), + // SystemData: &armnetworkanalytics.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // CreatedBy: to.Ptr("abc@micros.com"), + // CreatedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // LastModifiedBy: to.Ptr("abc@micros.com"), + // LastModifiedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // }, + // Properties: &armnetworkanalytics.DataTypeProperties{ + // DatabaseCacheRetention: to.Ptr[int32](23), + // DatabaseRetention: to.Ptr[int32](6), + // ProvisioningState: to.Ptr(armnetworkanalytics.ProvisioningStateSucceeded), + // State: to.Ptr(armnetworkanalytics.DataTypeState("STARTED")), + // StateReason: to.Ptr("state Reason"), + // StorageOutputRetention: to.Ptr[int32](27), + // VisualizationURL: to.Ptr("visualizationUrl"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataTypes_Get_MinimumSet_Gen.json +func ExampleDataTypesClient_Get_dataTypesGetMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDataTypesClient().Get(ctx, "aoiresourceGroupName", "dataproduct01", "datatypename", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataType = armnetworkanalytics.DataType{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/dataProducts/dataproduct01/dataTypes/datatypename"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataTypes_Create_MaximumSet_Gen.json +func ExampleDataTypesClient_BeginCreate_dataTypesCreateMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDataTypesClient().BeginCreate(ctx, "aoiresourceGroupName", "dataproduct01", "datatypename", armnetworkanalytics.DataType{ + Properties: &armnetworkanalytics.DataTypeProperties{ + DatabaseCacheRetention: to.Ptr[int32](23), + DatabaseRetention: to.Ptr[int32](6), + ProvisioningState: to.Ptr(armnetworkanalytics.ProvisioningStateSucceeded), + State: to.Ptr(armnetworkanalytics.DataTypeState("STARTED")), + StorageOutputRetention: to.Ptr[int32](27), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataType = armnetworkanalytics.DataType{ + // Name: to.Ptr("datatypeName"), + // Type: to.Ptr("Microsoft.NetworkAnalytics/DataProducts/DataTypes"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/dataProducts/dataproduct01/dataTypes/datatypename"), + // SystemData: &armnetworkanalytics.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // CreatedBy: to.Ptr("abc@micros.com"), + // CreatedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // LastModifiedBy: to.Ptr("abc@micros.com"), + // LastModifiedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // }, + // Properties: &armnetworkanalytics.DataTypeProperties{ + // DatabaseCacheRetention: to.Ptr[int32](23), + // DatabaseRetention: to.Ptr[int32](6), + // ProvisioningState: to.Ptr(armnetworkanalytics.ProvisioningStateSucceeded), + // State: to.Ptr(armnetworkanalytics.DataTypeState("STARTED")), + // StateReason: to.Ptr("State Reason"), + // StorageOutputRetention: to.Ptr[int32](27), + // VisualizationURL: to.Ptr("visualizationUrl"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataTypes_Create_MinimumSet_Gen.json +func ExampleDataTypesClient_BeginCreate_dataTypesCreateMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDataTypesClient().BeginCreate(ctx, "aoiresourceGroupName", "dataproduct01", "datatypename", armnetworkanalytics.DataType{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataType = armnetworkanalytics.DataType{ + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataTypes_Update_MaximumSet_Gen.json +func ExampleDataTypesClient_BeginUpdate_dataTypesUpdateMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDataTypesClient().BeginUpdate(ctx, "aoiresourceGroupName", "dataproduct01", "datatypename", armnetworkanalytics.DataTypeUpdate{ + Properties: &armnetworkanalytics.DataTypeUpdateProperties{ + DatabaseCacheRetention: to.Ptr[int32](16), + DatabaseRetention: to.Ptr[int32](9), + State: to.Ptr(armnetworkanalytics.DataTypeState("STARTED")), + StorageOutputRetention: to.Ptr[int32](30), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataType = armnetworkanalytics.DataType{ + // Name: to.Ptr("datatypename"), + // Type: to.Ptr("Microsoft.NetworkAnalytics/DataProducts/DataTypes"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/aoiresourceGroupName/providers/Microsoft.NetworkAnalytics/dataProducts/dataproduct01/dataTypes/datatypename"), + // SystemData: &armnetworkanalytics.SystemData{ + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // CreatedBy: to.Ptr("abc@micros.com"), + // CreatedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-04T08:26:27.150Z"); return t}()), + // LastModifiedBy: to.Ptr("abc@micros.com"), + // LastModifiedByType: to.Ptr(armnetworkanalytics.CreatedByTypeUser), + // }, + // Properties: &armnetworkanalytics.DataTypeProperties{ + // DatabaseCacheRetention: to.Ptr[int32](16), + // DatabaseRetention: to.Ptr[int32](9), + // ProvisioningState: to.Ptr(armnetworkanalytics.ProvisioningStateSucceeded), + // State: to.Ptr(armnetworkanalytics.DataTypeState("STARTED")), + // StateReason: to.Ptr("State Reason"), + // StorageOutputRetention: to.Ptr[int32](30), + // VisualizationURL: to.Ptr("visualizationUrl"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataTypes_Update_MinimumSet_Gen.json +func ExampleDataTypesClient_BeginUpdate_dataTypesUpdateMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDataTypesClient().BeginUpdate(ctx, "aoiresourceGroupName", "dataproduct01", "datatypename", armnetworkanalytics.DataTypeUpdate{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.DataType = armnetworkanalytics.DataType{ + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataTypes_Delete_MaximumSet_Gen.json +func ExampleDataTypesClient_BeginDelete_dataTypesDeleteMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDataTypesClient().BeginDelete(ctx, "aoiresourceGroupName", "dataproduct01", "datatypename", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataTypes_Delete_MinimumSet_Gen.json +func ExampleDataTypesClient_BeginDelete_dataTypesDeleteMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDataTypesClient().BeginDelete(ctx, "aoiresourceGroupName", "dataproduct01", "datatypename", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataTypes_DeleteData_MaximumSet_Gen.json +func ExampleDataTypesClient_BeginDeleteData_dataTypesDeleteDataMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDataTypesClient().BeginDeleteData(ctx, "aoiresourceGroupName", "dataproduct01", "datatypename", map[string]any{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataTypes_DeleteData_MinimumSet_Gen.json +func ExampleDataTypesClient_BeginDeleteData_dataTypesDeleteDataMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewDataTypesClient().BeginDeleteData(ctx, "aoiresourceGroupName", "dataproduct01", "datatypename", map[string]any{}, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataTypes_GenerateStorageContainerSasToken_MaximumSet_Gen.json +func ExampleDataTypesClient_GenerateStorageContainerSasToken_dataTypesGenerateStorageContainerSasTokenMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDataTypesClient().GenerateStorageContainerSasToken(ctx, "aoiresourceGroupName", "dataproduct01", "datatypename", armnetworkanalytics.ContainerSaS{ + ExpiryTimeStamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-24T05:34:58.039Z"); return t }()), + IPAddress: to.Ptr("1.1.1.1"), + StartTimeStamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-24T05:34:58.039Z"); return t }()), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ContainerSasToken = armnetworkanalytics.ContainerSasToken{ + // StorageContainerSasToken: to.Ptr("storageContainerSasToken"), + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataTypes_GenerateStorageContainerSasToken_MinimumSet_Gen.json +func ExampleDataTypesClient_GenerateStorageContainerSasToken_dataTypesGenerateStorageContainerSasTokenMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewDataTypesClient().GenerateStorageContainerSasToken(ctx, "aoiresourceGroupName", "dataproduct01", "datatypename", armnetworkanalytics.ContainerSaS{ + ExpiryTimeStamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-24T05:35:16.887Z"); return t }()), + IPAddress: to.Ptr("1.1.1.1"), + StartTimeStamp: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-08-24T05:35:16.887Z"); return t }()), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ContainerSasToken = armnetworkanalytics.ContainerSasToken{ + // StorageContainerSasToken: to.Ptr("storageContainerSasToken"), + // } +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/dataproducts_server.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/dataproducts_server.go new file mode 100644 index 000000000000..ffe5d6b861fa --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/dataproducts_server.go @@ -0,0 +1,568 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkanalytics/armnetworkanalytics" + "net/http" + "net/url" + "regexp" +) + +// DataProductsServer is a fake server for instances of the armnetworkanalytics.DataProductsClient type. +type DataProductsServer struct { + // AddUserRole is the fake for method DataProductsClient.AddUserRole + // HTTP status codes to indicate success: http.StatusOK + AddUserRole func(ctx context.Context, resourceGroupName string, dataProductName string, body armnetworkanalytics.RoleAssignmentCommonProperties, options *armnetworkanalytics.DataProductsClientAddUserRoleOptions) (resp azfake.Responder[armnetworkanalytics.DataProductsClientAddUserRoleResponse], errResp azfake.ErrorResponder) + + // BeginCreate is the fake for method DataProductsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, dataProductName string, resource armnetworkanalytics.DataProduct, options *armnetworkanalytics.DataProductsClientBeginCreateOptions) (resp azfake.PollerResponder[armnetworkanalytics.DataProductsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method DataProductsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, dataProductName string, options *armnetworkanalytics.DataProductsClientBeginDeleteOptions) (resp azfake.PollerResponder[armnetworkanalytics.DataProductsClientDeleteResponse], errResp azfake.ErrorResponder) + + // GenerateStorageAccountSasToken is the fake for method DataProductsClient.GenerateStorageAccountSasToken + // HTTP status codes to indicate success: http.StatusOK + GenerateStorageAccountSasToken func(ctx context.Context, resourceGroupName string, dataProductName string, body armnetworkanalytics.AccountSas, options *armnetworkanalytics.DataProductsClientGenerateStorageAccountSasTokenOptions) (resp azfake.Responder[armnetworkanalytics.DataProductsClientGenerateStorageAccountSasTokenResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method DataProductsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, dataProductName string, options *armnetworkanalytics.DataProductsClientGetOptions) (resp azfake.Responder[armnetworkanalytics.DataProductsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method DataProductsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armnetworkanalytics.DataProductsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armnetworkanalytics.DataProductsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method DataProductsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armnetworkanalytics.DataProductsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armnetworkanalytics.DataProductsClientListBySubscriptionResponse]) + + // ListRolesAssignments is the fake for method DataProductsClient.ListRolesAssignments + // HTTP status codes to indicate success: http.StatusOK + ListRolesAssignments func(ctx context.Context, resourceGroupName string, dataProductName string, body any, options *armnetworkanalytics.DataProductsClientListRolesAssignmentsOptions) (resp azfake.Responder[armnetworkanalytics.DataProductsClientListRolesAssignmentsResponse], errResp azfake.ErrorResponder) + + // RemoveUserRole is the fake for method DataProductsClient.RemoveUserRole + // HTTP status codes to indicate success: http.StatusNoContent + RemoveUserRole func(ctx context.Context, resourceGroupName string, dataProductName string, body armnetworkanalytics.RoleAssignmentDetail, options *armnetworkanalytics.DataProductsClientRemoveUserRoleOptions) (resp azfake.Responder[armnetworkanalytics.DataProductsClientRemoveUserRoleResponse], errResp azfake.ErrorResponder) + + // RotateKey is the fake for method DataProductsClient.RotateKey + // HTTP status codes to indicate success: http.StatusNoContent + RotateKey func(ctx context.Context, resourceGroupName string, dataProductName string, body armnetworkanalytics.KeyVaultInfo, options *armnetworkanalytics.DataProductsClientRotateKeyOptions) (resp azfake.Responder[armnetworkanalytics.DataProductsClientRotateKeyResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method DataProductsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, dataProductName string, properties armnetworkanalytics.DataProductUpdate, options *armnetworkanalytics.DataProductsClientBeginUpdateOptions) (resp azfake.PollerResponder[armnetworkanalytics.DataProductsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewDataProductsServerTransport creates a new instance of DataProductsServerTransport with the provided implementation. +// The returned DataProductsServerTransport instance is connected to an instance of armnetworkanalytics.DataProductsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDataProductsServerTransport(srv *DataProductsServer) *DataProductsServerTransport { + return &DataProductsServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armnetworkanalytics.DataProductsClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armnetworkanalytics.DataProductsClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armnetworkanalytics.DataProductsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armnetworkanalytics.DataProductsClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armnetworkanalytics.DataProductsClientUpdateResponse]](), + } +} + +// DataProductsServerTransport connects instances of armnetworkanalytics.DataProductsClient to instances of DataProductsServer. +// Don't use this type directly, use NewDataProductsServerTransport instead. +type DataProductsServerTransport struct { + srv *DataProductsServer + beginCreate *tracker[azfake.PollerResponder[armnetworkanalytics.DataProductsClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armnetworkanalytics.DataProductsClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armnetworkanalytics.DataProductsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armnetworkanalytics.DataProductsClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armnetworkanalytics.DataProductsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for DataProductsServerTransport. +func (d *DataProductsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "DataProductsClient.AddUserRole": + resp, err = d.dispatchAddUserRole(req) + case "DataProductsClient.BeginCreate": + resp, err = d.dispatchBeginCreate(req) + case "DataProductsClient.BeginDelete": + resp, err = d.dispatchBeginDelete(req) + case "DataProductsClient.GenerateStorageAccountSasToken": + resp, err = d.dispatchGenerateStorageAccountSasToken(req) + case "DataProductsClient.Get": + resp, err = d.dispatchGet(req) + case "DataProductsClient.NewListByResourceGroupPager": + resp, err = d.dispatchNewListByResourceGroupPager(req) + case "DataProductsClient.NewListBySubscriptionPager": + resp, err = d.dispatchNewListBySubscriptionPager(req) + case "DataProductsClient.ListRolesAssignments": + resp, err = d.dispatchListRolesAssignments(req) + case "DataProductsClient.RemoveUserRole": + resp, err = d.dispatchRemoveUserRole(req) + case "DataProductsClient.RotateKey": + resp, err = d.dispatchRotateKey(req) + case "DataProductsClient.BeginUpdate": + resp, err = d.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DataProductsServerTransport) dispatchAddUserRole(req *http.Request) (*http.Response, error) { + if d.srv.AddUserRole == nil { + return nil, &nonRetriableError{errors.New("fake for method AddUserRole not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/addUserRole` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armnetworkanalytics.RoleAssignmentCommonProperties](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.AddUserRole(req.Context(), resourceGroupNameParam, dataProductNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).RoleAssignmentDetail, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DataProductsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if d.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := d.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armnetworkanalytics.DataProduct](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginCreate(req.Context(), resourceGroupNameParam, dataProductNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + d.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + d.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + d.beginCreate.remove(req) + } + + return resp, nil +} + +func (d *DataProductsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if d.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := d.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginDelete(req.Context(), resourceGroupNameParam, dataProductNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + d.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + d.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + d.beginDelete.remove(req) + } + + return resp, nil +} + +func (d *DataProductsServerTransport) dispatchGenerateStorageAccountSasToken(req *http.Request) (*http.Response, error) { + if d.srv.GenerateStorageAccountSasToken == nil { + return nil, &nonRetriableError{errors.New("fake for method GenerateStorageAccountSasToken not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/generateStorageAccountSasToken` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armnetworkanalytics.AccountSas](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.GenerateStorageAccountSasToken(req.Context(), resourceGroupNameParam, dataProductNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AccountSasToken, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DataProductsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), resourceGroupNameParam, dataProductNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DataProduct, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DataProductsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := d.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := d.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + d.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armnetworkanalytics.DataProductsClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + d.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (d *DataProductsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := d.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := d.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + d.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armnetworkanalytics.DataProductsClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + d.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (d *DataProductsServerTransport) dispatchListRolesAssignments(req *http.Request) (*http.Response, error) { + if d.srv.ListRolesAssignments == nil { + return nil, &nonRetriableError{errors.New("fake for method ListRolesAssignments not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listRolesAssignments` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[any](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.ListRolesAssignments(req.Context(), resourceGroupNameParam, dataProductNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ListRoleAssignments, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DataProductsServerTransport) dispatchRemoveUserRole(req *http.Request) (*http.Response, error) { + if d.srv.RemoveUserRole == nil { + return nil, &nonRetriableError{errors.New("fake for method RemoveUserRole not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/removeUserRole` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armnetworkanalytics.RoleAssignmentDetail](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.RemoveUserRole(req.Context(), resourceGroupNameParam, dataProductNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DataProductsServerTransport) dispatchRotateKey(req *http.Request) (*http.Response, error) { + if d.srv.RotateKey == nil { + return nil, &nonRetriableError{errors.New("fake for method RotateKey not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/rotateKey` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armnetworkanalytics.KeyVaultInfo](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.RotateKey(req.Context(), resourceGroupNameParam, dataProductNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DataProductsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if d.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := d.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armnetworkanalytics.DataProductUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginUpdate(req.Context(), resourceGroupNameParam, dataProductNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + d.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + d.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + d.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/dataproductscatalogs_server.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/dataproductscatalogs_server.go new file mode 100644 index 000000000000..5927596cc537 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/dataproductscatalogs_server.go @@ -0,0 +1,185 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkanalytics/armnetworkanalytics" + "net/http" + "net/url" + "regexp" +) + +// DataProductsCatalogsServer is a fake server for instances of the armnetworkanalytics.DataProductsCatalogsClient type. +type DataProductsCatalogsServer struct { + // Get is the fake for method DataProductsCatalogsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, options *armnetworkanalytics.DataProductsCatalogsClientGetOptions) (resp azfake.Responder[armnetworkanalytics.DataProductsCatalogsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method DataProductsCatalogsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armnetworkanalytics.DataProductsCatalogsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armnetworkanalytics.DataProductsCatalogsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method DataProductsCatalogsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armnetworkanalytics.DataProductsCatalogsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armnetworkanalytics.DataProductsCatalogsClientListBySubscriptionResponse]) +} + +// NewDataProductsCatalogsServerTransport creates a new instance of DataProductsCatalogsServerTransport with the provided implementation. +// The returned DataProductsCatalogsServerTransport instance is connected to an instance of armnetworkanalytics.DataProductsCatalogsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDataProductsCatalogsServerTransport(srv *DataProductsCatalogsServer) *DataProductsCatalogsServerTransport { + return &DataProductsCatalogsServerTransport{ + srv: srv, + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armnetworkanalytics.DataProductsCatalogsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armnetworkanalytics.DataProductsCatalogsClientListBySubscriptionResponse]](), + } +} + +// DataProductsCatalogsServerTransport connects instances of armnetworkanalytics.DataProductsCatalogsClient to instances of DataProductsCatalogsServer. +// Don't use this type directly, use NewDataProductsCatalogsServerTransport instead. +type DataProductsCatalogsServerTransport struct { + srv *DataProductsCatalogsServer + newListByResourceGroupPager *tracker[azfake.PagerResponder[armnetworkanalytics.DataProductsCatalogsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armnetworkanalytics.DataProductsCatalogsClientListBySubscriptionResponse]] +} + +// Do implements the policy.Transporter interface for DataProductsCatalogsServerTransport. +func (d *DataProductsCatalogsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "DataProductsCatalogsClient.Get": + resp, err = d.dispatchGet(req) + case "DataProductsCatalogsClient.NewListByResourceGroupPager": + resp, err = d.dispatchNewListByResourceGroupPager(req) + case "DataProductsCatalogsClient.NewListBySubscriptionPager": + resp, err = d.dispatchNewListBySubscriptionPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DataProductsCatalogsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProductsCatalogs/default` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), resourceGroupNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DataProductsCatalog, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DataProductsCatalogsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := d.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProductsCatalogs` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := d.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + d.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armnetworkanalytics.DataProductsCatalogsClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + d.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (d *DataProductsCatalogsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := d.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProductsCatalogs` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := d.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + d.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armnetworkanalytics.DataProductsCatalogsClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + d.newListBySubscriptionPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/datatypes_server.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/datatypes_server.go new file mode 100644 index 000000000000..d5daa46eee03 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/datatypes_server.go @@ -0,0 +1,439 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkanalytics/armnetworkanalytics" + "net/http" + "net/url" + "regexp" +) + +// DataTypesServer is a fake server for instances of the armnetworkanalytics.DataTypesClient type. +type DataTypesServer struct { + // BeginCreate is the fake for method DataTypesClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, resource armnetworkanalytics.DataType, options *armnetworkanalytics.DataTypesClientBeginCreateOptions) (resp azfake.PollerResponder[armnetworkanalytics.DataTypesClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method DataTypesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, options *armnetworkanalytics.DataTypesClientBeginDeleteOptions) (resp azfake.PollerResponder[armnetworkanalytics.DataTypesClientDeleteResponse], errResp azfake.ErrorResponder) + + // BeginDeleteData is the fake for method DataTypesClient.BeginDeleteData + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDeleteData func(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, body any, options *armnetworkanalytics.DataTypesClientBeginDeleteDataOptions) (resp azfake.PollerResponder[armnetworkanalytics.DataTypesClientDeleteDataResponse], errResp azfake.ErrorResponder) + + // GenerateStorageContainerSasToken is the fake for method DataTypesClient.GenerateStorageContainerSasToken + // HTTP status codes to indicate success: http.StatusOK + GenerateStorageContainerSasToken func(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, body armnetworkanalytics.ContainerSaS, options *armnetworkanalytics.DataTypesClientGenerateStorageContainerSasTokenOptions) (resp azfake.Responder[armnetworkanalytics.DataTypesClientGenerateStorageContainerSasTokenResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method DataTypesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, options *armnetworkanalytics.DataTypesClientGetOptions) (resp azfake.Responder[armnetworkanalytics.DataTypesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByDataProductPager is the fake for method DataTypesClient.NewListByDataProductPager + // HTTP status codes to indicate success: http.StatusOK + NewListByDataProductPager func(resourceGroupName string, dataProductName string, options *armnetworkanalytics.DataTypesClientListByDataProductOptions) (resp azfake.PagerResponder[armnetworkanalytics.DataTypesClientListByDataProductResponse]) + + // BeginUpdate is the fake for method DataTypesClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, dataProductName string, dataTypeName string, properties armnetworkanalytics.DataTypeUpdate, options *armnetworkanalytics.DataTypesClientBeginUpdateOptions) (resp azfake.PollerResponder[armnetworkanalytics.DataTypesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewDataTypesServerTransport creates a new instance of DataTypesServerTransport with the provided implementation. +// The returned DataTypesServerTransport instance is connected to an instance of armnetworkanalytics.DataTypesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDataTypesServerTransport(srv *DataTypesServer) *DataTypesServerTransport { + return &DataTypesServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armnetworkanalytics.DataTypesClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armnetworkanalytics.DataTypesClientDeleteResponse]](), + beginDeleteData: newTracker[azfake.PollerResponder[armnetworkanalytics.DataTypesClientDeleteDataResponse]](), + newListByDataProductPager: newTracker[azfake.PagerResponder[armnetworkanalytics.DataTypesClientListByDataProductResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armnetworkanalytics.DataTypesClientUpdateResponse]](), + } +} + +// DataTypesServerTransport connects instances of armnetworkanalytics.DataTypesClient to instances of DataTypesServer. +// Don't use this type directly, use NewDataTypesServerTransport instead. +type DataTypesServerTransport struct { + srv *DataTypesServer + beginCreate *tracker[azfake.PollerResponder[armnetworkanalytics.DataTypesClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armnetworkanalytics.DataTypesClientDeleteResponse]] + beginDeleteData *tracker[azfake.PollerResponder[armnetworkanalytics.DataTypesClientDeleteDataResponse]] + newListByDataProductPager *tracker[azfake.PagerResponder[armnetworkanalytics.DataTypesClientListByDataProductResponse]] + beginUpdate *tracker[azfake.PollerResponder[armnetworkanalytics.DataTypesClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for DataTypesServerTransport. +func (d *DataTypesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "DataTypesClient.BeginCreate": + resp, err = d.dispatchBeginCreate(req) + case "DataTypesClient.BeginDelete": + resp, err = d.dispatchBeginDelete(req) + case "DataTypesClient.BeginDeleteData": + resp, err = d.dispatchBeginDeleteData(req) + case "DataTypesClient.GenerateStorageContainerSasToken": + resp, err = d.dispatchGenerateStorageContainerSasToken(req) + case "DataTypesClient.Get": + resp, err = d.dispatchGet(req) + case "DataTypesClient.NewListByDataProductPager": + resp, err = d.dispatchNewListByDataProductPager(req) + case "DataTypesClient.BeginUpdate": + resp, err = d.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DataTypesServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if d.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := d.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armnetworkanalytics.DataType](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + dataTypeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataTypeName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginCreate(req.Context(), resourceGroupNameParam, dataProductNameParam, dataTypeNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + d.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + d.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + d.beginCreate.remove(req) + } + + return resp, nil +} + +func (d *DataTypesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if d.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := d.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + dataTypeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataTypeName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginDelete(req.Context(), resourceGroupNameParam, dataProductNameParam, dataTypeNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + d.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + d.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + d.beginDelete.remove(req) + } + + return resp, nil +} + +func (d *DataTypesServerTransport) dispatchBeginDeleteData(req *http.Request) (*http.Response, error) { + if d.srv.BeginDeleteData == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDeleteData not implemented")} + } + beginDeleteData := d.beginDeleteData.get(req) + if beginDeleteData == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deleteData` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[any](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + dataTypeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataTypeName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginDeleteData(req.Context(), resourceGroupNameParam, dataProductNameParam, dataTypeNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDeleteData = &respr + d.beginDeleteData.add(req, beginDeleteData) + } + + resp, err := server.PollerResponderNext(beginDeleteData, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + d.beginDeleteData.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDeleteData) { + d.beginDeleteData.remove(req) + } + + return resp, nil +} + +func (d *DataTypesServerTransport) dispatchGenerateStorageContainerSasToken(req *http.Request) (*http.Response, error) { + if d.srv.GenerateStorageContainerSasToken == nil { + return nil, &nonRetriableError{errors.New("fake for method GenerateStorageContainerSasToken not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/generateStorageContainerSasToken` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armnetworkanalytics.ContainerSaS](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + dataTypeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataTypeName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.GenerateStorageContainerSasToken(req.Context(), resourceGroupNameParam, dataProductNameParam, dataTypeNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ContainerSasToken, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DataTypesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + dataTypeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataTypeName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), resourceGroupNameParam, dataProductNameParam, dataTypeNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DataType, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DataTypesServerTransport) dispatchNewListByDataProductPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListByDataProductPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByDataProductPager not implemented")} + } + newListByDataProductPager := d.newListByDataProductPager.get(req) + if newListByDataProductPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataTypes` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + resp := d.srv.NewListByDataProductPager(resourceGroupNameParam, dataProductNameParam, nil) + newListByDataProductPager = &resp + d.newListByDataProductPager.add(req, newListByDataProductPager) + server.PagerResponderInjectNextLinks(newListByDataProductPager, req, func(page *armnetworkanalytics.DataTypesClientListByDataProductResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByDataProductPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListByDataProductPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByDataProductPager) { + d.newListByDataProductPager.remove(req) + } + return resp, nil +} + +func (d *DataTypesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if d.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := d.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.NetworkAnalytics/dataProducts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armnetworkanalytics.DataTypeUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + dataProductNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataProductName")]) + if err != nil { + return nil, err + } + dataTypeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataTypeName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginUpdate(req.Context(), resourceGroupNameParam, dataProductNameParam, dataTypeNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + d.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + d.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + d.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/internal.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/internal.go new file mode 100644 index 000000000000..5f75802a569e --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/internal.go @@ -0,0 +1,64 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/operations_server.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/operations_server.go new file mode 100644 index 000000000000..162bed7c9a27 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/operations_server.go @@ -0,0 +1,96 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkanalytics/armnetworkanalytics" + "net/http" +) + +// OperationsServer is a fake server for instances of the armnetworkanalytics.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armnetworkanalytics.OperationsClientListOptions) (resp azfake.PagerResponder[armnetworkanalytics.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armnetworkanalytics.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armnetworkanalytics.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armnetworkanalytics.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armnetworkanalytics.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armnetworkanalytics.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/server_factory.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/server_factory.go new file mode 100644 index 000000000000..264bc7997952 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/server_factory.go @@ -0,0 +1,92 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armnetworkanalytics.ClientFactory type. +type ServerFactory struct { + DataProductsCatalogsServer DataProductsCatalogsServer + DataProductsServer DataProductsServer + DataTypesServer DataTypesServer + OperationsServer OperationsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armnetworkanalytics.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armnetworkanalytics.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trDataProductsCatalogsServer *DataProductsCatalogsServerTransport + trDataProductsServer *DataProductsServerTransport + trDataTypesServer *DataTypesServerTransport + trOperationsServer *OperationsServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "DataProductsCatalogsClient": + initServer(s, &s.trDataProductsCatalogsServer, func() *DataProductsCatalogsServerTransport { + return NewDataProductsCatalogsServerTransport(&s.srv.DataProductsCatalogsServer) + }) + resp, err = s.trDataProductsCatalogsServer.Do(req) + case "DataProductsClient": + initServer(s, &s.trDataProductsServer, func() *DataProductsServerTransport { return NewDataProductsServerTransport(&s.srv.DataProductsServer) }) + resp, err = s.trDataProductsServer.Do(req) + case "DataTypesClient": + initServer(s, &s.trDataTypesServer, func() *DataTypesServerTransport { return NewDataTypesServerTransport(&s.srv.DataTypesServer) }) + resp, err = s.trDataTypesServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/time_rfc3339.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/time_rfc3339.go new file mode 100644 index 000000000000..b0535a7b63e6 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/fake/time_rfc3339.go @@ -0,0 +1,86 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/go.mod b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/go.mod new file mode 100644 index 000000000000..d2421333b143 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/go.mod @@ -0,0 +1,21 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkanalytics/armnetworkanalytics + +go 1.18 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect + github.com/google/uuid v1.3.1 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect +) diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/go.sum b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/go.sum new file mode 100644 index 000000000000..7985f1da436f --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/go.sum @@ -0,0 +1,31 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/models.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/models.go new file mode 100644 index 000000000000..48a4869d8ec2 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/models.go @@ -0,0 +1,548 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnetworkanalytics + +import "time" + +// AccountSas - The details for storage account sas creation. +type AccountSas struct { + // REQUIRED; Sas token expiry timestamp. + ExpiryTimeStamp *time.Time + + // REQUIRED; Ip Address + IPAddress *string + + // REQUIRED; Sas token start timestamp. + StartTimeStamp *time.Time +} + +// AccountSasToken - Details of storage account sas token . +type AccountSasToken struct { + // REQUIRED; Field to specify storage account sas token. + StorageAccountSasToken *string +} + +// ConsumptionEndpointsProperties - Details of Consumption Properties +type ConsumptionEndpointsProperties struct { + // READ-ONLY; Resource Id of file access endpoint. + FileAccessResourceID *string + + // READ-ONLY; Url to consume file type. + FileAccessURL *string + + // READ-ONLY; Resource Id of ingestion endpoint. + IngestionResourceID *string + + // READ-ONLY; Ingestion url to upload the data. + IngestionURL *string + + // READ-ONLY; Resource Id of query endpoint. + QueryResourceID *string + + // READ-ONLY; Url to consume the processed data. + QueryURL *string +} + +// ContainerSaS - The details for container sas creation. +type ContainerSaS struct { + // REQUIRED; Sas token expiry timestamp. + ExpiryTimeStamp *time.Time + + // REQUIRED; Ip Address + IPAddress *string + + // REQUIRED; Sas token start timestamp. + StartTimeStamp *time.Time +} + +// ContainerSasToken - Details of storage container account sas token . +type ContainerSasToken struct { + // REQUIRED; Field to specify storage container sas token. + StorageContainerSasToken *string +} + +// DataProduct - The data product resource. +type DataProduct struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The managed service identities assigned to this resource. + Identity *ManagedServiceIdentity + + // The resource-specific properties for this resource. + Properties *DataProductProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// DataProductInformation - Data Product Information +type DataProductInformation struct { + // REQUIRED; Name of data product. + DataProductName *string + + // REQUIRED; Version information of data product. + DataProductVersions []*DataProductVersion + + // REQUIRED; Description about data product. + Description *string +} + +// DataProductListResult - The response of a DataProduct list operation. +type DataProductListResult struct { + // REQUIRED; The DataProduct items on this page + Value []*DataProduct + + // The link to the next page of items + NextLink *string +} + +// DataProductNetworkACLs - Data Product Network rule set +type DataProductNetworkACLs struct { + // REQUIRED; The list of query ips in the format of CIDR allowed to connect to query/visualization endpoint. + AllowedQueryIPRangeList []*string + + // REQUIRED; Default Action + DefaultAction *DefaultAction + + // REQUIRED; IP rule with specific IP or IP range in CIDR format. + IPRules []*IPRules + + // REQUIRED; Virtual Network Rule + VirtualNetworkRule []*VirtualNetworkRule +} + +// DataProductProperties - The data product properties. +type DataProductProperties struct { + // REQUIRED; Major version of data product. + MajorVersion *string + + // REQUIRED; Product name of data product. + Product *string + + // REQUIRED; Data product publisher name. + Publisher *string + + // Current configured minor version of the data product resource. + CurrentMinorVersion *string + + // Customer managed encryption key details for data product. + CustomerEncryptionKey *EncryptionKeyDetails + + // Flag to enable customer managed key encryption for data product. + CustomerManagedKeyEncryptionEnabled *ControlState + + // Managed resource group configuration. + ManagedResourceGroupConfiguration *ManagedResourceGroupConfiguration + + // Network rule set for data product. + Networkacls *DataProductNetworkACLs + + // List of name or email associated with data product resource deployment. + Owners []*string + + // Flag to enable or disable private link for data product resource. + PrivateLinksEnabled *ControlState + + // Flag to enable or disable public access of data product resource. + PublicNetworkAccess *ControlState + + // Purview account url for data product to connect to. + PurviewAccount *string + + // Purview collection url for data product to connect to. + PurviewCollection *string + + // Flag to enable or disable redundancy for data product. + Redundancy *ControlState + + // READ-ONLY; List of available minor versions of the data product resource. + AvailableMinorVersions []*string + + // READ-ONLY; Resource links which exposed to the customer to query the data. + ConsumptionEndpoints *ConsumptionEndpointsProperties + + // READ-ONLY; Documentation link for the data product based on definition file. + Documentation *string + + // READ-ONLY; Key vault url. + KeyVaultURL *string + + // READ-ONLY; Latest provisioning state of data product. + ProvisioningState *ProvisioningState + + // READ-ONLY; The resource GUID property of the data product resource. + ResourceGUID *string +} + +// DataProductUpdate - The type used for update operations of the DataProduct. +type DataProductUpdate struct { + // The managed service identities assigned to this resource. + Identity *ManagedServiceIdentity + + // The updatable properties of the DataProduct. + Properties *DataProductUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// DataProductUpdateProperties - The updatable properties of the DataProduct. +type DataProductUpdateProperties struct { + // Current configured minor version of the data product resource. + CurrentMinorVersion *string + + // List of name or email associated with data product resource deployment. + Owners []*string + + // Flag to enable or disable private link for data product resource. + PrivateLinksEnabled *ControlState + + // Purview account url for data product to connect to. + PurviewAccount *string + + // Purview collection url for data product to connect to. + PurviewCollection *string +} + +// DataProductVersion - Data Product Version. +type DataProductVersion struct { + // REQUIRED; Version of data product + Version *string +} + +// DataProductsCatalog - The data catalog resource. +type DataProductsCatalog struct { + // The resource-specific properties for this resource. + Properties *DataProductsCatalogProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// DataProductsCatalogListResult - The response of a DataProductsCatalog list operation. +type DataProductsCatalogListResult struct { + // REQUIRED; The DataProductsCatalog items on this page + Value []*DataProductsCatalog + + // The link to the next page of items + NextLink *string +} + +// DataProductsCatalogProperties - Details for data catalog properties. +type DataProductsCatalogProperties struct { + // REQUIRED; The data product publisher information. + Publishers []*PublisherInformation + + // READ-ONLY; The data catalog provisioning state. + ProvisioningState *ProvisioningState +} + +// DataType - The data type resource. +type DataType struct { + // The resource-specific properties for this resource. + Properties *DataTypeProperties + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// DataTypeListResult - The response of a DataType list operation. +type DataTypeListResult struct { + // REQUIRED; The DataType items on this page + Value []*DataType + + // The link to the next page of items + NextLink *string +} + +// DataTypeProperties - The data type properties +type DataTypeProperties struct { + // Field for database cache retention in days. + DatabaseCacheRetention *int32 + + // Field for database data retention in days. + DatabaseRetention *int32 + + // State of data type. + State *DataTypeState + + // Field for storage output retention in days. + StorageOutputRetention *int32 + + // READ-ONLY; Latest provisioning state of data product. + ProvisioningState *ProvisioningState + + // READ-ONLY; Reason for the state of data type. + StateReason *string + + // READ-ONLY; Url for data visualization. + VisualizationURL *string +} + +// DataTypeUpdate - The type used for update operations of the DataType. +type DataTypeUpdate struct { + // The updatable properties of the DataType. + Properties *DataTypeUpdateProperties +} + +// DataTypeUpdateProperties - The updatable properties of the DataType. +type DataTypeUpdateProperties struct { + // Field for database cache retention in days. + DatabaseCacheRetention *int32 + + // Field for database data retention in days. + DatabaseRetention *int32 + + // State of data type. + State *DataTypeState + + // Field for storage output retention in days. + StorageOutputRetention *int32 +} + +// EncryptionKeyDetails - Encryption key details. +type EncryptionKeyDetails struct { + // REQUIRED; The name of the key vault key. + KeyName *string + + // REQUIRED; The Uri of the key vault. + KeyVaultURI *string + + // REQUIRED; The version of the key vault key. + KeyVersion *string +} + +// IPRules - IP rule with specific IP or IP range in CIDR format. +type IPRules struct { + // REQUIRED; The action of virtual network rule. + Action *string + + // IP Rules Value + Value *string +} + +// KeyVaultInfo - Details for KeyVault. +type KeyVaultInfo struct { + // REQUIRED; key vault url. + KeyVaultURL *string +} + +// ListRoleAssignments - list role assignments. +type ListRoleAssignments struct { + // REQUIRED; Count of role assignments. + Count *int32 + + // REQUIRED; list of role assignments + RoleAssignmentResponse []*RoleAssignmentDetail +} + +// ManagedResourceGroupConfiguration - ManagedResourceGroup related properties +type ManagedResourceGroupConfiguration struct { + // REQUIRED; Managed Resource Group location + Location *string + + // REQUIRED; Name of managed resource group + Name *string +} + +// ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) +type ManagedServiceIdentity struct { + // REQUIRED; Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + Type *ManagedServiceIdentityType + + // The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM + // resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + // The dictionary values can be empty objects ({}) in + // requests. + UserAssignedIdentities map[string]*UserAssignedIdentity + + // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned + // identity. + PrincipalID *string + + // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *string +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation +} + +// PublisherInformation - Details for Publisher Information. +type PublisherInformation struct { + // REQUIRED; Data product information. + DataProducts []*DataProductInformation + + // REQUIRED; Name of the publisher. + PublisherName *string +} + +// RoleAssignmentCommonProperties - The details for role assignment common properties. +type RoleAssignmentCommonProperties struct { + // REQUIRED; Data Type Scope at which the role assignment is created. + DataTypeScope []*string + + // REQUIRED; Object ID of the AAD principal or security-group. + PrincipalID *string + + // REQUIRED; Type of the principal Id: User, Group or ServicePrincipal + PrincipalType *string + + // REQUIRED; Data Product role to be assigned to a user. + Role *DataProductUserRole + + // REQUIRED; Role Id of the Built-In Role + RoleID *string + + // REQUIRED; User name. + UserName *string +} + +// RoleAssignmentDetail - The details for role assignment response. +type RoleAssignmentDetail struct { + // REQUIRED; Data Type Scope at which the role assignment is created. + DataTypeScope []*string + + // REQUIRED; Object ID of the AAD principal or security-group. + PrincipalID *string + + // REQUIRED; Type of the principal Id: User, Group or ServicePrincipal + PrincipalType *string + + // REQUIRED; Data Product role to be assigned to a user. + Role *DataProductUserRole + + // REQUIRED; Id of role assignment request + RoleAssignmentID *string + + // REQUIRED; Role Id of the Built-In Role + RoleID *string + + // REQUIRED; User name. + UserName *string +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + +// UserAssignedIdentity - User assigned identity properties +type UserAssignedIdentity struct { + // READ-ONLY; The client ID of the assigned identity. + ClientID *string + + // READ-ONLY; The principal ID of the assigned identity. + PrincipalID *string +} + +// VirtualNetworkRule - Virtual Network Rule +type VirtualNetworkRule struct { + // REQUIRED; Resource ID of a subnet + ID *string + + // The action of virtual network rule. + Action *string + + // Gets the state of virtual network rule. + State *string +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/models_serde.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/models_serde.go new file mode 100644 index 000000000000..c9f2b7da320b --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/models_serde.go @@ -0,0 +1,1420 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnetworkanalytics + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type AccountSas. +func (a AccountSas) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "expiryTimeStamp", a.ExpiryTimeStamp) + populate(objectMap, "ipAddress", a.IPAddress) + populateDateTimeRFC3339(objectMap, "startTimeStamp", a.StartTimeStamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountSas. +func (a *AccountSas) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "expiryTimeStamp": + err = unpopulateDateTimeRFC3339(val, "ExpiryTimeStamp", &a.ExpiryTimeStamp) + delete(rawMsg, key) + case "ipAddress": + err = unpopulate(val, "IPAddress", &a.IPAddress) + delete(rawMsg, key) + case "startTimeStamp": + err = unpopulateDateTimeRFC3339(val, "StartTimeStamp", &a.StartTimeStamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type AccountSasToken. +func (a AccountSasToken) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "storageAccountSasToken", a.StorageAccountSasToken) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type AccountSasToken. +func (a *AccountSasToken) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "storageAccountSasToken": + err = unpopulate(val, "StorageAccountSasToken", &a.StorageAccountSasToken) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ConsumptionEndpointsProperties. +func (c ConsumptionEndpointsProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "fileAccessResourceId", c.FileAccessResourceID) + populate(objectMap, "fileAccessUrl", c.FileAccessURL) + populate(objectMap, "ingestionResourceId", c.IngestionResourceID) + populate(objectMap, "ingestionUrl", c.IngestionURL) + populate(objectMap, "queryResourceId", c.QueryResourceID) + populate(objectMap, "queryUrl", c.QueryURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConsumptionEndpointsProperties. +func (c *ConsumptionEndpointsProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "fileAccessResourceId": + err = unpopulate(val, "FileAccessResourceID", &c.FileAccessResourceID) + delete(rawMsg, key) + case "fileAccessUrl": + err = unpopulate(val, "FileAccessURL", &c.FileAccessURL) + delete(rawMsg, key) + case "ingestionResourceId": + err = unpopulate(val, "IngestionResourceID", &c.IngestionResourceID) + delete(rawMsg, key) + case "ingestionUrl": + err = unpopulate(val, "IngestionURL", &c.IngestionURL) + delete(rawMsg, key) + case "queryResourceId": + err = unpopulate(val, "QueryResourceID", &c.QueryResourceID) + delete(rawMsg, key) + case "queryUrl": + err = unpopulate(val, "QueryURL", &c.QueryURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerSaS. +func (c ContainerSaS) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "expiryTimeStamp", c.ExpiryTimeStamp) + populate(objectMap, "ipAddress", c.IPAddress) + populateDateTimeRFC3339(objectMap, "startTimeStamp", c.StartTimeStamp) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerSaS. +func (c *ContainerSaS) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "expiryTimeStamp": + err = unpopulateDateTimeRFC3339(val, "ExpiryTimeStamp", &c.ExpiryTimeStamp) + delete(rawMsg, key) + case "ipAddress": + err = unpopulate(val, "IPAddress", &c.IPAddress) + delete(rawMsg, key) + case "startTimeStamp": + err = unpopulateDateTimeRFC3339(val, "StartTimeStamp", &c.StartTimeStamp) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ContainerSasToken. +func (c ContainerSasToken) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "storageContainerSasToken", c.StorageContainerSasToken) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ContainerSasToken. +func (c *ContainerSasToken) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "storageContainerSasToken": + err = unpopulate(val, "StorageContainerSasToken", &c.StorageContainerSasToken) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataProduct. +func (d DataProduct) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "identity", d.Identity) + populate(objectMap, "location", d.Location) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "tags", d.Tags) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataProduct. +func (d *DataProduct) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &d.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &d.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataProductInformation. +func (d DataProductInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dataProductName", d.DataProductName) + populate(objectMap, "dataProductVersions", d.DataProductVersions) + populate(objectMap, "description", d.Description) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataProductInformation. +func (d *DataProductInformation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dataProductName": + err = unpopulate(val, "DataProductName", &d.DataProductName) + delete(rawMsg, key) + case "dataProductVersions": + err = unpopulate(val, "DataProductVersions", &d.DataProductVersions) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &d.Description) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataProductListResult. +func (d DataProductListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataProductListResult. +func (d *DataProductListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataProductNetworkACLs. +func (d DataProductNetworkACLs) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "allowedQueryIpRangeList", d.AllowedQueryIPRangeList) + populate(objectMap, "defaultAction", d.DefaultAction) + populate(objectMap, "ipRules", d.IPRules) + populate(objectMap, "virtualNetworkRule", d.VirtualNetworkRule) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataProductNetworkACLs. +func (d *DataProductNetworkACLs) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "allowedQueryIpRangeList": + err = unpopulate(val, "AllowedQueryIPRangeList", &d.AllowedQueryIPRangeList) + delete(rawMsg, key) + case "defaultAction": + err = unpopulate(val, "DefaultAction", &d.DefaultAction) + delete(rawMsg, key) + case "ipRules": + err = unpopulate(val, "IPRules", &d.IPRules) + delete(rawMsg, key) + case "virtualNetworkRule": + err = unpopulate(val, "VirtualNetworkRule", &d.VirtualNetworkRule) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataProductProperties. +func (d DataProductProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "availableMinorVersions", d.AvailableMinorVersions) + populate(objectMap, "consumptionEndpoints", d.ConsumptionEndpoints) + populate(objectMap, "currentMinorVersion", d.CurrentMinorVersion) + populate(objectMap, "customerEncryptionKey", d.CustomerEncryptionKey) + populate(objectMap, "customerManagedKeyEncryptionEnabled", d.CustomerManagedKeyEncryptionEnabled) + populate(objectMap, "documentation", d.Documentation) + populate(objectMap, "keyVaultUrl", d.KeyVaultURL) + populate(objectMap, "majorVersion", d.MajorVersion) + populate(objectMap, "managedResourceGroupConfiguration", d.ManagedResourceGroupConfiguration) + populate(objectMap, "networkacls", d.Networkacls) + populate(objectMap, "owners", d.Owners) + populate(objectMap, "privateLinksEnabled", d.PrivateLinksEnabled) + populate(objectMap, "product", d.Product) + populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "publicNetworkAccess", d.PublicNetworkAccess) + populate(objectMap, "publisher", d.Publisher) + populate(objectMap, "purviewAccount", d.PurviewAccount) + populate(objectMap, "purviewCollection", d.PurviewCollection) + populate(objectMap, "redundancy", d.Redundancy) + populate(objectMap, "resourceGuid", d.ResourceGUID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataProductProperties. +func (d *DataProductProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "availableMinorVersions": + err = unpopulate(val, "AvailableMinorVersions", &d.AvailableMinorVersions) + delete(rawMsg, key) + case "consumptionEndpoints": + err = unpopulate(val, "ConsumptionEndpoints", &d.ConsumptionEndpoints) + delete(rawMsg, key) + case "currentMinorVersion": + err = unpopulate(val, "CurrentMinorVersion", &d.CurrentMinorVersion) + delete(rawMsg, key) + case "customerEncryptionKey": + err = unpopulate(val, "CustomerEncryptionKey", &d.CustomerEncryptionKey) + delete(rawMsg, key) + case "customerManagedKeyEncryptionEnabled": + err = unpopulate(val, "CustomerManagedKeyEncryptionEnabled", &d.CustomerManagedKeyEncryptionEnabled) + delete(rawMsg, key) + case "documentation": + err = unpopulate(val, "Documentation", &d.Documentation) + delete(rawMsg, key) + case "keyVaultUrl": + err = unpopulate(val, "KeyVaultURL", &d.KeyVaultURL) + delete(rawMsg, key) + case "majorVersion": + err = unpopulate(val, "MajorVersion", &d.MajorVersion) + delete(rawMsg, key) + case "managedResourceGroupConfiguration": + err = unpopulate(val, "ManagedResourceGroupConfiguration", &d.ManagedResourceGroupConfiguration) + delete(rawMsg, key) + case "networkacls": + err = unpopulate(val, "Networkacls", &d.Networkacls) + delete(rawMsg, key) + case "owners": + err = unpopulate(val, "Owners", &d.Owners) + delete(rawMsg, key) + case "privateLinksEnabled": + err = unpopulate(val, "PrivateLinksEnabled", &d.PrivateLinksEnabled) + delete(rawMsg, key) + case "product": + err = unpopulate(val, "Product", &d.Product) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + case "publicNetworkAccess": + err = unpopulate(val, "PublicNetworkAccess", &d.PublicNetworkAccess) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &d.Publisher) + delete(rawMsg, key) + case "purviewAccount": + err = unpopulate(val, "PurviewAccount", &d.PurviewAccount) + delete(rawMsg, key) + case "purviewCollection": + err = unpopulate(val, "PurviewCollection", &d.PurviewCollection) + delete(rawMsg, key) + case "redundancy": + err = unpopulate(val, "Redundancy", &d.Redundancy) + delete(rawMsg, key) + case "resourceGuid": + err = unpopulate(val, "ResourceGUID", &d.ResourceGUID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataProductUpdate. +func (d DataProductUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", d.Identity) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "tags", d.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataProductUpdate. +func (d *DataProductUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &d.Identity) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &d.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataProductUpdateProperties. +func (d DataProductUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "currentMinorVersion", d.CurrentMinorVersion) + populate(objectMap, "owners", d.Owners) + populate(objectMap, "privateLinksEnabled", d.PrivateLinksEnabled) + populate(objectMap, "purviewAccount", d.PurviewAccount) + populate(objectMap, "purviewCollection", d.PurviewCollection) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataProductUpdateProperties. +func (d *DataProductUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "currentMinorVersion": + err = unpopulate(val, "CurrentMinorVersion", &d.CurrentMinorVersion) + delete(rawMsg, key) + case "owners": + err = unpopulate(val, "Owners", &d.Owners) + delete(rawMsg, key) + case "privateLinksEnabled": + err = unpopulate(val, "PrivateLinksEnabled", &d.PrivateLinksEnabled) + delete(rawMsg, key) + case "purviewAccount": + err = unpopulate(val, "PurviewAccount", &d.PurviewAccount) + delete(rawMsg, key) + case "purviewCollection": + err = unpopulate(val, "PurviewCollection", &d.PurviewCollection) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataProductVersion. +func (d DataProductVersion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "version", d.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataProductVersion. +func (d *DataProductVersion) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "version": + err = unpopulate(val, "Version", &d.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataProductsCatalog. +func (d DataProductsCatalog) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataProductsCatalog. +func (d *DataProductsCatalog) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataProductsCatalogListResult. +func (d DataProductsCatalogListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataProductsCatalogListResult. +func (d *DataProductsCatalogListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataProductsCatalogProperties. +func (d DataProductsCatalogProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "publishers", d.Publishers) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataProductsCatalogProperties. +func (d *DataProductsCatalogProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + case "publishers": + err = unpopulate(val, "Publishers", &d.Publishers) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataType. +func (d DataType) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", d.ID) + populate(objectMap, "name", d.Name) + populate(objectMap, "properties", d.Properties) + populate(objectMap, "systemData", d.SystemData) + populate(objectMap, "type", d.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataType. +func (d *DataType) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &d.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &d.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &d.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &d.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataTypeListResult. +func (d DataTypeListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataTypeListResult. +func (d *DataTypeListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &d.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &d.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataTypeProperties. +func (d DataTypeProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "databaseCacheRetention", d.DatabaseCacheRetention) + populate(objectMap, "databaseRetention", d.DatabaseRetention) + populate(objectMap, "provisioningState", d.ProvisioningState) + populate(objectMap, "state", d.State) + populate(objectMap, "stateReason", d.StateReason) + populate(objectMap, "storageOutputRetention", d.StorageOutputRetention) + populate(objectMap, "visualizationUrl", d.VisualizationURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataTypeProperties. +func (d *DataTypeProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "databaseCacheRetention": + err = unpopulate(val, "DatabaseCacheRetention", &d.DatabaseCacheRetention) + delete(rawMsg, key) + case "databaseRetention": + err = unpopulate(val, "DatabaseRetention", &d.DatabaseRetention) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &d.ProvisioningState) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &d.State) + delete(rawMsg, key) + case "stateReason": + err = unpopulate(val, "StateReason", &d.StateReason) + delete(rawMsg, key) + case "storageOutputRetention": + err = unpopulate(val, "StorageOutputRetention", &d.StorageOutputRetention) + delete(rawMsg, key) + case "visualizationUrl": + err = unpopulate(val, "VisualizationURL", &d.VisualizationURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataTypeUpdate. +func (d DataTypeUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataTypeUpdate. +func (d *DataTypeUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &d.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type DataTypeUpdateProperties. +func (d DataTypeUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "databaseCacheRetention", d.DatabaseCacheRetention) + populate(objectMap, "databaseRetention", d.DatabaseRetention) + populate(objectMap, "state", d.State) + populate(objectMap, "storageOutputRetention", d.StorageOutputRetention) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DataTypeUpdateProperties. +func (d *DataTypeUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "databaseCacheRetention": + err = unpopulate(val, "DatabaseCacheRetention", &d.DatabaseCacheRetention) + delete(rawMsg, key) + case "databaseRetention": + err = unpopulate(val, "DatabaseRetention", &d.DatabaseRetention) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &d.State) + delete(rawMsg, key) + case "storageOutputRetention": + err = unpopulate(val, "StorageOutputRetention", &d.StorageOutputRetention) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", d, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type EncryptionKeyDetails. +func (e EncryptionKeyDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "keyName", e.KeyName) + populate(objectMap, "keyVaultUri", e.KeyVaultURI) + populate(objectMap, "keyVersion", e.KeyVersion) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type EncryptionKeyDetails. +func (e *EncryptionKeyDetails) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "keyName": + err = unpopulate(val, "KeyName", &e.KeyName) + delete(rawMsg, key) + case "keyVaultUri": + err = unpopulate(val, "KeyVaultURI", &e.KeyVaultURI) + delete(rawMsg, key) + case "keyVersion": + err = unpopulate(val, "KeyVersion", &e.KeyVersion) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", e, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type IPRules. +func (i IPRules) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", i.Action) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IPRules. +func (i *IPRules) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &i.Action) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &i.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultInfo. +func (k KeyVaultInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "keyVaultUrl", k.KeyVaultURL) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultInfo. +func (k *KeyVaultInfo) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "keyVaultUrl": + err = unpopulate(val, "KeyVaultURL", &k.KeyVaultURL) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", k, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ListRoleAssignments. +func (l ListRoleAssignments) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "count", l.Count) + populate(objectMap, "roleAssignmentResponse", l.RoleAssignmentResponse) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListRoleAssignments. +func (l *ListRoleAssignments) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "count": + err = unpopulate(val, "Count", &l.Count) + delete(rawMsg, key) + case "roleAssignmentResponse": + err = unpopulate(val, "RoleAssignmentResponse", &l.RoleAssignmentResponse) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedResourceGroupConfiguration. +func (m ManagedResourceGroupConfiguration) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "location", m.Location) + populate(objectMap, "name", m.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedResourceGroupConfiguration. +func (m *ManagedResourceGroupConfiguration) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "location": + err = unpopulate(val, "Location", &m.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &m.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentity. +func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", m.PrincipalID) + populate(objectMap, "tenantId", m.TenantID) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedServiceIdentity. +func (m *ManagedServiceIdentity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &m.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &m.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &m.UserAssignedIdentities) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type PublisherInformation. +func (p PublisherInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dataProducts", p.DataProducts) + populate(objectMap, "publisherName", p.PublisherName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PublisherInformation. +func (p *PublisherInformation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dataProducts": + err = unpopulate(val, "DataProducts", &p.DataProducts) + delete(rawMsg, key) + case "publisherName": + err = unpopulate(val, "PublisherName", &p.PublisherName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", p, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoleAssignmentCommonProperties. +func (r RoleAssignmentCommonProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dataTypeScope", r.DataTypeScope) + populate(objectMap, "principalId", r.PrincipalID) + populate(objectMap, "principalType", r.PrincipalType) + populate(objectMap, "role", r.Role) + populate(objectMap, "roleId", r.RoleID) + populate(objectMap, "userName", r.UserName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoleAssignmentCommonProperties. +func (r *RoleAssignmentCommonProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dataTypeScope": + err = unpopulate(val, "DataTypeScope", &r.DataTypeScope) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &r.PrincipalID) + delete(rawMsg, key) + case "principalType": + err = unpopulate(val, "PrincipalType", &r.PrincipalType) + delete(rawMsg, key) + case "role": + err = unpopulate(val, "Role", &r.Role) + delete(rawMsg, key) + case "roleId": + err = unpopulate(val, "RoleID", &r.RoleID) + delete(rawMsg, key) + case "userName": + err = unpopulate(val, "UserName", &r.UserName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type RoleAssignmentDetail. +func (r RoleAssignmentDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dataTypeScope", r.DataTypeScope) + populate(objectMap, "principalId", r.PrincipalID) + populate(objectMap, "principalType", r.PrincipalType) + populate(objectMap, "role", r.Role) + populate(objectMap, "roleAssignmentId", r.RoleAssignmentID) + populate(objectMap, "roleId", r.RoleID) + populate(objectMap, "userName", r.UserName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RoleAssignmentDetail. +func (r *RoleAssignmentDetail) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dataTypeScope": + err = unpopulate(val, "DataTypeScope", &r.DataTypeScope) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &r.PrincipalID) + delete(rawMsg, key) + case "principalType": + err = unpopulate(val, "PrincipalType", &r.PrincipalType) + delete(rawMsg, key) + case "role": + err = unpopulate(val, "Role", &r.Role) + delete(rawMsg, key) + case "roleAssignmentId": + err = unpopulate(val, "RoleAssignmentID", &r.RoleAssignmentID) + delete(rawMsg, key) + case "roleId": + err = unpopulate(val, "RoleID", &r.RoleID) + delete(rawMsg, key) + case "userName": + err = unpopulate(val, "UserName", &r.UserName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", r, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentity. +func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "clientId", u.ClientID) + populate(objectMap, "principalId", u.PrincipalID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentity. +func (u *UserAssignedIdentity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "clientId": + err = unpopulate(val, "ClientID", &u.ClientID) + delete(rawMsg, key) + case "principalId": + err = unpopulate(val, "PrincipalID", &u.PrincipalID) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", u, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type VirtualNetworkRule. +func (v VirtualNetworkRule) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "action", v.Action) + populate(objectMap, "id", v.ID) + populate(objectMap, "state", v.State) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type VirtualNetworkRule. +func (v *VirtualNetworkRule) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "action": + err = unpopulate(val, "Action", &v.Action) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &v.ID) + delete(rawMsg, key) + case "state": + err = unpopulate(val, "State", &v.State) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", v, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/operations_client.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/operations_client.go new file mode 100644 index 000000000000..94ae25bb1b62 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/operations_client.go @@ -0,0 +1,88 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnetworkanalytics + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + internal *arm.Client +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - List the operations for the provider +// +// Generated from API version 2023-11-15 +// - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return OperationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.NetworkAnalytics/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-15") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { + result := OperationsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { + return OperationsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/operations_client_example_test.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/operations_client_example_test.go new file mode 100644 index 000000000000..4e94f22a37ea --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/operations_client_example_test.go @@ -0,0 +1,85 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armnetworkanalytics_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/networkanalytics/armnetworkanalytics" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/Operations_List_MaximumSet_Gen.json +func ExampleOperationsClient_NewListPager_operationsListMaximumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationListResult = armnetworkanalytics.OperationListResult{ + // Value: []*armnetworkanalytics.Operation{ + // { + // Name: to.Ptr("Microsoft.NetworkAnalytics/resourceName/operationName"), + // ActionType: to.Ptr(armnetworkanalytics.ActionTypeInternal), + // Display: &armnetworkanalytics.OperationDisplay{ + // Description: to.Ptr("Description of the operation"), + // Operation: to.Ptr("OperationName"), + // Provider: to.Ptr("Microsoft.NetworkAnalytics"), + // Resource: to.Ptr("ResourceName"), + // }, + // IsDataAction: to.Ptr(false), + // Origin: to.Ptr(armnetworkanalytics.OriginUser), + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/Operations_List_MinimumSet_Gen.json +func ExampleOperationsClient_NewListPager_operationsListMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armnetworkanalytics.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationListResult = armnetworkanalytics.OperationListResult{ + // } + } +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/options.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/options.go new file mode 100644 index 000000000000..378d05f100ff --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/options.go @@ -0,0 +1,134 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnetworkanalytics + +// DataProductsCatalogsClientGetOptions contains the optional parameters for the DataProductsCatalogsClient.Get method. +type DataProductsCatalogsClientGetOptions struct { + // placeholder for future optional parameters +} + +// DataProductsCatalogsClientListByResourceGroupOptions contains the optional parameters for the DataProductsCatalogsClient.NewListByResourceGroupPager +// method. +type DataProductsCatalogsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// DataProductsCatalogsClientListBySubscriptionOptions contains the optional parameters for the DataProductsCatalogsClient.NewListBySubscriptionPager +// method. +type DataProductsCatalogsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// DataProductsClientAddUserRoleOptions contains the optional parameters for the DataProductsClient.AddUserRole method. +type DataProductsClientAddUserRoleOptions struct { + // placeholder for future optional parameters +} + +// DataProductsClientBeginCreateOptions contains the optional parameters for the DataProductsClient.BeginCreate method. +type DataProductsClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DataProductsClientBeginDeleteOptions contains the optional parameters for the DataProductsClient.BeginDelete method. +type DataProductsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DataProductsClientBeginUpdateOptions contains the optional parameters for the DataProductsClient.BeginUpdate method. +type DataProductsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DataProductsClientGenerateStorageAccountSasTokenOptions contains the optional parameters for the DataProductsClient.GenerateStorageAccountSasToken +// method. +type DataProductsClientGenerateStorageAccountSasTokenOptions struct { + // placeholder for future optional parameters +} + +// DataProductsClientGetOptions contains the optional parameters for the DataProductsClient.Get method. +type DataProductsClientGetOptions struct { + // placeholder for future optional parameters +} + +// DataProductsClientListByResourceGroupOptions contains the optional parameters for the DataProductsClient.NewListByResourceGroupPager +// method. +type DataProductsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// DataProductsClientListBySubscriptionOptions contains the optional parameters for the DataProductsClient.NewListBySubscriptionPager +// method. +type DataProductsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// DataProductsClientListRolesAssignmentsOptions contains the optional parameters for the DataProductsClient.ListRolesAssignments +// method. +type DataProductsClientListRolesAssignmentsOptions struct { + // placeholder for future optional parameters +} + +// DataProductsClientRemoveUserRoleOptions contains the optional parameters for the DataProductsClient.RemoveUserRole method. +type DataProductsClientRemoveUserRoleOptions struct { + // placeholder for future optional parameters +} + +// DataProductsClientRotateKeyOptions contains the optional parameters for the DataProductsClient.RotateKey method. +type DataProductsClientRotateKeyOptions struct { + // placeholder for future optional parameters +} + +// DataTypesClientBeginCreateOptions contains the optional parameters for the DataTypesClient.BeginCreate method. +type DataTypesClientBeginCreateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DataTypesClientBeginDeleteDataOptions contains the optional parameters for the DataTypesClient.BeginDeleteData method. +type DataTypesClientBeginDeleteDataOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DataTypesClientBeginDeleteOptions contains the optional parameters for the DataTypesClient.BeginDelete method. +type DataTypesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DataTypesClientBeginUpdateOptions contains the optional parameters for the DataTypesClient.BeginUpdate method. +type DataTypesClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// DataTypesClientGenerateStorageContainerSasTokenOptions contains the optional parameters for the DataTypesClient.GenerateStorageContainerSasToken +// method. +type DataTypesClientGenerateStorageContainerSasTokenOptions struct { + // placeholder for future optional parameters +} + +// DataTypesClientGetOptions contains the optional parameters for the DataTypesClient.Get method. +type DataTypesClientGetOptions struct { + // placeholder for future optional parameters +} + +// DataTypesClientListByDataProductOptions contains the optional parameters for the DataTypesClient.NewListByDataProductPager +// method. +type DataTypesClientListByDataProductOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/response_types.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/response_types.go new file mode 100644 index 000000000000..65e08765a925 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/response_types.go @@ -0,0 +1,136 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnetworkanalytics + +// DataProductsCatalogsClientGetResponse contains the response from method DataProductsCatalogsClient.Get. +type DataProductsCatalogsClientGetResponse struct { + // The data catalog resource. + DataProductsCatalog +} + +// DataProductsCatalogsClientListByResourceGroupResponse contains the response from method DataProductsCatalogsClient.NewListByResourceGroupPager. +type DataProductsCatalogsClientListByResourceGroupResponse struct { + // The response of a DataProductsCatalog list operation. + DataProductsCatalogListResult +} + +// DataProductsCatalogsClientListBySubscriptionResponse contains the response from method DataProductsCatalogsClient.NewListBySubscriptionPager. +type DataProductsCatalogsClientListBySubscriptionResponse struct { + // The response of a DataProductsCatalog list operation. + DataProductsCatalogListResult +} + +// DataProductsClientAddUserRoleResponse contains the response from method DataProductsClient.AddUserRole. +type DataProductsClientAddUserRoleResponse struct { + // The details for role assignment response. + RoleAssignmentDetail +} + +// DataProductsClientCreateResponse contains the response from method DataProductsClient.BeginCreate. +type DataProductsClientCreateResponse struct { + // The data product resource. + DataProduct +} + +// DataProductsClientDeleteResponse contains the response from method DataProductsClient.BeginDelete. +type DataProductsClientDeleteResponse struct { + // placeholder for future response values +} + +// DataProductsClientGenerateStorageAccountSasTokenResponse contains the response from method DataProductsClient.GenerateStorageAccountSasToken. +type DataProductsClientGenerateStorageAccountSasTokenResponse struct { + // Details of storage account sas token . + AccountSasToken +} + +// DataProductsClientGetResponse contains the response from method DataProductsClient.Get. +type DataProductsClientGetResponse struct { + // The data product resource. + DataProduct +} + +// DataProductsClientListByResourceGroupResponse contains the response from method DataProductsClient.NewListByResourceGroupPager. +type DataProductsClientListByResourceGroupResponse struct { + // The response of a DataProduct list operation. + DataProductListResult +} + +// DataProductsClientListBySubscriptionResponse contains the response from method DataProductsClient.NewListBySubscriptionPager. +type DataProductsClientListBySubscriptionResponse struct { + // The response of a DataProduct list operation. + DataProductListResult +} + +// DataProductsClientListRolesAssignmentsResponse contains the response from method DataProductsClient.ListRolesAssignments. +type DataProductsClientListRolesAssignmentsResponse struct { + // list role assignments. + ListRoleAssignments +} + +// DataProductsClientRemoveUserRoleResponse contains the response from method DataProductsClient.RemoveUserRole. +type DataProductsClientRemoveUserRoleResponse struct { + // placeholder for future response values +} + +// DataProductsClientRotateKeyResponse contains the response from method DataProductsClient.RotateKey. +type DataProductsClientRotateKeyResponse struct { + // placeholder for future response values +} + +// DataProductsClientUpdateResponse contains the response from method DataProductsClient.BeginUpdate. +type DataProductsClientUpdateResponse struct { + // The data product resource. + DataProduct +} + +// DataTypesClientCreateResponse contains the response from method DataTypesClient.BeginCreate. +type DataTypesClientCreateResponse struct { + // The data type resource. + DataType +} + +// DataTypesClientDeleteDataResponse contains the response from method DataTypesClient.BeginDeleteData. +type DataTypesClientDeleteDataResponse struct { + // placeholder for future response values +} + +// DataTypesClientDeleteResponse contains the response from method DataTypesClient.BeginDelete. +type DataTypesClientDeleteResponse struct { + // placeholder for future response values +} + +// DataTypesClientGenerateStorageContainerSasTokenResponse contains the response from method DataTypesClient.GenerateStorageContainerSasToken. +type DataTypesClientGenerateStorageContainerSasTokenResponse struct { + // Details of storage container account sas token . + ContainerSasToken +} + +// DataTypesClientGetResponse contains the response from method DataTypesClient.Get. +type DataTypesClientGetResponse struct { + // The data type resource. + DataType +} + +// DataTypesClientListByDataProductResponse contains the response from method DataTypesClient.NewListByDataProductPager. +type DataTypesClientListByDataProductResponse struct { + // The response of a DataType list operation. + DataTypeListResult +} + +// DataTypesClientUpdateResponse contains the response from method DataTypesClient.BeginUpdate. +type DataTypesClientUpdateResponse struct { + // The data type resource. + DataType +} + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + OperationListResult +} diff --git a/sdk/resourcemanager/networkanalytics/armnetworkanalytics/time_rfc3339.go b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/time_rfc3339.go new file mode 100644 index 000000000000..1a4afc9adfe0 --- /dev/null +++ b/sdk/resourcemanager/networkanalytics/armnetworkanalytics/time_rfc3339.go @@ -0,0 +1,86 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armnetworkanalytics + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +}