diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/CHANGELOG.md b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/CHANGELOG.md new file mode 100644 index 000000000000..8be8a3eb9207 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-05-12) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer` 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/azuredatatransfer/armazuredatatransfer/LICENSE.txt b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/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/azuredatatransfer/armazuredatatransfer/README.md b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/README.md new file mode 100644 index 000000000000..73bf6ea31ac8 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/README.md @@ -0,0 +1,90 @@ +# Azure Azuredatatransfer Module for Go + +The `armazuredatatransfer` module provides operations for working with Azure Azuredatatransfer. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer) + +# 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 Azuredatatransfer module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Azuredatatransfer. 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 Azuredatatransfer 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 := armazuredatatransfer.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 := armazuredatatransfer.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.NewConnectionsClient() +``` + +## 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 `Azuredatatransfer` 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/azuredatatransfer/armazuredatatransfer/autorest.md b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/autorest.md new file mode 100644 index 000000000000..fef518311bc7 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/azuredatatransfer/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/azuredatatransfer/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/build.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/build.go new file mode 100644 index 000000000000..bb04f34302d0 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/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/azuredatatransfer/armazuredatatransfer + +package armazuredatatransfer diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/ci.yml b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/ci.yml new file mode 100644 index 000000000000..9a463371ecf3 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/ci.yml @@ -0,0 +1,27 @@ +# 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/azuredatatransfer/armazuredatatransfer/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/azuredatatransfer/armazuredatatransfer' diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/client.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/client.go new file mode 100644 index 000000000000..17796b815020 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/client.go @@ -0,0 +1,143 @@ +// 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 armazuredatatransfer + +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" +) + +// Client contains the methods for the AzureDataTransfer group. +// Don't use this type directly, use NewClient() instead. +type Client struct { + internal *arm.Client +} + +// NewClient creates a new instance of Client with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &Client{ + internal: cl, + } + return client, nil +} + +// ListApprovedSchemas - Lists approved schemas for Azure Data Transfer. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - pipeline - The request to list approved schemas. +// - options - ClientListApprovedSchemasOptions contains the optional parameters for the Client.ListApprovedSchemas method. +func (client *Client) ListApprovedSchemas(ctx context.Context, pipeline ListApprovedSchemasRequest, options *ClientListApprovedSchemasOptions) (ClientListApprovedSchemasResponse, error) { + var err error + const operationName = "Client.ListApprovedSchemas" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listApprovedSchemasCreateRequest(ctx, pipeline, options) + if err != nil { + return ClientListApprovedSchemasResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientListApprovedSchemasResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientListApprovedSchemasResponse{}, err + } + resp, err := client.listApprovedSchemasHandleResponse(httpResp) + return resp, err +} + +// listApprovedSchemasCreateRequest creates the ListApprovedSchemas request. +func (client *Client) listApprovedSchemasCreateRequest(ctx context.Context, pipeline ListApprovedSchemasRequest, _ *ClientListApprovedSchemasOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AzureDataTransfer/listApprovedSchemas" + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, pipeline); err != nil { + return nil, err + } + return req, nil +} + +// listApprovedSchemasHandleResponse handles the ListApprovedSchemas response. +func (client *Client) listApprovedSchemasHandleResponse(resp *http.Response) (ClientListApprovedSchemasResponse, error) { + result := ClientListApprovedSchemasResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SchemasListResult); err != nil { + return ClientListApprovedSchemasResponse{}, err + } + return result, nil +} + +// ValidateSchema - Validates a schema for Azure Data Transfer. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - schema - The schema to validate +// - options - ClientValidateSchemaOptions contains the optional parameters for the Client.ValidateSchema method. +func (client *Client) ValidateSchema(ctx context.Context, schema Schema, options *ClientValidateSchemaOptions) (ClientValidateSchemaResponse, error) { + var err error + const operationName = "Client.ValidateSchema" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.validateSchemaCreateRequest(ctx, schema, options) + if err != nil { + return ClientValidateSchemaResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientValidateSchemaResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientValidateSchemaResponse{}, err + } + resp, err := client.validateSchemaHandleResponse(httpResp) + return resp, err +} + +// validateSchemaCreateRequest creates the ValidateSchema request. +func (client *Client) validateSchemaCreateRequest(ctx context.Context, schema Schema, _ *ClientValidateSchemaOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AzureDataTransfer/validateSchema" + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, schema); err != nil { + return nil, err + } + return req, nil +} + +// validateSchemaHandleResponse handles the ValidateSchema response. +func (client *Client) validateSchemaHandleResponse(resp *http.Response) (ClientValidateSchemaResponse, error) { + result := ClientValidateSchemaResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ValidateSchemaResult); err != nil { + return ClientValidateSchemaResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/client_factory.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/client_factory.go new file mode 100644 index 000000000000..ac4fb7b27761 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/client_factory.go @@ -0,0 +1,96 @@ +// 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 armazuredatatransfer + +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 + internal *arm.Client +} + +// 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. The value must be an UUID. +// - 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) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewClient creates a new instance of Client. +func (c *ClientFactory) NewClient() *Client { + return &Client{ + internal: c.internal, + } +} + +// NewConnectionsClient creates a new instance of ConnectionsClient. +func (c *ClientFactory) NewConnectionsClient() *ConnectionsClient { + return &ConnectionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewFlowsClient creates a new instance of FlowsClient. +func (c *ClientFactory) NewFlowsClient() *FlowsClient { + return &FlowsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewListPendingConnectionsClient creates a new instance of ListPendingConnectionsClient. +func (c *ClientFactory) NewListPendingConnectionsClient() *ListPendingConnectionsClient { + return &ListPendingConnectionsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewListPendingFlowsClient creates a new instance of ListPendingFlowsClient. +func (c *ClientFactory) NewListPendingFlowsClient() *ListPendingFlowsClient { + return &ListPendingFlowsClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewListSchemasClient creates a new instance of ListSchemasClient. +func (c *ClientFactory) NewListSchemasClient() *ListSchemasClient { + return &ListSchemasClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } +} + +// NewPipelinesClient creates a new instance of PipelinesClient. +func (c *ClientFactory) NewPipelinesClient() *PipelinesClient { + return &PipelinesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/connections_client.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/connections_client.go new file mode 100644 index 000000000000..26d36f5bdfdf --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/connections_client.go @@ -0,0 +1,537 @@ +// 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 armazuredatatransfer + +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" +) + +// ConnectionsClient contains the methods for the Connections group. +// Don't use this type directly, use NewConnectionsClient() instead. +type ConnectionsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewConnectionsClient creates a new instance of ConnectionsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ConnectionsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ConnectionsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates the connection resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - connection - Connection body +// - options - ConnectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the ConnectionsClient.BeginCreateOrUpdate +// method. +func (client *ConnectionsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, connectionName string, connection Connection, options *ConnectionsClientBeginCreateOrUpdateOptions) (*runtime.Poller[ConnectionsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, connectionName, connection, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConnectionsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ConnectionsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Creates or updates the connection resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *ConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, connectionName string, connection Connection, options *ConnectionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "ConnectionsClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, connectionName, connection, 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 +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ConnectionsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, connection Connection, _ *ConnectionsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, connection); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Deletes the connection resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - options - ConnectionsClientBeginDeleteOptions contains the optional parameters for the ConnectionsClient.BeginDelete method. +func (client *ConnectionsClient) BeginDelete(ctx context.Context, resourceGroupName string, connectionName string, options *ConnectionsClientBeginDeleteOptions) (*runtime.Poller[ConnectionsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, connectionName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConnectionsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ConnectionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes the connection resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *ConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, connectionName string, options *ConnectionsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "ConnectionsClient.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, connectionName, 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 *ConnectionsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, _ *ConnectionsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets connection resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - options - ConnectionsClientGetOptions contains the optional parameters for the ConnectionsClient.Get method. +func (client *ConnectionsClient) Get(ctx context.Context, resourceGroupName string, connectionName string, options *ConnectionsClientGetOptions) (ConnectionsClientGetResponse, error) { + var err error + const operationName = "ConnectionsClient.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, connectionName, options) + if err != nil { + return ConnectionsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ConnectionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ConnectionsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ConnectionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, _ *ConnectionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ConnectionsClient) getHandleResponse(resp *http.Response) (ConnectionsClientGetResponse, error) { + result := ConnectionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Connection); err != nil { + return ConnectionsClientGetResponse{}, err + } + return result, nil +} + +// BeginLink - Links the connection to its pending connection. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - connection - Connection body +// - options - ConnectionsClientBeginLinkOptions contains the optional parameters for the ConnectionsClient.BeginLink method. +func (client *ConnectionsClient) BeginLink(ctx context.Context, resourceGroupName string, connectionName string, connection ResourceBody, options *ConnectionsClientBeginLinkOptions) (*runtime.Poller[ConnectionsClientLinkResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.link(ctx, resourceGroupName, connectionName, connection, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConnectionsClientLinkResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ConnectionsClientLinkResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Link - Links the connection to its pending connection. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *ConnectionsClient) link(ctx context.Context, resourceGroupName string, connectionName string, connection ResourceBody, options *ConnectionsClientBeginLinkOptions) (*http.Response, error) { + var err error + const operationName = "ConnectionsClient.BeginLink" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.linkCreateRequest(ctx, resourceGroupName, connectionName, connection, 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 +} + +// linkCreateRequest creates the Link request. +func (client *ConnectionsClient) linkCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, connection ResourceBody, _ *ConnectionsClientBeginLinkOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/link" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, connection); err != nil { + return nil, err + } + return req, nil +} + +// NewListByResourceGroupPager - Gets connections in a resource group. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - ConnectionsClientListByResourceGroupOptions contains the optional parameters for the ConnectionsClient.NewListByResourceGroupPager +// method. +func (client *ConnectionsClient) NewListByResourceGroupPager(resourceGroupName string, options *ConnectionsClientListByResourceGroupOptions) *runtime.Pager[ConnectionsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ConnectionsClientListByResourceGroupResponse]{ + More: func(page ConnectionsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ConnectionsClientListByResourceGroupResponse) (ConnectionsClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ConnectionsClient.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 ConnectionsClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ConnectionsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *ConnectionsClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections" + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *ConnectionsClient) listByResourceGroupHandleResponse(resp *http.Response) (ConnectionsClientListByResourceGroupResponse, error) { + result := ConnectionsClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ConnectionsListResult); err != nil { + return ConnectionsClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Gets connections in a subscription. +// +// Generated from API version 2025-05-12 +// - options - ConnectionsClientListBySubscriptionOptions contains the optional parameters for the ConnectionsClient.NewListBySubscriptionPager +// method. +func (client *ConnectionsClient) NewListBySubscriptionPager(options *ConnectionsClientListBySubscriptionOptions) *runtime.Pager[ConnectionsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[ConnectionsClientListBySubscriptionResponse]{ + More: func(page ConnectionsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ConnectionsClientListBySubscriptionResponse) (ConnectionsClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ConnectionsClient.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 ConnectionsClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *ConnectionsClient) listBySubscriptionCreateRequest(ctx context.Context, _ *ConnectionsClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AzureDataTransfer/connections" + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *ConnectionsClient) listBySubscriptionHandleResponse(resp *http.Response) (ConnectionsClientListBySubscriptionResponse, error) { + result := ConnectionsClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ConnectionsListResult); err != nil { + return ConnectionsClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginUpdate - Updates the connection resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - connection - Connection body +// - options - ConnectionsClientBeginUpdateOptions contains the optional parameters for the ConnectionsClient.BeginUpdate method. +func (client *ConnectionsClient) BeginUpdate(ctx context.Context, resourceGroupName string, connectionName string, connection ConnectionsPatch, options *ConnectionsClientBeginUpdateOptions) (*runtime.Poller[ConnectionsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, connectionName, connection, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ConnectionsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ConnectionsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Updates the connection resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *ConnectionsClient) update(ctx context.Context, resourceGroupName string, connectionName string, connection ConnectionsPatch, options *ConnectionsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "ConnectionsClient.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, connectionName, connection, 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 *ConnectionsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, connection ConnectionsPatch, _ *ConnectionsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, connection); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/constants.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/constants.go new file mode 100644 index 000000000000..4f0917aa9348 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/constants.go @@ -0,0 +1,372 @@ +// 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 armazuredatatransfer + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer" + 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, + } +} + +// 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, + } +} + +// DataType - Type of data to transfer via the flow +type DataType string + +const ( + DataTypeBlob DataType = "Blob" + DataTypeTable DataType = "Table" +) + +// PossibleDataTypeValues returns the possible values for the DataType const type. +func PossibleDataTypeValues() []DataType { + return []DataType{ + DataTypeBlob, + DataTypeTable, + } +} + +// Direction - Direction of data movement +type Direction string + +const ( + DirectionReceive Direction = "Receive" + DirectionSend Direction = "Send" +) + +// PossibleDirectionValues returns the possible values for the Direction const type. +func PossibleDirectionValues() []Direction { + return []Direction{ + DirectionReceive, + DirectionSend, + } +} + +// FlowBillingTier - Billing tier for this messaging flow +type FlowBillingTier string + +const ( + FlowBillingTierBlobTransport FlowBillingTier = "BlobTransport" + FlowBillingTierPremium FlowBillingTier = "Premium" + FlowBillingTierStandard FlowBillingTier = "Standard" +) + +// PossibleFlowBillingTierValues returns the possible values for the FlowBillingTier const type. +func PossibleFlowBillingTierValues() []FlowBillingTier { + return []FlowBillingTier{ + FlowBillingTierBlobTransport, + FlowBillingTierPremium, + FlowBillingTierStandard, + } +} + +// FlowStatus - Status of the current flow +type FlowStatus string + +const ( + FlowStatusDisabled FlowStatus = "Disabled" + FlowStatusEnabled FlowStatus = "Enabled" +) + +// PossibleFlowStatusValues returns the possible values for the FlowStatus const type. +func PossibleFlowStatusValues() []FlowStatus { + return []FlowStatus{ + FlowStatusDisabled, + FlowStatusEnabled, + } +} + +// FlowType - Flow type for the specified resource +type FlowType string + +const ( + FlowTypeBasicFiles FlowType = "BasicFiles" + FlowTypeComplex FlowType = "Complex" + FlowTypeData FlowType = "Data" + FlowTypeDevSecOps FlowType = "DevSecOps" + FlowTypeMessaging FlowType = "Messaging" + FlowTypeMicrosoftInternal FlowType = "MicrosoftInternal" + FlowTypeMission FlowType = "Mission" + FlowTypeMissionOpaqueXML FlowType = "MissionOpaqueXML" + FlowTypeOpaque FlowType = "Opaque" + FlowTypeStandard FlowType = "Standard" + FlowTypeStreamingVideo FlowType = "StreamingVideo" + FlowTypeUnknown FlowType = "Unknown" +) + +// PossibleFlowTypeValues returns the possible values for the FlowType const type. +func PossibleFlowTypeValues() []FlowType { + return []FlowType{ + FlowTypeBasicFiles, + FlowTypeComplex, + FlowTypeData, + FlowTypeDevSecOps, + FlowTypeMessaging, + FlowTypeMicrosoftInternal, + FlowTypeMission, + FlowTypeMissionOpaqueXML, + FlowTypeOpaque, + FlowTypeStandard, + FlowTypeStreamingVideo, + FlowTypeUnknown, + } +} + +// LinkStatus - Link status of the current connection +type LinkStatus string + +const ( + LinkStatusLinked LinkStatus = "Linked" + LinkStatusUnlinked LinkStatus = "Unlinked" +) + +// PossibleLinkStatusValues returns the possible values for the LinkStatus const type. +func PossibleLinkStatusValues() []LinkStatus { + return []LinkStatus{ + LinkStatusLinked, + LinkStatusUnlinked, + } +} + +// LinkStatusFlow - Link status of the current flow +type LinkStatusFlow string + +const ( + LinkStatusFlowLinked LinkStatusFlow = "Linked" + LinkStatusFlowUnlinked LinkStatusFlow = "Unlinked" +) + +// PossibleLinkStatusFlowValues returns the possible values for the LinkStatusFlow const type. +func PossibleLinkStatusFlowValues() []LinkStatusFlow { + return []LinkStatusFlow{ + LinkStatusFlowLinked, + LinkStatusFlowUnlinked, + } +} + +// ListApprovedSchemasDirection - The direction pipeline to filter approved schemas. +type ListApprovedSchemasDirection string + +const ( + ListApprovedSchemasDirectionReceive ListApprovedSchemasDirection = "Receive" + ListApprovedSchemasDirectionSend ListApprovedSchemasDirection = "Send" +) + +// PossibleListApprovedSchemasDirectionValues returns the possible values for the ListApprovedSchemasDirection const type. +func PossibleListApprovedSchemasDirectionValues() []ListApprovedSchemasDirection { + return []ListApprovedSchemasDirection{ + ListApprovedSchemasDirectionReceive, + ListApprovedSchemasDirectionSend, + } +} + +// 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, + } +} + +// OperationStatusEnum - Operation status for the last patch request for this connection. +type OperationStatusEnum string + +const ( + OperationStatusEnumFailed OperationStatusEnum = "Failed" + OperationStatusEnumSucceeded OperationStatusEnum = "Succeeded" +) + +// PossibleOperationStatusEnumValues returns the possible values for the OperationStatusEnum const type. +func PossibleOperationStatusEnumValues() []OperationStatusEnum { + return []OperationStatusEnum{ + OperationStatusEnumFailed, + OperationStatusEnumSucceeded, + } +} + +// 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 - Provisioning state of the flow +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateFailed, + ProvisioningStateSucceeded, + } +} + +// SchemaDirection - The direction of the schema. +type SchemaDirection string + +const ( + SchemaDirectionReceive SchemaDirection = "Receive" + SchemaDirectionSend SchemaDirection = "Send" +) + +// PossibleSchemaDirectionValues returns the possible values for the SchemaDirection const type. +func PossibleSchemaDirectionValues() []SchemaDirection { + return []SchemaDirection{ + SchemaDirectionReceive, + SchemaDirectionSend, + } +} + +// SchemaStatus - Status of the schema +type SchemaStatus string + +const ( + SchemaStatusApproved SchemaStatus = "Approved" + SchemaStatusNew SchemaStatus = "New" +) + +// PossibleSchemaStatusValues returns the possible values for the SchemaStatus const type. +func PossibleSchemaStatusValues() []SchemaStatus { + return []SchemaStatus{ + SchemaStatusApproved, + SchemaStatusNew, + } +} + +// SchemaType - The Schema Type +type SchemaType string + +const ( + SchemaTypeXsd SchemaType = "Xsd" + SchemaTypeZip SchemaType = "Zip" +) + +// PossibleSchemaTypeValues returns the possible values for the SchemaType const type. +func PossibleSchemaTypeValues() []SchemaType { + return []SchemaType{ + SchemaTypeXsd, + SchemaTypeZip, + } +} + +// Status - Status of the connection +type Status string + +const ( + StatusAccepted Status = "Accepted" + StatusApproved Status = "Approved" + StatusInReview Status = "InReview" + StatusRejected Status = "Rejected" +) + +// PossibleStatusValues returns the possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{ + StatusAccepted, + StatusApproved, + StatusInReview, + StatusRejected, + } +} + +// StreamProtocol - The protocol of the stream +type StreamProtocol string + +const ( + StreamProtocolRTP StreamProtocol = "RTP" + StreamProtocolSRT StreamProtocol = "SRT" + StreamProtocolUDP StreamProtocol = "UDP" +) + +// PossibleStreamProtocolValues returns the possible values for the StreamProtocol const type. +func PossibleStreamProtocolValues() []StreamProtocol { + return []StreamProtocol{ + StreamProtocolRTP, + StreamProtocolSRT, + StreamProtocolUDP, + } +} + +// ValidateSchemaStatus - Validation status of the schema +type ValidateSchemaStatus string + +const ( + ValidateSchemaStatusFailed ValidateSchemaStatus = "Failed" + ValidateSchemaStatusSucceeded ValidateSchemaStatus = "Succeeded" +) + +// PossibleValidateSchemaStatusValues returns the possible values for the ValidateSchemaStatus const type. +func PossibleValidateSchemaStatusValues() []ValidateSchemaStatus { + return []ValidateSchemaStatus{ + ValidateSchemaStatusFailed, + ValidateSchemaStatusSucceeded, + } +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/connections_server.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/connections_server.go new file mode 100644 index 000000000000..e3fa5b77b573 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/connections_server.go @@ -0,0 +1,431 @@ +// 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/azuredatatransfer/armazuredatatransfer" + "net/http" + "net/url" + "regexp" +) + +// ConnectionsServer is a fake server for instances of the armazuredatatransfer.ConnectionsClient type. +type ConnectionsServer struct { + // BeginCreateOrUpdate is the fake for method ConnectionsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, connectionName string, connection armazuredatatransfer.Connection, options *armazuredatatransfer.ConnectionsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armazuredatatransfer.ConnectionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ConnectionsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, connectionName string, options *armazuredatatransfer.ConnectionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armazuredatatransfer.ConnectionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ConnectionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, connectionName string, options *armazuredatatransfer.ConnectionsClientGetOptions) (resp azfake.Responder[armazuredatatransfer.ConnectionsClientGetResponse], errResp azfake.ErrorResponder) + + // BeginLink is the fake for method ConnectionsClient.BeginLink + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginLink func(ctx context.Context, resourceGroupName string, connectionName string, connection armazuredatatransfer.ResourceBody, options *armazuredatatransfer.ConnectionsClientBeginLinkOptions) (resp azfake.PollerResponder[armazuredatatransfer.ConnectionsClientLinkResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method ConnectionsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armazuredatatransfer.ConnectionsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armazuredatatransfer.ConnectionsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method ConnectionsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armazuredatatransfer.ConnectionsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armazuredatatransfer.ConnectionsClientListBySubscriptionResponse]) + + // BeginUpdate is the fake for method ConnectionsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, connectionName string, connection armazuredatatransfer.ConnectionsPatch, options *armazuredatatransfer.ConnectionsClientBeginUpdateOptions) (resp azfake.PollerResponder[armazuredatatransfer.ConnectionsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewConnectionsServerTransport creates a new instance of ConnectionsServerTransport with the provided implementation. +// The returned ConnectionsServerTransport instance is connected to an instance of armazuredatatransfer.ConnectionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewConnectionsServerTransport(srv *ConnectionsServer) *ConnectionsServerTransport { + return &ConnectionsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armazuredatatransfer.ConnectionsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armazuredatatransfer.ConnectionsClientDeleteResponse]](), + beginLink: newTracker[azfake.PollerResponder[armazuredatatransfer.ConnectionsClientLinkResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armazuredatatransfer.ConnectionsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armazuredatatransfer.ConnectionsClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armazuredatatransfer.ConnectionsClientUpdateResponse]](), + } +} + +// ConnectionsServerTransport connects instances of armazuredatatransfer.ConnectionsClient to instances of ConnectionsServer. +// Don't use this type directly, use NewConnectionsServerTransport instead. +type ConnectionsServerTransport struct { + srv *ConnectionsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armazuredatatransfer.ConnectionsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armazuredatatransfer.ConnectionsClientDeleteResponse]] + beginLink *tracker[azfake.PollerResponder[armazuredatatransfer.ConnectionsClientLinkResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armazuredatatransfer.ConnectionsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armazuredatatransfer.ConnectionsClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armazuredatatransfer.ConnectionsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for ConnectionsServerTransport. +func (c *ConnectionsServerTransport) 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")} + } + + return c.dispatchToMethodFake(req, method) +} + +func (c *ConnectionsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if connectionsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = connectionsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ConnectionsClient.BeginCreateOrUpdate": + res.resp, res.err = c.dispatchBeginCreateOrUpdate(req) + case "ConnectionsClient.BeginDelete": + res.resp, res.err = c.dispatchBeginDelete(req) + case "ConnectionsClient.Get": + res.resp, res.err = c.dispatchGet(req) + case "ConnectionsClient.BeginLink": + res.resp, res.err = c.dispatchBeginLink(req) + case "ConnectionsClient.NewListByResourceGroupPager": + res.resp, res.err = c.dispatchNewListByResourceGroupPager(req) + case "ConnectionsClient.NewListBySubscriptionPager": + res.resp, res.err = c.dispatchNewListBySubscriptionPager(req) + case "ConnectionsClient.BeginUpdate": + res.resp, res.err = c.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (c *ConnectionsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if c.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := c.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?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[armazuredatatransfer.Connection](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, connectionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + c.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + c.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + c.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (c *ConnectionsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if c.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := c.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?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 + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginDelete(req.Context(), resourceGroupNameParam, connectionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + c.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + c.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + c.beginDelete.remove(req) + } + + return resp, nil +} + +func (c *ConnectionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.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\.AzureDataTransfer/connections/(?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 + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, connectionNameParam, 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).Connection, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *ConnectionsServerTransport) dispatchBeginLink(req *http.Request) (*http.Response, error) { + if c.srv.BeginLink == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginLink not implemented")} + } + beginLink := c.beginLink.get(req) + if beginLink == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/link` + 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[armazuredatatransfer.ResourceBody](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginLink(req.Context(), resourceGroupNameParam, connectionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginLink = &respr + c.beginLink.add(req, beginLink) + } + + resp, err := server.PollerResponderNext(beginLink, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + c.beginLink.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginLink) { + c.beginLink.remove(req) + } + + return resp, nil +} + +func (c *ConnectionsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := c.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections` + 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 := c.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + c.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armazuredatatransfer.ConnectionsClientListByResourceGroupResponse, 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) { + c.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + c.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (c *ConnectionsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := c.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections` + 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 := c.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + c.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armazuredatatransfer.ConnectionsClientListBySubscriptionResponse, 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) { + c.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + c.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (c *ConnectionsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if c.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := c.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?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[armazuredatatransfer.ConnectionsPatch](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginUpdate(req.Context(), resourceGroupNameParam, connectionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + c.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) { + c.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) { + c.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to ConnectionsServerTransport +var connectionsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/flows_server.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/flows_server.go new file mode 100644 index 000000000000..2c5a70e562ad --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/flows_server.go @@ -0,0 +1,994 @@ +// 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/azuredatatransfer/armazuredatatransfer" + "net/http" + "net/url" + "regexp" +) + +// FlowsServer is a fake server for instances of the armazuredatatransfer.FlowsClient type. +type FlowsServer struct { + // BeginCreateOrUpdate is the fake for method FlowsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, flow armazuredatatransfer.Flow, options *armazuredatatransfer.FlowsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armazuredatatransfer.FlowsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method FlowsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *armazuredatatransfer.FlowsClientBeginDeleteOptions) (resp azfake.PollerResponder[armazuredatatransfer.FlowsClientDeleteResponse], errResp azfake.ErrorResponder) + + // BeginDisable is the fake for method FlowsClient.BeginDisable + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginDisable func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *armazuredatatransfer.FlowsClientBeginDisableOptions) (resp azfake.PollerResponder[armazuredatatransfer.FlowsClientDisableResponse], errResp azfake.ErrorResponder) + + // BeginEnable is the fake for method FlowsClient.BeginEnable + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginEnable func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *armazuredatatransfer.FlowsClientBeginEnableOptions) (resp azfake.PollerResponder[armazuredatatransfer.FlowsClientEnableResponse], errResp azfake.ErrorResponder) + + // BeginGeneratePassphrase is the fake for method FlowsClient.BeginGeneratePassphrase + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginGeneratePassphrase func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *armazuredatatransfer.FlowsClientBeginGeneratePassphraseOptions) (resp azfake.PollerResponder[armazuredatatransfer.FlowsClientGeneratePassphraseResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method FlowsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *armazuredatatransfer.FlowsClientGetOptions) (resp azfake.Responder[armazuredatatransfer.FlowsClientGetResponse], errResp azfake.ErrorResponder) + + // GetDestinationEndpointPorts is the fake for method FlowsClient.GetDestinationEndpointPorts + // HTTP status codes to indicate success: http.StatusOK + GetDestinationEndpointPorts func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *armazuredatatransfer.FlowsClientGetDestinationEndpointPortsOptions) (resp azfake.Responder[armazuredatatransfer.FlowsClientGetDestinationEndpointPortsResponse], errResp azfake.ErrorResponder) + + // GetDestinationEndpoints is the fake for method FlowsClient.GetDestinationEndpoints + // HTTP status codes to indicate success: http.StatusOK + GetDestinationEndpoints func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *armazuredatatransfer.FlowsClientGetDestinationEndpointsOptions) (resp azfake.Responder[armazuredatatransfer.FlowsClientGetDestinationEndpointsResponse], errResp azfake.ErrorResponder) + + // GetSourceAddresses is the fake for method FlowsClient.GetSourceAddresses + // HTTP status codes to indicate success: http.StatusOK + GetSourceAddresses func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *armazuredatatransfer.FlowsClientGetSourceAddressesOptions) (resp azfake.Responder[armazuredatatransfer.FlowsClientGetSourceAddressesResponse], errResp azfake.ErrorResponder) + + // GetStreamConnectionString is the fake for method FlowsClient.GetStreamConnectionString + // HTTP status codes to indicate success: http.StatusOK + GetStreamConnectionString func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *armazuredatatransfer.FlowsClientGetStreamConnectionStringOptions) (resp azfake.Responder[armazuredatatransfer.FlowsClientGetStreamConnectionStringResponse], errResp azfake.ErrorResponder) + + // BeginLink is the fake for method FlowsClient.BeginLink + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginLink func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, flow armazuredatatransfer.ResourceBody, options *armazuredatatransfer.FlowsClientBeginLinkOptions) (resp azfake.PollerResponder[armazuredatatransfer.FlowsClientLinkResponse], errResp azfake.ErrorResponder) + + // NewListByConnectionPager is the fake for method FlowsClient.NewListByConnectionPager + // HTTP status codes to indicate success: http.StatusOK + NewListByConnectionPager func(resourceGroupName string, connectionName string, options *armazuredatatransfer.FlowsClientListByConnectionOptions) (resp azfake.PagerResponder[armazuredatatransfer.FlowsClientListByConnectionResponse]) + + // BeginSetDestinationEndpointPorts is the fake for method FlowsClient.BeginSetDestinationEndpointPorts + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginSetDestinationEndpointPorts func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, streamDestinationEndpointPorts armazuredatatransfer.SetDestinationEndpointPorts, options *armazuredatatransfer.FlowsClientBeginSetDestinationEndpointPortsOptions) (resp azfake.PollerResponder[armazuredatatransfer.FlowsClientSetDestinationEndpointPortsResponse], errResp azfake.ErrorResponder) + + // BeginSetDestinationEndpoints is the fake for method FlowsClient.BeginSetDestinationEndpoints + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginSetDestinationEndpoints func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, streamDestinationEndpoints armazuredatatransfer.SetDestinationEndpoints, options *armazuredatatransfer.FlowsClientBeginSetDestinationEndpointsOptions) (resp azfake.PollerResponder[armazuredatatransfer.FlowsClientSetDestinationEndpointsResponse], errResp azfake.ErrorResponder) + + // BeginSetPassphrase is the fake for method FlowsClient.BeginSetPassphrase + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginSetPassphrase func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, passphrase armazuredatatransfer.SetStreamPassphrase, options *armazuredatatransfer.FlowsClientBeginSetPassphraseOptions) (resp azfake.PollerResponder[armazuredatatransfer.FlowsClientSetPassphraseResponse], errResp azfake.ErrorResponder) + + // BeginSetSourceAddresses is the fake for method FlowsClient.BeginSetSourceAddresses + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginSetSourceAddresses func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, sourceAddresses armazuredatatransfer.SetSourceAddresses, options *armazuredatatransfer.FlowsClientBeginSetSourceAddressesOptions) (resp azfake.PollerResponder[armazuredatatransfer.FlowsClientSetSourceAddressesResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method FlowsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, connectionName string, flowName string, flow armazuredatatransfer.FlowsPatch, options *armazuredatatransfer.FlowsClientBeginUpdateOptions) (resp azfake.PollerResponder[armazuredatatransfer.FlowsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewFlowsServerTransport creates a new instance of FlowsServerTransport with the provided implementation. +// The returned FlowsServerTransport instance is connected to an instance of armazuredatatransfer.FlowsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewFlowsServerTransport(srv *FlowsServer) *FlowsServerTransport { + return &FlowsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientDeleteResponse]](), + beginDisable: newTracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientDisableResponse]](), + beginEnable: newTracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientEnableResponse]](), + beginGeneratePassphrase: newTracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientGeneratePassphraseResponse]](), + beginLink: newTracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientLinkResponse]](), + newListByConnectionPager: newTracker[azfake.PagerResponder[armazuredatatransfer.FlowsClientListByConnectionResponse]](), + beginSetDestinationEndpointPorts: newTracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientSetDestinationEndpointPortsResponse]](), + beginSetDestinationEndpoints: newTracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientSetDestinationEndpointsResponse]](), + beginSetPassphrase: newTracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientSetPassphraseResponse]](), + beginSetSourceAddresses: newTracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientSetSourceAddressesResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientUpdateResponse]](), + } +} + +// FlowsServerTransport connects instances of armazuredatatransfer.FlowsClient to instances of FlowsServer. +// Don't use this type directly, use NewFlowsServerTransport instead. +type FlowsServerTransport struct { + srv *FlowsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientDeleteResponse]] + beginDisable *tracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientDisableResponse]] + beginEnable *tracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientEnableResponse]] + beginGeneratePassphrase *tracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientGeneratePassphraseResponse]] + beginLink *tracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientLinkResponse]] + newListByConnectionPager *tracker[azfake.PagerResponder[armazuredatatransfer.FlowsClientListByConnectionResponse]] + beginSetDestinationEndpointPorts *tracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientSetDestinationEndpointPortsResponse]] + beginSetDestinationEndpoints *tracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientSetDestinationEndpointsResponse]] + beginSetPassphrase *tracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientSetPassphraseResponse]] + beginSetSourceAddresses *tracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientSetSourceAddressesResponse]] + beginUpdate *tracker[azfake.PollerResponder[armazuredatatransfer.FlowsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for FlowsServerTransport. +func (f *FlowsServerTransport) 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")} + } + + return f.dispatchToMethodFake(req, method) +} + +func (f *FlowsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if flowsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = flowsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "FlowsClient.BeginCreateOrUpdate": + res.resp, res.err = f.dispatchBeginCreateOrUpdate(req) + case "FlowsClient.BeginDelete": + res.resp, res.err = f.dispatchBeginDelete(req) + case "FlowsClient.BeginDisable": + res.resp, res.err = f.dispatchBeginDisable(req) + case "FlowsClient.BeginEnable": + res.resp, res.err = f.dispatchBeginEnable(req) + case "FlowsClient.BeginGeneratePassphrase": + res.resp, res.err = f.dispatchBeginGeneratePassphrase(req) + case "FlowsClient.Get": + res.resp, res.err = f.dispatchGet(req) + case "FlowsClient.GetDestinationEndpointPorts": + res.resp, res.err = f.dispatchGetDestinationEndpointPorts(req) + case "FlowsClient.GetDestinationEndpoints": + res.resp, res.err = f.dispatchGetDestinationEndpoints(req) + case "FlowsClient.GetSourceAddresses": + res.resp, res.err = f.dispatchGetSourceAddresses(req) + case "FlowsClient.GetStreamConnectionString": + res.resp, res.err = f.dispatchGetStreamConnectionString(req) + case "FlowsClient.BeginLink": + res.resp, res.err = f.dispatchBeginLink(req) + case "FlowsClient.NewListByConnectionPager": + res.resp, res.err = f.dispatchNewListByConnectionPager(req) + case "FlowsClient.BeginSetDestinationEndpointPorts": + res.resp, res.err = f.dispatchBeginSetDestinationEndpointPorts(req) + case "FlowsClient.BeginSetDestinationEndpoints": + res.resp, res.err = f.dispatchBeginSetDestinationEndpoints(req) + case "FlowsClient.BeginSetPassphrase": + res.resp, res.err = f.dispatchBeginSetPassphrase(req) + case "FlowsClient.BeginSetSourceAddresses": + res.resp, res.err = f.dispatchBeginSetSourceAddresses(req) + case "FlowsClient.BeginUpdate": + res.resp, res.err = f.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (f *FlowsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if f.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := f.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?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[armazuredatatransfer.Flow](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + f.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + f.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + f.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (f *FlowsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if f.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := f.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?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 + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginDelete(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + f.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + f.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + f.beginDelete.remove(req) + } + + return resp, nil +} + +func (f *FlowsServerTransport) dispatchBeginDisable(req *http.Request) (*http.Response, error) { + if f.srv.BeginDisable == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDisable not implemented")} + } + beginDisable := f.beginDisable.get(req) + if beginDisable == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/disable` + 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 + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginDisable(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDisable = &respr + f.beginDisable.add(req, beginDisable) + } + + resp, err := server.PollerResponderNext(beginDisable, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + f.beginDisable.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDisable) { + f.beginDisable.remove(req) + } + + return resp, nil +} + +func (f *FlowsServerTransport) dispatchBeginEnable(req *http.Request) (*http.Response, error) { + if f.srv.BeginEnable == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginEnable not implemented")} + } + beginEnable := f.beginEnable.get(req) + if beginEnable == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enable` + 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 + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginEnable(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginEnable = &respr + f.beginEnable.add(req, beginEnable) + } + + resp, err := server.PollerResponderNext(beginEnable, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + f.beginEnable.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginEnable) { + f.beginEnable.remove(req) + } + + return resp, nil +} + +func (f *FlowsServerTransport) dispatchBeginGeneratePassphrase(req *http.Request) (*http.Response, error) { + if f.srv.BeginGeneratePassphrase == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginGeneratePassphrase not implemented")} + } + beginGeneratePassphrase := f.beginGeneratePassphrase.get(req) + if beginGeneratePassphrase == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/generatePassphrase` + 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 + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginGeneratePassphrase(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginGeneratePassphrase = &respr + f.beginGeneratePassphrase.add(req, beginGeneratePassphrase) + } + + resp, err := server.PollerResponderNext(beginGeneratePassphrase, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + f.beginGeneratePassphrase.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginGeneratePassphrase) { + f.beginGeneratePassphrase.remove(req) + } + + return resp, nil +} + +func (f *FlowsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if f.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\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?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 + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.Get(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, 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).Flow, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FlowsServerTransport) dispatchGetDestinationEndpointPorts(req *http.Request) (*http.Response, error) { + if f.srv.GetDestinationEndpointPorts == nil { + return nil, &nonRetriableError{errors.New("fake for method GetDestinationEndpointPorts not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getDestinationEndpointPorts` + 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 + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.GetDestinationEndpointPorts(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, 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).GetDestinationEndpointPortsResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FlowsServerTransport) dispatchGetDestinationEndpoints(req *http.Request) (*http.Response, error) { + if f.srv.GetDestinationEndpoints == nil { + return nil, &nonRetriableError{errors.New("fake for method GetDestinationEndpoints not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getDestinationEndpoints` + 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 + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.GetDestinationEndpoints(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, 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).GetDestinationEndpointsResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FlowsServerTransport) dispatchGetSourceAddresses(req *http.Request) (*http.Response, error) { + if f.srv.GetSourceAddresses == nil { + return nil, &nonRetriableError{errors.New("fake for method GetSourceAddresses not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getSourceAddresses` + 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 + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.GetSourceAddresses(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, 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).StreamSourceAddresses, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FlowsServerTransport) dispatchGetStreamConnectionString(req *http.Request) (*http.Response, error) { + if f.srv.GetStreamConnectionString == nil { + return nil, &nonRetriableError{errors.New("fake for method GetStreamConnectionString not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getStreamConnectionString` + 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 + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.GetStreamConnectionString(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, 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).GetStreamConnectionStringResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FlowsServerTransport) dispatchBeginLink(req *http.Request) (*http.Response, error) { + if f.srv.BeginLink == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginLink not implemented")} + } + beginLink := f.beginLink.get(req) + if beginLink == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/link` + 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[armazuredatatransfer.ResourceBody](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginLink(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginLink = &respr + f.beginLink.add(req, beginLink) + } + + resp, err := server.PollerResponderNext(beginLink, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + f.beginLink.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginLink) { + f.beginLink.remove(req) + } + + return resp, nil +} + +func (f *FlowsServerTransport) dispatchNewListByConnectionPager(req *http.Request) (*http.Response, error) { + if f.srv.NewListByConnectionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByConnectionPager not implemented")} + } + newListByConnectionPager := f.newListByConnectionPager.get(req) + if newListByConnectionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows` + 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 + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + resp := f.srv.NewListByConnectionPager(resourceGroupNameParam, connectionNameParam, nil) + newListByConnectionPager = &resp + f.newListByConnectionPager.add(req, newListByConnectionPager) + server.PagerResponderInjectNextLinks(newListByConnectionPager, req, func(page *armazuredatatransfer.FlowsClientListByConnectionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByConnectionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + f.newListByConnectionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByConnectionPager) { + f.newListByConnectionPager.remove(req) + } + return resp, nil +} + +func (f *FlowsServerTransport) dispatchBeginSetDestinationEndpointPorts(req *http.Request) (*http.Response, error) { + if f.srv.BeginSetDestinationEndpointPorts == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginSetDestinationEndpointPorts not implemented")} + } + beginSetDestinationEndpointPorts := f.beginSetDestinationEndpointPorts.get(req) + if beginSetDestinationEndpointPorts == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/setDestinationEndpointPorts` + 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[armazuredatatransfer.SetDestinationEndpointPorts](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginSetDestinationEndpointPorts(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginSetDestinationEndpointPorts = &respr + f.beginSetDestinationEndpointPorts.add(req, beginSetDestinationEndpointPorts) + } + + resp, err := server.PollerResponderNext(beginSetDestinationEndpointPorts, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + f.beginSetDestinationEndpointPorts.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginSetDestinationEndpointPorts) { + f.beginSetDestinationEndpointPorts.remove(req) + } + + return resp, nil +} + +func (f *FlowsServerTransport) dispatchBeginSetDestinationEndpoints(req *http.Request) (*http.Response, error) { + if f.srv.BeginSetDestinationEndpoints == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginSetDestinationEndpoints not implemented")} + } + beginSetDestinationEndpoints := f.beginSetDestinationEndpoints.get(req) + if beginSetDestinationEndpoints == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/setDestinationEndpoints` + 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[armazuredatatransfer.SetDestinationEndpoints](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginSetDestinationEndpoints(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginSetDestinationEndpoints = &respr + f.beginSetDestinationEndpoints.add(req, beginSetDestinationEndpoints) + } + + resp, err := server.PollerResponderNext(beginSetDestinationEndpoints, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + f.beginSetDestinationEndpoints.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginSetDestinationEndpoints) { + f.beginSetDestinationEndpoints.remove(req) + } + + return resp, nil +} + +func (f *FlowsServerTransport) dispatchBeginSetPassphrase(req *http.Request) (*http.Response, error) { + if f.srv.BeginSetPassphrase == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginSetPassphrase not implemented")} + } + beginSetPassphrase := f.beginSetPassphrase.get(req) + if beginSetPassphrase == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/setPassphrase` + 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[armazuredatatransfer.SetStreamPassphrase](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginSetPassphrase(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginSetPassphrase = &respr + f.beginSetPassphrase.add(req, beginSetPassphrase) + } + + resp, err := server.PollerResponderNext(beginSetPassphrase, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + f.beginSetPassphrase.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginSetPassphrase) { + f.beginSetPassphrase.remove(req) + } + + return resp, nil +} + +func (f *FlowsServerTransport) dispatchBeginSetSourceAddresses(req *http.Request) (*http.Response, error) { + if f.srv.BeginSetSourceAddresses == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginSetSourceAddresses not implemented")} + } + beginSetSourceAddresses := f.beginSetSourceAddresses.get(req) + if beginSetSourceAddresses == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/setSourceAddresses` + 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[armazuredatatransfer.SetSourceAddresses](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginSetSourceAddresses(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginSetSourceAddresses = &respr + f.beginSetSourceAddresses.add(req, beginSetSourceAddresses) + } + + resp, err := server.PollerResponderNext(beginSetSourceAddresses, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + f.beginSetSourceAddresses.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginSetSourceAddresses) { + f.beginSetSourceAddresses.remove(req) + } + + return resp, nil +} + +func (f *FlowsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if f.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := f.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/flows/(?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[armazuredatatransfer.FlowsPatch](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + flowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("flowName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginUpdate(req.Context(), resourceGroupNameParam, connectionNameParam, flowNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + f.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) { + f.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) { + f.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to FlowsServerTransport +var flowsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/internal.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/internal.go new file mode 100644 index 000000000000..4b65adc76adb --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/internal.go @@ -0,0 +1,66 @@ +// 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 result struct { + resp *http.Response + err error +} + +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/azuredatatransfer/armazuredatatransfer/fake/listpendingconnections_server.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/listpendingconnections_server.go new file mode 100644 index 000000000000..bd16ff6a8d76 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/listpendingconnections_server.go @@ -0,0 +1,134 @@ +// 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/azuredatatransfer/armazuredatatransfer" + "net/http" + "net/url" + "regexp" +) + +// ListPendingConnectionsServer is a fake server for instances of the armazuredatatransfer.ListPendingConnectionsClient type. +type ListPendingConnectionsServer struct { + // NewListPager is the fake for method ListPendingConnectionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, connectionName string, options *armazuredatatransfer.ListPendingConnectionsClientListOptions) (resp azfake.PagerResponder[armazuredatatransfer.ListPendingConnectionsClientListResponse]) +} + +// NewListPendingConnectionsServerTransport creates a new instance of ListPendingConnectionsServerTransport with the provided implementation. +// The returned ListPendingConnectionsServerTransport instance is connected to an instance of armazuredatatransfer.ListPendingConnectionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewListPendingConnectionsServerTransport(srv *ListPendingConnectionsServer) *ListPendingConnectionsServerTransport { + return &ListPendingConnectionsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armazuredatatransfer.ListPendingConnectionsClientListResponse]](), + } +} + +// ListPendingConnectionsServerTransport connects instances of armazuredatatransfer.ListPendingConnectionsClient to instances of ListPendingConnectionsServer. +// Don't use this type directly, use NewListPendingConnectionsServerTransport instead. +type ListPendingConnectionsServerTransport struct { + srv *ListPendingConnectionsServer + newListPager *tracker[azfake.PagerResponder[armazuredatatransfer.ListPendingConnectionsClientListResponse]] +} + +// Do implements the policy.Transporter interface for ListPendingConnectionsServerTransport. +func (l *ListPendingConnectionsServerTransport) 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")} + } + + return l.dispatchToMethodFake(req, method) +} + +func (l *ListPendingConnectionsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if listPendingConnectionsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = listPendingConnectionsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ListPendingConnectionsClient.NewListPager": + res.resp, res.err = l.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (l *ListPendingConnectionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if l.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := l.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listPendingConnections` + 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 + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + resp := l.srv.NewListPager(resourceGroupNameParam, connectionNameParam, nil) + newListPager = &resp + l.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armazuredatatransfer.ListPendingConnectionsClientListResponse, 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) { + l.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + l.newListPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to ListPendingConnectionsServerTransport +var listPendingConnectionsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/listpendingflows_server.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/listpendingflows_server.go new file mode 100644 index 000000000000..b0939fc83c48 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/listpendingflows_server.go @@ -0,0 +1,134 @@ +// 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/azuredatatransfer/armazuredatatransfer" + "net/http" + "net/url" + "regexp" +) + +// ListPendingFlowsServer is a fake server for instances of the armazuredatatransfer.ListPendingFlowsClient type. +type ListPendingFlowsServer struct { + // NewListPager is the fake for method ListPendingFlowsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, connectionName string, options *armazuredatatransfer.ListPendingFlowsClientListOptions) (resp azfake.PagerResponder[armazuredatatransfer.ListPendingFlowsClientListResponse]) +} + +// NewListPendingFlowsServerTransport creates a new instance of ListPendingFlowsServerTransport with the provided implementation. +// The returned ListPendingFlowsServerTransport instance is connected to an instance of armazuredatatransfer.ListPendingFlowsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewListPendingFlowsServerTransport(srv *ListPendingFlowsServer) *ListPendingFlowsServerTransport { + return &ListPendingFlowsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armazuredatatransfer.ListPendingFlowsClientListResponse]](), + } +} + +// ListPendingFlowsServerTransport connects instances of armazuredatatransfer.ListPendingFlowsClient to instances of ListPendingFlowsServer. +// Don't use this type directly, use NewListPendingFlowsServerTransport instead. +type ListPendingFlowsServerTransport struct { + srv *ListPendingFlowsServer + newListPager *tracker[azfake.PagerResponder[armazuredatatransfer.ListPendingFlowsClientListResponse]] +} + +// Do implements the policy.Transporter interface for ListPendingFlowsServerTransport. +func (l *ListPendingFlowsServerTransport) 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")} + } + + return l.dispatchToMethodFake(req, method) +} + +func (l *ListPendingFlowsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if listPendingFlowsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = listPendingFlowsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ListPendingFlowsClient.NewListPager": + res.resp, res.err = l.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (l *ListPendingFlowsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if l.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := l.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/connections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listPendingFlows` + 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 + } + connectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("connectionName")]) + if err != nil { + return nil, err + } + resp := l.srv.NewListPager(resourceGroupNameParam, connectionNameParam, nil) + newListPager = &resp + l.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armazuredatatransfer.ListPendingFlowsClientListResponse, 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) { + l.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + l.newListPager.remove(req) + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to ListPendingFlowsServerTransport +var listPendingFlowsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/listschemas_server.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/listschemas_server.go new file mode 100644 index 000000000000..81a492174c9a --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/listschemas_server.go @@ -0,0 +1,126 @@ +// 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/resourcemanager/azuredatatransfer/armazuredatatransfer" + "net/http" + "net/url" + "regexp" +) + +// ListSchemasServer is a fake server for instances of the armazuredatatransfer.ListSchemasClient type. +type ListSchemasServer struct { + // List is the fake for method ListSchemasClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, resourceGroupName string, pipelineName string, schema armazuredatatransfer.Schema, options *armazuredatatransfer.ListSchemasClientListOptions) (resp azfake.Responder[armazuredatatransfer.ListSchemasClientListResponse], errResp azfake.ErrorResponder) +} + +// NewListSchemasServerTransport creates a new instance of ListSchemasServerTransport with the provided implementation. +// The returned ListSchemasServerTransport instance is connected to an instance of armazuredatatransfer.ListSchemasClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewListSchemasServerTransport(srv *ListSchemasServer) *ListSchemasServerTransport { + return &ListSchemasServerTransport{srv: srv} +} + +// ListSchemasServerTransport connects instances of armazuredatatransfer.ListSchemasClient to instances of ListSchemasServer. +// Don't use this type directly, use NewListSchemasServerTransport instead. +type ListSchemasServerTransport struct { + srv *ListSchemasServer +} + +// Do implements the policy.Transporter interface for ListSchemasServerTransport. +func (l *ListSchemasServerTransport) 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")} + } + + return l.dispatchToMethodFake(req, method) +} + +func (l *ListSchemasServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if listSchemasServerTransportInterceptor != nil { + res.resp, res.err, intercepted = listSchemasServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "ListSchemasClient.List": + res.resp, res.err = l.dispatchList(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (l *ListSchemasServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if l.srv.List == nil { + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/pipelines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listSchemas` + 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[armazuredatatransfer.Schema](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + pipelineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("pipelineName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.List(req.Context(), resourceGroupNameParam, pipelineNameParam, 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).SchemasListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to ListSchemasServerTransport +var listSchemasServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/operations_server.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/operations_server.go new file mode 100644 index 000000000000..4500c9901b41 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/operations_server.go @@ -0,0 +1,118 @@ +// 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/azuredatatransfer/armazuredatatransfer" + "net/http" +) + +// OperationsServer is a fake server for instances of the armazuredatatransfer.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armazuredatatransfer.OperationsClientListOptions) (resp azfake.PagerResponder[armazuredatatransfer.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armazuredatatransfer.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[armazuredatatransfer.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armazuredatatransfer.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armazuredatatransfer.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")} + } + + return o.dispatchToMethodFake(req, method) +} + +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +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 *armazuredatatransfer.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 +} + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/pipelines_server.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/pipelines_server.go new file mode 100644 index 000000000000..cfd32ea0aa33 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/pipelines_server.go @@ -0,0 +1,487 @@ +// 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/azuredatatransfer/armazuredatatransfer" + "net/http" + "net/url" + "regexp" +) + +// PipelinesServer is a fake server for instances of the armazuredatatransfer.PipelinesClient type. +type PipelinesServer struct { + // BeginApproveConnection is the fake for method PipelinesClient.BeginApproveConnection + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginApproveConnection func(ctx context.Context, resourceGroupName string, pipelineName string, connection armazuredatatransfer.ResourceBody, options *armazuredatatransfer.PipelinesClientBeginApproveConnectionOptions) (resp azfake.PollerResponder[armazuredatatransfer.PipelinesClientApproveConnectionResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method PipelinesClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, pipelineName string, pipeline armazuredatatransfer.Pipeline, options *armazuredatatransfer.PipelinesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armazuredatatransfer.PipelinesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method PipelinesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, pipelineName string, options *armazuredatatransfer.PipelinesClientBeginDeleteOptions) (resp azfake.PollerResponder[armazuredatatransfer.PipelinesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method PipelinesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, pipelineName string, options *armazuredatatransfer.PipelinesClientGetOptions) (resp azfake.Responder[armazuredatatransfer.PipelinesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method PipelinesClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armazuredatatransfer.PipelinesClientListByResourceGroupOptions) (resp azfake.PagerResponder[armazuredatatransfer.PipelinesClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method PipelinesClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armazuredatatransfer.PipelinesClientListBySubscriptionOptions) (resp azfake.PagerResponder[armazuredatatransfer.PipelinesClientListBySubscriptionResponse]) + + // BeginRejectConnection is the fake for method PipelinesClient.BeginRejectConnection + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginRejectConnection func(ctx context.Context, resourceGroupName string, pipelineName string, connection armazuredatatransfer.ResourceBody, options *armazuredatatransfer.PipelinesClientBeginRejectConnectionOptions) (resp azfake.PollerResponder[armazuredatatransfer.PipelinesClientRejectConnectionResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method PipelinesClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, pipelineName string, pipeline armazuredatatransfer.PipelinesPatch, options *armazuredatatransfer.PipelinesClientBeginUpdateOptions) (resp azfake.PollerResponder[armazuredatatransfer.PipelinesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewPipelinesServerTransport creates a new instance of PipelinesServerTransport with the provided implementation. +// The returned PipelinesServerTransport instance is connected to an instance of armazuredatatransfer.PipelinesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPipelinesServerTransport(srv *PipelinesServer) *PipelinesServerTransport { + return &PipelinesServerTransport{ + srv: srv, + beginApproveConnection: newTracker[azfake.PollerResponder[armazuredatatransfer.PipelinesClientApproveConnectionResponse]](), + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armazuredatatransfer.PipelinesClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armazuredatatransfer.PipelinesClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armazuredatatransfer.PipelinesClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armazuredatatransfer.PipelinesClientListBySubscriptionResponse]](), + beginRejectConnection: newTracker[azfake.PollerResponder[armazuredatatransfer.PipelinesClientRejectConnectionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armazuredatatransfer.PipelinesClientUpdateResponse]](), + } +} + +// PipelinesServerTransport connects instances of armazuredatatransfer.PipelinesClient to instances of PipelinesServer. +// Don't use this type directly, use NewPipelinesServerTransport instead. +type PipelinesServerTransport struct { + srv *PipelinesServer + beginApproveConnection *tracker[azfake.PollerResponder[armazuredatatransfer.PipelinesClientApproveConnectionResponse]] + beginCreateOrUpdate *tracker[azfake.PollerResponder[armazuredatatransfer.PipelinesClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armazuredatatransfer.PipelinesClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armazuredatatransfer.PipelinesClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armazuredatatransfer.PipelinesClientListBySubscriptionResponse]] + beginRejectConnection *tracker[azfake.PollerResponder[armazuredatatransfer.PipelinesClientRejectConnectionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armazuredatatransfer.PipelinesClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for PipelinesServerTransport. +func (p *PipelinesServerTransport) 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")} + } + + return p.dispatchToMethodFake(req, method) +} + +func (p *PipelinesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if pipelinesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = pipelinesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "PipelinesClient.BeginApproveConnection": + res.resp, res.err = p.dispatchBeginApproveConnection(req) + case "PipelinesClient.BeginCreateOrUpdate": + res.resp, res.err = p.dispatchBeginCreateOrUpdate(req) + case "PipelinesClient.BeginDelete": + res.resp, res.err = p.dispatchBeginDelete(req) + case "PipelinesClient.Get": + res.resp, res.err = p.dispatchGet(req) + case "PipelinesClient.NewListByResourceGroupPager": + res.resp, res.err = p.dispatchNewListByResourceGroupPager(req) + case "PipelinesClient.NewListBySubscriptionPager": + res.resp, res.err = p.dispatchNewListBySubscriptionPager(req) + case "PipelinesClient.BeginRejectConnection": + res.resp, res.err = p.dispatchBeginRejectConnection(req) + case "PipelinesClient.BeginUpdate": + res.resp, res.err = p.dispatchBeginUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (p *PipelinesServerTransport) dispatchBeginApproveConnection(req *http.Request) (*http.Response, error) { + if p.srv.BeginApproveConnection == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginApproveConnection not implemented")} + } + beginApproveConnection := p.beginApproveConnection.get(req) + if beginApproveConnection == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/pipelines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/approveConnection` + 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[armazuredatatransfer.ResourceBody](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + pipelineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("pipelineName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginApproveConnection(req.Context(), resourceGroupNameParam, pipelineNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginApproveConnection = &respr + p.beginApproveConnection.add(req, beginApproveConnection) + } + + resp, err := server.PollerResponderNext(beginApproveConnection, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + p.beginApproveConnection.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginApproveConnection) { + p.beginApproveConnection.remove(req) + } + + return resp, nil +} + +func (p *PipelinesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if p.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := p.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/pipelines/(?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[armazuredatatransfer.Pipeline](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + pipelineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("pipelineName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, pipelineNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + p.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + p.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + p.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (p *PipelinesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if p.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := p.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/pipelines/(?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 + } + pipelineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("pipelineName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginDelete(req.Context(), resourceGroupNameParam, pipelineNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + p.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + p.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + p.beginDelete.remove(req) + } + + return resp, nil +} + +func (p *PipelinesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.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\.AzureDataTransfer/pipelines/(?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 + } + pipelineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("pipelineName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, pipelineNameParam, 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).Pipeline, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PipelinesServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := p.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/pipelines` + 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 := p.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + p.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armazuredatatransfer.PipelinesClientListByResourceGroupResponse, 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) { + p.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + p.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (p *PipelinesServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := p.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/pipelines` + 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 := p.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + p.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armazuredatatransfer.PipelinesClientListBySubscriptionResponse, 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) { + p.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + p.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (p *PipelinesServerTransport) dispatchBeginRejectConnection(req *http.Request) (*http.Response, error) { + if p.srv.BeginRejectConnection == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginRejectConnection not implemented")} + } + beginRejectConnection := p.beginRejectConnection.get(req) + if beginRejectConnection == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/pipelines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/rejectConnection` + 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[armazuredatatransfer.ResourceBody](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + pipelineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("pipelineName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginRejectConnection(req.Context(), resourceGroupNameParam, pipelineNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginRejectConnection = &respr + p.beginRejectConnection.add(req, beginRejectConnection) + } + + resp, err := server.PollerResponderNext(beginRejectConnection, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + p.beginRejectConnection.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginRejectConnection) { + p.beginRejectConnection.remove(req) + } + + return resp, nil +} + +func (p *PipelinesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if p.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := p.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.AzureDataTransfer/pipelines/(?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[armazuredatatransfer.PipelinesPatch](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + pipelineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("pipelineName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginUpdate(req.Context(), resourceGroupNameParam, pipelineNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + p.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) { + p.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) { + p.beginUpdate.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to PipelinesServerTransport +var pipelinesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/server.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/server.go new file mode 100644 index 000000000000..35ab9c86b781 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/server.go @@ -0,0 +1,139 @@ +// 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/resourcemanager/azuredatatransfer/armazuredatatransfer" + "net/http" +) + +// Server is a fake server for instances of the armazuredatatransfer.Client type. +type Server struct { + // ListApprovedSchemas is the fake for method Client.ListApprovedSchemas + // HTTP status codes to indicate success: http.StatusOK + ListApprovedSchemas func(ctx context.Context, pipeline armazuredatatransfer.ListApprovedSchemasRequest, options *armazuredatatransfer.ClientListApprovedSchemasOptions) (resp azfake.Responder[armazuredatatransfer.ClientListApprovedSchemasResponse], errResp azfake.ErrorResponder) + + // ValidateSchema is the fake for method Client.ValidateSchema + // HTTP status codes to indicate success: http.StatusOK + ValidateSchema func(ctx context.Context, schema armazuredatatransfer.Schema, options *armazuredatatransfer.ClientValidateSchemaOptions) (resp azfake.Responder[armazuredatatransfer.ClientValidateSchemaResponse], errResp azfake.ErrorResponder) +} + +// NewServerTransport creates a new instance of ServerTransport with the provided implementation. +// The returned ServerTransport instance is connected to an instance of armazuredatatransfer.Client via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerTransport(srv *Server) *ServerTransport { + return &ServerTransport{srv: srv} +} + +// ServerTransport connects instances of armazuredatatransfer.Client to instances of Server. +// Don't use this type directly, use NewServerTransport instead. +type ServerTransport struct { + srv *Server +} + +// Do implements the policy.Transporter interface for ServerTransport. +func (s *ServerTransport) 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")} + } + + return s.dispatchToMethodFake(req, method) +} + +func (s *ServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if serverTransportInterceptor != nil { + res.resp, res.err, intercepted = serverTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "Client.ListApprovedSchemas": + res.resp, res.err = s.dispatchListApprovedSchemas(req) + case "Client.ValidateSchema": + res.resp, res.err = s.dispatchValidateSchema(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (s *ServerTransport) dispatchListApprovedSchemas(req *http.Request) (*http.Response, error) { + if s.srv.ListApprovedSchemas == nil { + return nil, &nonRetriableError{errors.New("fake for method ListApprovedSchemas not implemented")} + } + body, err := server.UnmarshalRequestAsJSON[armazuredatatransfer.ListApprovedSchemasRequest](req) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.ListApprovedSchemas(req.Context(), 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).SchemasListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ServerTransport) dispatchValidateSchema(req *http.Request) (*http.Response, error) { + if s.srv.ValidateSchema == nil { + return nil, &nonRetriableError{errors.New("fake for method ValidateSchema not implemented")} + } + body, err := server.UnmarshalRequestAsJSON[armazuredatatransfer.Schema](req) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.ValidateSchema(req.Context(), 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).ValidateSchemaResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to ServerTransport +var serverTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/server_factory.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/server_factory.go new file mode 100644 index 000000000000..51e27a12823d --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/fake/server_factory.go @@ -0,0 +1,126 @@ +// 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 armazuredatatransfer.ClientFactory type. +type ServerFactory struct { + // Server contains the fakes for client Client + Server Server + + // ConnectionsServer contains the fakes for client ConnectionsClient + ConnectionsServer ConnectionsServer + + // FlowsServer contains the fakes for client FlowsClient + FlowsServer FlowsServer + + // ListPendingConnectionsServer contains the fakes for client ListPendingConnectionsClient + ListPendingConnectionsServer ListPendingConnectionsServer + + // ListPendingFlowsServer contains the fakes for client ListPendingFlowsClient + ListPendingFlowsServer ListPendingFlowsServer + + // ListSchemasServer contains the fakes for client ListSchemasClient + ListSchemasServer ListSchemasServer + + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // PipelinesServer contains the fakes for client PipelinesClient + PipelinesServer PipelinesServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armazuredatatransfer.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 armazuredatatransfer.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trServer *ServerTransport + trConnectionsServer *ConnectionsServerTransport + trFlowsServer *FlowsServerTransport + trListPendingConnectionsServer *ListPendingConnectionsServerTransport + trListPendingFlowsServer *ListPendingFlowsServerTransport + trListSchemasServer *ListSchemasServerTransport + trOperationsServer *OperationsServerTransport + trPipelinesServer *PipelinesServerTransport +} + +// 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 "Client": + initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) + resp, err = s.trServer.Do(req) + case "ConnectionsClient": + initServer(s, &s.trConnectionsServer, func() *ConnectionsServerTransport { return NewConnectionsServerTransport(&s.srv.ConnectionsServer) }) + resp, err = s.trConnectionsServer.Do(req) + case "FlowsClient": + initServer(s, &s.trFlowsServer, func() *FlowsServerTransport { return NewFlowsServerTransport(&s.srv.FlowsServer) }) + resp, err = s.trFlowsServer.Do(req) + case "ListPendingConnectionsClient": + initServer(s, &s.trListPendingConnectionsServer, func() *ListPendingConnectionsServerTransport { + return NewListPendingConnectionsServerTransport(&s.srv.ListPendingConnectionsServer) + }) + resp, err = s.trListPendingConnectionsServer.Do(req) + case "ListPendingFlowsClient": + initServer(s, &s.trListPendingFlowsServer, func() *ListPendingFlowsServerTransport { + return NewListPendingFlowsServerTransport(&s.srv.ListPendingFlowsServer) + }) + resp, err = s.trListPendingFlowsServer.Do(req) + case "ListSchemasClient": + initServer(s, &s.trListSchemasServer, func() *ListSchemasServerTransport { return NewListSchemasServerTransport(&s.srv.ListSchemasServer) }) + resp, err = s.trListSchemasServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "PipelinesClient": + initServer(s, &s.trPipelinesServer, func() *PipelinesServerTransport { return NewPipelinesServerTransport(&s.srv.PipelinesServer) }) + resp, err = s.trPipelinesServer.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/azuredatatransfer/armazuredatatransfer/flows_client.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/flows_client.go new file mode 100644 index 000000000000..3226575381a3 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/flows_client.go @@ -0,0 +1,1380 @@ +// 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 armazuredatatransfer + +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" +) + +// FlowsClient contains the methods for the Flows group. +// Don't use this type directly, use NewFlowsClient() instead. +type FlowsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewFlowsClient creates a new instance of FlowsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewFlowsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FlowsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &FlowsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates the flow resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - flow - Flow body +// - options - FlowsClientBeginCreateOrUpdateOptions contains the optional parameters for the FlowsClient.BeginCreateOrUpdate +// method. +func (client *FlowsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, connectionName string, flowName string, flow Flow, options *FlowsClientBeginCreateOrUpdateOptions) (*runtime.Poller[FlowsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, connectionName, flowName, flow, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FlowsClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FlowsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Creates or updates the flow resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *FlowsClient) createOrUpdate(ctx context.Context, resourceGroupName string, connectionName string, flowName string, flow Flow, options *FlowsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "FlowsClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, connectionName, flowName, flow, 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 +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *FlowsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, flow Flow, _ *FlowsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, flow); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Deletes the flow resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - options - FlowsClientBeginDeleteOptions contains the optional parameters for the FlowsClient.BeginDelete method. +func (client *FlowsClient) BeginDelete(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientBeginDeleteOptions) (*runtime.Poller[FlowsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, connectionName, flowName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FlowsClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FlowsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes the flow resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *FlowsClient) deleteOperation(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "FlowsClient.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, connectionName, flowName, 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 *FlowsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, _ *FlowsClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginDisable - Disables the specified flow +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - options - FlowsClientBeginDisableOptions contains the optional parameters for the FlowsClient.BeginDisable method. +func (client *FlowsClient) BeginDisable(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientBeginDisableOptions) (*runtime.Poller[FlowsClientDisableResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.disable(ctx, resourceGroupName, connectionName, flowName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FlowsClientDisableResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FlowsClientDisableResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Disable - Disables the specified flow +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *FlowsClient) disable(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientBeginDisableOptions) (*http.Response, error) { + var err error + const operationName = "FlowsClient.BeginDisable" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.disableCreateRequest(ctx, resourceGroupName, connectionName, flowName, 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 +} + +// disableCreateRequest creates the Disable request. +func (client *FlowsClient) disableCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, _ *FlowsClientBeginDisableOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}/disable" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginEnable - Enables the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - options - FlowsClientBeginEnableOptions contains the optional parameters for the FlowsClient.BeginEnable method. +func (client *FlowsClient) BeginEnable(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientBeginEnableOptions) (*runtime.Poller[FlowsClientEnableResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.enable(ctx, resourceGroupName, connectionName, flowName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FlowsClientEnableResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FlowsClientEnableResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Enable - Enables the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *FlowsClient) enable(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientBeginEnableOptions) (*http.Response, error) { + var err error + const operationName = "FlowsClient.BeginEnable" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.enableCreateRequest(ctx, resourceGroupName, connectionName, flowName, 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 +} + +// enableCreateRequest creates the Enable request. +func (client *FlowsClient) enableCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, _ *FlowsClientBeginEnableOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}/enable" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// BeginGeneratePassphrase - Generate a compliant passphrase for the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - options - FlowsClientBeginGeneratePassphraseOptions contains the optional parameters for the FlowsClient.BeginGeneratePassphrase +// method. +func (client *FlowsClient) BeginGeneratePassphrase(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientBeginGeneratePassphraseOptions) (*runtime.Poller[FlowsClientGeneratePassphraseResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.generatePassphrase(ctx, resourceGroupName, connectionName, flowName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FlowsClientGeneratePassphraseResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FlowsClientGeneratePassphraseResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// GeneratePassphrase - Generate a compliant passphrase for the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *FlowsClient) generatePassphrase(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientBeginGeneratePassphraseOptions) (*http.Response, error) { + var err error + const operationName = "FlowsClient.BeginGeneratePassphrase" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.generatePassphraseCreateRequest(ctx, resourceGroupName, connectionName, flowName, 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 +} + +// generatePassphraseCreateRequest creates the GeneratePassphrase request. +func (client *FlowsClient) generatePassphraseCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, _ *FlowsClientBeginGeneratePassphraseOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}/generatePassphrase" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets flow resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - options - FlowsClientGetOptions contains the optional parameters for the FlowsClient.Get method. +func (client *FlowsClient) Get(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientGetOptions) (FlowsClientGetResponse, error) { + var err error + const operationName = "FlowsClient.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, connectionName, flowName, options) + if err != nil { + return FlowsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FlowsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FlowsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *FlowsClient) getCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, _ *FlowsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *FlowsClient) getHandleResponse(resp *http.Response) (FlowsClientGetResponse, error) { + result := FlowsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Flow); err != nil { + return FlowsClientGetResponse{}, err + } + return result, nil +} + +// GetDestinationEndpointPorts - Get the destination endpoint ports for the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - options - FlowsClientGetDestinationEndpointPortsOptions contains the optional parameters for the FlowsClient.GetDestinationEndpointPorts +// method. +func (client *FlowsClient) GetDestinationEndpointPorts(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientGetDestinationEndpointPortsOptions) (FlowsClientGetDestinationEndpointPortsResponse, error) { + var err error + const operationName = "FlowsClient.GetDestinationEndpointPorts" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getDestinationEndpointPortsCreateRequest(ctx, resourceGroupName, connectionName, flowName, options) + if err != nil { + return FlowsClientGetDestinationEndpointPortsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FlowsClientGetDestinationEndpointPortsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FlowsClientGetDestinationEndpointPortsResponse{}, err + } + resp, err := client.getDestinationEndpointPortsHandleResponse(httpResp) + return resp, err +} + +// getDestinationEndpointPortsCreateRequest creates the GetDestinationEndpointPorts request. +func (client *FlowsClient) getDestinationEndpointPortsCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, _ *FlowsClientGetDestinationEndpointPortsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}/getDestinationEndpointPorts" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getDestinationEndpointPortsHandleResponse handles the GetDestinationEndpointPorts response. +func (client *FlowsClient) getDestinationEndpointPortsHandleResponse(resp *http.Response) (FlowsClientGetDestinationEndpointPortsResponse, error) { + result := FlowsClientGetDestinationEndpointPortsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GetDestinationEndpointPortsResult); err != nil { + return FlowsClientGetDestinationEndpointPortsResponse{}, err + } + return result, nil +} + +// GetDestinationEndpoints - Get the destination endpoints for the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - options - FlowsClientGetDestinationEndpointsOptions contains the optional parameters for the FlowsClient.GetDestinationEndpoints +// method. +func (client *FlowsClient) GetDestinationEndpoints(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientGetDestinationEndpointsOptions) (FlowsClientGetDestinationEndpointsResponse, error) { + var err error + const operationName = "FlowsClient.GetDestinationEndpoints" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getDestinationEndpointsCreateRequest(ctx, resourceGroupName, connectionName, flowName, options) + if err != nil { + return FlowsClientGetDestinationEndpointsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FlowsClientGetDestinationEndpointsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FlowsClientGetDestinationEndpointsResponse{}, err + } + resp, err := client.getDestinationEndpointsHandleResponse(httpResp) + return resp, err +} + +// getDestinationEndpointsCreateRequest creates the GetDestinationEndpoints request. +func (client *FlowsClient) getDestinationEndpointsCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, _ *FlowsClientGetDestinationEndpointsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}/getDestinationEndpoints" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getDestinationEndpointsHandleResponse handles the GetDestinationEndpoints response. +func (client *FlowsClient) getDestinationEndpointsHandleResponse(resp *http.Response) (FlowsClientGetDestinationEndpointsResponse, error) { + result := FlowsClientGetDestinationEndpointsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GetDestinationEndpointsResult); err != nil { + return FlowsClientGetDestinationEndpointsResponse{}, err + } + return result, nil +} + +// GetSourceAddresses - Get the source addresses for the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - options - FlowsClientGetSourceAddressesOptions contains the optional parameters for the FlowsClient.GetSourceAddresses +// method. +func (client *FlowsClient) GetSourceAddresses(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientGetSourceAddressesOptions) (FlowsClientGetSourceAddressesResponse, error) { + var err error + const operationName = "FlowsClient.GetSourceAddresses" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getSourceAddressesCreateRequest(ctx, resourceGroupName, connectionName, flowName, options) + if err != nil { + return FlowsClientGetSourceAddressesResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FlowsClientGetSourceAddressesResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FlowsClientGetSourceAddressesResponse{}, err + } + resp, err := client.getSourceAddressesHandleResponse(httpResp) + return resp, err +} + +// getSourceAddressesCreateRequest creates the GetSourceAddresses request. +func (client *FlowsClient) getSourceAddressesCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, _ *FlowsClientGetSourceAddressesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}/getSourceAddresses" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getSourceAddressesHandleResponse handles the GetSourceAddresses response. +func (client *FlowsClient) getSourceAddressesHandleResponse(resp *http.Response) (FlowsClientGetSourceAddressesResponse, error) { + result := FlowsClientGetSourceAddressesResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.StreamSourceAddresses); err != nil { + return FlowsClientGetSourceAddressesResponse{}, err + } + return result, nil +} + +// GetStreamConnectionString - Get the connection string for the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - options - FlowsClientGetStreamConnectionStringOptions contains the optional parameters for the FlowsClient.GetStreamConnectionString +// method. +func (client *FlowsClient) GetStreamConnectionString(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientGetStreamConnectionStringOptions) (FlowsClientGetStreamConnectionStringResponse, error) { + var err error + const operationName = "FlowsClient.GetStreamConnectionString" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getStreamConnectionStringCreateRequest(ctx, resourceGroupName, connectionName, flowName, options) + if err != nil { + return FlowsClientGetStreamConnectionStringResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FlowsClientGetStreamConnectionStringResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FlowsClientGetStreamConnectionStringResponse{}, err + } + resp, err := client.getStreamConnectionStringHandleResponse(httpResp) + return resp, err +} + +// getStreamConnectionStringCreateRequest creates the GetStreamConnectionString request. +func (client *FlowsClient) getStreamConnectionStringCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, _ *FlowsClientGetStreamConnectionStringOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}/getStreamConnectionString" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getStreamConnectionStringHandleResponse handles the GetStreamConnectionString response. +func (client *FlowsClient) getStreamConnectionStringHandleResponse(resp *http.Response) (FlowsClientGetStreamConnectionStringResponse, error) { + result := FlowsClientGetStreamConnectionStringResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.GetStreamConnectionStringResult); err != nil { + return FlowsClientGetStreamConnectionStringResponse{}, err + } + return result, nil +} + +// BeginLink - Links the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - flow - Flow body +// - options - FlowsClientBeginLinkOptions contains the optional parameters for the FlowsClient.BeginLink method. +func (client *FlowsClient) BeginLink(ctx context.Context, resourceGroupName string, connectionName string, flowName string, flow ResourceBody, options *FlowsClientBeginLinkOptions) (*runtime.Poller[FlowsClientLinkResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.link(ctx, resourceGroupName, connectionName, flowName, flow, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FlowsClientLinkResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FlowsClientLinkResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Link - Links the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *FlowsClient) link(ctx context.Context, resourceGroupName string, connectionName string, flowName string, flow ResourceBody, options *FlowsClientBeginLinkOptions) (*http.Response, error) { + var err error + const operationName = "FlowsClient.BeginLink" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.linkCreateRequest(ctx, resourceGroupName, connectionName, flowName, flow, 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 +} + +// linkCreateRequest creates the Link request. +func (client *FlowsClient) linkCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, flow ResourceBody, _ *FlowsClientBeginLinkOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}/link" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, flow); err != nil { + return nil, err + } + return req, nil +} + +// NewListByConnectionPager - Gets flows in a connection. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - options - FlowsClientListByConnectionOptions contains the optional parameters for the FlowsClient.NewListByConnectionPager +// method. +func (client *FlowsClient) NewListByConnectionPager(resourceGroupName string, connectionName string, options *FlowsClientListByConnectionOptions) *runtime.Pager[FlowsClientListByConnectionResponse] { + return runtime.NewPager(runtime.PagingHandler[FlowsClientListByConnectionResponse]{ + More: func(page FlowsClientListByConnectionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *FlowsClientListByConnectionResponse) (FlowsClientListByConnectionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "FlowsClient.NewListByConnectionPager") + 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.listByConnectionCreateRequest(ctx, resourceGroupName, connectionName, options) + }, nil) + if err != nil { + return FlowsClientListByConnectionResponse{}, err + } + return client.listByConnectionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByConnectionCreateRequest creates the ListByConnection request. +func (client *FlowsClient) listByConnectionCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, _ *FlowsClientListByConnectionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByConnectionHandleResponse handles the ListByConnection response. +func (client *FlowsClient) listByConnectionHandleResponse(resp *http.Response) (FlowsClientListByConnectionResponse, error) { + result := FlowsClientListByConnectionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.FlowsListResult); err != nil { + return FlowsClientListByConnectionResponse{}, err + } + return result, nil +} + +// BeginSetDestinationEndpointPorts - Set the destination endpoint ports for the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - streamDestinationEndpointPorts - The destination endpoint ports wanted +// - options - FlowsClientBeginSetDestinationEndpointPortsOptions contains the optional parameters for the FlowsClient.BeginSetDestinationEndpointPorts +// method. +func (client *FlowsClient) BeginSetDestinationEndpointPorts(ctx context.Context, resourceGroupName string, connectionName string, flowName string, streamDestinationEndpointPorts SetDestinationEndpointPorts, options *FlowsClientBeginSetDestinationEndpointPortsOptions) (*runtime.Poller[FlowsClientSetDestinationEndpointPortsResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.setDestinationEndpointPorts(ctx, resourceGroupName, connectionName, flowName, streamDestinationEndpointPorts, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FlowsClientSetDestinationEndpointPortsResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FlowsClientSetDestinationEndpointPortsResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// SetDestinationEndpointPorts - Set the destination endpoint ports for the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *FlowsClient) setDestinationEndpointPorts(ctx context.Context, resourceGroupName string, connectionName string, flowName string, streamDestinationEndpointPorts SetDestinationEndpointPorts, options *FlowsClientBeginSetDestinationEndpointPortsOptions) (*http.Response, error) { + var err error + const operationName = "FlowsClient.BeginSetDestinationEndpointPorts" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.setDestinationEndpointPortsCreateRequest(ctx, resourceGroupName, connectionName, flowName, streamDestinationEndpointPorts, 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 +} + +// setDestinationEndpointPortsCreateRequest creates the SetDestinationEndpointPorts request. +func (client *FlowsClient) setDestinationEndpointPortsCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, streamDestinationEndpointPorts SetDestinationEndpointPorts, _ *FlowsClientBeginSetDestinationEndpointPortsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}/setDestinationEndpointPorts" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, streamDestinationEndpointPorts); err != nil { + return nil, err + } + return req, nil +} + +// BeginSetDestinationEndpoints - Set the destination endpoints for the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - streamDestinationEndpoints - Destination endpoints wanted +// - options - FlowsClientBeginSetDestinationEndpointsOptions contains the optional parameters for the FlowsClient.BeginSetDestinationEndpoints +// method. +func (client *FlowsClient) BeginSetDestinationEndpoints(ctx context.Context, resourceGroupName string, connectionName string, flowName string, streamDestinationEndpoints SetDestinationEndpoints, options *FlowsClientBeginSetDestinationEndpointsOptions) (*runtime.Poller[FlowsClientSetDestinationEndpointsResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.setDestinationEndpoints(ctx, resourceGroupName, connectionName, flowName, streamDestinationEndpoints, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FlowsClientSetDestinationEndpointsResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FlowsClientSetDestinationEndpointsResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// SetDestinationEndpoints - Set the destination endpoints for the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *FlowsClient) setDestinationEndpoints(ctx context.Context, resourceGroupName string, connectionName string, flowName string, streamDestinationEndpoints SetDestinationEndpoints, options *FlowsClientBeginSetDestinationEndpointsOptions) (*http.Response, error) { + var err error + const operationName = "FlowsClient.BeginSetDestinationEndpoints" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.setDestinationEndpointsCreateRequest(ctx, resourceGroupName, connectionName, flowName, streamDestinationEndpoints, 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 +} + +// setDestinationEndpointsCreateRequest creates the SetDestinationEndpoints request. +func (client *FlowsClient) setDestinationEndpointsCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, streamDestinationEndpoints SetDestinationEndpoints, _ *FlowsClientBeginSetDestinationEndpointsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}/setDestinationEndpoints" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, streamDestinationEndpoints); err != nil { + return nil, err + } + return req, nil +} + +// BeginSetPassphrase - Sets the passphrase of the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - passphrase - Passphrase to set +// - options - FlowsClientBeginSetPassphraseOptions contains the optional parameters for the FlowsClient.BeginSetPassphrase +// method. +func (client *FlowsClient) BeginSetPassphrase(ctx context.Context, resourceGroupName string, connectionName string, flowName string, passphrase SetStreamPassphrase, options *FlowsClientBeginSetPassphraseOptions) (*runtime.Poller[FlowsClientSetPassphraseResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.setPassphrase(ctx, resourceGroupName, connectionName, flowName, passphrase, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FlowsClientSetPassphraseResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FlowsClientSetPassphraseResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// SetPassphrase - Sets the passphrase of the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *FlowsClient) setPassphrase(ctx context.Context, resourceGroupName string, connectionName string, flowName string, passphrase SetStreamPassphrase, options *FlowsClientBeginSetPassphraseOptions) (*http.Response, error) { + var err error + const operationName = "FlowsClient.BeginSetPassphrase" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.setPassphraseCreateRequest(ctx, resourceGroupName, connectionName, flowName, passphrase, 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 +} + +// setPassphraseCreateRequest creates the SetPassphrase request. +func (client *FlowsClient) setPassphraseCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, passphrase SetStreamPassphrase, _ *FlowsClientBeginSetPassphraseOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}/setPassphrase" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, passphrase); err != nil { + return nil, err + } + return req, nil +} + +// BeginSetSourceAddresses - Set the source addresses for the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - sourceAddresses - Source addresses wanted +// - options - FlowsClientBeginSetSourceAddressesOptions contains the optional parameters for the FlowsClient.BeginSetSourceAddresses +// method. +func (client *FlowsClient) BeginSetSourceAddresses(ctx context.Context, resourceGroupName string, connectionName string, flowName string, sourceAddresses SetSourceAddresses, options *FlowsClientBeginSetSourceAddressesOptions) (*runtime.Poller[FlowsClientSetSourceAddressesResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.setSourceAddresses(ctx, resourceGroupName, connectionName, flowName, sourceAddresses, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FlowsClientSetSourceAddressesResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FlowsClientSetSourceAddressesResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// SetSourceAddresses - Set the source addresses for the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *FlowsClient) setSourceAddresses(ctx context.Context, resourceGroupName string, connectionName string, flowName string, sourceAddresses SetSourceAddresses, options *FlowsClientBeginSetSourceAddressesOptions) (*http.Response, error) { + var err error + const operationName = "FlowsClient.BeginSetSourceAddresses" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.setSourceAddressesCreateRequest(ctx, resourceGroupName, connectionName, flowName, sourceAddresses, 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 +} + +// setSourceAddressesCreateRequest creates the SetSourceAddresses request. +func (client *FlowsClient) setSourceAddressesCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, sourceAddresses SetSourceAddresses, _ *FlowsClientBeginSetSourceAddressesOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}/setSourceAddresses" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, sourceAddresses); err != nil { + return nil, err + } + return req, nil +} + +// BeginUpdate - Updates the flow resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - flowName - The name for the flow to perform the operation on. +// - flow - Flow body +// - options - FlowsClientBeginUpdateOptions contains the optional parameters for the FlowsClient.BeginUpdate method. +func (client *FlowsClient) BeginUpdate(ctx context.Context, resourceGroupName string, connectionName string, flowName string, flow FlowsPatch, options *FlowsClientBeginUpdateOptions) (*runtime.Poller[FlowsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, connectionName, flowName, flow, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FlowsClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FlowsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Updates the flow resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *FlowsClient) update(ctx context.Context, resourceGroupName string, connectionName string, flowName string, flow FlowsPatch, options *FlowsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "FlowsClient.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, connectionName, flowName, flow, 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 *FlowsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, flowName string, flow FlowsPatch, _ *FlowsClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/flows/{flowName}" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + if flowName == "" { + return nil, errors.New("parameter flowName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{flowName}", url.PathEscape(flowName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, flow); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/go.mod b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/go.mod new file mode 100644 index 000000000000..cd8d1cb7afca --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/go.mod @@ -0,0 +1,13 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer + +go 1.23.0 + +toolchain go1.23.8 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/text v0.23.0 // indirect +) diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/go.sum b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/go.sum new file mode 100644 index 000000000000..cfff861c9769 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/go.sum @@ -0,0 +1,16 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/listpendingconnections_client.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/listpendingconnections_client.go new file mode 100644 index 000000000000..7d216f15af70 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/listpendingconnections_client.go @@ -0,0 +1,106 @@ +// 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 armazuredatatransfer + +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" +) + +// ListPendingConnectionsClient contains the methods for the ListPendingConnections group. +// Don't use this type directly, use NewListPendingConnectionsClient() instead. +type ListPendingConnectionsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewListPendingConnectionsClient creates a new instance of ListPendingConnectionsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewListPendingConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ListPendingConnectionsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ListPendingConnectionsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// NewListPager - Lists all pending remote connections that are linkable to this connection. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - options - ListPendingConnectionsClientListOptions contains the optional parameters for the ListPendingConnectionsClient.NewListPager +// method. +func (client *ListPendingConnectionsClient) NewListPager(resourceGroupName string, connectionName string, options *ListPendingConnectionsClientListOptions) *runtime.Pager[ListPendingConnectionsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ListPendingConnectionsClientListResponse]{ + More: func(page ListPendingConnectionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ListPendingConnectionsClientListResponse) (ListPendingConnectionsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ListPendingConnectionsClient.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, resourceGroupName, connectionName, options) + }, nil) + if err != nil { + return ListPendingConnectionsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *ListPendingConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, _ *ListPendingConnectionsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/listPendingConnections" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ListPendingConnectionsClient) listHandleResponse(resp *http.Response) (ListPendingConnectionsClientListResponse, error) { + result := ListPendingConnectionsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PendingConnectionsListResult); err != nil { + return ListPendingConnectionsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/listpendingflows_client.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/listpendingflows_client.go new file mode 100644 index 000000000000..9d50ba9d3142 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/listpendingflows_client.go @@ -0,0 +1,106 @@ +// 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 armazuredatatransfer + +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" +) + +// ListPendingFlowsClient contains the methods for the ListPendingFlows group. +// Don't use this type directly, use NewListPendingFlowsClient() instead. +type ListPendingFlowsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewListPendingFlowsClient creates a new instance of ListPendingFlowsClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewListPendingFlowsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ListPendingFlowsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ListPendingFlowsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// NewListPager - Lists all remote flows that have not yet been linked to local flows. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection to perform the operation on. +// - options - ListPendingFlowsClientListOptions contains the optional parameters for the ListPendingFlowsClient.NewListPager +// method. +func (client *ListPendingFlowsClient) NewListPager(resourceGroupName string, connectionName string, options *ListPendingFlowsClientListOptions) *runtime.Pager[ListPendingFlowsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ListPendingFlowsClientListResponse]{ + More: func(page ListPendingFlowsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ListPendingFlowsClientListResponse) (ListPendingFlowsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ListPendingFlowsClient.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, resourceGroupName, connectionName, options) + }, nil) + if err != nil { + return ListPendingFlowsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *ListPendingFlowsClient) listCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, _ *ListPendingFlowsClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/connections/{connectionName}/listPendingFlows" + 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 connectionName == "" { + return nil, errors.New("parameter connectionName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{connectionName}", url.PathEscape(connectionName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ListPendingFlowsClient) listHandleResponse(resp *http.Response) (ListPendingFlowsClientListResponse, error) { + result := ListPendingFlowsClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PendingFlowsListResult); err != nil { + return ListPendingFlowsClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/listschemas_client.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/listschemas_client.go new file mode 100644 index 000000000000..c1f5fd4dd31d --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/listschemas_client.go @@ -0,0 +1,109 @@ +// 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 armazuredatatransfer + +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" +) + +// ListSchemasClient contains the methods for the ListSchemas group. +// Don't use this type directly, use NewListSchemasClient() instead. +type ListSchemasClient struct { + internal *arm.Client + subscriptionID string +} + +// NewListSchemasClient creates a new instance of ListSchemasClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewListSchemasClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ListSchemasClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ListSchemasClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// List - Lists the schemas for the specified connection in a pipeline. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - pipelineName - The name for the pipeline to perform the operation on. +// - schema - Schema(s) to retrieve +// - options - ListSchemasClientListOptions contains the optional parameters for the ListSchemasClient.List method. +func (client *ListSchemasClient) List(ctx context.Context, resourceGroupName string, pipelineName string, schema Schema, options *ListSchemasClientListOptions) (ListSchemasClientListResponse, error) { + var err error + const operationName = "ListSchemasClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listCreateRequest(ctx, resourceGroupName, pipelineName, schema, options) + if err != nil { + return ListSchemasClientListResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ListSchemasClientListResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ListSchemasClientListResponse{}, err + } + resp, err := client.listHandleResponse(httpResp) + return resp, err +} + +// listCreateRequest creates the List request. +func (client *ListSchemasClient) listCreateRequest(ctx context.Context, resourceGroupName string, pipelineName string, schema Schema, _ *ListSchemasClientListOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/pipelines/{pipelineName}/listSchemas" + 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 pipelineName == "" { + return nil, errors.New("parameter pipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineName}", url.PathEscape(pipelineName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, schema); err != nil { + return nil, err + } + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ListSchemasClient) listHandleResponse(resp *http.Response) (ListSchemasClientListResponse, error) { + result := ListSchemasClientListResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SchemasListResult); err != nil { + return ListSchemasClientListResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/models.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/models.go new file mode 100644 index 000000000000..ccf4f13c05d2 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/models.go @@ -0,0 +1,817 @@ +// 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 armazuredatatransfer + +import "time" + +// Connection - The connection resource definition. +type Connection struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // Properties of connection + Properties *ConnectionProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/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 +} + +// ConnectionProperties - Properties of connection +type ConnectionProperties struct { + // REQUIRED; Pipeline to use to transfer data + Pipeline *string + + // Direction of data movement + Direction *Direction + + // The flow types being requested for this connection + FlowTypes []*FlowType + + // Justification for the connection request + Justification *string + + // PIN to link requests together + Pin *string + + // The policies for this connection + Policies []*string + + // The primary contact for this connection request + PrimaryContact *string + + // Subscription ID to link cloud subscriptions together + RemoteSubscriptionID *string + + // Requirement ID of the connection + RequirementID *string + + // The schema URIs for this connection + SchemaUris []*string + + // The schemas for this connection + Schemas []*Schema + + // The secondary contacts for this connection request + SecondaryContacts []*string + + // READ-ONLY; Approver of this connection request + Approver *string + + // READ-ONLY; The timestamp that this connection request was submitted at + DateSubmitted *time.Time + + // READ-ONLY; Link status of the current connection + LinkStatus *LinkStatus + + // READ-ONLY; Resource ID of the linked connection + LinkedConnectionID *string + + // READ-ONLY; Provisioning state of the connection + ProvisioningState *ProvisioningState + + // READ-ONLY; Status of the connection + Status *Status + + // READ-ONLY; Reason for status + StatusReason *string +} + +// ConnectionsListResult - The connections list result. +type ConnectionsListResult struct { + // Link to next results + NextLink *string + + // Connections array. + Value []*Connection +} + +// ConnectionsPatch - The connections resource patch definition. +type ConnectionsPatch struct { + // Resource tags + Tags map[string]*string +} + +// Flow - The flow resource definition. +type Flow struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The managed identity of the flow resource, if configured. + Identity *ManagedServiceIdentity + + // Plan for the resource. + Plan *Plan + + // Properties of flow + Properties *FlowProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/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 +} + +// FlowProperties - Properties of flow +type FlowProperties struct { + // The connection associated with this flow + Connection *SelectedResource + + // The URI to the customer managed key for this flow + CustomerManagedKeyVaultURI *string + + // Type of data to transfer via the flow + DataType *DataType + + // The destination endpoint ports of the stream + DestinationEndpointPorts []*int64 + + // The destination endpoints of the stream + DestinationEndpoints []*string + + // The flow type for this flow + FlowType *FlowType + + // URI to a Key Vault Secret containing a SAS token + KeyVaultURI *string + + // The messaging options for this flow + MessagingOptions *MessagingOptions + + // The passphrase used for SRT streams + Passphrase *string + + // The policies for this flow + Policies []*string + + // The selected schema for this flow + Schema *Schema + + // Service Bus Queue ID + ServiceBusQueueID *string + + // The source IP address and CIDR ranges of the stream + SourceAddresses *StreamSourceAddresses + + // Status of the current flow + Status *FlowStatus + + // Storage Account ID + StorageAccountID *string + + // Storage Account + StorageAccountName *string + + // Storage Container Name + StorageContainerName *string + + // The flow stream identifier + StreamID *string + + // The latency of the stream in milliseconds + StreamLatency *int64 + + // The protocol of the stream + StreamProtocol *StreamProtocol + + // READ-ONLY; Dataflow GUID associated with this flow + FlowID *string + + // READ-ONLY; Link status of the current flow + LinkStatus *LinkStatusFlow + + // READ-ONLY; Resource ID of the linked flow + LinkedFlowID *string + + // READ-ONLY; Provisioning state of the flow + ProvisioningState *ProvisioningState +} + +// FlowsListResult - The flows list result. +type FlowsListResult struct { + // Link to next results + NextLink *string + + // Flows array. + Value []*Flow +} + +// FlowsPatch - The flows resource patch definition. +type FlowsPatch struct { + // The managed identity of the flow resource, if configured. + Identity *ManagedServiceIdentity + + // Resource tags + Tags map[string]*string +} + +// GetDestinationEndpointPortsResult - List of destination endpoint ports for the flow stream +type GetDestinationEndpointPortsResult struct { + // The destination endpoint port for the flow stream + Ports []*int64 +} + +// GetDestinationEndpointsResult - List of destination endpoints for the flow stream +type GetDestinationEndpointsResult struct { + // The destination endpoints for the flow stream + Endpoints []*string +} + +// GetStreamConnectionStringResult - The connection string for the specified streaming flow +type GetStreamConnectionStringResult struct { + // The connection string for the specified streaming flow + ConnectionString *string +} + +// InternalMetadataProperties - Internal metadata of the connection inside pipeline. +type InternalMetadataProperties struct { + // OPTIONAL; Contains additional key/value pairs not defined in the schema. + AdditionalProperties map[string]any + + // Operation status associated with the last patch request + OperationStatus *OperationStatusProperties + + // READ-ONLY; User that last set the approved status for this connection + StatusSetBy *string +} + +type ListApprovedSchemasRequest struct { + // The direction pipeline to filter approved schemas. + Direction *ListApprovedSchemasDirection + + // The name of the pipeline to filter approved schemas. + Pipeline *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 +} + +// MessagingOptions - The option associated with messaging flows. +type MessagingOptions struct { + // Billing tier for this messaging flow + BillingTier *FlowBillingTier +} + +// 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 +} + +// OperationStatusProperties - Operation status associated with the last patch request +type OperationStatusProperties struct { + // READ-ONLY; Operation status ID of the last patch request for this connection. + ID *string + + // READ-ONLY; Message for the operation for the last patch request for this connection. + Message *string + + // READ-ONLY; Operation status for the last patch request for this connection. + Status *OperationStatusEnum +} + +// PendingConnection - Pending connection object +type PendingConnection struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // REQUIRED; Pipeline to use to transfer data + Pipeline *string + + // Direction of data movement + Direction *Direction + + // The flow types being requested for this connection + FlowTypes []*FlowType + + // Justification for the connection request + Justification *string + + // PIN to link requests together + Pin *string + + // The policies for this connection + Policies []*string + + // The primary contact for this connection request + PrimaryContact *string + + // Subscription ID to link cloud subscriptions together + RemoteSubscriptionID *string + + // Requirement ID of the connection + RequirementID *string + + // The schema URIs for this connection + SchemaUris []*string + + // The schemas for this connection + Schemas []*Schema + + // The secondary contacts for this connection request + SecondaryContacts []*string + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Approver of this connection request + Approver *string + + // READ-ONLY; The timestamp that this connection request was submitted at + DateSubmitted *time.Time + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; Link status of the current connection + LinkStatus *LinkStatus + + // READ-ONLY; Resource ID of the linked connection + LinkedConnectionID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Provisioning state of the connection + ProvisioningState *ProvisioningState + + // READ-ONLY; Status of the connection + Status *Status + + // READ-ONLY; Reason for status + StatusReason *string + + // READ-ONLY; Subscription ID of the pending connection. + SubscriptionID *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 +} + +// PendingConnectionsListResult - The pending connections list result. +type PendingConnectionsListResult struct { + // Link to next results + NextLink *string + + // Connections array. + Value []*PendingConnection +} + +// PendingFlow - Pending flow object +type PendingFlow struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The connection associated with this flow + Connection *SelectedResource + + // The URI to the customer managed key for this flow + CustomerManagedKeyVaultURI *string + + // Type of data to transfer via the flow + DataType *DataType + + // The destination endpoint ports of the stream + DestinationEndpointPorts []*int64 + + // The destination endpoints of the stream + DestinationEndpoints []*string + + // The flow type for this flow + FlowType *FlowType + + // URI to a Key Vault Secret containing a SAS token + KeyVaultURI *string + + // The messaging options for this flow + MessagingOptions *MessagingOptions + + // The passphrase used for SRT streams + Passphrase *string + + // The policies for this flow + Policies []*string + + // The selected schema for this flow + Schema *Schema + + // Service Bus Queue ID + ServiceBusQueueID *string + + // The source IP address and CIDR ranges of the stream + SourceAddresses *StreamSourceAddresses + + // Status of the current flow + Status *FlowStatus + + // Storage Account ID + StorageAccountID *string + + // Storage Account + StorageAccountName *string + + // Storage Container Name + StorageContainerName *string + + // The flow stream identifier + StreamID *string + + // The latency of the stream in milliseconds + StreamLatency *int64 + + // The protocol of the stream + StreamProtocol *StreamProtocol + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Connection ID of the pending flow. + ConnectionID *string + + // READ-ONLY; Dataflow GUID associated with this flow + FlowID *string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}" + ID *string + + // READ-ONLY; Link status of the current flow + LinkStatus *LinkStatusFlow + + // READ-ONLY; Resource ID of the linked flow + LinkedFlowID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Provisioning state of the flow + ProvisioningState *ProvisioningState + + // READ-ONLY; Subscription ID of the pending flow. + SubscriptionID *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 +} + +// PendingFlowsListResult - The pending flows list result. +type PendingFlowsListResult struct { + // Link to next results + NextLink *string + + // flows array. + Value []*PendingFlow +} + +// Pipeline - The pipeline resource definition. +type Pipeline struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // Properties of pipeline + Properties *PipelineProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; Fully qualified resource ID for the resource. E.g. "/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 +} + +// PipelineConnection - Connection body inside a pipeline +type PipelineConnection struct { + // REQUIRED; Connection id inside pipeline + ID *string + + // OPTIONAL; Contains additional key/value pairs not defined in the schema. + AdditionalProperties map[string]any + + // Connection properties inside pipeline + Properties *PipelineConnectionProperties + + // READ-ONLY; Connection etag inside pipeline + Etag *string + + // READ-ONLY; Connection location inside pipeline + Location *string + + // READ-ONLY; Connection name inside pipeline + Name *string + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource. + SystemData *SystemData + + // READ-ONLY; Connection type inside pipeline + Type *string +} + +// PipelineConnectionProperties - Connection properties inside pipeline +type PipelineConnectionProperties struct { + // OPTIONAL; Contains additional key/value pairs not defined in the schema. + AdditionalProperties map[string]any + + // Internal metadata of the connection inside pipeline. + InternalMetadata *InternalMetadataProperties +} + +// PipelineProperties - Properties of pipeline +type PipelineProperties struct { + // REQUIRED; Remote cloud of the data to be transferred or received + RemoteCloud *string + + // Display name of this pipeline + DisplayName *string + + // The flow types allowed for this pipeline + FlowTypes []*FlowType + + // The policies for this pipeline + Policies []*string + + // Subscribers of this resource + Subscribers []*Subscriber + + // READ-ONLY; Connections associated with pipeline + Connections []*PipelineConnection + + // READ-ONLY; Provisioning state of the pipeline + ProvisioningState *ProvisioningState +} + +// PipelinesListResult - The pipelines list result. +type PipelinesListResult struct { + // Link to next results + NextLink *string + + // Pipelines array. + Value []*Pipeline +} + +// PipelinesPatch - The pipelines resource patch definition. +type PipelinesPatch struct { + // Properties of pipelines patch body. + Properties *PipelinesPatchProperties + + // Resource tags + Tags map[string]*string +} + +// PipelinesPatchProperties - Properties of pipelines patch body. +type PipelinesPatchProperties struct { + // Connections associated with pipeline + Connections []*PipelineConnection + + // The flow types allowed for this pipeline + FlowTypes []*FlowType +} + +// Plan for the resource. +type Plan struct { + // REQUIRED; A user defined name of the 3rd Party Artifact that is being procured. + Name *string + + // REQUIRED; The 3rd Party artifact that is being procured. E.g. NewRelic. Product maps to the OfferID specified for the artifact + // at the time of Data Market onboarding. + Product *string + + // REQUIRED; The publisher of the 3rd Party Artifact that is being bought. E.g. NewRelic + Publisher *string + + // A publisher provided promotion code as provisioned in Data Market for the said product/artifact. + PromotionCode *string + + // The version of the desired product/artifact. + Version *string +} + +// ResourceBody - The resource to reference. +type ResourceBody struct { + // REQUIRED; ID of the resource. + ID *string + + // Reason for resource operation. + StatusReason *string +} + +// Schema - The schema object. +type Schema struct { + // Connection ID associated with this schema + ConnectionID *string + + // Content of the schema + Content *string + + // The direction of the schema. + Direction *SchemaDirection + + // ID associated with this schema + ID *string + + // Name of the schema + Name *string + + // The Schema Type + SchemaType *SchemaType + + // Uri containing SAS token for the zipped schema + SchemaURI *string + + // Status of the schema + Status *SchemaStatus +} + +// SchemasListResult - The schemas list result. +type SchemasListResult struct { + // Schemas array. + Value []*Schema +} + +// SelectedResource - A resource selected from ARM +type SelectedResource struct { + // REQUIRED; Id of the connection + ID *string + + // Location of the connection + Location *string + + // Name of the connection + Name *string + + // Name of the subscription with the connection + SubscriptionName *string +} + +// SetDestinationEndpointPorts - Set the destination endpoint ports for the specified flow +type SetDestinationEndpointPorts struct { + // The specified flow destination endpoint ports + Ports []*int64 +} + +// SetDestinationEndpoints - Set the destination endpoints for the specified flow +type SetDestinationEndpoints struct { + // The specified flow destination endpoints + Endpoints []*string +} + +// SetSourceAddresses - Set the source addresses for the specified flow +type SetSourceAddresses struct { + // Source addresses + Values []*string +} + +// SetStreamPassphrase - Set the passphrase used for SRT streams +type SetStreamPassphrase struct { + // The passphrase used for SRT streams + Value *string +} + +// StreamSourceAddresses - The source IP address and CIDR ranges of the stream +type StreamSourceAddresses struct { + // A source IP address or CIDR range + SourceAddresses []*string +} + +type Subscriber struct { + // Email of the subscriber + Email *string + + // Number specifying what notifications to receive + Notifications *int64 +} + +// 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 +} + +// ValidateSchemaResult - Result of the schema validation. +type ValidateSchemaResult struct { + // Message describing the schema validation + Message *string + + // Validation status of the schema + Status *ValidateSchemaStatus +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/models_serde.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/models_serde.go new file mode 100644 index 000000000000..0885fa327efa --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/models_serde.go @@ -0,0 +1,1966 @@ +// 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 armazuredatatransfer + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Connection. +func (c Connection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", c.ID) + populate(objectMap, "location", c.Location) + populate(objectMap, "name", c.Name) + populate(objectMap, "properties", c.Properties) + populate(objectMap, "systemData", c.SystemData) + populate(objectMap, "tags", c.Tags) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Connection. +func (c *Connection) 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 "id": + err = unpopulate(val, "ID", &c.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &c.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &c.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &c.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &c.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + 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 ConnectionProperties. +func (c ConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "approver", c.Approver) + populateDateTimeRFC3339(objectMap, "dateSubmitted", c.DateSubmitted) + populate(objectMap, "direction", c.Direction) + populate(objectMap, "flowTypes", c.FlowTypes) + populate(objectMap, "justification", c.Justification) + populate(objectMap, "linkStatus", c.LinkStatus) + populate(objectMap, "linkedConnectionId", c.LinkedConnectionID) + populate(objectMap, "pin", c.Pin) + populate(objectMap, "pipeline", c.Pipeline) + populate(objectMap, "policies", c.Policies) + populate(objectMap, "primaryContact", c.PrimaryContact) + populate(objectMap, "provisioningState", c.ProvisioningState) + populate(objectMap, "remoteSubscriptionId", c.RemoteSubscriptionID) + populate(objectMap, "requirementId", c.RequirementID) + populate(objectMap, "schemaUris", c.SchemaUris) + populate(objectMap, "schemas", c.Schemas) + populate(objectMap, "secondaryContacts", c.SecondaryContacts) + populate(objectMap, "status", c.Status) + populate(objectMap, "statusReason", c.StatusReason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConnectionProperties. +func (c *ConnectionProperties) 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 "approver": + err = unpopulate(val, "Approver", &c.Approver) + delete(rawMsg, key) + case "dateSubmitted": + err = unpopulateDateTimeRFC3339(val, "DateSubmitted", &c.DateSubmitted) + delete(rawMsg, key) + case "direction": + err = unpopulate(val, "Direction", &c.Direction) + delete(rawMsg, key) + case "flowTypes": + err = unpopulate(val, "FlowTypes", &c.FlowTypes) + delete(rawMsg, key) + case "justification": + err = unpopulate(val, "Justification", &c.Justification) + delete(rawMsg, key) + case "linkStatus": + err = unpopulate(val, "LinkStatus", &c.LinkStatus) + delete(rawMsg, key) + case "linkedConnectionId": + err = unpopulate(val, "LinkedConnectionID", &c.LinkedConnectionID) + delete(rawMsg, key) + case "pin": + err = unpopulate(val, "Pin", &c.Pin) + delete(rawMsg, key) + case "pipeline": + err = unpopulate(val, "Pipeline", &c.Pipeline) + delete(rawMsg, key) + case "policies": + err = unpopulate(val, "Policies", &c.Policies) + delete(rawMsg, key) + case "primaryContact": + err = unpopulate(val, "PrimaryContact", &c.PrimaryContact) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) + delete(rawMsg, key) + case "remoteSubscriptionId": + err = unpopulate(val, "RemoteSubscriptionID", &c.RemoteSubscriptionID) + delete(rawMsg, key) + case "requirementId": + err = unpopulate(val, "RequirementID", &c.RequirementID) + delete(rawMsg, key) + case "schemaUris": + err = unpopulate(val, "SchemaUris", &c.SchemaUris) + delete(rawMsg, key) + case "schemas": + err = unpopulate(val, "Schemas", &c.Schemas) + delete(rawMsg, key) + case "secondaryContacts": + err = unpopulate(val, "SecondaryContacts", &c.SecondaryContacts) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &c.Status) + delete(rawMsg, key) + case "statusReason": + err = unpopulate(val, "StatusReason", &c.StatusReason) + 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 ConnectionsListResult. +func (c ConnectionsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConnectionsListResult. +func (c *ConnectionsListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &c.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &c.Value) + 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 ConnectionsPatch. +func (c ConnectionsPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "tags", c.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConnectionsPatch. +func (c *ConnectionsPatch) 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 "tags": + err = unpopulate(val, "Tags", &c.Tags) + 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 Flow. +func (f Flow) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", f.ID) + populate(objectMap, "identity", f.Identity) + populate(objectMap, "location", f.Location) + populate(objectMap, "name", f.Name) + populate(objectMap, "plan", f.Plan) + populate(objectMap, "properties", f.Properties) + populate(objectMap, "systemData", f.SystemData) + populate(objectMap, "tags", f.Tags) + populate(objectMap, "type", f.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Flow. +func (f *Flow) 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", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &f.ID) + delete(rawMsg, key) + case "identity": + err = unpopulate(val, "Identity", &f.Identity) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &f.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &f.Name) + delete(rawMsg, key) + case "plan": + err = unpopulate(val, "Plan", &f.Plan) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &f.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &f.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &f.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &f.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FlowProperties. +func (f FlowProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "connection", f.Connection) + populate(objectMap, "customerManagedKeyVaultUri", f.CustomerManagedKeyVaultURI) + populate(objectMap, "dataType", f.DataType) + populate(objectMap, "destinationEndpointPorts", f.DestinationEndpointPorts) + populate(objectMap, "destinationEndpoints", f.DestinationEndpoints) + populate(objectMap, "flowId", f.FlowID) + populate(objectMap, "flowType", f.FlowType) + populate(objectMap, "keyVaultUri", f.KeyVaultURI) + populate(objectMap, "linkStatus", f.LinkStatus) + populate(objectMap, "linkedFlowId", f.LinkedFlowID) + populate(objectMap, "messagingOptions", f.MessagingOptions) + populate(objectMap, "passphrase", f.Passphrase) + populate(objectMap, "policies", f.Policies) + populate(objectMap, "provisioningState", f.ProvisioningState) + populate(objectMap, "schema", f.Schema) + populate(objectMap, "serviceBusQueueId", f.ServiceBusQueueID) + populate(objectMap, "sourceAddresses", f.SourceAddresses) + populate(objectMap, "status", f.Status) + populate(objectMap, "storageAccountId", f.StorageAccountID) + populate(objectMap, "storageAccountName", f.StorageAccountName) + populate(objectMap, "storageContainerName", f.StorageContainerName) + populate(objectMap, "streamId", f.StreamID) + populate(objectMap, "streamLatency", f.StreamLatency) + populate(objectMap, "streamProtocol", f.StreamProtocol) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FlowProperties. +func (f *FlowProperties) 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", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "connection": + err = unpopulate(val, "Connection", &f.Connection) + delete(rawMsg, key) + case "customerManagedKeyVaultUri": + err = unpopulate(val, "CustomerManagedKeyVaultURI", &f.CustomerManagedKeyVaultURI) + delete(rawMsg, key) + case "dataType": + err = unpopulate(val, "DataType", &f.DataType) + delete(rawMsg, key) + case "destinationEndpointPorts": + err = unpopulate(val, "DestinationEndpointPorts", &f.DestinationEndpointPorts) + delete(rawMsg, key) + case "destinationEndpoints": + err = unpopulate(val, "DestinationEndpoints", &f.DestinationEndpoints) + delete(rawMsg, key) + case "flowId": + err = unpopulate(val, "FlowID", &f.FlowID) + delete(rawMsg, key) + case "flowType": + err = unpopulate(val, "FlowType", &f.FlowType) + delete(rawMsg, key) + case "keyVaultUri": + err = unpopulate(val, "KeyVaultURI", &f.KeyVaultURI) + delete(rawMsg, key) + case "linkStatus": + err = unpopulate(val, "LinkStatus", &f.LinkStatus) + delete(rawMsg, key) + case "linkedFlowId": + err = unpopulate(val, "LinkedFlowID", &f.LinkedFlowID) + delete(rawMsg, key) + case "messagingOptions": + err = unpopulate(val, "MessagingOptions", &f.MessagingOptions) + delete(rawMsg, key) + case "passphrase": + err = unpopulate(val, "Passphrase", &f.Passphrase) + delete(rawMsg, key) + case "policies": + err = unpopulate(val, "Policies", &f.Policies) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &f.ProvisioningState) + delete(rawMsg, key) + case "schema": + err = unpopulate(val, "Schema", &f.Schema) + delete(rawMsg, key) + case "serviceBusQueueId": + err = unpopulate(val, "ServiceBusQueueID", &f.ServiceBusQueueID) + delete(rawMsg, key) + case "sourceAddresses": + err = unpopulate(val, "SourceAddresses", &f.SourceAddresses) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &f.Status) + delete(rawMsg, key) + case "storageAccountId": + err = unpopulate(val, "StorageAccountID", &f.StorageAccountID) + delete(rawMsg, key) + case "storageAccountName": + err = unpopulate(val, "StorageAccountName", &f.StorageAccountName) + delete(rawMsg, key) + case "storageContainerName": + err = unpopulate(val, "StorageContainerName", &f.StorageContainerName) + delete(rawMsg, key) + case "streamId": + err = unpopulate(val, "StreamID", &f.StreamID) + delete(rawMsg, key) + case "streamLatency": + err = unpopulate(val, "StreamLatency", &f.StreamLatency) + delete(rawMsg, key) + case "streamProtocol": + err = unpopulate(val, "StreamProtocol", &f.StreamProtocol) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FlowsListResult. +func (f FlowsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", f.NextLink) + populate(objectMap, "value", f.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FlowsListResult. +func (f *FlowsListResult) 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", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &f.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &f.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FlowsPatch. +func (f FlowsPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "identity", f.Identity) + populate(objectMap, "tags", f.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FlowsPatch. +func (f *FlowsPatch) 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", f, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "identity": + err = unpopulate(val, "Identity", &f.Identity) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &f.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", f, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GetDestinationEndpointPortsResult. +func (g GetDestinationEndpointPortsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ports", g.Ports) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GetDestinationEndpointPortsResult. +func (g *GetDestinationEndpointPortsResult) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "ports": + err = unpopulate(val, "Ports", &g.Ports) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GetDestinationEndpointsResult. +func (g GetDestinationEndpointsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "endpoints", g.Endpoints) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GetDestinationEndpointsResult. +func (g *GetDestinationEndpointsResult) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "endpoints": + err = unpopulate(val, "Endpoints", &g.Endpoints) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type GetStreamConnectionStringResult. +func (g GetStreamConnectionStringResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "connectionString", g.ConnectionString) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GetStreamConnectionStringResult. +func (g *GetStreamConnectionStringResult) 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", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "connectionString": + err = unpopulate(val, "ConnectionString", &g.ConnectionString) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type InternalMetadataProperties. +func (i InternalMetadataProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "operationStatus", i.OperationStatus) + populate(objectMap, "statusSetBy", i.StatusSetBy) + if i.AdditionalProperties != nil { + for key, val := range i.AdditionalProperties { + objectMap[key] = val + } + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InternalMetadataProperties. +func (i *InternalMetadataProperties) 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 "operationStatus": + err = unpopulate(val, "OperationStatus", &i.OperationStatus) + delete(rawMsg, key) + case "statusSetBy": + err = unpopulate(val, "StatusSetBy", &i.StatusSetBy) + delete(rawMsg, key) + default: + if i.AdditionalProperties == nil { + i.AdditionalProperties = map[string]any{} + } + if val != nil { + var aux any + err = json.Unmarshal(val, &aux) + i.AdditionalProperties[key] = aux + } + 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 ListApprovedSchemasRequest. +func (l ListApprovedSchemasRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "direction", l.Direction) + populate(objectMap, "pipeline", l.Pipeline) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListApprovedSchemasRequest. +func (l *ListApprovedSchemasRequest) 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 "direction": + err = unpopulate(val, "Direction", &l.Direction) + delete(rawMsg, key) + case "pipeline": + err = unpopulate(val, "Pipeline", &l.Pipeline) + 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 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 MessagingOptions. +func (m MessagingOptions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "billingTier", m.BillingTier) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type MessagingOptions. +func (m *MessagingOptions) 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 "billingTier": + err = unpopulate(val, "BillingTier", &m.BillingTier) + 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 OperationStatusProperties. +func (o OperationStatusProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", o.ID) + populate(objectMap, "message", o.Message) + populate(objectMap, "status", o.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationStatusProperties. +func (o *OperationStatusProperties) 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 "id": + err = unpopulate(val, "ID", &o.ID) + delete(rawMsg, key) + case "message": + err = unpopulate(val, "Message", &o.Message) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &o.Status) + 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 PendingConnection. +func (p PendingConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "approver", p.Approver) + populateDateTimeRFC3339(objectMap, "dateSubmitted", p.DateSubmitted) + populate(objectMap, "direction", p.Direction) + populate(objectMap, "flowTypes", p.FlowTypes) + populate(objectMap, "id", p.ID) + populate(objectMap, "justification", p.Justification) + populate(objectMap, "linkStatus", p.LinkStatus) + populate(objectMap, "linkedConnectionId", p.LinkedConnectionID) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "pin", p.Pin) + populate(objectMap, "pipeline", p.Pipeline) + populate(objectMap, "policies", p.Policies) + populate(objectMap, "primaryContact", p.PrimaryContact) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "remoteSubscriptionId", p.RemoteSubscriptionID) + populate(objectMap, "requirementId", p.RequirementID) + populate(objectMap, "schemaUris", p.SchemaUris) + populate(objectMap, "schemas", p.Schemas) + populate(objectMap, "secondaryContacts", p.SecondaryContacts) + populate(objectMap, "status", p.Status) + populate(objectMap, "statusReason", p.StatusReason) + populate(objectMap, "subscriptionId", p.SubscriptionID) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PendingConnection. +func (p *PendingConnection) 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 "approver": + err = unpopulate(val, "Approver", &p.Approver) + delete(rawMsg, key) + case "dateSubmitted": + err = unpopulateDateTimeRFC3339(val, "DateSubmitted", &p.DateSubmitted) + delete(rawMsg, key) + case "direction": + err = unpopulate(val, "Direction", &p.Direction) + delete(rawMsg, key) + case "flowTypes": + err = unpopulate(val, "FlowTypes", &p.FlowTypes) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "justification": + err = unpopulate(val, "Justification", &p.Justification) + delete(rawMsg, key) + case "linkStatus": + err = unpopulate(val, "LinkStatus", &p.LinkStatus) + delete(rawMsg, key) + case "linkedConnectionId": + err = unpopulate(val, "LinkedConnectionID", &p.LinkedConnectionID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "pin": + err = unpopulate(val, "Pin", &p.Pin) + delete(rawMsg, key) + case "pipeline": + err = unpopulate(val, "Pipeline", &p.Pipeline) + delete(rawMsg, key) + case "policies": + err = unpopulate(val, "Policies", &p.Policies) + delete(rawMsg, key) + case "primaryContact": + err = unpopulate(val, "PrimaryContact", &p.PrimaryContact) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "remoteSubscriptionId": + err = unpopulate(val, "RemoteSubscriptionID", &p.RemoteSubscriptionID) + delete(rawMsg, key) + case "requirementId": + err = unpopulate(val, "RequirementID", &p.RequirementID) + delete(rawMsg, key) + case "schemaUris": + err = unpopulate(val, "SchemaUris", &p.SchemaUris) + delete(rawMsg, key) + case "schemas": + err = unpopulate(val, "Schemas", &p.Schemas) + delete(rawMsg, key) + case "secondaryContacts": + err = unpopulate(val, "SecondaryContacts", &p.SecondaryContacts) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "statusReason": + err = unpopulate(val, "StatusReason", &p.StatusReason) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &p.SubscriptionID) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + 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 PendingConnectionsListResult. +func (p PendingConnectionsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PendingConnectionsListResult. +func (p *PendingConnectionsListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + 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 PendingFlow. +func (p PendingFlow) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "connection", p.Connection) + populate(objectMap, "connectionId", p.ConnectionID) + populate(objectMap, "customerManagedKeyVaultUri", p.CustomerManagedKeyVaultURI) + populate(objectMap, "dataType", p.DataType) + populate(objectMap, "destinationEndpointPorts", p.DestinationEndpointPorts) + populate(objectMap, "destinationEndpoints", p.DestinationEndpoints) + populate(objectMap, "flowId", p.FlowID) + populate(objectMap, "flowType", p.FlowType) + populate(objectMap, "id", p.ID) + populate(objectMap, "keyVaultUri", p.KeyVaultURI) + populate(objectMap, "linkStatus", p.LinkStatus) + populate(objectMap, "linkedFlowId", p.LinkedFlowID) + populate(objectMap, "location", p.Location) + populate(objectMap, "messagingOptions", p.MessagingOptions) + populate(objectMap, "name", p.Name) + populate(objectMap, "passphrase", p.Passphrase) + populate(objectMap, "policies", p.Policies) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "schema", p.Schema) + populate(objectMap, "serviceBusQueueId", p.ServiceBusQueueID) + populate(objectMap, "sourceAddresses", p.SourceAddresses) + populate(objectMap, "status", p.Status) + populate(objectMap, "storageAccountId", p.StorageAccountID) + populate(objectMap, "storageAccountName", p.StorageAccountName) + populate(objectMap, "storageContainerName", p.StorageContainerName) + populate(objectMap, "streamId", p.StreamID) + populate(objectMap, "streamLatency", p.StreamLatency) + populate(objectMap, "streamProtocol", p.StreamProtocol) + populate(objectMap, "subscriptionId", p.SubscriptionID) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PendingFlow. +func (p *PendingFlow) 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 "connection": + err = unpopulate(val, "Connection", &p.Connection) + delete(rawMsg, key) + case "connectionId": + err = unpopulate(val, "ConnectionID", &p.ConnectionID) + delete(rawMsg, key) + case "customerManagedKeyVaultUri": + err = unpopulate(val, "CustomerManagedKeyVaultURI", &p.CustomerManagedKeyVaultURI) + delete(rawMsg, key) + case "dataType": + err = unpopulate(val, "DataType", &p.DataType) + delete(rawMsg, key) + case "destinationEndpointPorts": + err = unpopulate(val, "DestinationEndpointPorts", &p.DestinationEndpointPorts) + delete(rawMsg, key) + case "destinationEndpoints": + err = unpopulate(val, "DestinationEndpoints", &p.DestinationEndpoints) + delete(rawMsg, key) + case "flowId": + err = unpopulate(val, "FlowID", &p.FlowID) + delete(rawMsg, key) + case "flowType": + err = unpopulate(val, "FlowType", &p.FlowType) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "keyVaultUri": + err = unpopulate(val, "KeyVaultURI", &p.KeyVaultURI) + delete(rawMsg, key) + case "linkStatus": + err = unpopulate(val, "LinkStatus", &p.LinkStatus) + delete(rawMsg, key) + case "linkedFlowId": + err = unpopulate(val, "LinkedFlowID", &p.LinkedFlowID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "messagingOptions": + err = unpopulate(val, "MessagingOptions", &p.MessagingOptions) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "passphrase": + err = unpopulate(val, "Passphrase", &p.Passphrase) + delete(rawMsg, key) + case "policies": + err = unpopulate(val, "Policies", &p.Policies) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "schema": + err = unpopulate(val, "Schema", &p.Schema) + delete(rawMsg, key) + case "serviceBusQueueId": + err = unpopulate(val, "ServiceBusQueueID", &p.ServiceBusQueueID) + delete(rawMsg, key) + case "sourceAddresses": + err = unpopulate(val, "SourceAddresses", &p.SourceAddresses) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &p.Status) + delete(rawMsg, key) + case "storageAccountId": + err = unpopulate(val, "StorageAccountID", &p.StorageAccountID) + delete(rawMsg, key) + case "storageAccountName": + err = unpopulate(val, "StorageAccountName", &p.StorageAccountName) + delete(rawMsg, key) + case "storageContainerName": + err = unpopulate(val, "StorageContainerName", &p.StorageContainerName) + delete(rawMsg, key) + case "streamId": + err = unpopulate(val, "StreamID", &p.StreamID) + delete(rawMsg, key) + case "streamLatency": + err = unpopulate(val, "StreamLatency", &p.StreamLatency) + delete(rawMsg, key) + case "streamProtocol": + err = unpopulate(val, "StreamProtocol", &p.StreamProtocol) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, "SubscriptionID", &p.SubscriptionID) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + 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 PendingFlowsListResult. +func (p PendingFlowsListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PendingFlowsListResult. +func (p *PendingFlowsListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + 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 Pipeline. +func (p Pipeline) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", p.ID) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "tags", p.Tags) + populate(objectMap, "type", p.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Pipeline. +func (p *Pipeline) 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 "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + 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 PipelineConnection. +func (p PipelineConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "etag", p.Etag) + populate(objectMap, "id", p.ID) + populate(objectMap, "location", p.Location) + populate(objectMap, "name", p.Name) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "systemData", p.SystemData) + populate(objectMap, "type", p.Type) + if p.AdditionalProperties != nil { + for key, val := range p.AdditionalProperties { + objectMap[key] = val + } + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelineConnection. +func (p *PipelineConnection) 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 "etag": + err = unpopulate(val, "Etag", &p.Etag) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &p.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &p.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &p.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &p.Type) + delete(rawMsg, key) + default: + if p.AdditionalProperties == nil { + p.AdditionalProperties = map[string]any{} + } + if val != nil { + var aux any + err = json.Unmarshal(val, &aux) + p.AdditionalProperties[key] = aux + } + 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 PipelineConnectionProperties. +func (p PipelineConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "internalMetadata", p.InternalMetadata) + if p.AdditionalProperties != nil { + for key, val := range p.AdditionalProperties { + objectMap[key] = val + } + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelineConnectionProperties. +func (p *PipelineConnectionProperties) 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 "internalMetadata": + err = unpopulate(val, "InternalMetadata", &p.InternalMetadata) + delete(rawMsg, key) + default: + if p.AdditionalProperties == nil { + p.AdditionalProperties = map[string]any{} + } + if val != nil { + var aux any + err = json.Unmarshal(val, &aux) + p.AdditionalProperties[key] = aux + } + 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 PipelineProperties. +func (p PipelineProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "connections", p.Connections) + populate(objectMap, "displayName", p.DisplayName) + populate(objectMap, "flowTypes", p.FlowTypes) + populate(objectMap, "policies", p.Policies) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "remoteCloud", p.RemoteCloud) + populate(objectMap, "subscribers", p.Subscribers) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelineProperties. +func (p *PipelineProperties) 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 "connections": + err = unpopulate(val, "Connections", &p.Connections) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, "DisplayName", &p.DisplayName) + delete(rawMsg, key) + case "flowTypes": + err = unpopulate(val, "FlowTypes", &p.FlowTypes) + delete(rawMsg, key) + case "policies": + err = unpopulate(val, "Policies", &p.Policies) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &p.ProvisioningState) + delete(rawMsg, key) + case "remoteCloud": + err = unpopulate(val, "RemoteCloud", &p.RemoteCloud) + delete(rawMsg, key) + case "subscribers": + err = unpopulate(val, "Subscribers", &p.Subscribers) + 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 PipelinesListResult. +func (p PipelinesListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelinesListResult. +func (p *PipelinesListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &p.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &p.Value) + 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 PipelinesPatch. +func (p PipelinesPatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", p.Properties) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelinesPatch. +func (p *PipelinesPatch) 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 "properties": + err = unpopulate(val, "Properties", &p.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &p.Tags) + 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 PipelinesPatchProperties. +func (p PipelinesPatchProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "connections", p.Connections) + populate(objectMap, "flowTypes", p.FlowTypes) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PipelinesPatchProperties. +func (p *PipelinesPatchProperties) 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 "connections": + err = unpopulate(val, "Connections", &p.Connections) + delete(rawMsg, key) + case "flowTypes": + err = unpopulate(val, "FlowTypes", &p.FlowTypes) + 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 Plan. +func (p Plan) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", p.Name) + populate(objectMap, "product", p.Product) + populate(objectMap, "promotionCode", p.PromotionCode) + populate(objectMap, "publisher", p.Publisher) + populate(objectMap, "version", p.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Plan. +func (p *Plan) 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 "name": + err = unpopulate(val, "Name", &p.Name) + delete(rawMsg, key) + case "product": + err = unpopulate(val, "Product", &p.Product) + delete(rawMsg, key) + case "promotionCode": + err = unpopulate(val, "PromotionCode", &p.PromotionCode) + delete(rawMsg, key) + case "publisher": + err = unpopulate(val, "Publisher", &p.Publisher) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &p.Version) + 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 ResourceBody. +func (r ResourceBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", r.ID) + populate(objectMap, "statusReason", r.StatusReason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceBody. +func (r *ResourceBody) 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 "id": + err = unpopulate(val, "ID", &r.ID) + delete(rawMsg, key) + case "statusReason": + err = unpopulate(val, "StatusReason", &r.StatusReason) + 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 Schema. +func (s Schema) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "connectionId", s.ConnectionID) + populate(objectMap, "content", s.Content) + populate(objectMap, "direction", s.Direction) + populate(objectMap, "id", s.ID) + populate(objectMap, "name", s.Name) + populate(objectMap, "schemaType", s.SchemaType) + populate(objectMap, "schemaUri", s.SchemaURI) + populate(objectMap, "status", s.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Schema. +func (s *Schema) 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 "connectionId": + err = unpopulate(val, "ConnectionID", &s.ConnectionID) + delete(rawMsg, key) + case "content": + err = unpopulate(val, "Content", &s.Content) + delete(rawMsg, key) + case "direction": + err = unpopulate(val, "Direction", &s.Direction) + delete(rawMsg, key) + case "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "schemaType": + err = unpopulate(val, "SchemaType", &s.SchemaType) + delete(rawMsg, key) + case "schemaUri": + err = unpopulate(val, "SchemaURI", &s.SchemaURI) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &s.Status) + 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 SchemasListResult. +func (s SchemasListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SchemasListResult. +func (s *SchemasListResult) 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 "value": + err = unpopulate(val, "Value", &s.Value) + 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 SelectedResource. +func (s SelectedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", s.ID) + populate(objectMap, "location", s.Location) + populate(objectMap, "name", s.Name) + populate(objectMap, "subscriptionName", s.SubscriptionName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SelectedResource. +func (s *SelectedResource) 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 "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &s.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "subscriptionName": + err = unpopulate(val, "SubscriptionName", &s.SubscriptionName) + 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 SetDestinationEndpointPorts. +func (s SetDestinationEndpointPorts) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "ports", s.Ports) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SetDestinationEndpointPorts. +func (s *SetDestinationEndpointPorts) 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 "ports": + err = unpopulate(val, "Ports", &s.Ports) + 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 SetDestinationEndpoints. +func (s SetDestinationEndpoints) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "endpoints", s.Endpoints) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SetDestinationEndpoints. +func (s *SetDestinationEndpoints) 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 "endpoints": + err = unpopulate(val, "Endpoints", &s.Endpoints) + 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 SetSourceAddresses. +func (s SetSourceAddresses) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "values", s.Values) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SetSourceAddresses. +func (s *SetSourceAddresses) 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 "values": + err = unpopulate(val, "Values", &s.Values) + 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 SetStreamPassphrase. +func (s SetStreamPassphrase) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SetStreamPassphrase. +func (s *SetStreamPassphrase) 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 "value": + err = unpopulate(val, "Value", &s.Value) + 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 StreamSourceAddresses. +func (s StreamSourceAddresses) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "sourceAddresses", s.SourceAddresses) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type StreamSourceAddresses. +func (s *StreamSourceAddresses) 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 "sourceAddresses": + err = unpopulate(val, "SourceAddresses", &s.SourceAddresses) + 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 Subscriber. +func (s Subscriber) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "email", s.Email) + populate(objectMap, "notifications", s.Notifications) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Subscriber. +func (s *Subscriber) 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 "email": + err = unpopulate(val, "Email", &s.Email) + delete(rawMsg, key) + case "notifications": + err = unpopulate(val, "Notifications", &s.Notifications) + 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 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 ValidateSchemaResult. +func (v ValidateSchemaResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", v.Message) + populate(objectMap, "status", v.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ValidateSchemaResult. +func (v *ValidateSchemaResult) 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 "message": + err = unpopulate(val, "Message", &v.Message) + delete(rawMsg, key) + case "status": + err = unpopulate(val, "Status", &v.Status) + 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 || string(data) == "null" { + 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/azuredatatransfer/armazuredatatransfer/operations_client.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/operations_client.go new file mode 100644 index 000000000000..20b878867765 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/operations_client.go @@ -0,0 +1,85 @@ +// 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 armazuredatatransfer + +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 - Lists all of the available Microsoft.AzureDataTransfer REST API operations. +// +// Generated from API version 2025-05-12 +// - 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, _ *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AzureDataTransfer/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", "2025-05-12") + 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/azuredatatransfer/armazuredatatransfer/options.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/options.go new file mode 100644 index 000000000000..750e4b1c54ab --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/options.go @@ -0,0 +1,232 @@ +// 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 armazuredatatransfer + +// ClientListApprovedSchemasOptions contains the optional parameters for the Client.ListApprovedSchemas method. +type ClientListApprovedSchemasOptions struct { + // placeholder for future optional parameters +} + +// ClientValidateSchemaOptions contains the optional parameters for the Client.ValidateSchema method. +type ClientValidateSchemaOptions struct { + // placeholder for future optional parameters +} + +// ConnectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the ConnectionsClient.BeginCreateOrUpdate +// method. +type ConnectionsClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ConnectionsClientBeginDeleteOptions contains the optional parameters for the ConnectionsClient.BeginDelete method. +type ConnectionsClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ConnectionsClientBeginLinkOptions contains the optional parameters for the ConnectionsClient.BeginLink method. +type ConnectionsClientBeginLinkOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ConnectionsClientBeginUpdateOptions contains the optional parameters for the ConnectionsClient.BeginUpdate method. +type ConnectionsClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// ConnectionsClientGetOptions contains the optional parameters for the ConnectionsClient.Get method. +type ConnectionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ConnectionsClientListByResourceGroupOptions contains the optional parameters for the ConnectionsClient.NewListByResourceGroupPager +// method. +type ConnectionsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// ConnectionsClientListBySubscriptionOptions contains the optional parameters for the ConnectionsClient.NewListBySubscriptionPager +// method. +type ConnectionsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// FlowsClientBeginCreateOrUpdateOptions contains the optional parameters for the FlowsClient.BeginCreateOrUpdate method. +type FlowsClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FlowsClientBeginDeleteOptions contains the optional parameters for the FlowsClient.BeginDelete method. +type FlowsClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FlowsClientBeginDisableOptions contains the optional parameters for the FlowsClient.BeginDisable method. +type FlowsClientBeginDisableOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FlowsClientBeginEnableOptions contains the optional parameters for the FlowsClient.BeginEnable method. +type FlowsClientBeginEnableOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FlowsClientBeginGeneratePassphraseOptions contains the optional parameters for the FlowsClient.BeginGeneratePassphrase +// method. +type FlowsClientBeginGeneratePassphraseOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FlowsClientBeginLinkOptions contains the optional parameters for the FlowsClient.BeginLink method. +type FlowsClientBeginLinkOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FlowsClientBeginSetDestinationEndpointPortsOptions contains the optional parameters for the FlowsClient.BeginSetDestinationEndpointPorts +// method. +type FlowsClientBeginSetDestinationEndpointPortsOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FlowsClientBeginSetDestinationEndpointsOptions contains the optional parameters for the FlowsClient.BeginSetDestinationEndpoints +// method. +type FlowsClientBeginSetDestinationEndpointsOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FlowsClientBeginSetPassphraseOptions contains the optional parameters for the FlowsClient.BeginSetPassphrase method. +type FlowsClientBeginSetPassphraseOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FlowsClientBeginSetSourceAddressesOptions contains the optional parameters for the FlowsClient.BeginSetSourceAddresses +// method. +type FlowsClientBeginSetSourceAddressesOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FlowsClientBeginUpdateOptions contains the optional parameters for the FlowsClient.BeginUpdate method. +type FlowsClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// FlowsClientGetDestinationEndpointPortsOptions contains the optional parameters for the FlowsClient.GetDestinationEndpointPorts +// method. +type FlowsClientGetDestinationEndpointPortsOptions struct { + // placeholder for future optional parameters +} + +// FlowsClientGetDestinationEndpointsOptions contains the optional parameters for the FlowsClient.GetDestinationEndpoints +// method. +type FlowsClientGetDestinationEndpointsOptions struct { + // placeholder for future optional parameters +} + +// FlowsClientGetOptions contains the optional parameters for the FlowsClient.Get method. +type FlowsClientGetOptions struct { + // placeholder for future optional parameters +} + +// FlowsClientGetSourceAddressesOptions contains the optional parameters for the FlowsClient.GetSourceAddresses method. +type FlowsClientGetSourceAddressesOptions struct { + // placeholder for future optional parameters +} + +// FlowsClientGetStreamConnectionStringOptions contains the optional parameters for the FlowsClient.GetStreamConnectionString +// method. +type FlowsClientGetStreamConnectionStringOptions struct { + // placeholder for future optional parameters +} + +// FlowsClientListByConnectionOptions contains the optional parameters for the FlowsClient.NewListByConnectionPager method. +type FlowsClientListByConnectionOptions struct { + // placeholder for future optional parameters +} + +// ListPendingConnectionsClientListOptions contains the optional parameters for the ListPendingConnectionsClient.NewListPager +// method. +type ListPendingConnectionsClientListOptions struct { + // placeholder for future optional parameters +} + +// ListPendingFlowsClientListOptions contains the optional parameters for the ListPendingFlowsClient.NewListPager method. +type ListPendingFlowsClientListOptions struct { + // placeholder for future optional parameters +} + +// ListSchemasClientListOptions contains the optional parameters for the ListSchemasClient.List method. +type ListSchemasClientListOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// PipelinesClientBeginApproveConnectionOptions contains the optional parameters for the PipelinesClient.BeginApproveConnection +// method. +type PipelinesClientBeginApproveConnectionOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// PipelinesClientBeginCreateOrUpdateOptions contains the optional parameters for the PipelinesClient.BeginCreateOrUpdate +// method. +type PipelinesClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// PipelinesClientBeginDeleteOptions contains the optional parameters for the PipelinesClient.BeginDelete method. +type PipelinesClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// PipelinesClientBeginRejectConnectionOptions contains the optional parameters for the PipelinesClient.BeginRejectConnection +// method. +type PipelinesClientBeginRejectConnectionOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// PipelinesClientBeginUpdateOptions contains the optional parameters for the PipelinesClient.BeginUpdate method. +type PipelinesClientBeginUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// PipelinesClientGetOptions contains the optional parameters for the PipelinesClient.Get method. +type PipelinesClientGetOptions struct { + // placeholder for future optional parameters +} + +// PipelinesClientListByResourceGroupOptions contains the optional parameters for the PipelinesClient.NewListByResourceGroupPager +// method. +type PipelinesClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// PipelinesClientListBySubscriptionOptions contains the optional parameters for the PipelinesClient.NewListBySubscriptionPager +// method. +type PipelinesClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/pipelines_client.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/pipelines_client.go new file mode 100644 index 000000000000..5b286bd968f9 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/pipelines_client.go @@ -0,0 +1,619 @@ +// 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 armazuredatatransfer + +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" +) + +// PipelinesClient contains the methods for the Pipelines group. +// Don't use this type directly, use NewPipelinesClient() instead. +type PipelinesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewPipelinesClient creates a new instance of PipelinesClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewPipelinesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PipelinesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PipelinesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginApproveConnection - Approves the specified connection request in a pipeline. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - pipelineName - The name for the pipeline to perform the operation on. +// - connection - Connection body +// - options - PipelinesClientBeginApproveConnectionOptions contains the optional parameters for the PipelinesClient.BeginApproveConnection +// method. +func (client *PipelinesClient) BeginApproveConnection(ctx context.Context, resourceGroupName string, pipelineName string, connection ResourceBody, options *PipelinesClientBeginApproveConnectionOptions) (*runtime.Poller[PipelinesClientApproveConnectionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.approveConnection(ctx, resourceGroupName, pipelineName, connection, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PipelinesClientApproveConnectionResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PipelinesClientApproveConnectionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// ApproveConnection - Approves the specified connection request in a pipeline. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *PipelinesClient) approveConnection(ctx context.Context, resourceGroupName string, pipelineName string, connection ResourceBody, options *PipelinesClientBeginApproveConnectionOptions) (*http.Response, error) { + var err error + const operationName = "PipelinesClient.BeginApproveConnection" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.approveConnectionCreateRequest(ctx, resourceGroupName, pipelineName, connection, 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 +} + +// approveConnectionCreateRequest creates the ApproveConnection request. +func (client *PipelinesClient) approveConnectionCreateRequest(ctx context.Context, resourceGroupName string, pipelineName string, connection ResourceBody, _ *PipelinesClientBeginApproveConnectionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/pipelines/{pipelineName}/approveConnection" + 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 pipelineName == "" { + return nil, errors.New("parameter pipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineName}", url.PathEscape(pipelineName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, connection); err != nil { + return nil, err + } + return req, nil +} + +// BeginCreateOrUpdate - Creates or updates the pipeline resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - pipelineName - The name for the pipeline to perform the operation on. +// - pipeline - Pipeline body +// - options - PipelinesClientBeginCreateOrUpdateOptions contains the optional parameters for the PipelinesClient.BeginCreateOrUpdate +// method. +func (client *PipelinesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, pipelineName string, pipeline Pipeline, options *PipelinesClientBeginCreateOrUpdateOptions) (*runtime.Poller[PipelinesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, pipelineName, pipeline, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PipelinesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PipelinesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Creates or updates the pipeline resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *PipelinesClient) createOrUpdate(ctx context.Context, resourceGroupName string, pipelineName string, pipeline Pipeline, options *PipelinesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "PipelinesClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, pipelineName, pipeline, 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 +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PipelinesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, pipelineName string, pipeline Pipeline, _ *PipelinesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/pipelines/{pipelineName}" + 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 pipelineName == "" { + return nil, errors.New("parameter pipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineName}", url.PathEscape(pipelineName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, pipeline); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Deletes the pipeline resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - pipelineName - The name for the pipeline to perform the operation on. +// - options - PipelinesClientBeginDeleteOptions contains the optional parameters for the PipelinesClient.BeginDelete method. +func (client *PipelinesClient) BeginDelete(ctx context.Context, resourceGroupName string, pipelineName string, options *PipelinesClientBeginDeleteOptions) (*runtime.Poller[PipelinesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, pipelineName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PipelinesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PipelinesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Deletes the pipeline resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *PipelinesClient) deleteOperation(ctx context.Context, resourceGroupName string, pipelineName string, options *PipelinesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "PipelinesClient.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, pipelineName, 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 *PipelinesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, pipelineName string, _ *PipelinesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/pipelines/{pipelineName}" + 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 pipelineName == "" { + return nil, errors.New("parameter pipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineName}", url.PathEscape(pipelineName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets pipeline resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - pipelineName - The name for the pipeline to perform the operation on. +// - options - PipelinesClientGetOptions contains the optional parameters for the PipelinesClient.Get method. +func (client *PipelinesClient) Get(ctx context.Context, resourceGroupName string, pipelineName string, options *PipelinesClientGetOptions) (PipelinesClientGetResponse, error) { + var err error + const operationName = "PipelinesClient.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, pipelineName, options) + if err != nil { + return PipelinesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PipelinesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return PipelinesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *PipelinesClient) getCreateRequest(ctx context.Context, resourceGroupName string, pipelineName string, _ *PipelinesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/pipelines/{pipelineName}" + 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 pipelineName == "" { + return nil, errors.New("parameter pipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineName}", url.PathEscape(pipelineName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PipelinesClient) getHandleResponse(resp *http.Response) (PipelinesClientGetResponse, error) { + result := PipelinesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Pipeline); err != nil { + return PipelinesClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Gets pipelines in a resource group. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - PipelinesClientListByResourceGroupOptions contains the optional parameters for the PipelinesClient.NewListByResourceGroupPager +// method. +func (client *PipelinesClient) NewListByResourceGroupPager(resourceGroupName string, options *PipelinesClientListByResourceGroupOptions) *runtime.Pager[PipelinesClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[PipelinesClientListByResourceGroupResponse]{ + More: func(page PipelinesClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PipelinesClientListByResourceGroupResponse) (PipelinesClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PipelinesClient.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 PipelinesClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *PipelinesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *PipelinesClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/pipelines" + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *PipelinesClient) listByResourceGroupHandleResponse(resp *http.Response) (PipelinesClientListByResourceGroupResponse, error) { + result := PipelinesClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PipelinesListResult); err != nil { + return PipelinesClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Gets pipelines in a subscription. +// +// Generated from API version 2025-05-12 +// - options - PipelinesClientListBySubscriptionOptions contains the optional parameters for the PipelinesClient.NewListBySubscriptionPager +// method. +func (client *PipelinesClient) NewListBySubscriptionPager(options *PipelinesClientListBySubscriptionOptions) *runtime.Pager[PipelinesClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[PipelinesClientListBySubscriptionResponse]{ + More: func(page PipelinesClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *PipelinesClientListBySubscriptionResponse) (PipelinesClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PipelinesClient.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 PipelinesClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *PipelinesClient) listBySubscriptionCreateRequest(ctx context.Context, _ *PipelinesClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.AzureDataTransfer/pipelines" + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *PipelinesClient) listBySubscriptionHandleResponse(resp *http.Response) (PipelinesClientListBySubscriptionResponse, error) { + result := PipelinesClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PipelinesListResult); err != nil { + return PipelinesClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// BeginRejectConnection - Rejects the specified connection request in a pipeline. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - pipelineName - The name for the pipeline to perform the operation on. +// - connection - Connection body +// - options - PipelinesClientBeginRejectConnectionOptions contains the optional parameters for the PipelinesClient.BeginRejectConnection +// method. +func (client *PipelinesClient) BeginRejectConnection(ctx context.Context, resourceGroupName string, pipelineName string, connection ResourceBody, options *PipelinesClientBeginRejectConnectionOptions) (*runtime.Poller[PipelinesClientRejectConnectionResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.rejectConnection(ctx, resourceGroupName, pipelineName, connection, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PipelinesClientRejectConnectionResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PipelinesClientRejectConnectionResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// RejectConnection - Rejects the specified connection request in a pipeline. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *PipelinesClient) rejectConnection(ctx context.Context, resourceGroupName string, pipelineName string, connection ResourceBody, options *PipelinesClientBeginRejectConnectionOptions) (*http.Response, error) { + var err error + const operationName = "PipelinesClient.BeginRejectConnection" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.rejectConnectionCreateRequest(ctx, resourceGroupName, pipelineName, connection, 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 +} + +// rejectConnectionCreateRequest creates the RejectConnection request. +func (client *PipelinesClient) rejectConnectionCreateRequest(ctx context.Context, resourceGroupName string, pipelineName string, connection ResourceBody, _ *PipelinesClientBeginRejectConnectionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/pipelines/{pipelineName}/rejectConnection" + 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 pipelineName == "" { + return nil, errors.New("parameter pipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineName}", url.PathEscape(pipelineName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, connection); err != nil { + return nil, err + } + return req, nil +} + +// BeginUpdate - Updates the pipeline resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - pipelineName - The name for the pipeline to perform the operation on. +// - pipeline - Pipeline body +// - options - PipelinesClientBeginUpdateOptions contains the optional parameters for the PipelinesClient.BeginUpdate method. +func (client *PipelinesClient) BeginUpdate(ctx context.Context, resourceGroupName string, pipelineName string, pipeline PipelinesPatch, options *PipelinesClientBeginUpdateOptions) (*runtime.Poller[PipelinesClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, pipelineName, pipeline, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PipelinesClientUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PipelinesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Update - Updates the pipeline resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-05-12 +func (client *PipelinesClient) update(ctx context.Context, resourceGroupName string, pipelineName string, pipeline PipelinesPatch, options *PipelinesClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "PipelinesClient.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, pipelineName, pipeline, 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 *PipelinesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, pipelineName string, pipeline PipelinesPatch, _ *PipelinesClientBeginUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureDataTransfer/pipelines/{pipelineName}" + 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 pipelineName == "" { + return nil, errors.New("parameter pipelineName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{pipelineName}", url.PathEscape(pipelineName)) + 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", "2025-05-12") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, pipeline); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/responses.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/responses.go new file mode 100644 index 000000000000..47a6e27f7233 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/responses.go @@ -0,0 +1,231 @@ +// 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 armazuredatatransfer + +// ClientListApprovedSchemasResponse contains the response from method Client.ListApprovedSchemas. +type ClientListApprovedSchemasResponse struct { + // The schemas list result. + SchemasListResult +} + +// ClientValidateSchemaResponse contains the response from method Client.ValidateSchema. +type ClientValidateSchemaResponse struct { + // Result of the schema validation. + ValidateSchemaResult +} + +// ConnectionsClientCreateOrUpdateResponse contains the response from method ConnectionsClient.BeginCreateOrUpdate. +type ConnectionsClientCreateOrUpdateResponse struct { + // The connection resource definition. + Connection +} + +// ConnectionsClientDeleteResponse contains the response from method ConnectionsClient.BeginDelete. +type ConnectionsClientDeleteResponse struct { + // placeholder for future response values +} + +// ConnectionsClientGetResponse contains the response from method ConnectionsClient.Get. +type ConnectionsClientGetResponse struct { + // The connection resource definition. + Connection +} + +// ConnectionsClientLinkResponse contains the response from method ConnectionsClient.BeginLink. +type ConnectionsClientLinkResponse struct { + // The connection resource definition. + Connection +} + +// ConnectionsClientListByResourceGroupResponse contains the response from method ConnectionsClient.NewListByResourceGroupPager. +type ConnectionsClientListByResourceGroupResponse struct { + // The connections list result. + ConnectionsListResult +} + +// ConnectionsClientListBySubscriptionResponse contains the response from method ConnectionsClient.NewListBySubscriptionPager. +type ConnectionsClientListBySubscriptionResponse struct { + // The connections list result. + ConnectionsListResult +} + +// ConnectionsClientUpdateResponse contains the response from method ConnectionsClient.BeginUpdate. +type ConnectionsClientUpdateResponse struct { + // The connection resource definition. + Connection +} + +// FlowsClientCreateOrUpdateResponse contains the response from method FlowsClient.BeginCreateOrUpdate. +type FlowsClientCreateOrUpdateResponse struct { + // The flow resource definition. + Flow +} + +// FlowsClientDeleteResponse contains the response from method FlowsClient.BeginDelete. +type FlowsClientDeleteResponse struct { + // placeholder for future response values +} + +// FlowsClientDisableResponse contains the response from method FlowsClient.BeginDisable. +type FlowsClientDisableResponse struct { + // The flow resource definition. + Flow +} + +// FlowsClientEnableResponse contains the response from method FlowsClient.BeginEnable. +type FlowsClientEnableResponse struct { + // The flow resource definition. + Flow +} + +// FlowsClientGeneratePassphraseResponse contains the response from method FlowsClient.BeginGeneratePassphrase. +type FlowsClientGeneratePassphraseResponse struct { + // The flow resource definition. + Flow +} + +// FlowsClientGetDestinationEndpointPortsResponse contains the response from method FlowsClient.GetDestinationEndpointPorts. +type FlowsClientGetDestinationEndpointPortsResponse struct { + // List of destination endpoint ports for the flow stream + GetDestinationEndpointPortsResult +} + +// FlowsClientGetDestinationEndpointsResponse contains the response from method FlowsClient.GetDestinationEndpoints. +type FlowsClientGetDestinationEndpointsResponse struct { + // List of destination endpoints for the flow stream + GetDestinationEndpointsResult +} + +// FlowsClientGetResponse contains the response from method FlowsClient.Get. +type FlowsClientGetResponse struct { + // The flow resource definition. + Flow +} + +// FlowsClientGetSourceAddressesResponse contains the response from method FlowsClient.GetSourceAddresses. +type FlowsClientGetSourceAddressesResponse struct { + // The source IP address and CIDR ranges of the stream + StreamSourceAddresses +} + +// FlowsClientGetStreamConnectionStringResponse contains the response from method FlowsClient.GetStreamConnectionString. +type FlowsClientGetStreamConnectionStringResponse struct { + // The connection string for the specified streaming flow + GetStreamConnectionStringResult +} + +// FlowsClientLinkResponse contains the response from method FlowsClient.BeginLink. +type FlowsClientLinkResponse struct { + // The flow resource definition. + Flow +} + +// FlowsClientListByConnectionResponse contains the response from method FlowsClient.NewListByConnectionPager. +type FlowsClientListByConnectionResponse struct { + // The flows list result. + FlowsListResult +} + +// FlowsClientSetDestinationEndpointPortsResponse contains the response from method FlowsClient.BeginSetDestinationEndpointPorts. +type FlowsClientSetDestinationEndpointPortsResponse struct { + // The flow resource definition. + Flow +} + +// FlowsClientSetDestinationEndpointsResponse contains the response from method FlowsClient.BeginSetDestinationEndpoints. +type FlowsClientSetDestinationEndpointsResponse struct { + // The flow resource definition. + Flow +} + +// FlowsClientSetPassphraseResponse contains the response from method FlowsClient.BeginSetPassphrase. +type FlowsClientSetPassphraseResponse struct { + // The flow resource definition. + Flow +} + +// FlowsClientSetSourceAddressesResponse contains the response from method FlowsClient.BeginSetSourceAddresses. +type FlowsClientSetSourceAddressesResponse struct { + // The flow resource definition. + Flow +} + +// FlowsClientUpdateResponse contains the response from method FlowsClient.BeginUpdate. +type FlowsClientUpdateResponse struct { + // The flow resource definition. + Flow +} + +// ListPendingConnectionsClientListResponse contains the response from method ListPendingConnectionsClient.NewListPager. +type ListPendingConnectionsClientListResponse struct { + // The pending connections list result. + PendingConnectionsListResult +} + +// ListPendingFlowsClientListResponse contains the response from method ListPendingFlowsClient.NewListPager. +type ListPendingFlowsClientListResponse struct { + // The pending flows list result. + PendingFlowsListResult +} + +// ListSchemasClientListResponse contains the response from method ListSchemasClient.List. +type ListSchemasClientListResponse struct { + // The schemas list result. + SchemasListResult +} + +// 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 +} + +// PipelinesClientApproveConnectionResponse contains the response from method PipelinesClient.BeginApproveConnection. +type PipelinesClientApproveConnectionResponse struct { + // The connection resource definition. + Connection +} + +// PipelinesClientCreateOrUpdateResponse contains the response from method PipelinesClient.BeginCreateOrUpdate. +type PipelinesClientCreateOrUpdateResponse struct { + // The pipeline resource definition. + Pipeline +} + +// PipelinesClientDeleteResponse contains the response from method PipelinesClient.BeginDelete. +type PipelinesClientDeleteResponse struct { + // placeholder for future response values +} + +// PipelinesClientGetResponse contains the response from method PipelinesClient.Get. +type PipelinesClientGetResponse struct { + // The pipeline resource definition. + Pipeline +} + +// PipelinesClientListByResourceGroupResponse contains the response from method PipelinesClient.NewListByResourceGroupPager. +type PipelinesClientListByResourceGroupResponse struct { + // The pipelines list result. + PipelinesListResult +} + +// PipelinesClientListBySubscriptionResponse contains the response from method PipelinesClient.NewListBySubscriptionPager. +type PipelinesClientListBySubscriptionResponse struct { + // The pipelines list result. + PipelinesListResult +} + +// PipelinesClientRejectConnectionResponse contains the response from method PipelinesClient.BeginRejectConnection. +type PipelinesClientRejectConnectionResponse struct { + // The connection resource definition. + Connection +} + +// PipelinesClientUpdateResponse contains the response from method PipelinesClient.BeginUpdate. +type PipelinesClientUpdateResponse struct { + // The pipeline resource definition. + Pipeline +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/time_rfc3339.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/time_rfc3339.go new file mode 100644 index 000000000000..88f10ff20c95 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/time_rfc3339.go @@ -0,0 +1,110 @@ +// 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 armazuredatatransfer + +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 ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +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 { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + 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 (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +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 || 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 +}