diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/CHANGELOG.md b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/CHANGELOG.md new file mode 100644 index 000000000000..fb2f232d8d4b --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 0.1.0 (2023-11-07) + +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..0f4097a3cac5 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/README.md @@ -0,0 +1,85 @@ +# Azure Azuredatatransfer Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer) + +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.NewListSchemasClient() +``` + +## 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..73c88009c33d --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/ci.yml @@ -0,0 +1,28 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + 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..8a6b5d7b9bc6 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/client.go @@ -0,0 +1,88 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package 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+".Client", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &Client{ + internal: cl, + } + return client, nil +} + +// Action - Performs an action request on Azure Data Transfer. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +// - parameters - The action request parameters. +// - options - ClientActionOptions contains the optional parameters for the Client.Action method. +func (client *Client) Action(ctx context.Context, parameters ActionRequest, options *ClientActionOptions) (ClientActionResponse, error) { + var err error + req, err := client.actionCreateRequest(ctx, parameters, options) + if err != nil { + return ClientActionResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ClientActionResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientActionResponse{}, err + } + resp, err := client.actionHandleResponse(httpResp) + return resp, err +} + +// actionCreateRequest creates the Action request. +func (client *Client) actionCreateRequest(ctx context.Context, parameters ActionRequest, options *ClientActionOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.AzureDataTransfer/action" + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-10-11-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil +} + +// actionHandleResponse handles the Action response. +func (client *Client) actionHandleResponse(resp *http.Response) (ClientActionResponse, error) { + result := ClientActionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ActionResult); err != nil { + return ClientActionResponse{}, 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..447f73c86745 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/client_factory.go @@ -0,0 +1,78 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package 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 + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName+".ClientFactory", moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +func (c *ClientFactory) NewClient() *Client { + subClient, _ := NewClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewConnectionsClient() *ConnectionsClient { + subClient, _ := NewConnectionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewFlowsClient() *FlowsClient { + subClient, _ := NewFlowsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewListPendingConnectionsClient() *ListPendingConnectionsClient { + subClient, _ := NewListPendingConnectionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewListPendingFlowsClient() *ListPendingFlowsClient { + subClient, _ := NewListPendingFlowsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewListSchemasClient() *ListSchemasClient { + subClient, _ := NewListSchemasClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +func (c *ClientFactory) NewPipelinesClient() *PipelinesClient { + subClient, _ := NewPipelinesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/connections_client.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/connections_client.go new file mode 100644 index 000000000000..a10d4fbcade7 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/connections_client.go @@ -0,0 +1,518 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package 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. +// - 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+".ConnectionsClient", 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection that is to be requested. +// - 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, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ConnectionsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Creates or updates the connection resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +func (client *ConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, connectionName string, connection Connection, options *ConnectionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + 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, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection that is to be requested. +// - 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, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ConnectionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Deletes the connection resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +func (client *ConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, connectionName string, options *ConnectionsClientBeginDeleteOptions) (*http.Response, error) { + var err error + 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.StatusOK, 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, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection that is to be requested. +// - 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 + 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, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection that is to be requested. +// - 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, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ConnectionsClientLinkResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Link - Links the connection to its pending connection. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +func (client *ConnectionsClient) link(ctx context.Context, resourceGroupName string, connectionName string, connection ResourceBody, options *ConnectionsClientBeginLinkOptions) (*http.Response, error) { + var err error + 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, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - 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) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ConnectionsClientListByResourceGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ConnectionsClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ConnectionsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *ConnectionsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - 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) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ConnectionsClientListBySubscriptionResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ConnectionsClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ConnectionsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *ConnectionsClient) listBySubscriptionCreateRequest(ctx context.Context, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection that is to be requested. +// - 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, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[ConnectionsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Updates the connection resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +func (client *ConnectionsClient) update(ctx context.Context, resourceGroupName string, connectionName string, connection ConnectionsPatch, options *ConnectionsClientBeginUpdateOptions) (*http.Response, error) { + var err error + 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, options *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", "2023-10-11-preview") + 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..a6966bb62c87 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/constants.go @@ -0,0 +1,265 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armazuredatatransfer + +const ( + moduleName = "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 - Transfer Storage Blobs or Tables +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, + } +} + +// 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" + FlowTypeDevSecOps FlowType = "DevSecOps" + FlowTypeMessaging FlowType = "Messaging" + FlowTypeMicrosoftInternal FlowType = "MicrosoftInternal" + FlowTypeMission FlowType = "Mission" + FlowTypeUnknown FlowType = "Unknown" +) + +// PossibleFlowTypeValues returns the possible values for the FlowType const type. +func PossibleFlowTypeValues() []FlowType { + return []FlowType{ + FlowTypeBasicFiles, + FlowTypeComplex, + FlowTypeDevSecOps, + FlowTypeMessaging, + FlowTypeMicrosoftInternal, + FlowTypeMission, + 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, + } +} + +// 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, + } +} + +// 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, + } +} + +// 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, + } +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/flows_client.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/flows_client.go new file mode 100644 index 000000000000..1b24eb276d7c --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/flows_client.go @@ -0,0 +1,636 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package 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. +// - 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+".FlowsClient", 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection that is to be requested. +// - flowName - The name for the flow that is to be onboarded. +// - 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, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[FlowsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Creates or updates the flow resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +func (client *FlowsClient) createOrUpdate(ctx context.Context, resourceGroupName string, connectionName string, flowName string, flow Flow, options *FlowsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + 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, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection that is to be requested. +// - flowName - The name for the flow that is to be onboarded. +// - 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, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[FlowsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Deletes the flow resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +func (client *FlowsClient) deleteOperation(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientBeginDeleteOptions) (*http.Response, error) { + var err error + 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.StatusOK, 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, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection that is to be requested. +// - flowName - The name for the flow that is to be onboarded. +// - 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, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[FlowsClientDisableResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Disable - Disables the specified flow +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +func (client *FlowsClient) disable(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientBeginDisableOptions) (*http.Response, error) { + var err error + 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, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection that is to be requested. +// - flowName - The name for the flow that is to be onboarded. +// - 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, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[FlowsClientEnableResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Enable - Enables the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +func (client *FlowsClient) enable(ctx context.Context, resourceGroupName string, connectionName string, flowName string, options *FlowsClientBeginEnableOptions) (*http.Response, error) { + var err error + 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, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection that is to be requested. +// - flowName - The name for the flow that is to be onboarded. +// - 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 + 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, options *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", "2023-10-11-preview") + 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 +} + +// BeginLink - Links the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection that is to be requested. +// - flowName - The name for the flow that is to be onboarded. +// - 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, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[FlowsClientLinkResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Link - Links the specified flow. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +func (client *FlowsClient) link(ctx context.Context, resourceGroupName string, connectionName string, flowName string, flow ResourceBody, options *FlowsClientBeginLinkOptions) (*http.Response, error) { + var err error + 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, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection that is to be requested. +// - 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) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByConnectionCreateRequest(ctx, resourceGroupName, connectionName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return FlowsClientListByConnectionResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return FlowsClientListByConnectionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return FlowsClientListByConnectionResponse{}, runtime.NewResponseError(resp) + } + return client.listByConnectionHandleResponse(resp) + }, + }) +} + +// listByConnectionCreateRequest creates the ListByConnection request. +func (client *FlowsClient) listByConnectionCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, options *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", "2023-10-11-preview") + 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 +} + +// BeginUpdate - Updates the flow resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection that is to be requested. +// - flowName - The name for the flow that is to be onboarded. +// - 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, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[FlowsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Updates the flow resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +func (client *FlowsClient) update(ctx context.Context, resourceGroupName string, connectionName string, flowName string, flow FlowsPatch, options *FlowsClientBeginUpdateOptions) (*http.Response, error) { + var err error + 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, options *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", "2023-10-11-preview") + 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..635333888dd8 --- /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.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/text v0.8.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/go.sum b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/go.sum new file mode 100644 index 000000000000..5c6bee428364 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/go.sum @@ -0,0 +1,15 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +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/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/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..22dd152e41ac --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/listpendingconnections_client.go @@ -0,0 +1,114 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package 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. +// - 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+".ListPendingConnectionsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ListPendingConnectionsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// NewListPager - Lists all pending connections for a connection. +// +// Generated from API version 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection that is to be requested. +// - 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) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, connectionName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ListPendingConnectionsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ListPendingConnectionsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ListPendingConnectionsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *ListPendingConnectionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, options *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", "2023-10-11-preview") + 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..d610caa7602c --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/listpendingflows_client.go @@ -0,0 +1,114 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package 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. +// - 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+".ListPendingFlowsClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ListPendingFlowsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// NewListPager - Lists all pending flows for a connection. +// +// Generated from API version 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - connectionName - The name for the connection that is to be requested. +// - 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) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, resourceGroupName, connectionName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return ListPendingFlowsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ListPendingFlowsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return ListPendingFlowsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *ListPendingFlowsClient) listCreateRequest(ctx context.Context, resourceGroupName string, connectionName string, options *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", "2023-10-11-preview") + 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..fab43b0c0876 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/listschemas_client.go @@ -0,0 +1,108 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package 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. +// - 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+".ListSchemasClient", 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - pipelineName - The name for the pipeline that is to be requested. +// - 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 + 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, options *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", "2023-10-11-preview") + 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..dd6c014805e9 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/models.go @@ -0,0 +1,692 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armazuredatatransfer + +import "time" + +// ActionRequest - An action request +type ActionRequest struct { + // Name of the action + Name *string + + // Action request payload + Payload map[string]any +} + +// ActionResult - An action result +type ActionResult struct { + // Action request result + Result map[string]any +} + +// 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. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// 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 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. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// FlowProperties - Properties of flow +type FlowProperties struct { + // The connection associated with this flow + Connection *SelectedResource + + // Transfer Storage Blobs or Tables + DataType *DataType + + // The flow type for this flow + FlowType *FlowType + + // AME, PME, or TORUS only! AKV Chain Containing SAS Token + KeyVaultURI *string + + // The policies for this flow + Policies []*string + + // The selected schema for this flow + Schema *Schema + + // Service Bus Queue ID + ServiceBusQueueID *string + + // Status of the current flow + Status *FlowStatus + + // Storage Account ID + StorageAccountID *string + + // Storage Account + StorageAccountName *string + + // Storage Container Name + StorageContainerName *string + + // 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 { + // Resource tags + Tags map[string]*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 +} + +// ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) +type ManagedServiceIdentity struct { + // REQUIRED; Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + Type *ManagedServiceIdentityType + + // The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM + // resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + // The dictionary values can be empty objects ({}) in + // requests. + UserAssignedIdentities map[string]*UserAssignedIdentity + + // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned + // identity. + PrincipalID *string + + // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *string +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay + + // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane + // operations. + IsDataAction *bool + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin +} + +// OperationDisplay - Localized display information for this particular operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // READ-ONLY; URL to get the next set of operation list results (if there are any). + NextLink *string + + // READ-ONLY; List of operations supported by the resource provider + Value []*Operation +} + +// 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 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. Ex - /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 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 + + // Transfer Storage Blobs or Tables + DataType *DataType + + // The flow type for this flow + FlowType *FlowType + + // AME, PME, or TORUS only! AKV Chain Containing SAS Token + KeyVaultURI *string + + // The policies for this flow + Policies []*string + + // The selected schema for this flow + Schema *Schema + + // Service Bus Queue ID + ServiceBusQueueID *string + + // Status of the current flow + Status *FlowStatus + + // Storage Account ID + StorageAccountID *string + + // Storage Account + StorageAccountName *string + + // Storage Container Name + StorageContainerName *string + + // 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. Ex - /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 connections 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. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; The name of the resource + Name *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// 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 + + // ID associated with this schema + ID *string + + // Name of the schema + Name *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 +} + +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 +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/models_serde.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/models_serde.go new file mode 100644 index 000000000000..dd5c9ac6c53c --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/models_serde.go @@ -0,0 +1,1626 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armazuredatatransfer + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ActionRequest. +func (a ActionRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", a.Name) + populate(objectMap, "payload", a.Payload) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ActionRequest. +func (a *ActionRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "payload": + err = unpopulate(val, "Payload", &a.Payload) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type ActionResult. +func (a ActionResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "result", a.Result) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ActionResult. +func (a *ActionResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "result": + err = unpopulate(val, "Result", &a.Result) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", a, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type 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) + populateTimeRFC3339(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, "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 = unpopulateTimeRFC3339(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 "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, "dataType", f.DataType) + 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, "policies", f.Policies) + populate(objectMap, "provisioningState", f.ProvisioningState) + populate(objectMap, "schema", f.Schema) + populate(objectMap, "serviceBusQueueId", f.ServiceBusQueueID) + populate(objectMap, "status", f.Status) + populate(objectMap, "storageAccountId", f.StorageAccountID) + populate(objectMap, "storageAccountName", f.StorageAccountName) + populate(objectMap, "storageContainerName", f.StorageContainerName) + 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 "dataType": + err = unpopulate(val, "DataType", &f.DataType) + 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 "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 "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) + } + 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, "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 "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 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 ManagedServiceIdentity. +func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "principalId", m.PrincipalID) + populate(objectMap, "tenantId", m.TenantID) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedServiceIdentity. +func (m *ManagedServiceIdentity) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "principalId": + err = unpopulate(val, "PrincipalID", &m.PrincipalID) + delete(rawMsg, key) + case "tenantId": + err = unpopulate(val, "TenantID", &m.TenantID) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &m.Type) + delete(rawMsg, key) + case "userAssignedIdentities": + err = unpopulate(val, "UserAssignedIdentities", &m.UserAssignedIdentities) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", m, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type 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) + populateTimeRFC3339(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, "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 = unpopulateTimeRFC3339(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 "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, "dataType", p.DataType) + 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, "name", p.Name) + populate(objectMap, "policies", p.Policies) + populate(objectMap, "provisioningState", p.ProvisioningState) + populate(objectMap, "schema", p.Schema) + populate(objectMap, "serviceBusQueueId", p.ServiceBusQueueID) + populate(objectMap, "status", p.Status) + populate(objectMap, "storageAccountId", p.StorageAccountID) + populate(objectMap, "storageAccountName", p.StorageAccountName) + populate(objectMap, "storageContainerName", p.StorageContainerName) + 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 "dataType": + err = unpopulate(val, "DataType", &p.DataType) + 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 "name": + err = unpopulate(val, "Name", &p.Name) + 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 "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 "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, "id", s.ID) + populate(objectMap, "name", s.Name) + 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 "id": + err = unpopulate(val, "ID", &s.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &s.Name) + 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 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) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(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 = unpopulateTimeRFC3339(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 = unpopulateTimeRFC3339(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 +} + +func populate(m map[string]any, k string, v any) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, fn string, v any) error { + if data == nil { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/operations_client.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/operations_client.go new file mode 100644 index 000000000000..d211689ab613 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/operations_client.go @@ -0,0 +1,93 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package 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+".OperationsClient", 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 2023-10-11-preview +// - 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) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) + }, + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *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", "2023-10-11-preview") + 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..8d21ed679847 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/options.go @@ -0,0 +1,173 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armazuredatatransfer + +// ClientActionOptions contains the optional parameters for the Client.Action method. +type ClientActionOptions struct { + // placeholder for future optional parameters +} + +// ConnectionsClientBeginCreateOrUpdateOptions contains the optional parameters for the ConnectionsClient.BeginCreateOrUpdate +// method. +type ConnectionsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ConnectionsClientBeginDeleteOptions contains the optional parameters for the ConnectionsClient.BeginDelete method. +type ConnectionsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ConnectionsClientBeginLinkOptions contains the optional parameters for the ConnectionsClient.BeginLink method. +type ConnectionsClientBeginLinkOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// ConnectionsClientBeginUpdateOptions contains the optional parameters for the ConnectionsClient.BeginUpdate method. +type ConnectionsClientBeginUpdateOptions struct { + // Resumes the LRO 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 LRO from the provided token. + ResumeToken string +} + +// FlowsClientBeginDeleteOptions contains the optional parameters for the FlowsClient.BeginDelete method. +type FlowsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// FlowsClientBeginDisableOptions contains the optional parameters for the FlowsClient.BeginDisable method. +type FlowsClientBeginDisableOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// FlowsClientBeginEnableOptions contains the optional parameters for the FlowsClient.BeginEnable method. +type FlowsClientBeginEnableOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// FlowsClientBeginLinkOptions contains the optional parameters for the FlowsClient.BeginLink method. +type FlowsClientBeginLinkOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// FlowsClientBeginUpdateOptions contains the optional parameters for the FlowsClient.BeginUpdate method. +type FlowsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// FlowsClientGetOptions contains the optional parameters for the FlowsClient.Get method. +type FlowsClientGetOptions 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 LRO from the provided token. + ResumeToken string +} + +// PipelinesClientBeginCreateOrUpdateOptions contains the optional parameters for the PipelinesClient.BeginCreateOrUpdate +// method. +type PipelinesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PipelinesClientBeginDeleteOptions contains the optional parameters for the PipelinesClient.BeginDelete method. +type PipelinesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PipelinesClientBeginRejectConnectionOptions contains the optional parameters for the PipelinesClient.BeginRejectConnection +// method. +type PipelinesClientBeginRejectConnectionOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// PipelinesClientBeginUpdateOptions contains the optional parameters for the PipelinesClient.BeginUpdate method. +type PipelinesClientBeginUpdateOptions struct { + // Resumes the LRO 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..c2376b6abf8a --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/pipelines_client.go @@ -0,0 +1,593 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package 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. +// - 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+".PipelinesClient", moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &PipelinesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// BeginApproveConnection - Approves the specified connection in a pipeline. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - pipelineName - The name for the pipeline that is to be requested. +// - 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, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PipelinesClientApproveConnectionResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// ApproveConnection - Approves the specified connection in a pipeline. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +func (client *PipelinesClient) approveConnection(ctx context.Context, resourceGroupName string, pipelineName string, connection ResourceBody, options *PipelinesClientBeginApproveConnectionOptions) (*http.Response, error) { + var err error + 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, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - pipelineName - The name for the pipeline that is to be requested. +// - 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, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PipelinesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// CreateOrUpdate - Creates or updates the pipeline resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +func (client *PipelinesClient) createOrUpdate(ctx context.Context, resourceGroupName string, pipelineName string, pipeline Pipeline, options *PipelinesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + 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, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - pipelineName - The name for the pipeline that is to be requested. +// - 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, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PipelinesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Delete - Deletes the pipeline resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +func (client *PipelinesClient) deleteOperation(ctx context.Context, resourceGroupName string, pipelineName string, options *PipelinesClientBeginDeleteOptions) (*http.Response, error) { + var err error + 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.StatusOK, 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, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - pipelineName - The name for the pipeline that is to be requested. +// - 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 + 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, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - 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) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return PipelinesClientListByResourceGroupResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PipelinesClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PipelinesClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *PipelinesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - 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) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return PipelinesClientListBySubscriptionResponse{}, err + } + resp, err := client.internal.Pipeline().Do(req) + if err != nil { + return PipelinesClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return PipelinesClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *PipelinesClient) listBySubscriptionCreateRequest(ctx context.Context, options *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", "2023-10-11-preview") + 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 in a pipeline. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - pipelineName - The name for the pipeline that is to be requested. +// - 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, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PipelinesClientRejectConnectionResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// RejectConnection - Rejects the specified connection in a pipeline. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +func (client *PipelinesClient) rejectConnection(ctx context.Context, resourceGroupName string, pipelineName string, connection ResourceBody, options *PipelinesClientBeginRejectConnectionOptions) (*http.Response, error) { + var err error + 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, options *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", "2023-10-11-preview") + 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 2023-10-11-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - pipelineName - The name for the pipeline that is to be requested. +// - 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, + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken[PipelinesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + } +} + +// Update - Updates the pipeline resource. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-10-11-preview +func (client *PipelinesClient) update(ctx context.Context, resourceGroupName string, pipelineName string, pipeline PipelinesPatch, options *PipelinesClientBeginUpdateOptions) (*http.Response, error) { + var err error + 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, options *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", "2023-10-11-preview") + 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/response_types.go b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/response_types.go new file mode 100644 index 000000000000..dcd1b46770d3 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/response_types.go @@ -0,0 +1,174 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armazuredatatransfer + +// ClientActionResponse contains the response from method Client.Action. +type ClientActionResponse struct { + // An action result + ActionResult +} + +// 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 +} + +// FlowsClientGetResponse contains the response from method FlowsClient.Get. +type FlowsClientGetResponse struct { + // The flow resource definition. + Flow +} + +// 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 +} + +// 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 connections list result. + PendingConnectionsListResult +} + +// ListPendingFlowsClientListResponse contains the response from method ListPendingFlowsClient.NewListPager. +type ListPendingFlowsClientListResponse struct { + // The connections 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..aada7030b947 --- /dev/null +++ b/sdk/resourcemanager/azuredatatransfer/armazuredatatransfer/time_rfc3339.go @@ -0,0 +1,86 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armazuredatatransfer + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// 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+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(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] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +}