From 0e69dd07d1c5396ea147c2dca3c4d88b61a3fec4 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Wed, 22 Nov 2023 19:20:28 -0800 Subject: [PATCH] [Release] sdk/resourcemanager/integrationspaces/armintegrationspaces/0.1.0 (#21945) * [Release] sdk/resourcemanager/integrationspaces/armintegrationspaces/0.1.0 generation from spec commit: db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3 * readme --------- Co-authored-by: ReleaseHelper Co-authored-by: Alancere <804873052@qq.com> --- .../armintegrationspaces/CHANGELOG.md | 7 + .../armintegrationspaces/LICENSE.txt | 21 + .../armintegrationspaces/README.md | 92 + .../applicationresources_client.go | 440 +++++ ...pplicationresources_client_example_test.go | 187 ++ .../applications_client.go | 758 ++++++++ .../applications_client_example_test.go | 1114 +++++++++++ .../armintegrationspaces/autorest.md | 13 + .../armintegrationspaces/build.go | 7 + .../businessprocesses_client.go | 438 +++++ .../businessprocesses_client_example_test.go | 569 ++++++ .../businessprocessversions_client.go | 227 +++ ...nessprocessversions_client_example_test.go | 249 +++ .../armintegrationspaces/ci.yml | 28 + .../armintegrationspaces/client_factory.go | 80 + .../armintegrationspaces/constants.go | 96 + .../fake/applicationresources_server.go | 401 ++++ .../fake/applications_server.go | 612 ++++++ .../fake/businessprocesses_server.go | 401 ++++ .../fake/businessprocessversions_server.go | 260 +++ .../fake/infrastructureresources_server.go | 381 ++++ .../armintegrationspaces/fake/internal.go | 83 + .../fake/operations_server.go | 96 + .../fake/server_factory.go | 113 ++ .../fake/spaces_server.go | 402 ++++ .../armintegrationspaces/fake/time_rfc3339.go | 86 + .../armintegrationspaces/go.mod | 21 + .../armintegrationspaces/go.sum | 31 + .../infrastructureresources_client.go | 415 +++++ ...astructureresources_client_example_test.go | 181 ++ .../armintegrationspaces/models.go | 582 ++++++ .../armintegrationspaces/models_serde.go | 1643 +++++++++++++++++ .../armintegrationspaces/operations_client.go | 88 + .../operations_client_example_test.go | 73 + .../armintegrationspaces/options.go | 309 ++++ .../armintegrationspaces/response_types.go | 206 +++ .../armintegrationspaces/spaces_client.go | 441 +++++ .../spaces_client_example_test.go | 239 +++ .../armintegrationspaces/time_rfc3339.go | 86 + 39 files changed, 11476 insertions(+) create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/CHANGELOG.md create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/LICENSE.txt create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/README.md create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/applicationresources_client.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/applicationresources_client_example_test.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/applications_client.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/applications_client_example_test.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/autorest.md create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/build.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocesses_client.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocesses_client_example_test.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocessversions_client.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocessversions_client_example_test.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/ci.yml create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/client_factory.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/constants.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/applicationresources_server.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/applications_server.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/businessprocesses_server.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/businessprocessversions_server.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/infrastructureresources_server.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/internal.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/operations_server.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/server_factory.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/spaces_server.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/time_rfc3339.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/go.mod create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/go.sum create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/infrastructureresources_client.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/infrastructureresources_client_example_test.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/models.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/models_serde.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/operations_client.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/operations_client_example_test.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/options.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/response_types.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/spaces_client.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/spaces_client_example_test.go create mode 100644 sdk/resourcemanager/integrationspaces/armintegrationspaces/time_rfc3339.go diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/CHANGELOG.md b/sdk/resourcemanager/integrationspaces/armintegrationspaces/CHANGELOG.md new file mode 100644 index 000000000000..85978a615c38 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/CHANGELOG.md @@ -0,0 +1,7 @@ +# Release History + +## 0.1.0 (2023-11-24) + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces` 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/integrationspaces/armintegrationspaces/LICENSE.txt b/sdk/resourcemanager/integrationspaces/armintegrationspaces/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/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/integrationspaces/armintegrationspaces/README.md b/sdk/resourcemanager/integrationspaces/armintegrationspaces/README.md new file mode 100644 index 000000000000..b6c7675f341d --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/README.md @@ -0,0 +1,92 @@ +# Azure Integrationspaces Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces) + +The `armintegrationspaces` module provides operations for working with Azure Integrationspaces. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/integrationspaces/armintegrationspaces) + +# 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 Integrationspaces module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Integrationspaces. 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 Integrationspaces 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 := armintegrationspaces.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 := armintegrationspaces.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.NewInfrastructureResourcesClient() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Integrationspaces` 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/integrationspaces/armintegrationspaces/applicationresources_client.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/applicationresources_client.go new file mode 100644 index 000000000000..f5b55977ba0d --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/applicationresources_client.go @@ -0,0 +1,440 @@ +//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 armintegrationspaces + +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" + "strconv" + "strings" +) + +// ApplicationResourcesClient contains the methods for the ApplicationResources group. +// Don't use this type directly, use NewApplicationResourcesClient() instead. +type ApplicationResourcesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewApplicationResourcesClient creates a new instance of ApplicationResourcesClient 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 NewApplicationResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ApplicationResourcesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ApplicationResourcesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Create a ApplicationResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - resourceName - The name of the application resource. +// - resource - Resource create parameters. +// - options - ApplicationResourcesClientCreateOrUpdateOptions contains the optional parameters for the ApplicationResourcesClient.CreateOrUpdate +// method. +func (client *ApplicationResourcesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, resourceName string, resource ApplicationResource, options *ApplicationResourcesClientCreateOrUpdateOptions) (ApplicationResourcesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "ApplicationResourcesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, spaceName, applicationName, resourceName, resource, options) + if err != nil { + return ApplicationResourcesClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApplicationResourcesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ApplicationResourcesClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ApplicationResourcesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, resourceName string, resource ApplicationResource, options *ApplicationResourcesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/resources/{resourceName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ApplicationResourcesClient) createOrUpdateHandleResponse(resp *http.Response) (ApplicationResourcesClientCreateOrUpdateResponse, error) { + result := ApplicationResourcesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ApplicationResource); err != nil { + return ApplicationResourcesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete a ApplicationResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - resourceName - The name of the application resource. +// - options - ApplicationResourcesClientDeleteOptions contains the optional parameters for the ApplicationResourcesClient.Delete +// method. +func (client *ApplicationResourcesClient) Delete(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, resourceName string, options *ApplicationResourcesClientDeleteOptions) (ApplicationResourcesClientDeleteResponse, error) { + var err error + const operationName = "ApplicationResourcesClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, spaceName, applicationName, resourceName, options) + if err != nil { + return ApplicationResourcesClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApplicationResourcesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ApplicationResourcesClientDeleteResponse{}, err + } + return ApplicationResourcesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ApplicationResourcesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, resourceName string, options *ApplicationResourcesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/resources/{resourceName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a ApplicationResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - resourceName - The name of the application resource. +// - options - ApplicationResourcesClientGetOptions contains the optional parameters for the ApplicationResourcesClient.Get +// method. +func (client *ApplicationResourcesClient) Get(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, resourceName string, options *ApplicationResourcesClientGetOptions) (ApplicationResourcesClientGetResponse, error) { + var err error + const operationName = "ApplicationResourcesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, spaceName, applicationName, resourceName, options) + if err != nil { + return ApplicationResourcesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApplicationResourcesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ApplicationResourcesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ApplicationResourcesClient) getCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, resourceName string, options *ApplicationResourcesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/resources/{resourceName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ApplicationResourcesClient) getHandleResponse(resp *http.Response) (ApplicationResourcesClientGetResponse, error) { + result := ApplicationResourcesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ApplicationResource); err != nil { + return ApplicationResourcesClientGetResponse{}, err + } + return result, nil +} + +// NewListByApplicationPager - List ApplicationResource resources by Application +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - options - ApplicationResourcesClientListByApplicationOptions contains the optional parameters for the ApplicationResourcesClient.NewListByApplicationPager +// method. +func (client *ApplicationResourcesClient) NewListByApplicationPager(resourceGroupName string, spaceName string, applicationName string, options *ApplicationResourcesClientListByApplicationOptions) *runtime.Pager[ApplicationResourcesClientListByApplicationResponse] { + return runtime.NewPager(runtime.PagingHandler[ApplicationResourcesClientListByApplicationResponse]{ + More: func(page ApplicationResourcesClientListByApplicationResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ApplicationResourcesClientListByApplicationResponse) (ApplicationResourcesClientListByApplicationResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ApplicationResourcesClient.NewListByApplicationPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByApplicationCreateRequest(ctx, resourceGroupName, spaceName, applicationName, options) + }, nil) + if err != nil { + return ApplicationResourcesClientListByApplicationResponse{}, err + } + return client.listByApplicationHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByApplicationCreateRequest creates the ListByApplication request. +func (client *ApplicationResourcesClient) listByApplicationCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, options *ApplicationResourcesClientListByApplicationOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/resources" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Maxpagesize != nil { + reqQP.Set("maxpagesize", strconv.FormatInt(int64(*options.Maxpagesize), 10)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.Select != nil { + for _, qv := range options.Select { + reqQP.Add("select", qv) + } + } + if options != nil && options.Expand != nil { + for _, qv := range options.Expand { + reqQP.Add("expand", qv) + } + } + if options != nil && options.Orderby != nil { + for _, qv := range options.Orderby { + reqQP.Add("orderby", qv) + } + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByApplicationHandleResponse handles the ListByApplication response. +func (client *ApplicationResourcesClient) listByApplicationHandleResponse(resp *http.Response) (ApplicationResourcesClientListByApplicationResponse, error) { + result := ApplicationResourcesClientListByApplicationResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ApplicationResourceListResult); err != nil { + return ApplicationResourcesClientListByApplicationResponse{}, err + } + return result, nil +} + +// Patch - Update a ApplicationResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - resourceName - The name of the application resource. +// - properties - The resource properties to be updated. +// - options - ApplicationResourcesClientPatchOptions contains the optional parameters for the ApplicationResourcesClient.Patch +// method. +func (client *ApplicationResourcesClient) Patch(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, resourceName string, properties ApplicationResourceUpdate, options *ApplicationResourcesClientPatchOptions) (ApplicationResourcesClientPatchResponse, error) { + var err error + const operationName = "ApplicationResourcesClient.Patch" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.patchCreateRequest(ctx, resourceGroupName, spaceName, applicationName, resourceName, properties, options) + if err != nil { + return ApplicationResourcesClientPatchResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApplicationResourcesClientPatchResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ApplicationResourcesClientPatchResponse{}, err + } + resp, err := client.patchHandleResponse(httpResp) + return resp, err +} + +// patchCreateRequest creates the Patch request. +func (client *ApplicationResourcesClient) patchCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, resourceName string, properties ApplicationResourceUpdate, options *ApplicationResourcesClientPatchOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/resources/{resourceName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + if resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// patchHandleResponse handles the Patch response. +func (client *ApplicationResourcesClient) patchHandleResponse(resp *http.Response) (ApplicationResourcesClientPatchResponse, error) { + result := ApplicationResourcesClientPatchResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ApplicationResource); err != nil { + return ApplicationResourcesClientPatchResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/applicationresources_client_example_test.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/applicationresources_client_example_test.go new file mode 100644 index 000000000000..13336bc6b6eb --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/applicationresources_client_example_test.go @@ -0,0 +1,187 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armintegrationspaces_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/ApplicationResources_ListByApplication.json +func ExampleApplicationResourcesClient_NewListByApplicationPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewApplicationResourcesClient().NewListByApplicationPager("testrg", "Space1", "Application1", &armintegrationspaces.ApplicationResourcesClientListByApplicationOptions{Top: nil, + Skip: nil, + Maxpagesize: nil, + Filter: nil, + Select: []string{}, + Expand: []string{}, + Orderby: []string{}, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ApplicationResourceListResult = armintegrationspaces.ApplicationResourceListResult{ + // Value: []*armintegrationspaces.ApplicationResource{ + // { + // Name: to.Ptr("Resource1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/applications/resources"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/applications/Application1/resources/Resource1"), + // Properties: &armintegrationspaces.ApplicationResourceProperties{ + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Web/sites/LogicApp1"), + // ResourceKind: to.Ptr("LogicApp"), + // ResourceType: to.Ptr("Microsoft.Web/sites"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/ApplicationResources_Get.json +func ExampleApplicationResourcesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewApplicationResourcesClient().Get(ctx, "testrg", "Space1", "Application1", "Resource1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ApplicationResource = armintegrationspaces.ApplicationResource{ + // Name: to.Ptr("Resource1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/applications/resources"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/applications/Application1/resources/Resource1"), + // Properties: &armintegrationspaces.ApplicationResourceProperties{ + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Web/sites/LogicApp1"), + // ResourceKind: to.Ptr("LogicApp"), + // ResourceType: to.Ptr("Microsoft.Web/sites"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/ApplicationResources_CreateOrUpdate.json +func ExampleApplicationResourcesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewApplicationResourcesClient().CreateOrUpdate(ctx, "testrg", "Space1", "Application1", "Resource1", armintegrationspaces.ApplicationResource{ + Properties: &armintegrationspaces.ApplicationResourceProperties{ + ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Web/sites/LogicApp1"), + ResourceKind: to.Ptr("LogicApp"), + ResourceType: to.Ptr("Microsoft.Web/sites"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ApplicationResource = armintegrationspaces.ApplicationResource{ + // Name: to.Ptr("Resource1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/applications/resources"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/applications/Application1/resources/Resource1"), + // Properties: &armintegrationspaces.ApplicationResourceProperties{ + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Web/sites/LogicApp1"), + // ResourceKind: to.Ptr("LogicApp"), + // ResourceType: to.Ptr("Microsoft.Web/sites"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/ApplicationResources_Patch.json +func ExampleApplicationResourcesClient_Patch() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewApplicationResourcesClient().Patch(ctx, "testrg", "Space1", "Application1", "Resource1", armintegrationspaces.ApplicationResourceUpdate{ + Properties: &armintegrationspaces.ApplicationResourceUpdateProperties{ + ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Web/sites/LogicApp1"), + ResourceKind: to.Ptr("LogicApp"), + ResourceType: to.Ptr("Microsoft.Web/sites"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ApplicationResource = armintegrationspaces.ApplicationResource{ + // Name: to.Ptr("Resource1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/applications/resources"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/applications/Application1/resources/Resource1"), + // Properties: &armintegrationspaces.ApplicationResourceProperties{ + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Web/sites/LogicApp1"), + // ResourceKind: to.Ptr("LogicApp"), + // ResourceType: to.Ptr("Microsoft.Web/sites"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/ApplicationResources_Delete.json +func ExampleApplicationResourcesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewApplicationResourcesClient().Delete(ctx, "testrg", "Space1", "Application1", "Resource1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/applications_client.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/applications_client.go new file mode 100644 index 000000000000..ecbc4c83aa3d --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/applications_client.go @@ -0,0 +1,758 @@ +//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 armintegrationspaces + +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" + "strconv" + "strings" +) + +// ApplicationsClient contains the methods for the Applications group. +// Don't use this type directly, use NewApplicationsClient() instead. +type ApplicationsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewApplicationsClient creates a new instance of ApplicationsClient 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 NewApplicationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ApplicationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &ApplicationsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Create a Application +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - resource - Resource create parameters. +// - options - ApplicationsClientCreateOrUpdateOptions contains the optional parameters for the ApplicationsClient.CreateOrUpdate +// method. +func (client *ApplicationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, resource Application, options *ApplicationsClientCreateOrUpdateOptions) (ApplicationsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "ApplicationsClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, spaceName, applicationName, resource, options) + if err != nil { + return ApplicationsClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApplicationsClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ApplicationsClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ApplicationsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, resource Application, options *ApplicationsClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ApplicationsClient) createOrUpdateHandleResponse(resp *http.Response) (ApplicationsClientCreateOrUpdateResponse, error) { + result := ApplicationsClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Application); err != nil { + return ApplicationsClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete a Application +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - options - ApplicationsClientDeleteOptions contains the optional parameters for the ApplicationsClient.Delete method. +func (client *ApplicationsClient) Delete(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, options *ApplicationsClientDeleteOptions) (ApplicationsClientDeleteResponse, error) { + var err error + const operationName = "ApplicationsClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, spaceName, applicationName, options) + if err != nil { + return ApplicationsClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApplicationsClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return ApplicationsClientDeleteResponse{}, err + } + return ApplicationsClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ApplicationsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, options *ApplicationsClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// DeleteBusinessProcessDevelopmentArtifact - The delete business process development artifact action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - body - The content of the action request +// - options - ApplicationsClientDeleteBusinessProcessDevelopmentArtifactOptions contains the optional parameters for the ApplicationsClient.DeleteBusinessProcessDevelopmentArtifact +// method. +func (client *ApplicationsClient) DeleteBusinessProcessDevelopmentArtifact(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, body GetOrDeleteBusinessProcessDevelopmentArtifactRequest, options *ApplicationsClientDeleteBusinessProcessDevelopmentArtifactOptions) (ApplicationsClientDeleteBusinessProcessDevelopmentArtifactResponse, error) { + var err error + const operationName = "ApplicationsClient.DeleteBusinessProcessDevelopmentArtifact" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteBusinessProcessDevelopmentArtifactCreateRequest(ctx, resourceGroupName, spaceName, applicationName, body, options) + if err != nil { + return ApplicationsClientDeleteBusinessProcessDevelopmentArtifactResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApplicationsClientDeleteBusinessProcessDevelopmentArtifactResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ApplicationsClientDeleteBusinessProcessDevelopmentArtifactResponse{}, err + } + return ApplicationsClientDeleteBusinessProcessDevelopmentArtifactResponse{}, nil +} + +// deleteBusinessProcessDevelopmentArtifactCreateRequest creates the DeleteBusinessProcessDevelopmentArtifact request. +func (client *ApplicationsClient) deleteBusinessProcessDevelopmentArtifactCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, body GetOrDeleteBusinessProcessDevelopmentArtifactRequest, options *ApplicationsClientDeleteBusinessProcessDevelopmentArtifactOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/deleteBusinessProcessDevelopmentArtifact" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// Get - Get a Application +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - options - ApplicationsClientGetOptions contains the optional parameters for the ApplicationsClient.Get method. +func (client *ApplicationsClient) Get(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, options *ApplicationsClientGetOptions) (ApplicationsClientGetResponse, error) { + var err error + const operationName = "ApplicationsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, spaceName, applicationName, options) + if err != nil { + return ApplicationsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApplicationsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ApplicationsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *ApplicationsClient) getCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, options *ApplicationsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ApplicationsClient) getHandleResponse(resp *http.Response) (ApplicationsClientGetResponse, error) { + result := ApplicationsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Application); err != nil { + return ApplicationsClientGetResponse{}, err + } + return result, nil +} + +// GetBusinessProcessDevelopmentArtifact - The get business process development artifact action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - body - The content of the action request +// - options - ApplicationsClientGetBusinessProcessDevelopmentArtifactOptions contains the optional parameters for the ApplicationsClient.GetBusinessProcessDevelopmentArtifact +// method. +func (client *ApplicationsClient) GetBusinessProcessDevelopmentArtifact(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, body GetOrDeleteBusinessProcessDevelopmentArtifactRequest, options *ApplicationsClientGetBusinessProcessDevelopmentArtifactOptions) (ApplicationsClientGetBusinessProcessDevelopmentArtifactResponse, error) { + var err error + const operationName = "ApplicationsClient.GetBusinessProcessDevelopmentArtifact" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getBusinessProcessDevelopmentArtifactCreateRequest(ctx, resourceGroupName, spaceName, applicationName, body, options) + if err != nil { + return ApplicationsClientGetBusinessProcessDevelopmentArtifactResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApplicationsClientGetBusinessProcessDevelopmentArtifactResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ApplicationsClientGetBusinessProcessDevelopmentArtifactResponse{}, err + } + resp, err := client.getBusinessProcessDevelopmentArtifactHandleResponse(httpResp) + return resp, err +} + +// getBusinessProcessDevelopmentArtifactCreateRequest creates the GetBusinessProcessDevelopmentArtifact request. +func (client *ApplicationsClient) getBusinessProcessDevelopmentArtifactCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, body GetOrDeleteBusinessProcessDevelopmentArtifactRequest, options *ApplicationsClientGetBusinessProcessDevelopmentArtifactOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/getBusinessProcessDevelopmentArtifact" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// getBusinessProcessDevelopmentArtifactHandleResponse handles the GetBusinessProcessDevelopmentArtifact response. +func (client *ApplicationsClient) getBusinessProcessDevelopmentArtifactHandleResponse(resp *http.Response) (ApplicationsClientGetBusinessProcessDevelopmentArtifactResponse, error) { + result := ApplicationsClientGetBusinessProcessDevelopmentArtifactResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SaveOrGetBusinessProcessDevelopmentArtifactResponse); err != nil { + return ApplicationsClientGetBusinessProcessDevelopmentArtifactResponse{}, err + } + return result, nil +} + +// ListBusinessProcessDevelopmentArtifacts - The list business process development artifacts action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - options - ApplicationsClientListBusinessProcessDevelopmentArtifactsOptions contains the optional parameters for the ApplicationsClient.ListBusinessProcessDevelopmentArtifacts +// method. +func (client *ApplicationsClient) ListBusinessProcessDevelopmentArtifacts(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, options *ApplicationsClientListBusinessProcessDevelopmentArtifactsOptions) (ApplicationsClientListBusinessProcessDevelopmentArtifactsResponse, error) { + var err error + const operationName = "ApplicationsClient.ListBusinessProcessDevelopmentArtifacts" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.listBusinessProcessDevelopmentArtifactsCreateRequest(ctx, resourceGroupName, spaceName, applicationName, options) + if err != nil { + return ApplicationsClientListBusinessProcessDevelopmentArtifactsResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApplicationsClientListBusinessProcessDevelopmentArtifactsResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ApplicationsClientListBusinessProcessDevelopmentArtifactsResponse{}, err + } + resp, err := client.listBusinessProcessDevelopmentArtifactsHandleResponse(httpResp) + return resp, err +} + +// listBusinessProcessDevelopmentArtifactsCreateRequest creates the ListBusinessProcessDevelopmentArtifacts request. +func (client *ApplicationsClient) listBusinessProcessDevelopmentArtifactsCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, options *ApplicationsClientListBusinessProcessDevelopmentArtifactsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/listBusinessProcessDevelopmentArtifacts" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBusinessProcessDevelopmentArtifactsHandleResponse handles the ListBusinessProcessDevelopmentArtifacts response. +func (client *ApplicationsClient) listBusinessProcessDevelopmentArtifactsHandleResponse(resp *http.Response) (ApplicationsClientListBusinessProcessDevelopmentArtifactsResponse, error) { + result := ApplicationsClientListBusinessProcessDevelopmentArtifactsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ListBusinessProcessDevelopmentArtifactsResponse); err != nil { + return ApplicationsClientListBusinessProcessDevelopmentArtifactsResponse{}, err + } + return result, nil +} + +// NewListBySpacePager - List Application resources by Space +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - options - ApplicationsClientListBySpaceOptions contains the optional parameters for the ApplicationsClient.NewListBySpacePager +// method. +func (client *ApplicationsClient) NewListBySpacePager(resourceGroupName string, spaceName string, options *ApplicationsClientListBySpaceOptions) *runtime.Pager[ApplicationsClientListBySpaceResponse] { + return runtime.NewPager(runtime.PagingHandler[ApplicationsClientListBySpaceResponse]{ + More: func(page ApplicationsClientListBySpaceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ApplicationsClientListBySpaceResponse) (ApplicationsClientListBySpaceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ApplicationsClient.NewListBySpacePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySpaceCreateRequest(ctx, resourceGroupName, spaceName, options) + }, nil) + if err != nil { + return ApplicationsClientListBySpaceResponse{}, err + } + return client.listBySpaceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySpaceCreateRequest creates the ListBySpace request. +func (client *ApplicationsClient) listBySpaceCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, options *ApplicationsClientListBySpaceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Maxpagesize != nil { + reqQP.Set("maxpagesize", strconv.FormatInt(int64(*options.Maxpagesize), 10)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.Select != nil { + for _, qv := range options.Select { + reqQP.Add("select", qv) + } + } + if options != nil && options.Expand != nil { + for _, qv := range options.Expand { + reqQP.Add("expand", qv) + } + } + if options != nil && options.Orderby != nil { + for _, qv := range options.Orderby { + reqQP.Add("orderby", qv) + } + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySpaceHandleResponse handles the ListBySpace response. +func (client *ApplicationsClient) listBySpaceHandleResponse(resp *http.Response) (ApplicationsClientListBySpaceResponse, error) { + result := ApplicationsClientListBySpaceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ApplicationListResult); err != nil { + return ApplicationsClientListBySpaceResponse{}, err + } + return result, nil +} + +// Patch - Update a Application +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - properties - The resource properties to be updated. +// - options - ApplicationsClientPatchOptions contains the optional parameters for the ApplicationsClient.Patch method. +func (client *ApplicationsClient) Patch(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, properties ApplicationUpdate, options *ApplicationsClientPatchOptions) (ApplicationsClientPatchResponse, error) { + var err error + const operationName = "ApplicationsClient.Patch" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.patchCreateRequest(ctx, resourceGroupName, spaceName, applicationName, properties, options) + if err != nil { + return ApplicationsClientPatchResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApplicationsClientPatchResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ApplicationsClientPatchResponse{}, err + } + resp, err := client.patchHandleResponse(httpResp) + return resp, err +} + +// patchCreateRequest creates the Patch request. +func (client *ApplicationsClient) patchCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, properties ApplicationUpdate, options *ApplicationsClientPatchOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// patchHandleResponse handles the Patch response. +func (client *ApplicationsClient) patchHandleResponse(resp *http.Response) (ApplicationsClientPatchResponse, error) { + result := ApplicationsClientPatchResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Application); err != nil { + return ApplicationsClientPatchResponse{}, err + } + return result, nil +} + +// SaveBusinessProcessDevelopmentArtifact - The save business process development artifact action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - body - The content of the action request +// - options - ApplicationsClientSaveBusinessProcessDevelopmentArtifactOptions contains the optional parameters for the ApplicationsClient.SaveBusinessProcessDevelopmentArtifact +// method. +func (client *ApplicationsClient) SaveBusinessProcessDevelopmentArtifact(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, body SaveOrValidateBusinessProcessDevelopmentArtifactRequest, options *ApplicationsClientSaveBusinessProcessDevelopmentArtifactOptions) (ApplicationsClientSaveBusinessProcessDevelopmentArtifactResponse, error) { + var err error + const operationName = "ApplicationsClient.SaveBusinessProcessDevelopmentArtifact" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.saveBusinessProcessDevelopmentArtifactCreateRequest(ctx, resourceGroupName, spaceName, applicationName, body, options) + if err != nil { + return ApplicationsClientSaveBusinessProcessDevelopmentArtifactResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApplicationsClientSaveBusinessProcessDevelopmentArtifactResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ApplicationsClientSaveBusinessProcessDevelopmentArtifactResponse{}, err + } + resp, err := client.saveBusinessProcessDevelopmentArtifactHandleResponse(httpResp) + return resp, err +} + +// saveBusinessProcessDevelopmentArtifactCreateRequest creates the SaveBusinessProcessDevelopmentArtifact request. +func (client *ApplicationsClient) saveBusinessProcessDevelopmentArtifactCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, body SaveOrValidateBusinessProcessDevelopmentArtifactRequest, options *ApplicationsClientSaveBusinessProcessDevelopmentArtifactOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/saveBusinessProcessDevelopmentArtifact" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// saveBusinessProcessDevelopmentArtifactHandleResponse handles the SaveBusinessProcessDevelopmentArtifact response. +func (client *ApplicationsClient) saveBusinessProcessDevelopmentArtifactHandleResponse(resp *http.Response) (ApplicationsClientSaveBusinessProcessDevelopmentArtifactResponse, error) { + result := ApplicationsClientSaveBusinessProcessDevelopmentArtifactResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SaveOrGetBusinessProcessDevelopmentArtifactResponse); err != nil { + return ApplicationsClientSaveBusinessProcessDevelopmentArtifactResponse{}, err + } + return result, nil +} + +// ValidateBusinessProcessDevelopmentArtifact - The validate business process development artifact action. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - body - The content of the action request +// - options - ApplicationsClientValidateBusinessProcessDevelopmentArtifactOptions contains the optional parameters for the +// ApplicationsClient.ValidateBusinessProcessDevelopmentArtifact method. +func (client *ApplicationsClient) ValidateBusinessProcessDevelopmentArtifact(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, body SaveOrValidateBusinessProcessDevelopmentArtifactRequest, options *ApplicationsClientValidateBusinessProcessDevelopmentArtifactOptions) (ApplicationsClientValidateBusinessProcessDevelopmentArtifactResponse, error) { + var err error + const operationName = "ApplicationsClient.ValidateBusinessProcessDevelopmentArtifact" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.validateBusinessProcessDevelopmentArtifactCreateRequest(ctx, resourceGroupName, spaceName, applicationName, body, options) + if err != nil { + return ApplicationsClientValidateBusinessProcessDevelopmentArtifactResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return ApplicationsClientValidateBusinessProcessDevelopmentArtifactResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ApplicationsClientValidateBusinessProcessDevelopmentArtifactResponse{}, err + } + return ApplicationsClientValidateBusinessProcessDevelopmentArtifactResponse{}, nil +} + +// validateBusinessProcessDevelopmentArtifactCreateRequest creates the ValidateBusinessProcessDevelopmentArtifact request. +func (client *ApplicationsClient) validateBusinessProcessDevelopmentArtifactCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, body SaveOrValidateBusinessProcessDevelopmentArtifactRequest, options *ApplicationsClientValidateBusinessProcessDevelopmentArtifactOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/validateBusinessProcessDevelopmentArtifact" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/applications_client_example_test.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/applications_client_example_test.go new file mode 100644 index 000000000000..9357a4b6192f --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/applications_client_example_test.go @@ -0,0 +1,1114 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armintegrationspaces_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Applications_ListBySpace.json +func ExampleApplicationsClient_NewListBySpacePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewApplicationsClient().NewListBySpacePager("testrg", "Space1", &armintegrationspaces.ApplicationsClientListBySpaceOptions{Top: nil, + Skip: nil, + Maxpagesize: nil, + Filter: nil, + Select: []string{}, + Expand: []string{}, + Orderby: []string{}, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.ApplicationListResult = armintegrationspaces.ApplicationListResult{ + // Value: []*armintegrationspaces.Application{ + // { + // Name: to.Ptr("Application1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/applications"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/applications/Application1"), + // Location: to.Ptr("CentralUS"), + // Tags: map[string]*string{ + // "key1": to.Ptr("Value1"), + // }, + // Properties: &armintegrationspaces.ApplicationProperties{ + // Description: to.Ptr("This is the user provided description of the application."), + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // TrackingDataStores: map[string]*armintegrationspaces.TrackingDataStore{ + // "dataStoreName1": &armintegrationspaces.TrackingDataStore{ + // DataStoreIngestionURI: to.Ptr("https://ingest-someClusterName.someRegionName.kusto.windows.net"), + // DataStoreResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Kusto/Clusters/cluster1"), + // DataStoreURI: to.Ptr("https://someClusterName.someRegionName.kusto.windows.net"), + // DatabaseName: to.Ptr("testDatabase1"), + // }, + // }, + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Applications_Get.json +func ExampleApplicationsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewApplicationsClient().Get(ctx, "testrg", "Space1", "Application1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Application = armintegrationspaces.Application{ + // Name: to.Ptr("Application1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/applications"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/applications/Application1"), + // Location: to.Ptr("CentralUS"), + // Tags: map[string]*string{ + // "key1": to.Ptr("Value1"), + // }, + // Properties: &armintegrationspaces.ApplicationProperties{ + // Description: to.Ptr("This is the user provided description of the application."), + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // TrackingDataStores: map[string]*armintegrationspaces.TrackingDataStore{ + // "dataStoreName1": &armintegrationspaces.TrackingDataStore{ + // DataStoreIngestionURI: to.Ptr("https://ingest-someClusterName.someRegionName.kusto.windows.net"), + // DataStoreResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Kusto/Clusters/cluster1"), + // DataStoreURI: to.Ptr("https://someClusterName.someRegionName.kusto.windows.net"), + // DatabaseName: to.Ptr("testDatabase1"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Applications_CreateOrUpdate.json +func ExampleApplicationsClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewApplicationsClient().CreateOrUpdate(ctx, "testrg", "Space1", "Application1", armintegrationspaces.Application{ + Location: to.Ptr("CentralUS"), + Tags: map[string]*string{ + "key1": to.Ptr("Value1"), + }, + Properties: &armintegrationspaces.ApplicationProperties{ + Description: to.Ptr("This is the user provided description of the application."), + TrackingDataStores: map[string]*armintegrationspaces.TrackingDataStore{ + "dataStoreName1": { + DataStoreIngestionURI: to.Ptr("https://ingest-someClusterName.someRegionName.kusto.windows.net"), + DataStoreResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Kusto/Clusters/cluster1"), + DataStoreURI: to.Ptr("https://someClusterName.someRegionName.kusto.windows.net"), + DatabaseName: to.Ptr("testDatabase1"), + }, + "dataStoreName2": { + DataStoreIngestionURI: to.Ptr("https://ingest-someClusterName.someRegionName.kusto.windows.net"), + DataStoreResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Kusto/Clusters/cluster1"), + DataStoreURI: to.Ptr("https://someClusterName.someRegionName.kusto.windows.net"), + DatabaseName: to.Ptr("testDatabase1"), + }, + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Application = armintegrationspaces.Application{ + // Name: to.Ptr("Application1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/applications"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/applications/Application1"), + // Location: to.Ptr("CentralUS"), + // Tags: map[string]*string{ + // "key1": to.Ptr("Value1"), + // }, + // Properties: &armintegrationspaces.ApplicationProperties{ + // Description: to.Ptr("This is the user provided description of the application."), + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // TrackingDataStores: map[string]*armintegrationspaces.TrackingDataStore{ + // "dataStoreName1": &armintegrationspaces.TrackingDataStore{ + // DataStoreIngestionURI: to.Ptr("https://ingest-someClusterName.someRegionName.kusto.windows.net"), + // DataStoreResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Kusto/Clusters/cluster1"), + // DataStoreURI: to.Ptr("https://someClusterName.someRegionName.kusto.windows.net"), + // DatabaseName: to.Ptr("testDatabase1"), + // }, + // "dataStoreName2": &armintegrationspaces.TrackingDataStore{ + // DataStoreIngestionURI: to.Ptr("https://ingest-someClusterName.someRegionName.kusto.windows.net"), + // DataStoreResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Kusto/Clusters/cluster1"), + // DataStoreURI: to.Ptr("https://someClusterName.someRegionName.kusto.windows.net"), + // DatabaseName: to.Ptr("testDatabase1"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Applications_Patch.json +func ExampleApplicationsClient_Patch() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewApplicationsClient().Patch(ctx, "testrg", "Space1", "Application1", armintegrationspaces.ApplicationUpdate{ + Properties: &armintegrationspaces.ApplicationUpdateProperties{ + Description: to.Ptr("This is the user provided PATCHED description of the application."), + }, + Tags: map[string]*string{ + "key1": to.Ptr("Value1"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Application = armintegrationspaces.Application{ + // Name: to.Ptr("Application1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/applications"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/applications/Application1"), + // Location: to.Ptr("CentralUS"), + // Tags: map[string]*string{ + // "key1": to.Ptr("Value1"), + // }, + // Properties: &armintegrationspaces.ApplicationProperties{ + // Description: to.Ptr("This is the user provided PATCHED description of the application."), + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // TrackingDataStores: map[string]*armintegrationspaces.TrackingDataStore{ + // "dataStoreName1": &armintegrationspaces.TrackingDataStore{ + // DataStoreIngestionURI: to.Ptr("https://ingest-someClusterName.someRegionName.kusto.windows.net"), + // DataStoreResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.Kusto/Clusters/cluster1"), + // DataStoreURI: to.Ptr("https://someClusterName.someRegionName.kusto.windows.net"), + // DatabaseName: to.Ptr("testDatabase1"), + // }, + // }, + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Applications_Delete.json +func ExampleApplicationsClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewApplicationsClient().Delete(ctx, "testrg", "Space1", "Application1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Applications_DeleteBusinessProcessDevelopmentArtifact.json +func ExampleApplicationsClient_DeleteBusinessProcessDevelopmentArtifact() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewApplicationsClient().DeleteBusinessProcessDevelopmentArtifact(ctx, "testrg", "Space1", "Application1", armintegrationspaces.GetOrDeleteBusinessProcessDevelopmentArtifactRequest{ + Name: to.Ptr("BusinessProcess1"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Applications_GetBusinessProcessDevelopmentArtifact.json +func ExampleApplicationsClient_GetBusinessProcessDevelopmentArtifact() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewApplicationsClient().GetBusinessProcessDevelopmentArtifact(ctx, "testrg", "Space1", "Application1", armintegrationspaces.GetOrDeleteBusinessProcessDevelopmentArtifactRequest{ + Name: to.Ptr("BusinessProcess1"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SaveOrGetBusinessProcessDevelopmentArtifactResponse = armintegrationspaces.SaveOrGetBusinessProcessDevelopmentArtifactResponse{ + // Name: to.Ptr("BusinessProcess1"), + // Properties: &armintegrationspaces.BusinessProcessDevelopmentArtifactProperties{ + // Description: to.Ptr("First Business Process"), + // BusinessProcessMapping: map[string]*armintegrationspaces.BusinessProcessMappingItem{ + // "Completed": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("CompletedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Denied": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("DeniedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Processing": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ApprovedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Received": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Shipped": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ShippedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // }, + // BusinessProcessStages: map[string]*armintegrationspaces.BusinessProcessStage{ + // "Completed": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Completed"), + // StagesBefore: []*string{ + // to.Ptr("Shipped")}, + // }, + // "Denied": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Denied"), + // StagesBefore: []*string{ + // to.Ptr("Processing")}, + // }, + // "Processing": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Processing"), + // Properties: map[string]*string{ + // "ApprovalState": to.Ptr("String"), + // "ApproverName": to.Ptr("String"), + // "POAmount": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Received")}, + // }, + // "Received": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("received"), + // Properties: map[string]*string{ + // "City": to.Ptr("String"), + // "Product": to.Ptr("String"), + // "Quantity": to.Ptr("Integer"), + // "State": to.Ptr("String"), + // }, + // }, + // "Shipped": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Shipped"), + // Properties: map[string]*string{ + // "ShipPriority": to.Ptr("Integer"), + // "TrackingID": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Denied")}, + // }, + // }, + // Identifier: &armintegrationspaces.BusinessProcessIdentifier{ + // PropertyName: to.Ptr("businessIdentifier-1"), + // PropertyType: to.Ptr("String"), + // }, + // TrackingProfiles: map[string]*armintegrationspaces.TrackingProfileDefinition{ + // "subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1": &armintegrationspaces.TrackingProfileDefinition{ + // Schema: to.Ptr("https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2023-01-01/trackingdefinitionschema.json#"), + // BusinessProcess: &armintegrationspaces.BusinessProcessReference{ + // Name: to.Ptr("businessProcess1"), + // Version: to.Ptr("d52c9c91-6e10-4a90-9c1f-08ee5d01c656"), + // }, + // TrackingDefinitions: map[string]*armintegrationspaces.FlowTrackingDefinition{ + // "Fulfillment": &armintegrationspaces.FlowTrackingDefinition{ + // CorrelationContext: &armintegrationspaces.TrackingCorrelationContext{ + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // PropertyName: to.Ptr("OrderNumber"), + // Value: to.Ptr("@trigger().outputs.body.OrderNumber"), + // }, + // Events: map[string]*armintegrationspaces.TrackingEventDefinition{ + // "Completed": &armintegrationspaces.TrackingEventDefinition{ + // OperationName: to.Ptr("CompletedPO"), + // OperationType: to.Ptr("Action"), + // Properties: map[string]any{ + // }, + // }, + // "Denied": &armintegrationspaces.TrackingEventDefinition{ + // OperationName: to.Ptr("DeniedPO"), + // OperationType: to.Ptr("Action"), + // Properties: map[string]any{ + // }, + // }, + // "Shipped": &armintegrationspaces.TrackingEventDefinition{ + // OperationName: to.Ptr("ShippedPO"), + // OperationType: to.Ptr("Action"), + // Properties: map[string]any{ + // "ShipPriority": "@action().inputs.shipPriority", + // "TrackingID": "@action().inputs.trackingID", + // }, + // }, + // }, + // }, + // "PurchaseOrder": &armintegrationspaces.FlowTrackingDefinition{ + // CorrelationContext: &armintegrationspaces.TrackingCorrelationContext{ + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // PropertyName: to.Ptr("OrderNumber"), + // Value: to.Ptr("@trigger().outputs.body.OrderNumber"), + // }, + // Events: map[string]*armintegrationspaces.TrackingEventDefinition{ + // "Processing": &armintegrationspaces.TrackingEventDefinition{ + // OperationName: to.Ptr("ApprovedPO"), + // OperationType: to.Ptr("Action"), + // Properties: map[string]any{ + // "ApprovalStatus": "@action().inputs.ApprovalStatus", + // "ApproverName": "@action().inputs.ApproverName", + // "POAmount": "@action().inputs.POamount", + // }, + // }, + // "Received": &armintegrationspaces.TrackingEventDefinition{ + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // Properties: map[string]any{ + // "City": "@trigger().outputs.body.Address.City", + // "Product": "@trigger().outputs.body.Product", + // "Quantity": "@trigger().outputs.body.Quantity", + // "State": "@trigger().outputs.body.Address.State", + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // SystemData: &armintegrationspaces.SystemData{ + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-06T22:53:01.849Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Applications_ListBusinessProcessDevelopmentArtifacts.json +func ExampleApplicationsClient_ListBusinessProcessDevelopmentArtifacts() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewApplicationsClient().ListBusinessProcessDevelopmentArtifacts(ctx, "testrg", "Space1", "Application1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.ListBusinessProcessDevelopmentArtifactsResponse = armintegrationspaces.ListBusinessProcessDevelopmentArtifactsResponse{ + // Value: []*armintegrationspaces.SaveOrGetBusinessProcessDevelopmentArtifactResponse{ + // { + // Name: to.Ptr("BusinessProcess1"), + // Properties: &armintegrationspaces.BusinessProcessDevelopmentArtifactProperties{ + // Description: to.Ptr("First Business Process"), + // BusinessProcessMapping: map[string]*armintegrationspaces.BusinessProcessMappingItem{ + // "Completed": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("CompletedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Denied": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("DeniedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Processing": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ApprovedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Received": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Shipped": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ShippedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // }, + // BusinessProcessStages: map[string]*armintegrationspaces.BusinessProcessStage{ + // "Completed": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Completed"), + // StagesBefore: []*string{ + // to.Ptr("Shipped")}, + // }, + // "Denied": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Denied"), + // StagesBefore: []*string{ + // to.Ptr("Processing")}, + // }, + // "Processing": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Processing"), + // Properties: map[string]*string{ + // "ApprovalState": to.Ptr("String"), + // "ApproverName": to.Ptr("String"), + // "POAmount": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Received")}, + // }, + // "Received": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("received"), + // Properties: map[string]*string{ + // "City": to.Ptr("String"), + // "Product": to.Ptr("String"), + // "Quantity": to.Ptr("Integer"), + // "State": to.Ptr("String"), + // }, + // }, + // "Shipped": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Shipped"), + // Properties: map[string]*string{ + // "ShipPriority": to.Ptr("Integer"), + // "TrackingID": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Denied")}, + // }, + // }, + // Identifier: &armintegrationspaces.BusinessProcessIdentifier{ + // PropertyName: to.Ptr("businessIdentifier-1"), + // PropertyType: to.Ptr("String"), + // }, + // TrackingProfiles: map[string]*armintegrationspaces.TrackingProfileDefinition{ + // "subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1": &armintegrationspaces.TrackingProfileDefinition{ + // Schema: to.Ptr("https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2023-01-01/trackingdefinitionschema.json#"), + // BusinessProcess: &armintegrationspaces.BusinessProcessReference{ + // Name: to.Ptr("businessProcess1"), + // Version: to.Ptr("d52c9c91-6e10-4a90-9c1f-08ee5d01c656"), + // }, + // TrackingDefinitions: map[string]*armintegrationspaces.FlowTrackingDefinition{ + // "Fulfillment": &armintegrationspaces.FlowTrackingDefinition{ + // CorrelationContext: &armintegrationspaces.TrackingCorrelationContext{ + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // PropertyName: to.Ptr("OrderNumber"), + // Value: to.Ptr("@trigger().outputs.body.OrderNumber"), + // }, + // Events: map[string]*armintegrationspaces.TrackingEventDefinition{ + // "Completed": &armintegrationspaces.TrackingEventDefinition{ + // OperationName: to.Ptr("CompletedPO"), + // OperationType: to.Ptr("Action"), + // Properties: map[string]any{ + // }, + // }, + // "Denied": &armintegrationspaces.TrackingEventDefinition{ + // OperationName: to.Ptr("DeniedPO"), + // OperationType: to.Ptr("Action"), + // Properties: map[string]any{ + // }, + // }, + // "Shipped": &armintegrationspaces.TrackingEventDefinition{ + // OperationName: to.Ptr("ShippedPO"), + // OperationType: to.Ptr("Action"), + // Properties: map[string]any{ + // "ShipPriority": "@action().inputs.shipPriority", + // "TrackingID": "@action().inputs.trackingID", + // }, + // }, + // }, + // }, + // "PurchaseOrder": &armintegrationspaces.FlowTrackingDefinition{ + // CorrelationContext: &armintegrationspaces.TrackingCorrelationContext{ + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // PropertyName: to.Ptr("OrderNumber"), + // Value: to.Ptr("@trigger().outputs.body.OrderNumber"), + // }, + // Events: map[string]*armintegrationspaces.TrackingEventDefinition{ + // "Processing": &armintegrationspaces.TrackingEventDefinition{ + // OperationName: to.Ptr("ApprovedPO"), + // OperationType: to.Ptr("Action"), + // Properties: map[string]any{ + // "ApprovalStatus": "@action().inputs.ApprovalStatus", + // "ApproverName": "@action().inputs.ApproverName", + // "POAmount": "@action().inputs.POamount", + // }, + // }, + // "Received": &armintegrationspaces.TrackingEventDefinition{ + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // Properties: map[string]any{ + // "City": "@trigger().outputs.body.Address.City", + // "Product": "@trigger().outputs.body.Product", + // "Quantity": "@trigger().outputs.body.Quantity", + // "State": "@trigger().outputs.body.Address.State", + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // SystemData: &armintegrationspaces.SystemData{ + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-06T22:53:01.849Z"); return t}()), + // }, + // }}, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Applications_SaveBusinessProcessDevelopmentArtifact.json +func ExampleApplicationsClient_SaveBusinessProcessDevelopmentArtifact() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewApplicationsClient().SaveBusinessProcessDevelopmentArtifact(ctx, "testrg", "Space1", "Application1", armintegrationspaces.SaveOrValidateBusinessProcessDevelopmentArtifactRequest{ + Name: to.Ptr("BusinessProcess1"), + Properties: &armintegrationspaces.BusinessProcessDevelopmentArtifactProperties{ + Description: to.Ptr("First Business Process"), + BusinessProcessMapping: map[string]*armintegrationspaces.BusinessProcessMappingItem{ + "Completed": { + LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + OperationName: to.Ptr("CompletedPO"), + OperationType: to.Ptr("Action"), + WorkflowName: to.Ptr("Fulfillment"), + }, + "Denied": { + LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + OperationName: to.Ptr("DeniedPO"), + OperationType: to.Ptr("Action"), + WorkflowName: to.Ptr("Fulfillment"), + }, + "Processing": { + LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + OperationName: to.Ptr("ApprovedPO"), + OperationType: to.Ptr("Action"), + WorkflowName: to.Ptr("PurchaseOrder"), + }, + "Received": { + LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + OperationName: to.Ptr("manual"), + OperationType: to.Ptr("Trigger"), + WorkflowName: to.Ptr("PurchaseOrder"), + }, + "Shipped": { + LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + OperationName: to.Ptr("ShippedPO"), + OperationType: to.Ptr("Action"), + WorkflowName: to.Ptr("Fulfillment"), + }, + }, + BusinessProcessStages: map[string]*armintegrationspaces.BusinessProcessStage{ + "Completed": { + Description: to.Ptr("Completed"), + StagesBefore: []*string{ + to.Ptr("Shipped")}, + }, + "Denied": { + Description: to.Ptr("Denied"), + StagesBefore: []*string{ + to.Ptr("Processing")}, + }, + "Processing": { + Description: to.Ptr("Processing"), + Properties: map[string]*string{ + "ApprovalState": to.Ptr("String"), + "ApproverName": to.Ptr("String"), + "POAmount": to.Ptr("Integer"), + }, + StagesBefore: []*string{ + to.Ptr("Received")}, + }, + "Received": { + Description: to.Ptr("received"), + Properties: map[string]*string{ + "City": to.Ptr("String"), + "Product": to.Ptr("String"), + "Quantity": to.Ptr("Integer"), + "State": to.Ptr("String"), + }, + }, + "Shipped": { + Description: to.Ptr("Shipped"), + Properties: map[string]*string{ + "ShipPriority": to.Ptr("Integer"), + "TrackingID": to.Ptr("Integer"), + }, + StagesBefore: []*string{ + to.Ptr("Denied")}, + }, + }, + Identifier: &armintegrationspaces.BusinessProcessIdentifier{ + PropertyName: to.Ptr("businessIdentifier-1"), + PropertyType: to.Ptr("String"), + }, + TrackingProfiles: map[string]*armintegrationspaces.TrackingProfileDefinition{ + "subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1": { + Schema: to.Ptr("https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2023-01-01/trackingdefinitionschema.json#"), + BusinessProcess: &armintegrationspaces.BusinessProcessReference{ + Name: to.Ptr("businessProcess1"), + Version: to.Ptr("d52c9c91-6e10-4a90-9c1f-08ee5d01c656"), + }, + TrackingDefinitions: map[string]*armintegrationspaces.FlowTrackingDefinition{ + "Fulfillment": { + CorrelationContext: &armintegrationspaces.TrackingCorrelationContext{ + OperationName: to.Ptr("manual"), + OperationType: to.Ptr("Trigger"), + PropertyName: to.Ptr("OrderNumber"), + Value: to.Ptr("@trigger().outputs.body.OrderNumber"), + }, + Events: map[string]*armintegrationspaces.TrackingEventDefinition{ + "Completed": { + OperationName: to.Ptr("CompletedPO"), + OperationType: to.Ptr("Action"), + Properties: map[string]any{}, + }, + "Denied": { + OperationName: to.Ptr("DeniedPO"), + OperationType: to.Ptr("Action"), + Properties: map[string]any{}, + }, + "Shipped": { + OperationName: to.Ptr("ShippedPO"), + OperationType: to.Ptr("Action"), + Properties: map[string]any{ + "ShipPriority": "@action().inputs.shipPriority", + "TrackingID": "@action().inputs.trackingID", + }, + }, + }, + }, + "PurchaseOrder": { + CorrelationContext: &armintegrationspaces.TrackingCorrelationContext{ + OperationName: to.Ptr("manual"), + OperationType: to.Ptr("Trigger"), + PropertyName: to.Ptr("OrderNumber"), + Value: to.Ptr("@trigger().outputs.body.OrderNumber"), + }, + Events: map[string]*armintegrationspaces.TrackingEventDefinition{ + "Processing": { + OperationName: to.Ptr("ApprovedPO"), + OperationType: to.Ptr("Action"), + Properties: map[string]any{ + "ApprovalStatus": "@action().inputs.ApprovalStatus", + "ApproverName": "@action().inputs.ApproverName", + "POAmount": "@action().inputs.POamount", + }, + }, + "Received": { + OperationName: to.Ptr("manual"), + OperationType: to.Ptr("Trigger"), + Properties: map[string]any{ + "City": "@trigger().outputs.body.Address.City", + "Product": "@trigger().outputs.body.Product", + "Quantity": "@trigger().outputs.body.Quantity", + "State": "@trigger().outputs.body.Address.State", + }, + }, + }, + }, + }, + }, + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.SaveOrGetBusinessProcessDevelopmentArtifactResponse = armintegrationspaces.SaveOrGetBusinessProcessDevelopmentArtifactResponse{ + // Name: to.Ptr("BusinessProcess1"), + // Properties: &armintegrationspaces.BusinessProcessDevelopmentArtifactProperties{ + // Description: to.Ptr("First Business Process"), + // BusinessProcessMapping: map[string]*armintegrationspaces.BusinessProcessMappingItem{ + // "Completed": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("CompletedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Denied": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("DeniedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Processing": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ApprovedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Received": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Shipped": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ShippedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // }, + // BusinessProcessStages: map[string]*armintegrationspaces.BusinessProcessStage{ + // "Completed": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Completed"), + // StagesBefore: []*string{ + // to.Ptr("Shipped")}, + // }, + // "Denied": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Denied"), + // StagesBefore: []*string{ + // to.Ptr("Processing")}, + // }, + // "Processing": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Processing"), + // Properties: map[string]*string{ + // "ApprovalState": to.Ptr("String"), + // "ApproverName": to.Ptr("String"), + // "POAmount": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Received")}, + // }, + // "Received": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("received"), + // Properties: map[string]*string{ + // "City": to.Ptr("String"), + // "Product": to.Ptr("String"), + // "Quantity": to.Ptr("Integer"), + // "State": to.Ptr("String"), + // }, + // }, + // "Shipped": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Shipped"), + // Properties: map[string]*string{ + // "ShipPriority": to.Ptr("Integer"), + // "TrackingID": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Denied")}, + // }, + // }, + // Identifier: &armintegrationspaces.BusinessProcessIdentifier{ + // PropertyName: to.Ptr("businessIdentifier-1"), + // PropertyType: to.Ptr("String"), + // }, + // TrackingProfiles: map[string]*armintegrationspaces.TrackingProfileDefinition{ + // "subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1": &armintegrationspaces.TrackingProfileDefinition{ + // Schema: to.Ptr("https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2023-01-01/trackingdefinitionschema.json#"), + // BusinessProcess: &armintegrationspaces.BusinessProcessReference{ + // Name: to.Ptr("businessProcess1"), + // Version: to.Ptr("d52c9c91-6e10-4a90-9c1f-08ee5d01c656"), + // }, + // TrackingDefinitions: map[string]*armintegrationspaces.FlowTrackingDefinition{ + // "Fulfillment": &armintegrationspaces.FlowTrackingDefinition{ + // CorrelationContext: &armintegrationspaces.TrackingCorrelationContext{ + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // PropertyName: to.Ptr("OrderNumber"), + // Value: to.Ptr("@trigger().outputs.body.OrderNumber"), + // }, + // Events: map[string]*armintegrationspaces.TrackingEventDefinition{ + // "Completed": &armintegrationspaces.TrackingEventDefinition{ + // OperationName: to.Ptr("CompletedPO"), + // OperationType: to.Ptr("Action"), + // Properties: map[string]any{ + // }, + // }, + // "Denied": &armintegrationspaces.TrackingEventDefinition{ + // OperationName: to.Ptr("DeniedPO"), + // OperationType: to.Ptr("Action"), + // Properties: map[string]any{ + // }, + // }, + // "Shipped": &armintegrationspaces.TrackingEventDefinition{ + // OperationName: to.Ptr("ShippedPO"), + // OperationType: to.Ptr("Action"), + // Properties: map[string]any{ + // "ShipPriority": "@action().inputs.shipPriority", + // "TrackingID": "@action().inputs.trackingID", + // }, + // }, + // }, + // }, + // "PurchaseOrder": &armintegrationspaces.FlowTrackingDefinition{ + // CorrelationContext: &armintegrationspaces.TrackingCorrelationContext{ + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // PropertyName: to.Ptr("OrderNumber"), + // Value: to.Ptr("@trigger().outputs.body.OrderNumber"), + // }, + // Events: map[string]*armintegrationspaces.TrackingEventDefinition{ + // "Processing": &armintegrationspaces.TrackingEventDefinition{ + // OperationName: to.Ptr("ApprovedPO"), + // OperationType: to.Ptr("Action"), + // Properties: map[string]any{ + // "ApprovalStatus": "@action().inputs.ApprovalStatus", + // "ApproverName": "@action().inputs.ApproverName", + // "POAmount": "@action().inputs.POamount", + // }, + // }, + // "Received": &armintegrationspaces.TrackingEventDefinition{ + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // Properties: map[string]any{ + // "City": "@trigger().outputs.body.Address.City", + // "Product": "@trigger().outputs.body.Product", + // "Quantity": "@trigger().outputs.body.Quantity", + // "State": "@trigger().outputs.body.Address.State", + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // SystemData: &armintegrationspaces.SystemData{ + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-09-06T22:53:01.849Z"); return t}()), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Applications_ValidateBusinessProcessDevelopmentArtifact.json +func ExampleApplicationsClient_ValidateBusinessProcessDevelopmentArtifact() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewApplicationsClient().ValidateBusinessProcessDevelopmentArtifact(ctx, "testrg", "Space1", "Application1", armintegrationspaces.SaveOrValidateBusinessProcessDevelopmentArtifactRequest{ + Name: to.Ptr("BusinessProcess1"), + Properties: &armintegrationspaces.BusinessProcessDevelopmentArtifactProperties{ + Description: to.Ptr("First Business Process"), + BusinessProcessMapping: map[string]*armintegrationspaces.BusinessProcessMappingItem{ + "Completed": { + LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + OperationName: to.Ptr("CompletedPO"), + OperationType: to.Ptr("Action"), + WorkflowName: to.Ptr("Fulfillment"), + }, + "Denied": { + LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + OperationName: to.Ptr("DeniedPO"), + OperationType: to.Ptr("Action"), + WorkflowName: to.Ptr("Fulfillment"), + }, + "Processing": { + LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + OperationName: to.Ptr("ApprovedPO"), + OperationType: to.Ptr("Action"), + WorkflowName: to.Ptr("PurchaseOrder"), + }, + "Received": { + LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + OperationName: to.Ptr("manual"), + OperationType: to.Ptr("Trigger"), + WorkflowName: to.Ptr("PurchaseOrder"), + }, + "Shipped": { + LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + OperationName: to.Ptr("ShippedPO"), + OperationType: to.Ptr("Action"), + WorkflowName: to.Ptr("Fulfillment"), + }, + }, + BusinessProcessStages: map[string]*armintegrationspaces.BusinessProcessStage{ + "Completed": { + Description: to.Ptr("Completed"), + StagesBefore: []*string{ + to.Ptr("Shipped")}, + }, + "Denied": { + Description: to.Ptr("Denied"), + StagesBefore: []*string{ + to.Ptr("Processing")}, + }, + "Processing": { + Description: to.Ptr("Processing"), + Properties: map[string]*string{ + "ApprovalState": to.Ptr("String"), + "ApproverName": to.Ptr("String"), + "POAmount": to.Ptr("Integer"), + }, + StagesBefore: []*string{ + to.Ptr("Received")}, + }, + "Received@": { + Description: to.Ptr("received"), + Properties: map[string]*string{ + "City": to.Ptr("String"), + "Product": to.Ptr("String"), + "Quantity": to.Ptr("Integer"), + "State": to.Ptr("String"), + }, + }, + "Shipped": { + Description: to.Ptr("Shipped"), + Properties: map[string]*string{ + "ShipPriority": to.Ptr("Integer"), + "TrackingID": to.Ptr("Integer"), + }, + StagesBefore: []*string{ + to.Ptr("Denied")}, + }, + }, + Identifier: &armintegrationspaces.BusinessProcessIdentifier{ + PropertyName: to.Ptr("businessIdentifier-1"), + PropertyType: to.Ptr("String"), + }, + TrackingProfiles: map[string]*armintegrationspaces.TrackingProfileDefinition{ + "subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1": { + Schema: to.Ptr("https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2023-01-01/trackingdefinitionschema.json#"), + BusinessProcess: &armintegrationspaces.BusinessProcessReference{ + Name: to.Ptr("businessProcess1"), + Version: to.Ptr("d52c9c91-6e10-4a90-9c1f-08ee5d01c656"), + }, + TrackingDefinitions: map[string]*armintegrationspaces.FlowTrackingDefinition{ + "Fulfillment": { + CorrelationContext: &armintegrationspaces.TrackingCorrelationContext{ + OperationName: to.Ptr("manual"), + OperationType: to.Ptr("Trigger"), + PropertyName: to.Ptr("OrderNumber"), + Value: to.Ptr("@trigger().outputs.body.OrderNumber"), + }, + Events: map[string]*armintegrationspaces.TrackingEventDefinition{ + "Completed": { + OperationName: to.Ptr("CompletedPO"), + OperationType: to.Ptr("Action"), + Properties: map[string]any{}, + }, + "Denied": { + OperationName: to.Ptr("DeniedPO"), + OperationType: to.Ptr("Action"), + Properties: map[string]any{}, + }, + "Shipped": { + OperationName: to.Ptr("ShippedPO"), + OperationType: to.Ptr("Action"), + Properties: map[string]any{ + "ShipPriority": "@action().inputs.shipPriority", + "TrackingID": "@action().inputs.trackingID", + }, + }, + }, + }, + "PurchaseOrder": { + CorrelationContext: &armintegrationspaces.TrackingCorrelationContext{ + OperationName: to.Ptr("manual"), + OperationType: to.Ptr("Trigger"), + PropertyName: to.Ptr("OrderNumber"), + Value: to.Ptr("@trigger().outputs.body.OrderNumber"), + }, + Events: map[string]*armintegrationspaces.TrackingEventDefinition{ + "Processing": { + OperationName: to.Ptr("ApprovedPO"), + OperationType: to.Ptr("Action"), + Properties: map[string]any{ + "ApprovalStatus": "@action().inputs.ApprovalStatus", + "ApproverName": "@action().inputs.ApproverName", + "POAmount": "@action().inputs.POamount", + }, + }, + "Received": { + OperationName: to.Ptr("manual"), + OperationType: to.Ptr("Trigger"), + Properties: map[string]any{ + "City": "@trigger().outputs.body.Address.City", + "Product": "@trigger().outputs.body.Product", + "Quantity": "@trigger().outputs.body.Quantity", + "State": "@trigger().outputs.body.Address.State", + }, + }, + }, + }, + }, + }, + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/autorest.md b/sdk/resourcemanager/integrationspaces/armintegrationspaces/autorest.md new file mode 100644 index 000000000000..45d436e42ee4 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 +tag: package-2023-11-14-preview +``` \ No newline at end of file diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/build.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/build.go new file mode 100644 index 000000000000..e41829288ab8 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/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/integrationspaces/armintegrationspaces + +package armintegrationspaces diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocesses_client.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocesses_client.go new file mode 100644 index 000000000000..144f0aa0956a --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocesses_client.go @@ -0,0 +1,438 @@ +//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 armintegrationspaces + +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" + "strconv" + "strings" +) + +// BusinessProcessesClient contains the methods for the BusinessProcesses group. +// Don't use this type directly, use NewBusinessProcessesClient() instead. +type BusinessProcessesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewBusinessProcessesClient creates a new instance of BusinessProcessesClient 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 NewBusinessProcessesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BusinessProcessesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &BusinessProcessesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Create a BusinessProcess +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - businessProcessName - The name of the business process +// - resource - Resource create parameters. +// - options - BusinessProcessesClientCreateOrUpdateOptions contains the optional parameters for the BusinessProcessesClient.CreateOrUpdate +// method. +func (client *BusinessProcessesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, resource BusinessProcess, options *BusinessProcessesClientCreateOrUpdateOptions) (BusinessProcessesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "BusinessProcessesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, spaceName, applicationName, businessProcessName, resource, options) + if err != nil { + return BusinessProcessesClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BusinessProcessesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return BusinessProcessesClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *BusinessProcessesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, resource BusinessProcess, options *BusinessProcessesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/businessProcesses/{businessProcessName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + if businessProcessName == "" { + return nil, errors.New("parameter businessProcessName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{businessProcessName}", url.PathEscape(businessProcessName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *BusinessProcessesClient) createOrUpdateHandleResponse(resp *http.Response) (BusinessProcessesClientCreateOrUpdateResponse, error) { + result := BusinessProcessesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BusinessProcess); err != nil { + return BusinessProcessesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete a BusinessProcess +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - businessProcessName - The name of the business process +// - options - BusinessProcessesClientDeleteOptions contains the optional parameters for the BusinessProcessesClient.Delete +// method. +func (client *BusinessProcessesClient) Delete(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, options *BusinessProcessesClientDeleteOptions) (BusinessProcessesClientDeleteResponse, error) { + var err error + const operationName = "BusinessProcessesClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, spaceName, applicationName, businessProcessName, options) + if err != nil { + return BusinessProcessesClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BusinessProcessesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return BusinessProcessesClientDeleteResponse{}, err + } + return BusinessProcessesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *BusinessProcessesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, options *BusinessProcessesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/businessProcesses/{businessProcessName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + if businessProcessName == "" { + return nil, errors.New("parameter businessProcessName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{businessProcessName}", url.PathEscape(businessProcessName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a BusinessProcess +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - businessProcessName - The name of the business process +// - options - BusinessProcessesClientGetOptions contains the optional parameters for the BusinessProcessesClient.Get method. +func (client *BusinessProcessesClient) Get(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, options *BusinessProcessesClientGetOptions) (BusinessProcessesClientGetResponse, error) { + var err error + const operationName = "BusinessProcessesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, spaceName, applicationName, businessProcessName, options) + if err != nil { + return BusinessProcessesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BusinessProcessesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BusinessProcessesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *BusinessProcessesClient) getCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, options *BusinessProcessesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/businessProcesses/{businessProcessName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + if businessProcessName == "" { + return nil, errors.New("parameter businessProcessName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{businessProcessName}", url.PathEscape(businessProcessName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *BusinessProcessesClient) getHandleResponse(resp *http.Response) (BusinessProcessesClientGetResponse, error) { + result := BusinessProcessesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BusinessProcess); err != nil { + return BusinessProcessesClientGetResponse{}, err + } + return result, nil +} + +// NewListByApplicationPager - List BusinessProcess resources by Application +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - options - BusinessProcessesClientListByApplicationOptions contains the optional parameters for the BusinessProcessesClient.NewListByApplicationPager +// method. +func (client *BusinessProcessesClient) NewListByApplicationPager(resourceGroupName string, spaceName string, applicationName string, options *BusinessProcessesClientListByApplicationOptions) *runtime.Pager[BusinessProcessesClientListByApplicationResponse] { + return runtime.NewPager(runtime.PagingHandler[BusinessProcessesClientListByApplicationResponse]{ + More: func(page BusinessProcessesClientListByApplicationResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *BusinessProcessesClientListByApplicationResponse) (BusinessProcessesClientListByApplicationResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BusinessProcessesClient.NewListByApplicationPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByApplicationCreateRequest(ctx, resourceGroupName, spaceName, applicationName, options) + }, nil) + if err != nil { + return BusinessProcessesClientListByApplicationResponse{}, err + } + return client.listByApplicationHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByApplicationCreateRequest creates the ListByApplication request. +func (client *BusinessProcessesClient) listByApplicationCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, options *BusinessProcessesClientListByApplicationOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/businessProcesses" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Maxpagesize != nil { + reqQP.Set("maxpagesize", strconv.FormatInt(int64(*options.Maxpagesize), 10)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.Select != nil { + for _, qv := range options.Select { + reqQP.Add("select", qv) + } + } + if options != nil && options.Expand != nil { + for _, qv := range options.Expand { + reqQP.Add("expand", qv) + } + } + if options != nil && options.Orderby != nil { + for _, qv := range options.Orderby { + reqQP.Add("orderby", qv) + } + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByApplicationHandleResponse handles the ListByApplication response. +func (client *BusinessProcessesClient) listByApplicationHandleResponse(resp *http.Response) (BusinessProcessesClientListByApplicationResponse, error) { + result := BusinessProcessesClientListByApplicationResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BusinessProcessListResult); err != nil { + return BusinessProcessesClientListByApplicationResponse{}, err + } + return result, nil +} + +// Patch - Update a BusinessProcess +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - businessProcessName - The name of the business process +// - properties - The resource properties to be updated. +// - options - BusinessProcessesClientPatchOptions contains the optional parameters for the BusinessProcessesClient.Patch method. +func (client *BusinessProcessesClient) Patch(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, properties BusinessProcessUpdate, options *BusinessProcessesClientPatchOptions) (BusinessProcessesClientPatchResponse, error) { + var err error + const operationName = "BusinessProcessesClient.Patch" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.patchCreateRequest(ctx, resourceGroupName, spaceName, applicationName, businessProcessName, properties, options) + if err != nil { + return BusinessProcessesClientPatchResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BusinessProcessesClientPatchResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BusinessProcessesClientPatchResponse{}, err + } + resp, err := client.patchHandleResponse(httpResp) + return resp, err +} + +// patchCreateRequest creates the Patch request. +func (client *BusinessProcessesClient) patchCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, properties BusinessProcessUpdate, options *BusinessProcessesClientPatchOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/businessProcesses/{businessProcessName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + if businessProcessName == "" { + return nil, errors.New("parameter businessProcessName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{businessProcessName}", url.PathEscape(businessProcessName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// patchHandleResponse handles the Patch response. +func (client *BusinessProcessesClient) patchHandleResponse(resp *http.Response) (BusinessProcessesClientPatchResponse, error) { + result := BusinessProcessesClientPatchResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BusinessProcess); err != nil { + return BusinessProcessesClientPatchResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocesses_client_example_test.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocesses_client_example_test.go new file mode 100644 index 000000000000..ed6fdf77e21f --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocesses_client_example_test.go @@ -0,0 +1,569 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armintegrationspaces_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/BusinessProcesses_ListByApplication.json +func ExampleBusinessProcessesClient_NewListByApplicationPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewBusinessProcessesClient().NewListByApplicationPager("testrg", "Space1", "Application1", &armintegrationspaces.BusinessProcessesClientListByApplicationOptions{Top: nil, + Skip: nil, + Maxpagesize: nil, + Filter: nil, + Select: []string{}, + Expand: []string{}, + Orderby: []string{}, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.BusinessProcessListResult = armintegrationspaces.BusinessProcessListResult{ + // Value: []*armintegrationspaces.BusinessProcess{ + // { + // Name: to.Ptr("BusinessProcess1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/applications/BusinessProcesses"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/applications/Application1/businessProcesses/BusinessProcess1"), + // Properties: &armintegrationspaces.BusinessProcessProperties{ + // Description: to.Ptr("First Business Process"), + // BusinessProcessMapping: map[string]*armintegrationspaces.BusinessProcessMappingItem{ + // "Completed": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("CompletedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Denied": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("DeniedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Processing": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ApprovedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Received": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Shipped": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ShippedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // }, + // BusinessProcessStages: map[string]*armintegrationspaces.BusinessProcessStage{ + // "Completed": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Completed"), + // StagesBefore: []*string{ + // to.Ptr("Shipped")}, + // }, + // "Denied": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Denied"), + // StagesBefore: []*string{ + // to.Ptr("Processing")}, + // }, + // "Processing": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Processing"), + // Properties: map[string]*string{ + // "ApprovalState": to.Ptr("String"), + // "ApproverName": to.Ptr("String"), + // "POAmount": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Received")}, + // }, + // "Received": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("received"), + // Properties: map[string]*string{ + // "City": to.Ptr("String"), + // "Product": to.Ptr("String"), + // "Quantity": to.Ptr("Integer"), + // "State": to.Ptr("String"), + // }, + // }, + // "Shipped": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Shipped"), + // Properties: map[string]*string{ + // "ShipPriority": to.Ptr("Integer"), + // "TrackingID": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Denied")}, + // }, + // }, + // Identifier: &armintegrationspaces.BusinessProcessIdentifier{ + // PropertyName: to.Ptr("businessIdentifier-1"), + // PropertyType: to.Ptr("String"), + // }, + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // TableName: to.Ptr("table1"), + // TrackingDataStoreReferenceName: to.Ptr("trackingDataStoreReferenceName1"), + // Version: to.Ptr("08585074782265427079"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/BusinessProcesses_Get.json +func ExampleBusinessProcessesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBusinessProcessesClient().Get(ctx, "testrg", "Space1", "Application1", "BusinessProcess1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BusinessProcess = armintegrationspaces.BusinessProcess{ + // Name: to.Ptr("BusinessProcess1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/applications/businessProcesses"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/applications/Application1/businessProcesses/BusinessProcess1"), + // Properties: &armintegrationspaces.BusinessProcessProperties{ + // Description: to.Ptr("Sample Business Process"), + // BusinessProcessMapping: map[string]*armintegrationspaces.BusinessProcessMappingItem{ + // "Completed": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("CompletedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Denied": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("DeniedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Processing": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ApprovedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Received": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Shipped": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ShippedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // }, + // BusinessProcessStages: map[string]*armintegrationspaces.BusinessProcessStage{ + // "Completed": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Completed"), + // StagesBefore: []*string{ + // to.Ptr("Shipped")}, + // }, + // "Denied": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Denied"), + // StagesBefore: []*string{ + // to.Ptr("Processing")}, + // }, + // "Processing": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Processing"), + // Properties: map[string]*string{ + // "ApprovalState": to.Ptr("String"), + // "ApproverName": to.Ptr("String"), + // "POAmount": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Received")}, + // }, + // "Received": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("received"), + // Properties: map[string]*string{ + // "City": to.Ptr("String"), + // "Product": to.Ptr("String"), + // "Quantity": to.Ptr("Integer"), + // "State": to.Ptr("String"), + // }, + // }, + // "Shipped": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Shipped"), + // Properties: map[string]*string{ + // "ShipPriority": to.Ptr("Integer"), + // "TrackingID": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Denied")}, + // }, + // }, + // Identifier: &armintegrationspaces.BusinessProcessIdentifier{ + // PropertyName: to.Ptr("businessIdentifier-1"), + // PropertyType: to.Ptr("String"), + // }, + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // TableName: to.Ptr("table1"), + // TrackingDataStoreReferenceName: to.Ptr("trackingDataStoreReferenceName1"), + // Version: to.Ptr("08585074782265427079"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/BusinessProcesses_CreateOrUpdate.json +func ExampleBusinessProcessesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBusinessProcessesClient().CreateOrUpdate(ctx, "testrg", "Space1", "Application1", "BusinessProcess1", armintegrationspaces.BusinessProcess{ + Properties: &armintegrationspaces.BusinessProcessProperties{ + Description: to.Ptr("First Business Process"), + BusinessProcessMapping: map[string]*armintegrationspaces.BusinessProcessMappingItem{ + "Completed": { + LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + OperationName: to.Ptr("CompletedPO"), + OperationType: to.Ptr("Action"), + WorkflowName: to.Ptr("Fulfillment"), + }, + "Denied": { + LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + OperationName: to.Ptr("DeniedPO"), + OperationType: to.Ptr("Action"), + WorkflowName: to.Ptr("Fulfillment"), + }, + "Processing": { + LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + OperationName: to.Ptr("ApprovedPO"), + OperationType: to.Ptr("Action"), + WorkflowName: to.Ptr("PurchaseOrder"), + }, + "Received": { + LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + OperationName: to.Ptr("manual"), + OperationType: to.Ptr("Trigger"), + WorkflowName: to.Ptr("PurchaseOrder"), + }, + "Shipped": { + LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + OperationName: to.Ptr("ShippedPO"), + OperationType: to.Ptr("Action"), + WorkflowName: to.Ptr("Fulfillment"), + }, + }, + BusinessProcessStages: map[string]*armintegrationspaces.BusinessProcessStage{ + "Completed": { + Description: to.Ptr("Completed"), + StagesBefore: []*string{ + to.Ptr("Shipped")}, + }, + "Denied": { + Description: to.Ptr("Denied"), + StagesBefore: []*string{ + to.Ptr("Processing")}, + }, + "Processing": { + Description: to.Ptr("Processing"), + Properties: map[string]*string{ + "ApprovalState": to.Ptr("String"), + "ApproverName": to.Ptr("String"), + "POAmount": to.Ptr("Integer"), + }, + StagesBefore: []*string{ + to.Ptr("Received")}, + }, + "Received": { + Description: to.Ptr("received"), + Properties: map[string]*string{ + "City": to.Ptr("String"), + "Product": to.Ptr("String"), + "Quantity": to.Ptr("Integer"), + "State": to.Ptr("String"), + }, + }, + "Shipped": { + Description: to.Ptr("Shipped"), + Properties: map[string]*string{ + "ShipPriority": to.Ptr("Integer"), + "TrackingID": to.Ptr("Integer"), + }, + StagesBefore: []*string{ + to.Ptr("Denied")}, + }, + }, + Identifier: &armintegrationspaces.BusinessProcessIdentifier{ + PropertyName: to.Ptr("businessIdentifier-1"), + PropertyType: to.Ptr("String"), + }, + TableName: to.Ptr("table1"), + TrackingDataStoreReferenceName: to.Ptr("trackingDataStoreReferenceName1"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BusinessProcess = armintegrationspaces.BusinessProcess{ + // Name: to.Ptr("BusinessProcess1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/applications/businessProcesses"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/applications/Application1/BusinessProcesses/BusinessProcess1"), + // Properties: &armintegrationspaces.BusinessProcessProperties{ + // Description: to.Ptr("First Business Process"), + // BusinessProcessMapping: map[string]*armintegrationspaces.BusinessProcessMappingItem{ + // "Completed": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("CompletedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Denied": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("DeniedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Processing": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ApprovedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Received": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Shipped": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ShippedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // }, + // BusinessProcessStages: map[string]*armintegrationspaces.BusinessProcessStage{ + // "Completed": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Completed"), + // StagesBefore: []*string{ + // to.Ptr("Shipped")}, + // }, + // "Denied": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Denied"), + // StagesBefore: []*string{ + // to.Ptr("Processing")}, + // }, + // "Processing": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Processing"), + // Properties: map[string]*string{ + // "ApprovalState": to.Ptr("String"), + // "ApproverName": to.Ptr("String"), + // "POAmount": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Received")}, + // }, + // "Received": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("received"), + // Properties: map[string]*string{ + // "City": to.Ptr("String"), + // "Product": to.Ptr("String"), + // "Quantity": to.Ptr("Integer"), + // "State": to.Ptr("String"), + // }, + // }, + // "Shipped": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Shipped"), + // Properties: map[string]*string{ + // "ShipPriority": to.Ptr("Integer"), + // "TrackingID": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Denied")}, + // }, + // }, + // Identifier: &armintegrationspaces.BusinessProcessIdentifier{ + // PropertyName: to.Ptr("businessIdentifier-1"), + // PropertyType: to.Ptr("String"), + // }, + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // TableName: to.Ptr("table1"), + // TrackingDataStoreReferenceName: to.Ptr("trackingDataStoreReferenceName1"), + // Version: to.Ptr("08585074782265427079"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/BusinessProcesses_Patch.json +func ExampleBusinessProcessesClient_Patch() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBusinessProcessesClient().Patch(ctx, "testrg", "Space1", "Application1", "BusinessProcess1", armintegrationspaces.BusinessProcessUpdate{ + Properties: &armintegrationspaces.BusinessProcessUpdateProperties{ + Description: to.Ptr("First updated business process."), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BusinessProcess = armintegrationspaces.BusinessProcess{ + // Name: to.Ptr("BusinessProcess1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/applications/businessProcesses"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/applications/Application1/businessProcesses/BusinessProcess1"), + // Properties: &armintegrationspaces.BusinessProcessProperties{ + // Description: to.Ptr("First updated business process."), + // BusinessProcessMapping: map[string]*armintegrationspaces.BusinessProcessMappingItem{ + // "Completed": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("CompletedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Denied": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("DeniedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Processing": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ApprovedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Received": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Shipped": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ShippedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // }, + // BusinessProcessStages: map[string]*armintegrationspaces.BusinessProcessStage{ + // "Completed": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Completed"), + // StagesBefore: []*string{ + // to.Ptr("Shipped")}, + // }, + // "Denied": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Denied"), + // StagesBefore: []*string{ + // to.Ptr("Processing")}, + // }, + // "Processing": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Processing"), + // Properties: map[string]*string{ + // "ApprovalState": to.Ptr("String"), + // "ApproverName": to.Ptr("String"), + // "POAmount": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Received")}, + // }, + // "Received": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("received"), + // Properties: map[string]*string{ + // "City": to.Ptr("String"), + // "Product": to.Ptr("String"), + // "Quantity": to.Ptr("Integer"), + // "State": to.Ptr("String"), + // }, + // }, + // "Shipped": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Shipped"), + // Properties: map[string]*string{ + // "ShipPriority": to.Ptr("Integer"), + // "TrackingID": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Denied")}, + // }, + // }, + // Identifier: &armintegrationspaces.BusinessProcessIdentifier{ + // PropertyName: to.Ptr("businessIdentifier-1"), + // PropertyType: to.Ptr("String"), + // }, + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // TableName: to.Ptr("table1"), + // TrackingDataStoreReferenceName: to.Ptr("trackingDataStoreReferenceName1"), + // Version: to.Ptr("08585074782265427080"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/BusinessProcesses_Delete.json +func ExampleBusinessProcessesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewBusinessProcessesClient().Delete(ctx, "testrg", "Space1", "Application1", "BusinessProcess1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocessversions_client.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocessversions_client.go new file mode 100644 index 000000000000..e62b62275263 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocessversions_client.go @@ -0,0 +1,227 @@ +//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 armintegrationspaces + +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" + "strconv" + "strings" +) + +// BusinessProcessVersionsClient contains the methods for the BusinessProcessVersions group. +// Don't use this type directly, use NewBusinessProcessVersionsClient() instead. +type BusinessProcessVersionsClient struct { + internal *arm.Client + subscriptionID string +} + +// NewBusinessProcessVersionsClient creates a new instance of BusinessProcessVersionsClient 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 NewBusinessProcessVersionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*BusinessProcessVersionsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &BusinessProcessVersionsClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// Get - Get a BusinessProcessVersion +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - businessProcessName - The name of the business process +// - businessProcessVersion - The version of the business process +// - options - BusinessProcessVersionsClientGetOptions contains the optional parameters for the BusinessProcessVersionsClient.Get +// method. +func (client *BusinessProcessVersionsClient) Get(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, businessProcessVersion string, options *BusinessProcessVersionsClientGetOptions) (BusinessProcessVersionsClientGetResponse, error) { + var err error + const operationName = "BusinessProcessVersionsClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, spaceName, applicationName, businessProcessName, businessProcessVersion, options) + if err != nil { + return BusinessProcessVersionsClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return BusinessProcessVersionsClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BusinessProcessVersionsClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *BusinessProcessVersionsClient) getCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, businessProcessVersion string, options *BusinessProcessVersionsClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/businessProcesses/{businessProcessName}/versions/{businessProcessVersion}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + if businessProcessName == "" { + return nil, errors.New("parameter businessProcessName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{businessProcessName}", url.PathEscape(businessProcessName)) + if businessProcessVersion == "" { + return nil, errors.New("parameter businessProcessVersion cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{businessProcessVersion}", url.PathEscape(businessProcessVersion)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *BusinessProcessVersionsClient) getHandleResponse(resp *http.Response) (BusinessProcessVersionsClientGetResponse, error) { + result := BusinessProcessVersionsClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BusinessProcessVersion); err != nil { + return BusinessProcessVersionsClientGetResponse{}, err + } + return result, nil +} + +// NewListByBusinessProcessPager - List BusinessProcessVersion resources by BusinessProcess +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - applicationName - The name of the Application +// - businessProcessName - The name of the business process +// - options - BusinessProcessVersionsClientListByBusinessProcessOptions contains the optional parameters for the BusinessProcessVersionsClient.NewListByBusinessProcessPager +// method. +func (client *BusinessProcessVersionsClient) NewListByBusinessProcessPager(resourceGroupName string, spaceName string, applicationName string, businessProcessName string, options *BusinessProcessVersionsClientListByBusinessProcessOptions) *runtime.Pager[BusinessProcessVersionsClientListByBusinessProcessResponse] { + return runtime.NewPager(runtime.PagingHandler[BusinessProcessVersionsClientListByBusinessProcessResponse]{ + More: func(page BusinessProcessVersionsClientListByBusinessProcessResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *BusinessProcessVersionsClientListByBusinessProcessResponse) (BusinessProcessVersionsClientListByBusinessProcessResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "BusinessProcessVersionsClient.NewListByBusinessProcessPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByBusinessProcessCreateRequest(ctx, resourceGroupName, spaceName, applicationName, businessProcessName, options) + }, nil) + if err != nil { + return BusinessProcessVersionsClientListByBusinessProcessResponse{}, err + } + return client.listByBusinessProcessHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByBusinessProcessCreateRequest creates the ListByBusinessProcess request. +func (client *BusinessProcessVersionsClient) listByBusinessProcessCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, options *BusinessProcessVersionsClientListByBusinessProcessOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/applications/{applicationName}/businessProcesses/{businessProcessName}/versions" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if applicationName == "" { + return nil, errors.New("parameter applicationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{applicationName}", url.PathEscape(applicationName)) + if businessProcessName == "" { + return nil, errors.New("parameter businessProcessName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{businessProcessName}", url.PathEscape(businessProcessName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Maxpagesize != nil { + reqQP.Set("maxpagesize", strconv.FormatInt(int64(*options.Maxpagesize), 10)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.Select != nil { + for _, qv := range options.Select { + reqQP.Add("select", qv) + } + } + if options != nil && options.Expand != nil { + for _, qv := range options.Expand { + reqQP.Add("expand", qv) + } + } + if options != nil && options.Orderby != nil { + for _, qv := range options.Orderby { + reqQP.Add("orderby", qv) + } + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByBusinessProcessHandleResponse handles the ListByBusinessProcess response. +func (client *BusinessProcessVersionsClient) listByBusinessProcessHandleResponse(resp *http.Response) (BusinessProcessVersionsClientListByBusinessProcessResponse, error) { + result := BusinessProcessVersionsClientListByBusinessProcessResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.BusinessProcessVersionListResult); err != nil { + return BusinessProcessVersionsClientListByBusinessProcessResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocessversions_client_example_test.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocessversions_client_example_test.go new file mode 100644 index 000000000000..11d39c816acc --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/businessprocessversions_client_example_test.go @@ -0,0 +1,249 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armintegrationspaces_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/BusinessProcessVersions_ListByBusinessProcess.json +func ExampleBusinessProcessVersionsClient_NewListByBusinessProcessPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewBusinessProcessVersionsClient().NewListByBusinessProcessPager("testrg", "Space1", "Application1", "BusinessProcess1", &armintegrationspaces.BusinessProcessVersionsClientListByBusinessProcessOptions{Top: nil, + Skip: nil, + Maxpagesize: nil, + Filter: nil, + Select: []string{}, + Expand: []string{}, + Orderby: []string{}, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.BusinessProcessVersionListResult = armintegrationspaces.BusinessProcessVersionListResult{ + // Value: []*armintegrationspaces.BusinessProcessVersion{ + // { + // Name: to.Ptr("08585074782265427079"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/applications/BusinessProcesses/versions"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/applications/Application1/businessProcesses/BusinessProcess1/versions/08585074782265427079"), + // Properties: &armintegrationspaces.BusinessProcessProperties{ + // Description: to.Ptr("First Business Process"), + // BusinessProcessMapping: map[string]*armintegrationspaces.BusinessProcessMappingItem{ + // "Completed": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("CompletedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Denied": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("DeniedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Processing": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ApprovedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Received": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Shipped": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ShippedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // }, + // BusinessProcessStages: map[string]*armintegrationspaces.BusinessProcessStage{ + // "Completed": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Completed"), + // StagesBefore: []*string{ + // to.Ptr("Shipped")}, + // }, + // "Denied": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Denied"), + // StagesBefore: []*string{ + // to.Ptr("Processing")}, + // }, + // "Processing": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Processing"), + // Properties: map[string]*string{ + // "ApprovalState": to.Ptr("String"), + // "ApproverName": to.Ptr("String"), + // "POAmount": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Received")}, + // }, + // "Received": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("received"), + // Properties: map[string]*string{ + // "City": to.Ptr("String"), + // "Product": to.Ptr("String"), + // "Quantity": to.Ptr("Integer"), + // "State": to.Ptr("String"), + // }, + // }, + // "Shipped": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Shipped"), + // Properties: map[string]*string{ + // "ShipPriority": to.Ptr("Integer"), + // "TrackingID": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Denied")}, + // }, + // }, + // Identifier: &armintegrationspaces.BusinessProcessIdentifier{ + // PropertyName: to.Ptr("businessIdentifier-1"), + // PropertyType: to.Ptr("String"), + // }, + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // TableName: to.Ptr("table1"), + // TrackingDataStoreReferenceName: to.Ptr("trackingDataStoreReferenceName1"), + // Version: to.Ptr("08585074782265427079"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/BusinessProcessVersions_Get.json +func ExampleBusinessProcessVersionsClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewBusinessProcessVersionsClient().Get(ctx, "testrg", "Space1", "Application1", "BusinessProcess1", "08585074782265427079", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.BusinessProcessVersion = armintegrationspaces.BusinessProcessVersion{ + // Name: to.Ptr("08585074782265427079"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/applications/businessProcesses/versions"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/applications/Application1/businessProcesses/BusinessProcess1/versions/08585074782265427079"), + // Properties: &armintegrationspaces.BusinessProcessProperties{ + // Description: to.Ptr("Sample Business Process"), + // BusinessProcessMapping: map[string]*armintegrationspaces.BusinessProcessMappingItem{ + // "Completed": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("CompletedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Denied": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("DeniedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // "Processing": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ApprovedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Received": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("manual"), + // OperationType: to.Ptr("Trigger"), + // WorkflowName: to.Ptr("PurchaseOrder"), + // }, + // "Shipped": &armintegrationspaces.BusinessProcessMappingItem{ + // LogicAppResourceID: to.Ptr("subscriptions/sub1/resourcegroups/group1/providers/Microsoft.Web/sites/logicApp1"), + // OperationName: to.Ptr("ShippedPO"), + // OperationType: to.Ptr("Action"), + // WorkflowName: to.Ptr("Fulfillment"), + // }, + // }, + // BusinessProcessStages: map[string]*armintegrationspaces.BusinessProcessStage{ + // "Completed": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Completed"), + // StagesBefore: []*string{ + // to.Ptr("Shipped")}, + // }, + // "Denied": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Denied"), + // StagesBefore: []*string{ + // to.Ptr("Processing")}, + // }, + // "Processing": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Processing"), + // Properties: map[string]*string{ + // "ApprovalState": to.Ptr("String"), + // "ApproverName": to.Ptr("String"), + // "POAmount": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Received")}, + // }, + // "Received": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("received"), + // Properties: map[string]*string{ + // "City": to.Ptr("String"), + // "Product": to.Ptr("String"), + // "Quantity": to.Ptr("Integer"), + // "State": to.Ptr("String"), + // }, + // }, + // "Shipped": &armintegrationspaces.BusinessProcessStage{ + // Description: to.Ptr("Shipped"), + // Properties: map[string]*string{ + // "ShipPriority": to.Ptr("Integer"), + // "TrackingID": to.Ptr("Integer"), + // }, + // StagesBefore: []*string{ + // to.Ptr("Denied")}, + // }, + // }, + // Identifier: &armintegrationspaces.BusinessProcessIdentifier{ + // PropertyName: to.Ptr("businessIdentifier-1"), + // PropertyType: to.Ptr("String"), + // }, + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // TableName: to.Ptr("table1"), + // TrackingDataStoreReferenceName: to.Ptr("trackingDataStoreReferenceName1"), + // Version: to.Ptr("08585074782265427079"), + // }, + // } +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/ci.yml b/sdk/resourcemanager/integrationspaces/armintegrationspaces/ci.yml new file mode 100644 index 000000000000..c977df248c59 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/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/integrationspaces/armintegrationspaces/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/integrationspaces/armintegrationspaces/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/integrationspaces/armintegrationspaces' diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/client_factory.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/client_factory.go new file mode 100644 index 000000000000..d14aaaa6a9bd --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/client_factory.go @@ -0,0 +1,80 @@ +//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 armintegrationspaces + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + credential azcore.TokenCredential + options *arm.ClientOptions +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, credential: credential, + options: options.Clone(), + }, nil +} + +// NewApplicationResourcesClient creates a new instance of ApplicationResourcesClient. +func (c *ClientFactory) NewApplicationResourcesClient() *ApplicationResourcesClient { + subClient, _ := NewApplicationResourcesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewApplicationsClient creates a new instance of ApplicationsClient. +func (c *ClientFactory) NewApplicationsClient() *ApplicationsClient { + subClient, _ := NewApplicationsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewBusinessProcessVersionsClient creates a new instance of BusinessProcessVersionsClient. +func (c *ClientFactory) NewBusinessProcessVersionsClient() *BusinessProcessVersionsClient { + subClient, _ := NewBusinessProcessVersionsClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewBusinessProcessesClient creates a new instance of BusinessProcessesClient. +func (c *ClientFactory) NewBusinessProcessesClient() *BusinessProcessesClient { + subClient, _ := NewBusinessProcessesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewInfrastructureResourcesClient creates a new instance of InfrastructureResourcesClient. +func (c *ClientFactory) NewInfrastructureResourcesClient() *InfrastructureResourcesClient { + subClient, _ := NewInfrastructureResourcesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) + return subClient +} + +// NewSpacesClient creates a new instance of SpacesClient. +func (c *ClientFactory) NewSpacesClient() *SpacesClient { + subClient, _ := NewSpacesClient(c.subscriptionID, c.credential, c.options) + return subClient +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/constants.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/constants.go new file mode 100644 index 000000000000..39406196e72f --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/constants.go @@ -0,0 +1,96 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armintegrationspaces + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces" + 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, + } +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + OriginSystem Origin = "system" + OriginUser Origin = "user" + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// ProvisioningState - The status of the current operation. +type ProvisioningState string + +const ( + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Resource creation was canceled. + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateProvisioning ProvisioningState = "Provisioning" + // ProvisioningStateSucceeded - Resource has been created. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateProvisioning, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, + } +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/applicationresources_server.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/applicationresources_server.go new file mode 100644 index 000000000000..9f6305ae1784 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/applicationresources_server.go @@ -0,0 +1,401 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// ApplicationResourcesServer is a fake server for instances of the armintegrationspaces.ApplicationResourcesClient type. +type ApplicationResourcesServer struct { + // CreateOrUpdate is the fake for method ApplicationResourcesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, resourceName string, resource armintegrationspaces.ApplicationResource, options *armintegrationspaces.ApplicationResourcesClientCreateOrUpdateOptions) (resp azfake.Responder[armintegrationspaces.ApplicationResourcesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method ApplicationResourcesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, resourceName string, options *armintegrationspaces.ApplicationResourcesClientDeleteOptions) (resp azfake.Responder[armintegrationspaces.ApplicationResourcesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ApplicationResourcesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, resourceName string, options *armintegrationspaces.ApplicationResourcesClientGetOptions) (resp azfake.Responder[armintegrationspaces.ApplicationResourcesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByApplicationPager is the fake for method ApplicationResourcesClient.NewListByApplicationPager + // HTTP status codes to indicate success: http.StatusOK + NewListByApplicationPager func(resourceGroupName string, spaceName string, applicationName string, options *armintegrationspaces.ApplicationResourcesClientListByApplicationOptions) (resp azfake.PagerResponder[armintegrationspaces.ApplicationResourcesClientListByApplicationResponse]) + + // Patch is the fake for method ApplicationResourcesClient.Patch + // HTTP status codes to indicate success: http.StatusOK + Patch func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, resourceName string, properties armintegrationspaces.ApplicationResourceUpdate, options *armintegrationspaces.ApplicationResourcesClientPatchOptions) (resp azfake.Responder[armintegrationspaces.ApplicationResourcesClientPatchResponse], errResp azfake.ErrorResponder) +} + +// NewApplicationResourcesServerTransport creates a new instance of ApplicationResourcesServerTransport with the provided implementation. +// The returned ApplicationResourcesServerTransport instance is connected to an instance of armintegrationspaces.ApplicationResourcesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewApplicationResourcesServerTransport(srv *ApplicationResourcesServer) *ApplicationResourcesServerTransport { + return &ApplicationResourcesServerTransport{ + srv: srv, + newListByApplicationPager: newTracker[azfake.PagerResponder[armintegrationspaces.ApplicationResourcesClientListByApplicationResponse]](), + } +} + +// ApplicationResourcesServerTransport connects instances of armintegrationspaces.ApplicationResourcesClient to instances of ApplicationResourcesServer. +// Don't use this type directly, use NewApplicationResourcesServerTransport instead. +type ApplicationResourcesServerTransport struct { + srv *ApplicationResourcesServer + newListByApplicationPager *tracker[azfake.PagerResponder[armintegrationspaces.ApplicationResourcesClientListByApplicationResponse]] +} + +// Do implements the policy.Transporter interface for ApplicationResourcesServerTransport. +func (a *ApplicationResourcesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ApplicationResourcesClient.CreateOrUpdate": + resp, err = a.dispatchCreateOrUpdate(req) + case "ApplicationResourcesClient.Delete": + resp, err = a.dispatchDelete(req) + case "ApplicationResourcesClient.Get": + resp, err = a.dispatchGet(req) + case "ApplicationResourcesClient.NewListByApplicationPager": + resp, err = a.dispatchNewListByApplicationPager(req) + case "ApplicationResourcesClient.Patch": + resp, err = a.dispatchPatch(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (a *ApplicationResourcesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if a.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resources/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armintegrationspaces.ApplicationResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, resourceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ApplicationResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *ApplicationResourcesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if a.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resources/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Delete(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, resourceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *ApplicationResourcesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resources/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, resourceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ApplicationResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *ApplicationResourcesServerTransport) dispatchNewListByApplicationPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByApplicationPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByApplicationPager not implemented")} + } + newListByApplicationPager := a.newListByApplicationPager.get(req) + if newListByApplicationPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resources` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + maxpagesizeUnescaped, err := url.QueryUnescape(qp.Get("maxpagesize")) + if err != nil { + return nil, err + } + maxpagesizeParam, err := parseOptional(maxpagesizeUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + selectEscaped := qp["select"] + selectParam := make([]string, len(selectEscaped)) + for i, v := range selectEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + selectParam[i] = u + } + expandEscaped := qp["expand"] + expandParam := make([]string, len(expandEscaped)) + for i, v := range expandEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + expandParam[i] = u + } + orderbyEscaped := qp["orderby"] + orderbyParam := make([]string, len(orderbyEscaped)) + for i, v := range orderbyEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + orderbyParam[i] = u + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + var options *armintegrationspaces.ApplicationResourcesClientListByApplicationOptions + if topParam != nil || skipParam != nil || maxpagesizeParam != nil || filterParam != nil || len(selectParam) > 0 || len(expandParam) > 0 || len(orderbyParam) > 0 { + options = &armintegrationspaces.ApplicationResourcesClientListByApplicationOptions{ + Top: topParam, + Skip: skipParam, + Maxpagesize: maxpagesizeParam, + Filter: filterParam, + Select: selectParam, + Expand: expandParam, + Orderby: orderbyParam, + } + } + resp := a.srv.NewListByApplicationPager(resourceGroupNameParam, spaceNameParam, applicationNameParam, options) + newListByApplicationPager = &resp + a.newListByApplicationPager.add(req, newListByApplicationPager) + server.PagerResponderInjectNextLinks(newListByApplicationPager, req, func(page *armintegrationspaces.ApplicationResourcesClientListByApplicationResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByApplicationPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListByApplicationPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByApplicationPager) { + a.newListByApplicationPager.remove(req) + } + return resp, nil +} + +func (a *ApplicationResourcesServerTransport) dispatchPatch(req *http.Request) (*http.Response, error) { + if a.srv.Patch == nil { + return nil, &nonRetriableError{errors.New("fake for method Patch not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resources/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armintegrationspaces.ApplicationResourceUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Patch(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, resourceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ApplicationResource, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/applications_server.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/applications_server.go new file mode 100644 index 000000000000..9dd270300ac7 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/applications_server.go @@ -0,0 +1,612 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// ApplicationsServer is a fake server for instances of the armintegrationspaces.ApplicationsClient type. +type ApplicationsServer struct { + // CreateOrUpdate is the fake for method ApplicationsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, resource armintegrationspaces.Application, options *armintegrationspaces.ApplicationsClientCreateOrUpdateOptions) (resp azfake.Responder[armintegrationspaces.ApplicationsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method ApplicationsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, options *armintegrationspaces.ApplicationsClientDeleteOptions) (resp azfake.Responder[armintegrationspaces.ApplicationsClientDeleteResponse], errResp azfake.ErrorResponder) + + // DeleteBusinessProcessDevelopmentArtifact is the fake for method ApplicationsClient.DeleteBusinessProcessDevelopmentArtifact + // HTTP status codes to indicate success: http.StatusOK + DeleteBusinessProcessDevelopmentArtifact func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, body armintegrationspaces.GetOrDeleteBusinessProcessDevelopmentArtifactRequest, options *armintegrationspaces.ApplicationsClientDeleteBusinessProcessDevelopmentArtifactOptions) (resp azfake.Responder[armintegrationspaces.ApplicationsClientDeleteBusinessProcessDevelopmentArtifactResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ApplicationsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, options *armintegrationspaces.ApplicationsClientGetOptions) (resp azfake.Responder[armintegrationspaces.ApplicationsClientGetResponse], errResp azfake.ErrorResponder) + + // GetBusinessProcessDevelopmentArtifact is the fake for method ApplicationsClient.GetBusinessProcessDevelopmentArtifact + // HTTP status codes to indicate success: http.StatusOK + GetBusinessProcessDevelopmentArtifact func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, body armintegrationspaces.GetOrDeleteBusinessProcessDevelopmentArtifactRequest, options *armintegrationspaces.ApplicationsClientGetBusinessProcessDevelopmentArtifactOptions) (resp azfake.Responder[armintegrationspaces.ApplicationsClientGetBusinessProcessDevelopmentArtifactResponse], errResp azfake.ErrorResponder) + + // ListBusinessProcessDevelopmentArtifacts is the fake for method ApplicationsClient.ListBusinessProcessDevelopmentArtifacts + // HTTP status codes to indicate success: http.StatusOK + ListBusinessProcessDevelopmentArtifacts func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, options *armintegrationspaces.ApplicationsClientListBusinessProcessDevelopmentArtifactsOptions) (resp azfake.Responder[armintegrationspaces.ApplicationsClientListBusinessProcessDevelopmentArtifactsResponse], errResp azfake.ErrorResponder) + + // NewListBySpacePager is the fake for method ApplicationsClient.NewListBySpacePager + // HTTP status codes to indicate success: http.StatusOK + NewListBySpacePager func(resourceGroupName string, spaceName string, options *armintegrationspaces.ApplicationsClientListBySpaceOptions) (resp azfake.PagerResponder[armintegrationspaces.ApplicationsClientListBySpaceResponse]) + + // Patch is the fake for method ApplicationsClient.Patch + // HTTP status codes to indicate success: http.StatusOK + Patch func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, properties armintegrationspaces.ApplicationUpdate, options *armintegrationspaces.ApplicationsClientPatchOptions) (resp azfake.Responder[armintegrationspaces.ApplicationsClientPatchResponse], errResp azfake.ErrorResponder) + + // SaveBusinessProcessDevelopmentArtifact is the fake for method ApplicationsClient.SaveBusinessProcessDevelopmentArtifact + // HTTP status codes to indicate success: http.StatusOK + SaveBusinessProcessDevelopmentArtifact func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, body armintegrationspaces.SaveOrValidateBusinessProcessDevelopmentArtifactRequest, options *armintegrationspaces.ApplicationsClientSaveBusinessProcessDevelopmentArtifactOptions) (resp azfake.Responder[armintegrationspaces.ApplicationsClientSaveBusinessProcessDevelopmentArtifactResponse], errResp azfake.ErrorResponder) + + // ValidateBusinessProcessDevelopmentArtifact is the fake for method ApplicationsClient.ValidateBusinessProcessDevelopmentArtifact + // HTTP status codes to indicate success: http.StatusOK + ValidateBusinessProcessDevelopmentArtifact func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, body armintegrationspaces.SaveOrValidateBusinessProcessDevelopmentArtifactRequest, options *armintegrationspaces.ApplicationsClientValidateBusinessProcessDevelopmentArtifactOptions) (resp azfake.Responder[armintegrationspaces.ApplicationsClientValidateBusinessProcessDevelopmentArtifactResponse], errResp azfake.ErrorResponder) +} + +// NewApplicationsServerTransport creates a new instance of ApplicationsServerTransport with the provided implementation. +// The returned ApplicationsServerTransport instance is connected to an instance of armintegrationspaces.ApplicationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewApplicationsServerTransport(srv *ApplicationsServer) *ApplicationsServerTransport { + return &ApplicationsServerTransport{ + srv: srv, + newListBySpacePager: newTracker[azfake.PagerResponder[armintegrationspaces.ApplicationsClientListBySpaceResponse]](), + } +} + +// ApplicationsServerTransport connects instances of armintegrationspaces.ApplicationsClient to instances of ApplicationsServer. +// Don't use this type directly, use NewApplicationsServerTransport instead. +type ApplicationsServerTransport struct { + srv *ApplicationsServer + newListBySpacePager *tracker[azfake.PagerResponder[armintegrationspaces.ApplicationsClientListBySpaceResponse]] +} + +// Do implements the policy.Transporter interface for ApplicationsServerTransport. +func (a *ApplicationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "ApplicationsClient.CreateOrUpdate": + resp, err = a.dispatchCreateOrUpdate(req) + case "ApplicationsClient.Delete": + resp, err = a.dispatchDelete(req) + case "ApplicationsClient.DeleteBusinessProcessDevelopmentArtifact": + resp, err = a.dispatchDeleteBusinessProcessDevelopmentArtifact(req) + case "ApplicationsClient.Get": + resp, err = a.dispatchGet(req) + case "ApplicationsClient.GetBusinessProcessDevelopmentArtifact": + resp, err = a.dispatchGetBusinessProcessDevelopmentArtifact(req) + case "ApplicationsClient.ListBusinessProcessDevelopmentArtifacts": + resp, err = a.dispatchListBusinessProcessDevelopmentArtifacts(req) + case "ApplicationsClient.NewListBySpacePager": + resp, err = a.dispatchNewListBySpacePager(req) + case "ApplicationsClient.Patch": + resp, err = a.dispatchPatch(req) + case "ApplicationsClient.SaveBusinessProcessDevelopmentArtifact": + resp, err = a.dispatchSaveBusinessProcessDevelopmentArtifact(req) + case "ApplicationsClient.ValidateBusinessProcessDevelopmentArtifact": + resp, err = a.dispatchValidateBusinessProcessDevelopmentArtifact(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (a *ApplicationsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if a.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armintegrationspaces.Application](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Application, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *ApplicationsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if a.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Delete(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *ApplicationsServerTransport) dispatchDeleteBusinessProcessDevelopmentArtifact(req *http.Request) (*http.Response, error) { + if a.srv.DeleteBusinessProcessDevelopmentArtifact == nil { + return nil, &nonRetriableError{errors.New("fake for method DeleteBusinessProcessDevelopmentArtifact not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deleteBusinessProcessDevelopmentArtifact` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armintegrationspaces.GetOrDeleteBusinessProcessDevelopmentArtifactRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.DeleteBusinessProcessDevelopmentArtifact(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *ApplicationsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Application, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *ApplicationsServerTransport) dispatchGetBusinessProcessDevelopmentArtifact(req *http.Request) (*http.Response, error) { + if a.srv.GetBusinessProcessDevelopmentArtifact == nil { + return nil, &nonRetriableError{errors.New("fake for method GetBusinessProcessDevelopmentArtifact not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/getBusinessProcessDevelopmentArtifact` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armintegrationspaces.GetOrDeleteBusinessProcessDevelopmentArtifactRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.GetBusinessProcessDevelopmentArtifact(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SaveOrGetBusinessProcessDevelopmentArtifactResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *ApplicationsServerTransport) dispatchListBusinessProcessDevelopmentArtifacts(req *http.Request) (*http.Response, error) { + if a.srv.ListBusinessProcessDevelopmentArtifacts == nil { + return nil, &nonRetriableError{errors.New("fake for method ListBusinessProcessDevelopmentArtifacts not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listBusinessProcessDevelopmentArtifacts` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.ListBusinessProcessDevelopmentArtifacts(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ListBusinessProcessDevelopmentArtifactsResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *ApplicationsServerTransport) dispatchNewListBySpacePager(req *http.Request) (*http.Response, error) { + if a.srv.NewListBySpacePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySpacePager not implemented")} + } + newListBySpacePager := a.newListBySpacePager.get(req) + if newListBySpacePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + maxpagesizeUnescaped, err := url.QueryUnescape(qp.Get("maxpagesize")) + if err != nil { + return nil, err + } + maxpagesizeParam, err := parseOptional(maxpagesizeUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + selectEscaped := qp["select"] + selectParam := make([]string, len(selectEscaped)) + for i, v := range selectEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + selectParam[i] = u + } + expandEscaped := qp["expand"] + expandParam := make([]string, len(expandEscaped)) + for i, v := range expandEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + expandParam[i] = u + } + orderbyEscaped := qp["orderby"] + orderbyParam := make([]string, len(orderbyEscaped)) + for i, v := range orderbyEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + orderbyParam[i] = u + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + var options *armintegrationspaces.ApplicationsClientListBySpaceOptions + if topParam != nil || skipParam != nil || maxpagesizeParam != nil || filterParam != nil || len(selectParam) > 0 || len(expandParam) > 0 || len(orderbyParam) > 0 { + options = &armintegrationspaces.ApplicationsClientListBySpaceOptions{ + Top: topParam, + Skip: skipParam, + Maxpagesize: maxpagesizeParam, + Filter: filterParam, + Select: selectParam, + Expand: expandParam, + Orderby: orderbyParam, + } + } + resp := a.srv.NewListBySpacePager(resourceGroupNameParam, spaceNameParam, options) + newListBySpacePager = &resp + a.newListBySpacePager.add(req, newListBySpacePager) + server.PagerResponderInjectNextLinks(newListBySpacePager, req, func(page *armintegrationspaces.ApplicationsClientListBySpaceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySpacePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListBySpacePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySpacePager) { + a.newListBySpacePager.remove(req) + } + return resp, nil +} + +func (a *ApplicationsServerTransport) dispatchPatch(req *http.Request) (*http.Response, error) { + if a.srv.Patch == nil { + return nil, &nonRetriableError{errors.New("fake for method Patch not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armintegrationspaces.ApplicationUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Patch(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Application, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *ApplicationsServerTransport) dispatchSaveBusinessProcessDevelopmentArtifact(req *http.Request) (*http.Response, error) { + if a.srv.SaveBusinessProcessDevelopmentArtifact == nil { + return nil, &nonRetriableError{errors.New("fake for method SaveBusinessProcessDevelopmentArtifact not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/saveBusinessProcessDevelopmentArtifact` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armintegrationspaces.SaveOrValidateBusinessProcessDevelopmentArtifactRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.SaveBusinessProcessDevelopmentArtifact(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SaveOrGetBusinessProcessDevelopmentArtifactResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *ApplicationsServerTransport) dispatchValidateBusinessProcessDevelopmentArtifact(req *http.Request) (*http.Response, error) { + if a.srv.ValidateBusinessProcessDevelopmentArtifact == nil { + return nil, &nonRetriableError{errors.New("fake for method ValidateBusinessProcessDevelopmentArtifact not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validateBusinessProcessDevelopmentArtifact` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armintegrationspaces.SaveOrValidateBusinessProcessDevelopmentArtifactRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.ValidateBusinessProcessDevelopmentArtifact(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/businessprocesses_server.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/businessprocesses_server.go new file mode 100644 index 000000000000..655a7768d92d --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/businessprocesses_server.go @@ -0,0 +1,401 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// BusinessProcessesServer is a fake server for instances of the armintegrationspaces.BusinessProcessesClient type. +type BusinessProcessesServer struct { + // CreateOrUpdate is the fake for method BusinessProcessesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, resource armintegrationspaces.BusinessProcess, options *armintegrationspaces.BusinessProcessesClientCreateOrUpdateOptions) (resp azfake.Responder[armintegrationspaces.BusinessProcessesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method BusinessProcessesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, options *armintegrationspaces.BusinessProcessesClientDeleteOptions) (resp azfake.Responder[armintegrationspaces.BusinessProcessesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method BusinessProcessesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, options *armintegrationspaces.BusinessProcessesClientGetOptions) (resp azfake.Responder[armintegrationspaces.BusinessProcessesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByApplicationPager is the fake for method BusinessProcessesClient.NewListByApplicationPager + // HTTP status codes to indicate success: http.StatusOK + NewListByApplicationPager func(resourceGroupName string, spaceName string, applicationName string, options *armintegrationspaces.BusinessProcessesClientListByApplicationOptions) (resp azfake.PagerResponder[armintegrationspaces.BusinessProcessesClientListByApplicationResponse]) + + // Patch is the fake for method BusinessProcessesClient.Patch + // HTTP status codes to indicate success: http.StatusOK + Patch func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, properties armintegrationspaces.BusinessProcessUpdate, options *armintegrationspaces.BusinessProcessesClientPatchOptions) (resp azfake.Responder[armintegrationspaces.BusinessProcessesClientPatchResponse], errResp azfake.ErrorResponder) +} + +// NewBusinessProcessesServerTransport creates a new instance of BusinessProcessesServerTransport with the provided implementation. +// The returned BusinessProcessesServerTransport instance is connected to an instance of armintegrationspaces.BusinessProcessesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewBusinessProcessesServerTransport(srv *BusinessProcessesServer) *BusinessProcessesServerTransport { + return &BusinessProcessesServerTransport{ + srv: srv, + newListByApplicationPager: newTracker[azfake.PagerResponder[armintegrationspaces.BusinessProcessesClientListByApplicationResponse]](), + } +} + +// BusinessProcessesServerTransport connects instances of armintegrationspaces.BusinessProcessesClient to instances of BusinessProcessesServer. +// Don't use this type directly, use NewBusinessProcessesServerTransport instead. +type BusinessProcessesServerTransport struct { + srv *BusinessProcessesServer + newListByApplicationPager *tracker[azfake.PagerResponder[armintegrationspaces.BusinessProcessesClientListByApplicationResponse]] +} + +// Do implements the policy.Transporter interface for BusinessProcessesServerTransport. +func (b *BusinessProcessesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "BusinessProcessesClient.CreateOrUpdate": + resp, err = b.dispatchCreateOrUpdate(req) + case "BusinessProcessesClient.Delete": + resp, err = b.dispatchDelete(req) + case "BusinessProcessesClient.Get": + resp, err = b.dispatchGet(req) + case "BusinessProcessesClient.NewListByApplicationPager": + resp, err = b.dispatchNewListByApplicationPager(req) + case "BusinessProcessesClient.Patch": + resp, err = b.dispatchPatch(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (b *BusinessProcessesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if b.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/businessProcesses/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armintegrationspaces.BusinessProcess](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + businessProcessNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("businessProcessName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, businessProcessNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BusinessProcess, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BusinessProcessesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if b.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/businessProcesses/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + businessProcessNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("businessProcessName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Delete(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, businessProcessNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BusinessProcessesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if b.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/businessProcesses/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + businessProcessNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("businessProcessName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Get(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, businessProcessNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BusinessProcess, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BusinessProcessesServerTransport) dispatchNewListByApplicationPager(req *http.Request) (*http.Response, error) { + if b.srv.NewListByApplicationPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByApplicationPager not implemented")} + } + newListByApplicationPager := b.newListByApplicationPager.get(req) + if newListByApplicationPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/businessProcesses` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + maxpagesizeUnescaped, err := url.QueryUnescape(qp.Get("maxpagesize")) + if err != nil { + return nil, err + } + maxpagesizeParam, err := parseOptional(maxpagesizeUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + selectEscaped := qp["select"] + selectParam := make([]string, len(selectEscaped)) + for i, v := range selectEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + selectParam[i] = u + } + expandEscaped := qp["expand"] + expandParam := make([]string, len(expandEscaped)) + for i, v := range expandEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + expandParam[i] = u + } + orderbyEscaped := qp["orderby"] + orderbyParam := make([]string, len(orderbyEscaped)) + for i, v := range orderbyEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + orderbyParam[i] = u + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + var options *armintegrationspaces.BusinessProcessesClientListByApplicationOptions + if topParam != nil || skipParam != nil || maxpagesizeParam != nil || filterParam != nil || len(selectParam) > 0 || len(expandParam) > 0 || len(orderbyParam) > 0 { + options = &armintegrationspaces.BusinessProcessesClientListByApplicationOptions{ + Top: topParam, + Skip: skipParam, + Maxpagesize: maxpagesizeParam, + Filter: filterParam, + Select: selectParam, + Expand: expandParam, + Orderby: orderbyParam, + } + } + resp := b.srv.NewListByApplicationPager(resourceGroupNameParam, spaceNameParam, applicationNameParam, options) + newListByApplicationPager = &resp + b.newListByApplicationPager.add(req, newListByApplicationPager) + server.PagerResponderInjectNextLinks(newListByApplicationPager, req, func(page *armintegrationspaces.BusinessProcessesClientListByApplicationResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByApplicationPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + b.newListByApplicationPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByApplicationPager) { + b.newListByApplicationPager.remove(req) + } + return resp, nil +} + +func (b *BusinessProcessesServerTransport) dispatchPatch(req *http.Request) (*http.Response, error) { + if b.srv.Patch == nil { + return nil, &nonRetriableError{errors.New("fake for method Patch not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/businessProcesses/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armintegrationspaces.BusinessProcessUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + businessProcessNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("businessProcessName")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Patch(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, businessProcessNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BusinessProcess, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/businessprocessversions_server.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/businessprocessversions_server.go new file mode 100644 index 000000000000..275e28d8938d --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/businessprocessversions_server.go @@ -0,0 +1,260 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// BusinessProcessVersionsServer is a fake server for instances of the armintegrationspaces.BusinessProcessVersionsClient type. +type BusinessProcessVersionsServer struct { + // Get is the fake for method BusinessProcessVersionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, spaceName string, applicationName string, businessProcessName string, businessProcessVersion string, options *armintegrationspaces.BusinessProcessVersionsClientGetOptions) (resp azfake.Responder[armintegrationspaces.BusinessProcessVersionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByBusinessProcessPager is the fake for method BusinessProcessVersionsClient.NewListByBusinessProcessPager + // HTTP status codes to indicate success: http.StatusOK + NewListByBusinessProcessPager func(resourceGroupName string, spaceName string, applicationName string, businessProcessName string, options *armintegrationspaces.BusinessProcessVersionsClientListByBusinessProcessOptions) (resp azfake.PagerResponder[armintegrationspaces.BusinessProcessVersionsClientListByBusinessProcessResponse]) +} + +// NewBusinessProcessVersionsServerTransport creates a new instance of BusinessProcessVersionsServerTransport with the provided implementation. +// The returned BusinessProcessVersionsServerTransport instance is connected to an instance of armintegrationspaces.BusinessProcessVersionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewBusinessProcessVersionsServerTransport(srv *BusinessProcessVersionsServer) *BusinessProcessVersionsServerTransport { + return &BusinessProcessVersionsServerTransport{ + srv: srv, + newListByBusinessProcessPager: newTracker[azfake.PagerResponder[armintegrationspaces.BusinessProcessVersionsClientListByBusinessProcessResponse]](), + } +} + +// BusinessProcessVersionsServerTransport connects instances of armintegrationspaces.BusinessProcessVersionsClient to instances of BusinessProcessVersionsServer. +// Don't use this type directly, use NewBusinessProcessVersionsServerTransport instead. +type BusinessProcessVersionsServerTransport struct { + srv *BusinessProcessVersionsServer + newListByBusinessProcessPager *tracker[azfake.PagerResponder[armintegrationspaces.BusinessProcessVersionsClientListByBusinessProcessResponse]] +} + +// Do implements the policy.Transporter interface for BusinessProcessVersionsServerTransport. +func (b *BusinessProcessVersionsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "BusinessProcessVersionsClient.Get": + resp, err = b.dispatchGet(req) + case "BusinessProcessVersionsClient.NewListByBusinessProcessPager": + resp, err = b.dispatchNewListByBusinessProcessPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (b *BusinessProcessVersionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if b.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/businessProcesses/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + businessProcessNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("businessProcessName")]) + if err != nil { + return nil, err + } + businessProcessVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("businessProcessVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := b.srv.Get(req.Context(), resourceGroupNameParam, spaceNameParam, applicationNameParam, businessProcessNameParam, businessProcessVersionParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BusinessProcessVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (b *BusinessProcessVersionsServerTransport) dispatchNewListByBusinessProcessPager(req *http.Request) (*http.Response, error) { + if b.srv.NewListByBusinessProcessPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByBusinessProcessPager not implemented")} + } + newListByBusinessProcessPager := b.newListByBusinessProcessPager.get(req) + if newListByBusinessProcessPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/businessProcesses/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + maxpagesizeUnescaped, err := url.QueryUnescape(qp.Get("maxpagesize")) + if err != nil { + return nil, err + } + maxpagesizeParam, err := parseOptional(maxpagesizeUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + selectEscaped := qp["select"] + selectParam := make([]string, len(selectEscaped)) + for i, v := range selectEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + selectParam[i] = u + } + expandEscaped := qp["expand"] + expandParam := make([]string, len(expandEscaped)) + for i, v := range expandEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + expandParam[i] = u + } + orderbyEscaped := qp["orderby"] + orderbyParam := make([]string, len(orderbyEscaped)) + for i, v := range orderbyEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + orderbyParam[i] = u + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + businessProcessNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("businessProcessName")]) + if err != nil { + return nil, err + } + var options *armintegrationspaces.BusinessProcessVersionsClientListByBusinessProcessOptions + if topParam != nil || skipParam != nil || maxpagesizeParam != nil || filterParam != nil || len(selectParam) > 0 || len(expandParam) > 0 || len(orderbyParam) > 0 { + options = &armintegrationspaces.BusinessProcessVersionsClientListByBusinessProcessOptions{ + Top: topParam, + Skip: skipParam, + Maxpagesize: maxpagesizeParam, + Filter: filterParam, + Select: selectParam, + Expand: expandParam, + Orderby: orderbyParam, + } + } + resp := b.srv.NewListByBusinessProcessPager(resourceGroupNameParam, spaceNameParam, applicationNameParam, businessProcessNameParam, options) + newListByBusinessProcessPager = &resp + b.newListByBusinessProcessPager.add(req, newListByBusinessProcessPager) + server.PagerResponderInjectNextLinks(newListByBusinessProcessPager, req, func(page *armintegrationspaces.BusinessProcessVersionsClientListByBusinessProcessResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByBusinessProcessPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + b.newListByBusinessProcessPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByBusinessProcessPager) { + b.newListByBusinessProcessPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/infrastructureresources_server.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/infrastructureresources_server.go new file mode 100644 index 000000000000..746958507646 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/infrastructureresources_server.go @@ -0,0 +1,381 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// InfrastructureResourcesServer is a fake server for instances of the armintegrationspaces.InfrastructureResourcesClient type. +type InfrastructureResourcesServer struct { + // CreateOrUpdate is the fake for method InfrastructureResourcesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, spaceName string, infrastructureResourceName string, resource armintegrationspaces.InfrastructureResource, options *armintegrationspaces.InfrastructureResourcesClientCreateOrUpdateOptions) (resp azfake.Responder[armintegrationspaces.InfrastructureResourcesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method InfrastructureResourcesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, spaceName string, infrastructureResourceName string, options *armintegrationspaces.InfrastructureResourcesClientDeleteOptions) (resp azfake.Responder[armintegrationspaces.InfrastructureResourcesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method InfrastructureResourcesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, spaceName string, infrastructureResourceName string, options *armintegrationspaces.InfrastructureResourcesClientGetOptions) (resp azfake.Responder[armintegrationspaces.InfrastructureResourcesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListBySpacePager is the fake for method InfrastructureResourcesClient.NewListBySpacePager + // HTTP status codes to indicate success: http.StatusOK + NewListBySpacePager func(resourceGroupName string, spaceName string, options *armintegrationspaces.InfrastructureResourcesClientListBySpaceOptions) (resp azfake.PagerResponder[armintegrationspaces.InfrastructureResourcesClientListBySpaceResponse]) + + // Patch is the fake for method InfrastructureResourcesClient.Patch + // HTTP status codes to indicate success: http.StatusOK + Patch func(ctx context.Context, resourceGroupName string, spaceName string, infrastructureResourceName string, properties armintegrationspaces.InfrastructureResourceUpdate, options *armintegrationspaces.InfrastructureResourcesClientPatchOptions) (resp azfake.Responder[armintegrationspaces.InfrastructureResourcesClientPatchResponse], errResp azfake.ErrorResponder) +} + +// NewInfrastructureResourcesServerTransport creates a new instance of InfrastructureResourcesServerTransport with the provided implementation. +// The returned InfrastructureResourcesServerTransport instance is connected to an instance of armintegrationspaces.InfrastructureResourcesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewInfrastructureResourcesServerTransport(srv *InfrastructureResourcesServer) *InfrastructureResourcesServerTransport { + return &InfrastructureResourcesServerTransport{ + srv: srv, + newListBySpacePager: newTracker[azfake.PagerResponder[armintegrationspaces.InfrastructureResourcesClientListBySpaceResponse]](), + } +} + +// InfrastructureResourcesServerTransport connects instances of armintegrationspaces.InfrastructureResourcesClient to instances of InfrastructureResourcesServer. +// Don't use this type directly, use NewInfrastructureResourcesServerTransport instead. +type InfrastructureResourcesServerTransport struct { + srv *InfrastructureResourcesServer + newListBySpacePager *tracker[azfake.PagerResponder[armintegrationspaces.InfrastructureResourcesClientListBySpaceResponse]] +} + +// Do implements the policy.Transporter interface for InfrastructureResourcesServerTransport. +func (i *InfrastructureResourcesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "InfrastructureResourcesClient.CreateOrUpdate": + resp, err = i.dispatchCreateOrUpdate(req) + case "InfrastructureResourcesClient.Delete": + resp, err = i.dispatchDelete(req) + case "InfrastructureResourcesClient.Get": + resp, err = i.dispatchGet(req) + case "InfrastructureResourcesClient.NewListBySpacePager": + resp, err = i.dispatchNewListBySpacePager(req) + case "InfrastructureResourcesClient.Patch": + resp, err = i.dispatchPatch(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *InfrastructureResourcesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if i.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/infrastructureResources/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armintegrationspaces.InfrastructureResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + infrastructureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("infrastructureResourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, spaceNameParam, infrastructureResourceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).InfrastructureResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *InfrastructureResourcesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if i.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/infrastructureResources/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + infrastructureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("infrastructureResourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Delete(req.Context(), resourceGroupNameParam, spaceNameParam, infrastructureResourceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *InfrastructureResourcesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/infrastructureResources/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + infrastructureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("infrastructureResourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameParam, spaceNameParam, infrastructureResourceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).InfrastructureResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *InfrastructureResourcesServerTransport) dispatchNewListBySpacePager(req *http.Request) (*http.Response, error) { + if i.srv.NewListBySpacePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySpacePager not implemented")} + } + newListBySpacePager := i.newListBySpacePager.get(req) + if newListBySpacePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/infrastructureResources` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + maxpagesizeUnescaped, err := url.QueryUnescape(qp.Get("maxpagesize")) + if err != nil { + return nil, err + } + maxpagesizeParam, err := parseOptional(maxpagesizeUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + selectEscaped := qp["select"] + selectParam := make([]string, len(selectEscaped)) + for i, v := range selectEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + selectParam[i] = u + } + expandEscaped := qp["expand"] + expandParam := make([]string, len(expandEscaped)) + for i, v := range expandEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + expandParam[i] = u + } + orderbyEscaped := qp["orderby"] + orderbyParam := make([]string, len(orderbyEscaped)) + for i, v := range orderbyEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + orderbyParam[i] = u + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + var options *armintegrationspaces.InfrastructureResourcesClientListBySpaceOptions + if topParam != nil || skipParam != nil || maxpagesizeParam != nil || filterParam != nil || len(selectParam) > 0 || len(expandParam) > 0 || len(orderbyParam) > 0 { + options = &armintegrationspaces.InfrastructureResourcesClientListBySpaceOptions{ + Top: topParam, + Skip: skipParam, + Maxpagesize: maxpagesizeParam, + Filter: filterParam, + Select: selectParam, + Expand: expandParam, + Orderby: orderbyParam, + } + } + resp := i.srv.NewListBySpacePager(resourceGroupNameParam, spaceNameParam, options) + newListBySpacePager = &resp + i.newListBySpacePager.add(req, newListBySpacePager) + server.PagerResponderInjectNextLinks(newListBySpacePager, req, func(page *armintegrationspaces.InfrastructureResourcesClientListBySpaceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySpacePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + i.newListBySpacePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySpacePager) { + i.newListBySpacePager.remove(req) + } + return resp, nil +} + +func (i *InfrastructureResourcesServerTransport) dispatchPatch(req *http.Request) (*http.Response, error) { + if i.srv.Patch == nil { + return nil, &nonRetriableError{errors.New("fake for method Patch not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/infrastructureResources/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armintegrationspaces.InfrastructureResourceUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + infrastructureResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("infrastructureResourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Patch(req.Context(), resourceGroupNameParam, spaceNameParam, infrastructureResourceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).InfrastructureResource, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/internal.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/internal.go new file mode 100644 index 000000000000..7d2f89ba4bb2 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/internal.go @@ -0,0 +1,83 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "reflect" + "sync" +) + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +func parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { + if v == "" { + return nil, nil + } + t, err := parse(v) + if err != nil { + return nil, err + } + return &t, err +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/operations_server.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/operations_server.go new file mode 100644 index 000000000000..cbae0fd11e0e --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/operations_server.go @@ -0,0 +1,96 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces" + "net/http" +) + +// OperationsServer is a fake server for instances of the armintegrationspaces.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armintegrationspaces.OperationsClientListOptions) (resp azfake.PagerResponder[armintegrationspaces.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armintegrationspaces.OperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { + return &OperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armintegrationspaces.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armintegrationspaces.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armintegrationspaces.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armintegrationspaces.OperationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/server_factory.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/server_factory.go new file mode 100644 index 000000000000..f59a9e0569aa --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/server_factory.go @@ -0,0 +1,113 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armintegrationspaces.ClientFactory type. +type ServerFactory struct { + ApplicationResourcesServer ApplicationResourcesServer + ApplicationsServer ApplicationsServer + BusinessProcessVersionsServer BusinessProcessVersionsServer + BusinessProcessesServer BusinessProcessesServer + InfrastructureResourcesServer InfrastructureResourcesServer + OperationsServer OperationsServer + SpacesServer SpacesServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armintegrationspaces.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armintegrationspaces.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trApplicationResourcesServer *ApplicationResourcesServerTransport + trApplicationsServer *ApplicationsServerTransport + trBusinessProcessVersionsServer *BusinessProcessVersionsServerTransport + trBusinessProcessesServer *BusinessProcessesServerTransport + trInfrastructureResourcesServer *InfrastructureResourcesServerTransport + trOperationsServer *OperationsServerTransport + trSpacesServer *SpacesServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "ApplicationResourcesClient": + initServer(s, &s.trApplicationResourcesServer, func() *ApplicationResourcesServerTransport { + return NewApplicationResourcesServerTransport(&s.srv.ApplicationResourcesServer) + }) + resp, err = s.trApplicationResourcesServer.Do(req) + case "ApplicationsClient": + initServer(s, &s.trApplicationsServer, func() *ApplicationsServerTransport { return NewApplicationsServerTransport(&s.srv.ApplicationsServer) }) + resp, err = s.trApplicationsServer.Do(req) + case "BusinessProcessVersionsClient": + initServer(s, &s.trBusinessProcessVersionsServer, func() *BusinessProcessVersionsServerTransport { + return NewBusinessProcessVersionsServerTransport(&s.srv.BusinessProcessVersionsServer) + }) + resp, err = s.trBusinessProcessVersionsServer.Do(req) + case "BusinessProcessesClient": + initServer(s, &s.trBusinessProcessesServer, func() *BusinessProcessesServerTransport { + return NewBusinessProcessesServerTransport(&s.srv.BusinessProcessesServer) + }) + resp, err = s.trBusinessProcessesServer.Do(req) + case "InfrastructureResourcesClient": + initServer(s, &s.trInfrastructureResourcesServer, func() *InfrastructureResourcesServerTransport { + return NewInfrastructureResourcesServerTransport(&s.srv.InfrastructureResourcesServer) + }) + resp, err = s.trInfrastructureResourcesServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "SpacesClient": + initServer(s, &s.trSpacesServer, func() *SpacesServerTransport { return NewSpacesServerTransport(&s.srv.SpacesServer) }) + resp, err = s.trSpacesServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/spaces_server.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/spaces_server.go new file mode 100644 index 000000000000..8f15ec2580c3 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/spaces_server.go @@ -0,0 +1,402 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// SpacesServer is a fake server for instances of the armintegrationspaces.SpacesClient type. +type SpacesServer struct { + // CreateOrUpdate is the fake for method SpacesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, spaceName string, resource armintegrationspaces.Space, options *armintegrationspaces.SpacesClientCreateOrUpdateOptions) (resp azfake.Responder[armintegrationspaces.SpacesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method SpacesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, spaceName string, options *armintegrationspaces.SpacesClientDeleteOptions) (resp azfake.Responder[armintegrationspaces.SpacesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SpacesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, spaceName string, options *armintegrationspaces.SpacesClientGetOptions) (resp azfake.Responder[armintegrationspaces.SpacesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method SpacesClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armintegrationspaces.SpacesClientListByResourceGroupOptions) (resp azfake.PagerResponder[armintegrationspaces.SpacesClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method SpacesClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armintegrationspaces.SpacesClientListBySubscriptionOptions) (resp azfake.PagerResponder[armintegrationspaces.SpacesClientListBySubscriptionResponse]) + + // Patch is the fake for method SpacesClient.Patch + // HTTP status codes to indicate success: http.StatusOK + Patch func(ctx context.Context, resourceGroupName string, spaceName string, properties armintegrationspaces.SpaceUpdate, options *armintegrationspaces.SpacesClientPatchOptions) (resp azfake.Responder[armintegrationspaces.SpacesClientPatchResponse], errResp azfake.ErrorResponder) +} + +// NewSpacesServerTransport creates a new instance of SpacesServerTransport with the provided implementation. +// The returned SpacesServerTransport instance is connected to an instance of armintegrationspaces.SpacesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSpacesServerTransport(srv *SpacesServer) *SpacesServerTransport { + return &SpacesServerTransport{ + srv: srv, + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armintegrationspaces.SpacesClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armintegrationspaces.SpacesClientListBySubscriptionResponse]](), + } +} + +// SpacesServerTransport connects instances of armintegrationspaces.SpacesClient to instances of SpacesServer. +// Don't use this type directly, use NewSpacesServerTransport instead. +type SpacesServerTransport struct { + srv *SpacesServer + newListByResourceGroupPager *tracker[azfake.PagerResponder[armintegrationspaces.SpacesClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armintegrationspaces.SpacesClientListBySubscriptionResponse]] +} + +// Do implements the policy.Transporter interface for SpacesServerTransport. +func (s *SpacesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + var resp *http.Response + var err error + + switch method { + case "SpacesClient.CreateOrUpdate": + resp, err = s.dispatchCreateOrUpdate(req) + case "SpacesClient.Delete": + resp, err = s.dispatchDelete(req) + case "SpacesClient.Get": + resp, err = s.dispatchGet(req) + case "SpacesClient.NewListByResourceGroupPager": + resp, err = s.dispatchNewListByResourceGroupPager(req) + case "SpacesClient.NewListBySubscriptionPager": + resp, err = s.dispatchNewListBySubscriptionPager(req) + case "SpacesClient.Patch": + resp, err = s.dispatchPatch(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SpacesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armintegrationspaces.Space](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, spaceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Space, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SpacesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if s.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Delete(req.Context(), resourceGroupNameParam, spaceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SpacesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, spaceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Space, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SpacesServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := s.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skipUnescaped, err := url.QueryUnescape(qp.Get("skip")) + if err != nil { + return nil, err + } + skipParam, err := parseOptional(skipUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + maxpagesizeUnescaped, err := url.QueryUnescape(qp.Get("maxpagesize")) + if err != nil { + return nil, err + } + maxpagesizeParam, err := parseOptional(maxpagesizeUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + selectEscaped := qp["select"] + selectParam := make([]string, len(selectEscaped)) + for i, v := range selectEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + selectParam[i] = u + } + expandEscaped := qp["expand"] + expandParam := make([]string, len(expandEscaped)) + for i, v := range expandEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + expandParam[i] = u + } + orderbyEscaped := qp["orderby"] + orderbyParam := make([]string, len(orderbyEscaped)) + for i, v := range orderbyEscaped { + u, unescapeErr := url.QueryUnescape(v) + if unescapeErr != nil { + return nil, unescapeErr + } + orderbyParam[i] = u + } + var options *armintegrationspaces.SpacesClientListByResourceGroupOptions + if topParam != nil || skipParam != nil || maxpagesizeParam != nil || filterParam != nil || len(selectParam) > 0 || len(expandParam) > 0 || len(orderbyParam) > 0 { + options = &armintegrationspaces.SpacesClientListByResourceGroupOptions{ + Top: topParam, + Skip: skipParam, + Maxpagesize: maxpagesizeParam, + Filter: filterParam, + Select: selectParam, + Expand: expandParam, + Orderby: orderbyParam, + } + } + resp := s.srv.NewListByResourceGroupPager(resourceGroupNameParam, options) + newListByResourceGroupPager = &resp + s.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armintegrationspaces.SpacesClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + s.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (s *SpacesServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := s.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := s.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + s.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armintegrationspaces.SpacesClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + s.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (s *SpacesServerTransport) dispatchPatch(req *http.Request) (*http.Response, error) { + if s.srv.Patch == nil { + return nil, &nonRetriableError{errors.New("fake for method Patch not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IntegrationSpaces/spaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armintegrationspaces.SpaceUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + spaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("spaceName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Patch(req.Context(), resourceGroupNameParam, spaceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Space, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/time_rfc3339.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/time_rfc3339.go new file mode 100644 index 000000000000..b0535a7b63e6 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/fake/time_rfc3339.go @@ -0,0 +1,86 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package fake + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/go.mod b/sdk/resourcemanager/integrationspaces/armintegrationspaces/go.mod new file mode 100644 index 000000000000..dd0d3480fbdd --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/go.mod @@ -0,0 +1,21 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces + +go 1.18 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect + github.com/google/uuid v1.3.1 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect +) diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/go.sum b/sdk/resourcemanager/integrationspaces/armintegrationspaces/go.sum new file mode 100644 index 000000000000..7985f1da436f --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/go.sum @@ -0,0 +1,31 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/infrastructureresources_client.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/infrastructureresources_client.go new file mode 100644 index 000000000000..7362d6d3f112 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/infrastructureresources_client.go @@ -0,0 +1,415 @@ +//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 armintegrationspaces + +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" + "strconv" + "strings" +) + +// InfrastructureResourcesClient contains the methods for the InfrastructureResources group. +// Don't use this type directly, use NewInfrastructureResourcesClient() instead. +type InfrastructureResourcesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewInfrastructureResourcesClient creates a new instance of InfrastructureResourcesClient 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 NewInfrastructureResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*InfrastructureResourcesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &InfrastructureResourcesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Create a InfrastructureResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - infrastructureResourceName - The name of the infrastructure resource in the space. +// - resource - Resource create parameters. +// - options - InfrastructureResourcesClientCreateOrUpdateOptions contains the optional parameters for the InfrastructureResourcesClient.CreateOrUpdate +// method. +func (client *InfrastructureResourcesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, spaceName string, infrastructureResourceName string, resource InfrastructureResource, options *InfrastructureResourcesClientCreateOrUpdateOptions) (InfrastructureResourcesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "InfrastructureResourcesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, spaceName, infrastructureResourceName, resource, options) + if err != nil { + return InfrastructureResourcesClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return InfrastructureResourcesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return InfrastructureResourcesClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *InfrastructureResourcesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, infrastructureResourceName string, resource InfrastructureResource, options *InfrastructureResourcesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/infrastructureResources/{infrastructureResourceName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if infrastructureResourceName == "" { + return nil, errors.New("parameter infrastructureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{infrastructureResourceName}", url.PathEscape(infrastructureResourceName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *InfrastructureResourcesClient) createOrUpdateHandleResponse(resp *http.Response) (InfrastructureResourcesClientCreateOrUpdateResponse, error) { + result := InfrastructureResourcesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.InfrastructureResource); err != nil { + return InfrastructureResourcesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete a InfrastructureResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - infrastructureResourceName - The name of the infrastructure resource in the space. +// - options - InfrastructureResourcesClientDeleteOptions contains the optional parameters for the InfrastructureResourcesClient.Delete +// method. +func (client *InfrastructureResourcesClient) Delete(ctx context.Context, resourceGroupName string, spaceName string, infrastructureResourceName string, options *InfrastructureResourcesClientDeleteOptions) (InfrastructureResourcesClientDeleteResponse, error) { + var err error + const operationName = "InfrastructureResourcesClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, spaceName, infrastructureResourceName, options) + if err != nil { + return InfrastructureResourcesClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return InfrastructureResourcesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return InfrastructureResourcesClientDeleteResponse{}, err + } + return InfrastructureResourcesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *InfrastructureResourcesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, infrastructureResourceName string, options *InfrastructureResourcesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/infrastructureResources/{infrastructureResourceName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if infrastructureResourceName == "" { + return nil, errors.New("parameter infrastructureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{infrastructureResourceName}", url.PathEscape(infrastructureResourceName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a InfrastructureResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - infrastructureResourceName - The name of the infrastructure resource in the space. +// - options - InfrastructureResourcesClientGetOptions contains the optional parameters for the InfrastructureResourcesClient.Get +// method. +func (client *InfrastructureResourcesClient) Get(ctx context.Context, resourceGroupName string, spaceName string, infrastructureResourceName string, options *InfrastructureResourcesClientGetOptions) (InfrastructureResourcesClientGetResponse, error) { + var err error + const operationName = "InfrastructureResourcesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, spaceName, infrastructureResourceName, options) + if err != nil { + return InfrastructureResourcesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return InfrastructureResourcesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return InfrastructureResourcesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *InfrastructureResourcesClient) getCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, infrastructureResourceName string, options *InfrastructureResourcesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/infrastructureResources/{infrastructureResourceName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if infrastructureResourceName == "" { + return nil, errors.New("parameter infrastructureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{infrastructureResourceName}", url.PathEscape(infrastructureResourceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *InfrastructureResourcesClient) getHandleResponse(resp *http.Response) (InfrastructureResourcesClientGetResponse, error) { + result := InfrastructureResourcesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.InfrastructureResource); err != nil { + return InfrastructureResourcesClientGetResponse{}, err + } + return result, nil +} + +// NewListBySpacePager - List InfrastructureResource resources by Space +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - options - InfrastructureResourcesClientListBySpaceOptions contains the optional parameters for the InfrastructureResourcesClient.NewListBySpacePager +// method. +func (client *InfrastructureResourcesClient) NewListBySpacePager(resourceGroupName string, spaceName string, options *InfrastructureResourcesClientListBySpaceOptions) *runtime.Pager[InfrastructureResourcesClientListBySpaceResponse] { + return runtime.NewPager(runtime.PagingHandler[InfrastructureResourcesClientListBySpaceResponse]{ + More: func(page InfrastructureResourcesClientListBySpaceResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *InfrastructureResourcesClientListBySpaceResponse) (InfrastructureResourcesClientListBySpaceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "InfrastructureResourcesClient.NewListBySpacePager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySpaceCreateRequest(ctx, resourceGroupName, spaceName, options) + }, nil) + if err != nil { + return InfrastructureResourcesClientListBySpaceResponse{}, err + } + return client.listBySpaceHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySpaceCreateRequest creates the ListBySpace request. +func (client *InfrastructureResourcesClient) listBySpaceCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, options *InfrastructureResourcesClientListBySpaceOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/infrastructureResources" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Maxpagesize != nil { + reqQP.Set("maxpagesize", strconv.FormatInt(int64(*options.Maxpagesize), 10)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.Select != nil { + for _, qv := range options.Select { + reqQP.Add("select", qv) + } + } + if options != nil && options.Expand != nil { + for _, qv := range options.Expand { + reqQP.Add("expand", qv) + } + } + if options != nil && options.Orderby != nil { + for _, qv := range options.Orderby { + reqQP.Add("orderby", qv) + } + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySpaceHandleResponse handles the ListBySpace response. +func (client *InfrastructureResourcesClient) listBySpaceHandleResponse(resp *http.Response) (InfrastructureResourcesClientListBySpaceResponse, error) { + result := InfrastructureResourcesClientListBySpaceResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.InfrastructureResourceListResult); err != nil { + return InfrastructureResourcesClientListBySpaceResponse{}, err + } + return result, nil +} + +// Patch - Update a InfrastructureResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - infrastructureResourceName - The name of the infrastructure resource in the space. +// - properties - The resource properties to be updated. +// - options - InfrastructureResourcesClientPatchOptions contains the optional parameters for the InfrastructureResourcesClient.Patch +// method. +func (client *InfrastructureResourcesClient) Patch(ctx context.Context, resourceGroupName string, spaceName string, infrastructureResourceName string, properties InfrastructureResourceUpdate, options *InfrastructureResourcesClientPatchOptions) (InfrastructureResourcesClientPatchResponse, error) { + var err error + const operationName = "InfrastructureResourcesClient.Patch" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.patchCreateRequest(ctx, resourceGroupName, spaceName, infrastructureResourceName, properties, options) + if err != nil { + return InfrastructureResourcesClientPatchResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return InfrastructureResourcesClientPatchResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return InfrastructureResourcesClientPatchResponse{}, err + } + resp, err := client.patchHandleResponse(httpResp) + return resp, err +} + +// patchCreateRequest creates the Patch request. +func (client *InfrastructureResourcesClient) patchCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, infrastructureResourceName string, properties InfrastructureResourceUpdate, options *InfrastructureResourcesClientPatchOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}/infrastructureResources/{infrastructureResourceName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + if infrastructureResourceName == "" { + return nil, errors.New("parameter infrastructureResourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{infrastructureResourceName}", url.PathEscape(infrastructureResourceName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// patchHandleResponse handles the Patch response. +func (client *InfrastructureResourcesClient) patchHandleResponse(resp *http.Response) (InfrastructureResourcesClientPatchResponse, error) { + result := InfrastructureResourcesClientPatchResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.InfrastructureResource); err != nil { + return InfrastructureResourcesClientPatchResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/infrastructureresources_client_example_test.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/infrastructureresources_client_example_test.go new file mode 100644 index 000000000000..7c66f42dfccb --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/infrastructureresources_client_example_test.go @@ -0,0 +1,181 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armintegrationspaces_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/InfrastructureResources_ListBySpace.json +func ExampleInfrastructureResourcesClient_NewListBySpacePager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewInfrastructureResourcesClient().NewListBySpacePager("testrg", "Space1", &armintegrationspaces.InfrastructureResourcesClientListBySpaceOptions{Top: nil, + Skip: nil, + Maxpagesize: nil, + Filter: nil, + Select: []string{}, + Expand: []string{}, + Orderby: []string{}, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.InfrastructureResourceListResult = armintegrationspaces.InfrastructureResourceListResult{ + // Value: []*armintegrationspaces.InfrastructureResource{ + // { + // Name: to.Ptr("InfrastructureResource1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/infrastructureresources"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/infrastructureResources/InfrastructureResource1"), + // Properties: &armintegrationspaces.InfrastructureResourceProperties{ + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.ApiManagement/service/APIM1"), + // ResourceType: to.Ptr("Microsoft.ApiManagement/service"), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/InfrastructureResources_Get.json +func ExampleInfrastructureResourcesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewInfrastructureResourcesClient().Get(ctx, "testrg", "Space1", "InfrastructureResource1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.InfrastructureResource = armintegrationspaces.InfrastructureResource{ + // Name: to.Ptr("InfrastructureResource1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/infrastructureresources"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/infrastructureResources/InfrastructureResource1"), + // Properties: &armintegrationspaces.InfrastructureResourceProperties{ + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.ApiManagement/service/APIM1"), + // ResourceType: to.Ptr("Microsoft.ApiManagement/service"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/InfrastructureResources_CreateOrUpdate.json +func ExampleInfrastructureResourcesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewInfrastructureResourcesClient().CreateOrUpdate(ctx, "testrg", "Space1", "InfrastructureResource1", armintegrationspaces.InfrastructureResource{ + Properties: &armintegrationspaces.InfrastructureResourceProperties{ + ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.ApiManagement/service/APIM1"), + ResourceType: to.Ptr("Microsoft.ApiManagement/service"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.InfrastructureResource = armintegrationspaces.InfrastructureResource{ + // Name: to.Ptr("InfrastructureResource1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/infrastructureresources"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/infrastructureResources/InfrastructureResource1"), + // Properties: &armintegrationspaces.InfrastructureResourceProperties{ + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.ApiManagement/service/APIM1"), + // ResourceType: to.Ptr("Microsoft.ApiManagement/service"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/InfrastructureResources_Patch.json +func ExampleInfrastructureResourcesClient_Patch() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewInfrastructureResourcesClient().Patch(ctx, "testrg", "Space1", "InfrastructureResource1", armintegrationspaces.InfrastructureResourceUpdate{ + Properties: &armintegrationspaces.InfrastructureResourceUpdateProperties{ + ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.ApiManagement/service/APIM1"), + ResourceType: to.Ptr("Microsoft.ApiManagement/service"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.InfrastructureResource = armintegrationspaces.InfrastructureResource{ + // Name: to.Ptr("InfrastructureResource1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces/infrastructureresources"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1/infrastructureResources/InfrastructureResource1"), + // Properties: &armintegrationspaces.InfrastructureResourceProperties{ + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.ApiManagement/service/APIM1"), + // ResourceType: to.Ptr("Microsoft.ApiManagement/service"), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/InfrastructureResources_Delete.json +func ExampleInfrastructureResourcesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewInfrastructureResourcesClient().Delete(ctx, "testrg", "Space1", "InfrastructureResource1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/models.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/models.go new file mode 100644 index 000000000000..d3ca2f42428f --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/models.go @@ -0,0 +1,582 @@ +//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 armintegrationspaces + +import "time" + +// Application - An integration application under space. +type Application struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *ApplicationProperties + + // 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 +} + +// ApplicationListResult - The response of a Application list operation. +type ApplicationListResult struct { + // REQUIRED; The Application items on this page + Value []*Application + + // The link to the next page of items + NextLink *string +} + +// ApplicationProperties - The properties of application. +type ApplicationProperties struct { + // REQUIRED; The tracking data stores. + TrackingDataStores map[string]*TrackingDataStore + + // The description of the resource. + Description *string + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState +} + +// ApplicationResource - A resource under application. +type ApplicationResource struct { + // The resource-specific properties for this resource. + Properties *ApplicationResourceProperties + + // 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 +} + +// ApplicationResourceListResult - The response of a ApplicationResource list operation. +type ApplicationResourceListResult struct { + // REQUIRED; The ApplicationResource items on this page + Value []*ApplicationResource + + // The link to the next page of items + NextLink *string +} + +// ApplicationResourceProperties - The properties of application resource. +type ApplicationResourceProperties struct { + // REQUIRED; The Arm id of the application resource. + ResourceID *string + + // REQUIRED; The type of the application resource. + ResourceType *string + + // The kind of the application resource. + ResourceKind *string + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState +} + +// ApplicationResourceUpdate - The type used for update operations of the ApplicationResource. +type ApplicationResourceUpdate struct { + // The updatable properties of the ApplicationResource. + Properties *ApplicationResourceUpdateProperties +} + +// ApplicationResourceUpdateProperties - The updatable properties of the ApplicationResource. +type ApplicationResourceUpdateProperties struct { + // The Arm id of the application resource. + ResourceID *string + + // The kind of the application resource. + ResourceKind *string + + // The type of the application resource. + ResourceType *string +} + +// ApplicationUpdate - The type used for update operations of the Application. +type ApplicationUpdate struct { + // The updatable properties of the Application. + Properties *ApplicationUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// ApplicationUpdateProperties - The updatable properties of the Application. +type ApplicationUpdateProperties struct { + // The description of the resource. + Description *string + + // The tracking data stores. + TrackingDataStores map[string]*TrackingDataStore +} + +// BusinessProcess - A business process under application. +type BusinessProcess struct { + // The resource-specific properties for this resource. + Properties *BusinessProcessProperties + + // 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 +} + +// BusinessProcessDevelopmentArtifactProperties - The properties of business process development artifact. +type BusinessProcessDevelopmentArtifactProperties struct { + // The business process mapping. + BusinessProcessMapping map[string]*BusinessProcessMappingItem + + // The business process stages. + BusinessProcessStages map[string]*BusinessProcessStage + + // The description of the business process. + Description *string + + // The business process identifier. + Identifier *BusinessProcessIdentifier + + // The tracking profile for the business process. + TrackingProfiles map[string]*TrackingProfileDefinition +} + +// BusinessProcessIdentifier - The properties of business process identifier. +type BusinessProcessIdentifier struct { + // The property name of the business process identifier. + PropertyName *string + + // The property type of the business process identifier. + PropertyType *string +} + +// BusinessProcessListResult - The response of a BusinessProcess list operation. +type BusinessProcessListResult struct { + // REQUIRED; The BusinessProcess items on this page + Value []*BusinessProcess + + // The link to the next page of items + NextLink *string +} + +// BusinessProcessMappingItem - The properties of business process mapping. +type BusinessProcessMappingItem struct { + // The logic app resource id. + LogicAppResourceID *string + + // The operation name. + OperationName *string + + // The mapping item operation type of the business process. + OperationType *string + + // The workflow name within the logic app. + WorkflowName *string +} + +// BusinessProcessProperties - The properties of business process. +type BusinessProcessProperties struct { + // The business process mapping. + BusinessProcessMapping map[string]*BusinessProcessMappingItem + + // The business process stages. + BusinessProcessStages map[string]*BusinessProcessStage + + // The description of the business process. + Description *string + + // The business process identifier. + Identifier *BusinessProcessIdentifier + + // The table name of the business process. + TableName *string + + // The tracking data store reference name. + TrackingDataStoreReferenceName *string + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState + + // READ-ONLY; The version of the business process. + Version *string +} + +// BusinessProcessReference - The business process reference. +type BusinessProcessReference struct { + // The business process name. + Name *string + + // The business process version. + Version *string +} + +// BusinessProcessStage - The properties of business process stage. +type BusinessProcessStage struct { + // The description of the business stage. + Description *string + + // The properties within the properties of the business process stage. + Properties map[string]*string + + // The property to keep track of stages before current in the business process stage. + StagesBefore []*string +} + +// BusinessProcessUpdate - The type used for update operations of the BusinessProcess. +type BusinessProcessUpdate struct { + // The updatable properties of the BusinessProcess. + Properties *BusinessProcessUpdateProperties +} + +// BusinessProcessUpdateProperties - The updatable properties of the BusinessProcess. +type BusinessProcessUpdateProperties struct { + // The business process mapping. + BusinessProcessMapping map[string]*BusinessProcessMappingItem + + // The business process stages. + BusinessProcessStages map[string]*BusinessProcessStage + + // The description of the business process. + Description *string + + // The business process identifier. + Identifier *BusinessProcessIdentifier + + // The table name of the business process. + TableName *string + + // The tracking data store reference name. + TrackingDataStoreReferenceName *string +} + +// BusinessProcessVersion - A business process version. +type BusinessProcessVersion struct { + // The resource-specific properties for this resource. + Properties *BusinessProcessProperties + + // 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 +} + +// BusinessProcessVersionListResult - The response of a BusinessProcessVersion list operation. +type BusinessProcessVersionListResult struct { + // REQUIRED; The BusinessProcessVersion items on this page + Value []*BusinessProcessVersion + + // The link to the next page of items + NextLink *string +} + +// FlowTrackingDefinition - The workflow tracking definition. +type FlowTrackingDefinition struct { + // The tracking correlation context. + CorrelationContext *TrackingCorrelationContext + + // The tracking events. + Events map[string]*TrackingEventDefinition +} + +// GetOrDeleteBusinessProcessDevelopmentArtifactRequest - The business process development artifact get or delete request. +type GetOrDeleteBusinessProcessDevelopmentArtifactRequest struct { + // REQUIRED; The name of the business process development artifact. + Name *string +} + +// InfrastructureResource - An infrastructure resource under Space. +type InfrastructureResource struct { + // The resource-specific properties for this resource. + Properties *InfrastructureResourceProperties + + // 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 +} + +// InfrastructureResourceListResult - The response of a InfrastructureResource list operation. +type InfrastructureResourceListResult struct { + // REQUIRED; The InfrastructureResource items on this page + Value []*InfrastructureResource + + // The link to the next page of items + NextLink *string +} + +// InfrastructureResourceProperties - The properties of infrastructure resource. +type InfrastructureResourceProperties struct { + // REQUIRED; The id of the infrastructure resource. + ResourceID *string + + // REQUIRED; The type of the infrastructure resource. + ResourceType *string + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState +} + +// InfrastructureResourceUpdate - The type used for update operations of the InfrastructureResource. +type InfrastructureResourceUpdate struct { + // The updatable properties of the InfrastructureResource. + Properties *InfrastructureResourceUpdateProperties +} + +// InfrastructureResourceUpdateProperties - The updatable properties of the InfrastructureResource. +type InfrastructureResourceUpdateProperties struct { + // The id of the infrastructure resource. + ResourceID *string + + // The type of the infrastructure resource. + ResourceType *string +} + +// ListBusinessProcessDevelopmentArtifactsResponse - The business process development artifact get collection response. +type ListBusinessProcessDevelopmentArtifactsResponse struct { + // REQUIRED; The list of the business process development artifact. + Value []*SaveOrGetBusinessProcessDevelopmentArtifactResponse +} + +// 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 +} + +// SaveOrGetBusinessProcessDevelopmentArtifactResponse - The business process development artifact save or get response. +type SaveOrGetBusinessProcessDevelopmentArtifactResponse struct { + // REQUIRED; The name of the business process development artifact. + Name *string + + // The properties of the business process development artifact. + Properties *BusinessProcessDevelopmentArtifactProperties + + // READ-ONLY; The system data of the business process development artifact. + SystemData *SystemData +} + +// SaveOrValidateBusinessProcessDevelopmentArtifactRequest - The business process development artifact save or validate request. +type SaveOrValidateBusinessProcessDevelopmentArtifactRequest struct { + // REQUIRED; The name of the business process development artifact. + Name *string + + // The properties of the business process development artifact. + Properties *BusinessProcessDevelopmentArtifactProperties +} + +// Space - An integration space. +type Space struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *SpaceResourceProperties + + // 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 +} + +// SpaceListResult - The response of a Space list operation. +type SpaceListResult struct { + // REQUIRED; The Space items on this page + Value []*Space + + // The link to the next page of items + NextLink *string +} + +// SpaceResourceProperties - The properties of space. +type SpaceResourceProperties struct { + // The description of the resource. + Description *string + + // READ-ONLY; The status of the last operation. + ProvisioningState *ProvisioningState +} + +// SpaceUpdate - The type used for update operations of the Space. +type SpaceUpdate struct { + // The updatable properties of the Space. + Properties *SpaceUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// SpaceUpdateProperties - The updatable properties of the Space. +type SpaceUpdateProperties struct { + // The description of the resource. + Description *string +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + +// TrackingCorrelationContext - The tracking correlation context. +type TrackingCorrelationContext struct { + // The operation name for correlation context. + OperationName *string + + // The operation type for correlation context. + OperationType *string + + // The name of the correlation property. + PropertyName *string + + // The template expression for correlation context property value. + Value *string +} + +// TrackingDataStore - The properties of tracking data store. +type TrackingDataStore struct { + // REQUIRED; The data store ingestion URI. + DataStoreIngestionURI *string + + // REQUIRED; The data store resource id. + DataStoreResourceID *string + + // REQUIRED; The data store URI. + DataStoreURI *string + + // REQUIRED; The database name. + DatabaseName *string +} + +// TrackingEventDefinition - The tracking event definition. +type TrackingEventDefinition struct { + // The operation name. + OperationName *string + + // The operation type. + OperationType *string + + // The properties to be collected for event. + Properties map[string]any +} + +// TrackingProfileDefinition - The tracking profile for the business process +type TrackingProfileDefinition struct { + // The business process reference. + BusinessProcess *BusinessProcessReference + + // The tracking definition schema uri. + Schema *string + + // The tracking definitions. + TrackingDefinitions map[string]*FlowTrackingDefinition +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/models_serde.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/models_serde.go new file mode 100644 index 000000000000..fb4d13b66ae0 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/models_serde.go @@ -0,0 +1,1643 @@ +//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 armintegrationspaces + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Application. +func (a Application) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "location", a.Location) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Application. +func (a *Application) 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 "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &a.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + 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 ApplicationListResult. +func (a ApplicationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationListResult. +func (a *ApplicationListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + 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 ApplicationProperties. +func (a ApplicationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", a.Description) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "trackingDataStores", a.TrackingDataStores) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationProperties. +func (a *ApplicationProperties) 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 "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "trackingDataStores": + err = unpopulate(val, "TrackingDataStores", &a.TrackingDataStores) + 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 ApplicationResource. +func (a ApplicationResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "systemData", a.SystemData) + populate(objectMap, "type", a.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationResource. +func (a *ApplicationResource) 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 "id": + err = unpopulate(val, "ID", &a.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &a.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &a.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &a.Type) + 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 ApplicationResourceListResult. +func (a ApplicationResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationResourceListResult. +func (a *ApplicationResourceListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &a.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &a.Value) + 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 ApplicationResourceProperties. +func (a ApplicationResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "resourceId", a.ResourceID) + populate(objectMap, "resourceKind", a.ResourceKind) + populate(objectMap, "resourceType", a.ResourceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationResourceProperties. +func (a *ApplicationResourceProperties) 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 "provisioningState": + err = unpopulate(val, "ProvisioningState", &a.ProvisioningState) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &a.ResourceID) + delete(rawMsg, key) + case "resourceKind": + err = unpopulate(val, "ResourceKind", &a.ResourceKind) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &a.ResourceType) + 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 ApplicationResourceUpdate. +func (a ApplicationResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationResourceUpdate. +func (a *ApplicationResourceUpdate) 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 "properties": + err = unpopulate(val, "Properties", &a.Properties) + 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 ApplicationResourceUpdateProperties. +func (a ApplicationResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceId", a.ResourceID) + populate(objectMap, "resourceKind", a.ResourceKind) + populate(objectMap, "resourceType", a.ResourceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationResourceUpdateProperties. +func (a *ApplicationResourceUpdateProperties) 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 "resourceId": + err = unpopulate(val, "ResourceID", &a.ResourceID) + delete(rawMsg, key) + case "resourceKind": + err = unpopulate(val, "ResourceKind", &a.ResourceKind) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &a.ResourceType) + 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 ApplicationUpdate. +func (a ApplicationUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "tags", a.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationUpdate. +func (a *ApplicationUpdate) 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 "properties": + err = unpopulate(val, "Properties", &a.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &a.Tags) + 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 ApplicationUpdateProperties. +func (a ApplicationUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", a.Description) + populate(objectMap, "trackingDataStores", a.TrackingDataStores) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationUpdateProperties. +func (a *ApplicationUpdateProperties) 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 "description": + err = unpopulate(val, "Description", &a.Description) + delete(rawMsg, key) + case "trackingDataStores": + err = unpopulate(val, "TrackingDataStores", &a.TrackingDataStores) + 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 BusinessProcess. +func (b BusinessProcess) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", b.ID) + populate(objectMap, "name", b.Name) + populate(objectMap, "properties", b.Properties) + populate(objectMap, "systemData", b.SystemData) + populate(objectMap, "type", b.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BusinessProcess. +func (b *BusinessProcess) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &b.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &b.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &b.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &b.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &b.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BusinessProcessDevelopmentArtifactProperties. +func (b BusinessProcessDevelopmentArtifactProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "businessProcessMapping", b.BusinessProcessMapping) + populate(objectMap, "businessProcessStages", b.BusinessProcessStages) + populate(objectMap, "description", b.Description) + populate(objectMap, "identifier", b.Identifier) + populate(objectMap, "trackingProfiles", b.TrackingProfiles) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BusinessProcessDevelopmentArtifactProperties. +func (b *BusinessProcessDevelopmentArtifactProperties) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "businessProcessMapping": + err = unpopulate(val, "BusinessProcessMapping", &b.BusinessProcessMapping) + delete(rawMsg, key) + case "businessProcessStages": + err = unpopulate(val, "BusinessProcessStages", &b.BusinessProcessStages) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &b.Description) + delete(rawMsg, key) + case "identifier": + err = unpopulate(val, "Identifier", &b.Identifier) + delete(rawMsg, key) + case "trackingProfiles": + err = unpopulate(val, "TrackingProfiles", &b.TrackingProfiles) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BusinessProcessIdentifier. +func (b BusinessProcessIdentifier) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "propertyName", b.PropertyName) + populate(objectMap, "propertyType", b.PropertyType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BusinessProcessIdentifier. +func (b *BusinessProcessIdentifier) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "propertyName": + err = unpopulate(val, "PropertyName", &b.PropertyName) + delete(rawMsg, key) + case "propertyType": + err = unpopulate(val, "PropertyType", &b.PropertyType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BusinessProcessListResult. +func (b BusinessProcessListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", b.NextLink) + populate(objectMap, "value", b.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BusinessProcessListResult. +func (b *BusinessProcessListResult) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &b.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &b.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BusinessProcessMappingItem. +func (b BusinessProcessMappingItem) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "logicAppResourceId", b.LogicAppResourceID) + populate(objectMap, "operationName", b.OperationName) + populate(objectMap, "operationType", b.OperationType) + populate(objectMap, "workflowName", b.WorkflowName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BusinessProcessMappingItem. +func (b *BusinessProcessMappingItem) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "logicAppResourceId": + err = unpopulate(val, "LogicAppResourceID", &b.LogicAppResourceID) + delete(rawMsg, key) + case "operationName": + err = unpopulate(val, "OperationName", &b.OperationName) + delete(rawMsg, key) + case "operationType": + err = unpopulate(val, "OperationType", &b.OperationType) + delete(rawMsg, key) + case "workflowName": + err = unpopulate(val, "WorkflowName", &b.WorkflowName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BusinessProcessProperties. +func (b BusinessProcessProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "businessProcessMapping", b.BusinessProcessMapping) + populate(objectMap, "businessProcessStages", b.BusinessProcessStages) + populate(objectMap, "description", b.Description) + populate(objectMap, "identifier", b.Identifier) + populate(objectMap, "provisioningState", b.ProvisioningState) + populate(objectMap, "tableName", b.TableName) + populate(objectMap, "trackingDataStoreReferenceName", b.TrackingDataStoreReferenceName) + populate(objectMap, "version", b.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BusinessProcessProperties. +func (b *BusinessProcessProperties) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "businessProcessMapping": + err = unpopulate(val, "BusinessProcessMapping", &b.BusinessProcessMapping) + delete(rawMsg, key) + case "businessProcessStages": + err = unpopulate(val, "BusinessProcessStages", &b.BusinessProcessStages) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &b.Description) + delete(rawMsg, key) + case "identifier": + err = unpopulate(val, "Identifier", &b.Identifier) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &b.ProvisioningState) + delete(rawMsg, key) + case "tableName": + err = unpopulate(val, "TableName", &b.TableName) + delete(rawMsg, key) + case "trackingDataStoreReferenceName": + err = unpopulate(val, "TrackingDataStoreReferenceName", &b.TrackingDataStoreReferenceName) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &b.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BusinessProcessReference. +func (b BusinessProcessReference) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", b.Name) + populate(objectMap, "version", b.Version) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BusinessProcessReference. +func (b *BusinessProcessReference) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &b.Name) + delete(rawMsg, key) + case "version": + err = unpopulate(val, "Version", &b.Version) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BusinessProcessStage. +func (b BusinessProcessStage) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", b.Description) + populate(objectMap, "properties", b.Properties) + populate(objectMap, "stagesBefore", b.StagesBefore) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BusinessProcessStage. +func (b *BusinessProcessStage) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &b.Description) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &b.Properties) + delete(rawMsg, key) + case "stagesBefore": + err = unpopulate(val, "StagesBefore", &b.StagesBefore) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BusinessProcessUpdate. +func (b BusinessProcessUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", b.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BusinessProcessUpdate. +func (b *BusinessProcessUpdate) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &b.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BusinessProcessUpdateProperties. +func (b BusinessProcessUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "businessProcessMapping", b.BusinessProcessMapping) + populate(objectMap, "businessProcessStages", b.BusinessProcessStages) + populate(objectMap, "description", b.Description) + populate(objectMap, "identifier", b.Identifier) + populate(objectMap, "tableName", b.TableName) + populate(objectMap, "trackingDataStoreReferenceName", b.TrackingDataStoreReferenceName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BusinessProcessUpdateProperties. +func (b *BusinessProcessUpdateProperties) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "businessProcessMapping": + err = unpopulate(val, "BusinessProcessMapping", &b.BusinessProcessMapping) + delete(rawMsg, key) + case "businessProcessStages": + err = unpopulate(val, "BusinessProcessStages", &b.BusinessProcessStages) + delete(rawMsg, key) + case "description": + err = unpopulate(val, "Description", &b.Description) + delete(rawMsg, key) + case "identifier": + err = unpopulate(val, "Identifier", &b.Identifier) + delete(rawMsg, key) + case "tableName": + err = unpopulate(val, "TableName", &b.TableName) + delete(rawMsg, key) + case "trackingDataStoreReferenceName": + err = unpopulate(val, "TrackingDataStoreReferenceName", &b.TrackingDataStoreReferenceName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BusinessProcessVersion. +func (b BusinessProcessVersion) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", b.ID) + populate(objectMap, "name", b.Name) + populate(objectMap, "properties", b.Properties) + populate(objectMap, "systemData", b.SystemData) + populate(objectMap, "type", b.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BusinessProcessVersion. +func (b *BusinessProcessVersion) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &b.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &b.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &b.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &b.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &b.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type BusinessProcessVersionListResult. +func (b BusinessProcessVersionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", b.NextLink) + populate(objectMap, "value", b.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type BusinessProcessVersionListResult. +func (b *BusinessProcessVersionListResult) 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", b, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &b.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &b.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", b, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type FlowTrackingDefinition. +func (f FlowTrackingDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "correlationContext", f.CorrelationContext) + populate(objectMap, "events", f.Events) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type FlowTrackingDefinition. +func (f *FlowTrackingDefinition) 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 "correlationContext": + err = unpopulate(val, "CorrelationContext", &f.CorrelationContext) + delete(rawMsg, key) + case "events": + err = unpopulate(val, "Events", &f.Events) + 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 GetOrDeleteBusinessProcessDevelopmentArtifactRequest. +func (g GetOrDeleteBusinessProcessDevelopmentArtifactRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", g.Name) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GetOrDeleteBusinessProcessDevelopmentArtifactRequest. +func (g *GetOrDeleteBusinessProcessDevelopmentArtifactRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &g.Name) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", g, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type InfrastructureResource. +func (i InfrastructureResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", i.ID) + populate(objectMap, "name", i.Name) + populate(objectMap, "properties", i.Properties) + populate(objectMap, "systemData", i.SystemData) + populate(objectMap, "type", i.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InfrastructureResource. +func (i *InfrastructureResource) 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 "id": + err = unpopulate(val, "ID", &i.ID) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &i.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &i.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &i.SystemData) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &i.Type) + 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 InfrastructureResourceListResult. +func (i InfrastructureResourceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InfrastructureResourceListResult. +func (i *InfrastructureResourceListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &i.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &i.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", i, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type InfrastructureResourceProperties. +func (i InfrastructureResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "provisioningState", i.ProvisioningState) + populate(objectMap, "resourceId", i.ResourceID) + populate(objectMap, "resourceType", i.ResourceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InfrastructureResourceProperties. +func (i *InfrastructureResourceProperties) 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 "provisioningState": + err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) + delete(rawMsg, key) + case "resourceId": + err = unpopulate(val, "ResourceID", &i.ResourceID) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &i.ResourceType) + 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 InfrastructureResourceUpdate. +func (i InfrastructureResourceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", i.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InfrastructureResourceUpdate. +func (i *InfrastructureResourceUpdate) 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 "properties": + err = unpopulate(val, "Properties", &i.Properties) + 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 InfrastructureResourceUpdateProperties. +func (i InfrastructureResourceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "resourceId", i.ResourceID) + populate(objectMap, "resourceType", i.ResourceType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type InfrastructureResourceUpdateProperties. +func (i *InfrastructureResourceUpdateProperties) 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 "resourceId": + err = unpopulate(val, "ResourceID", &i.ResourceID) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, "ResourceType", &i.ResourceType) + 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 ListBusinessProcessDevelopmentArtifactsResponse. +func (l ListBusinessProcessDevelopmentArtifactsResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ListBusinessProcessDevelopmentArtifactsResponse. +func (l *ListBusinessProcessDevelopmentArtifactsResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "value": + err = unpopulate(val, "Value", &l.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", l, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type 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 SaveOrGetBusinessProcessDevelopmentArtifactResponse. +func (s SaveOrGetBusinessProcessDevelopmentArtifactResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SaveOrGetBusinessProcessDevelopmentArtifactResponse. +func (s *SaveOrGetBusinessProcessDevelopmentArtifactResponse) 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 "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + 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 SaveOrValidateBusinessProcessDevelopmentArtifactRequest. +func (s SaveOrValidateBusinessProcessDevelopmentArtifactRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", s.Name) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SaveOrValidateBusinessProcessDevelopmentArtifactRequest. +func (s *SaveOrValidateBusinessProcessDevelopmentArtifactRequest) 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 "name": + err = unpopulate(val, "Name", &s.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &s.Properties) + 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 Space. +func (s Space) 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, "properties", s.Properties) + populate(objectMap, "systemData", s.SystemData) + populate(objectMap, "tags", s.Tags) + populate(objectMap, "type", s.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Space. +func (s *Space) 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 "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &s.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &s.Type) + 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 SpaceListResult. +func (s SpaceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SpaceListResult. +func (s *SpaceListResult) 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 "nextLink": + err = unpopulate(val, "NextLink", &s.NextLink) + delete(rawMsg, 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 SpaceResourceProperties. +func (s SpaceResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", s.Description) + populate(objectMap, "provisioningState", s.ProvisioningState) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SpaceResourceProperties. +func (s *SpaceResourceProperties) 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 "description": + err = unpopulate(val, "Description", &s.Description) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &s.ProvisioningState) + 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 SpaceUpdate. +func (s SpaceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", s.Properties) + populate(objectMap, "tags", s.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SpaceUpdate. +func (s *SpaceUpdate) 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 "properties": + err = unpopulate(val, "Properties", &s.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &s.Tags) + 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 SpaceUpdateProperties. +func (s SpaceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", s.Description) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SpaceUpdateProperties. +func (s *SpaceUpdateProperties) 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 "description": + err = unpopulate(val, "Description", &s.Description) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackingCorrelationContext. +func (t TrackingCorrelationContext) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "operationName", t.OperationName) + populate(objectMap, "operationType", t.OperationType) + populate(objectMap, "propertyName", t.PropertyName) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackingCorrelationContext. +func (t *TrackingCorrelationContext) 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", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "operationName": + err = unpopulate(val, "OperationName", &t.OperationName) + delete(rawMsg, key) + case "operationType": + err = unpopulate(val, "OperationType", &t.OperationType) + delete(rawMsg, key) + case "propertyName": + err = unpopulate(val, "PropertyName", &t.PropertyName) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &t.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackingDataStore. +func (t TrackingDataStore) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dataStoreIngestionUri", t.DataStoreIngestionURI) + populate(objectMap, "dataStoreResourceId", t.DataStoreResourceID) + populate(objectMap, "dataStoreUri", t.DataStoreURI) + populate(objectMap, "databaseName", t.DatabaseName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackingDataStore. +func (t *TrackingDataStore) 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", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dataStoreIngestionUri": + err = unpopulate(val, "DataStoreIngestionURI", &t.DataStoreIngestionURI) + delete(rawMsg, key) + case "dataStoreResourceId": + err = unpopulate(val, "DataStoreResourceID", &t.DataStoreResourceID) + delete(rawMsg, key) + case "dataStoreUri": + err = unpopulate(val, "DataStoreURI", &t.DataStoreURI) + delete(rawMsg, key) + case "databaseName": + err = unpopulate(val, "DatabaseName", &t.DatabaseName) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackingEventDefinition. +func (t TrackingEventDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "operationName", t.OperationName) + populate(objectMap, "operationType", t.OperationType) + populate(objectMap, "properties", t.Properties) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackingEventDefinition. +func (t *TrackingEventDefinition) 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", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "operationName": + err = unpopulate(val, "OperationName", &t.OperationName) + delete(rawMsg, key) + case "operationType": + err = unpopulate(val, "OperationType", &t.OperationType) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &t.Properties) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackingProfileDefinition. +func (t TrackingProfileDefinition) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "businessProcess", t.BusinessProcess) + populate(objectMap, "$schema", t.Schema) + populate(objectMap, "trackingDefinitions", t.TrackingDefinitions) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TrackingProfileDefinition. +func (t *TrackingProfileDefinition) 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", t, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "businessProcess": + err = unpopulate(val, "BusinessProcess", &t.BusinessProcess) + delete(rawMsg, key) + case "$schema": + err = unpopulate(val, "Schema", &t.Schema) + delete(rawMsg, key) + case "trackingDefinitions": + err = unpopulate(val, "TrackingDefinitions", &t.TrackingDefinitions) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", t, 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/integrationspaces/armintegrationspaces/operations_client.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/operations_client.go new file mode 100644 index 000000000000..ac2ab70cbb45 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/operations_client.go @@ -0,0 +1,88 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armintegrationspaces + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" +) + +// OperationsClient contains the methods for the Operations group. +// Don't use this type directly, use NewOperationsClient() instead. +type OperationsClient struct { + internal *arm.Client +} + +// NewOperationsClient creates a new instance of OperationsClient with the specified values. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &OperationsClient{ + internal: cl, + } + return client, nil +} + +// NewListPager - List the operations for the provider +// +// Generated from API version 2023-11-14-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) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return OperationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listCreateRequest creates the List request. +func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.IntegrationSpaces/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-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/integrationspaces/armintegrationspaces/operations_client_example_test.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/operations_client_example_test.go new file mode 100644 index 000000000000..2ff233afee0b --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/operations_client_example_test.go @@ -0,0 +1,73 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armintegrationspaces_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Operations_List.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.OperationListResult = armintegrationspaces.OperationListResult{ + // Value: []*armintegrationspaces.Operation{ + // { + // Name: to.Ptr("Microsoft.IntegrationSpaces/spaces/read"), + // Display: &armintegrationspaces.OperationDisplay{ + // Description: to.Ptr("Read space"), + // Operation: to.Ptr("Read space"), + // Provider: to.Ptr("Microsoft Azure Integration Spaces"), + // Resource: to.Ptr("space"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.IntegrationSpaces/spaces/write"), + // Display: &armintegrationspaces.OperationDisplay{ + // Description: to.Ptr("Update space"), + // Operation: to.Ptr("Update space"), + // Provider: to.Ptr("Microsoft Azure Integration Spaces"), + // Resource: to.Ptr("space"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.IntegrationSpaces/spaces/delete"), + // Display: &armintegrationspaces.OperationDisplay{ + // Description: to.Ptr("Delete space"), + // Operation: to.Ptr("Delete space"), + // Provider: to.Ptr("Microsoft Azure Integration Spaces"), + // Resource: to.Ptr("space"), + // }, + // }}, + // } + } +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/options.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/options.go new file mode 100644 index 000000000000..482bfc9e0346 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/options.go @@ -0,0 +1,309 @@ +//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 armintegrationspaces + +// ApplicationResourcesClientCreateOrUpdateOptions contains the optional parameters for the ApplicationResourcesClient.CreateOrUpdate +// method. +type ApplicationResourcesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ApplicationResourcesClientDeleteOptions contains the optional parameters for the ApplicationResourcesClient.Delete method. +type ApplicationResourcesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ApplicationResourcesClientGetOptions contains the optional parameters for the ApplicationResourcesClient.Get method. +type ApplicationResourcesClientGetOptions struct { + // placeholder for future optional parameters +} + +// ApplicationResourcesClientListByApplicationOptions contains the optional parameters for the ApplicationResourcesClient.NewListByApplicationPager +// method. +type ApplicationResourcesClientListByApplicationOptions struct { + // Expand the indicated resources into the response. + Expand []string + + // Filter the result list using the given expression. + Filter *string + + // The maximum number of result items per page. + Maxpagesize *int32 + + // Expressions that specify the order of returned results. + Orderby []string + + // Select the specified fields to be included in the response. + Select []string + + // The number of result items to skip. + Skip *int32 + + // The number of result items to return. + Top *int32 +} + +// ApplicationResourcesClientPatchOptions contains the optional parameters for the ApplicationResourcesClient.Patch method. +type ApplicationResourcesClientPatchOptions struct { + // placeholder for future optional parameters +} + +// ApplicationsClientCreateOrUpdateOptions contains the optional parameters for the ApplicationsClient.CreateOrUpdate method. +type ApplicationsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ApplicationsClientDeleteBusinessProcessDevelopmentArtifactOptions contains the optional parameters for the ApplicationsClient.DeleteBusinessProcessDevelopmentArtifact +// method. +type ApplicationsClientDeleteBusinessProcessDevelopmentArtifactOptions struct { + // placeholder for future optional parameters +} + +// ApplicationsClientDeleteOptions contains the optional parameters for the ApplicationsClient.Delete method. +type ApplicationsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// ApplicationsClientGetBusinessProcessDevelopmentArtifactOptions contains the optional parameters for the ApplicationsClient.GetBusinessProcessDevelopmentArtifact +// method. +type ApplicationsClientGetBusinessProcessDevelopmentArtifactOptions struct { + // placeholder for future optional parameters +} + +// ApplicationsClientGetOptions contains the optional parameters for the ApplicationsClient.Get method. +type ApplicationsClientGetOptions struct { + // placeholder for future optional parameters +} + +// ApplicationsClientListBusinessProcessDevelopmentArtifactsOptions contains the optional parameters for the ApplicationsClient.ListBusinessProcessDevelopmentArtifacts +// method. +type ApplicationsClientListBusinessProcessDevelopmentArtifactsOptions struct { + // placeholder for future optional parameters +} + +// ApplicationsClientListBySpaceOptions contains the optional parameters for the ApplicationsClient.NewListBySpacePager method. +type ApplicationsClientListBySpaceOptions struct { + // Expand the indicated resources into the response. + Expand []string + + // Filter the result list using the given expression. + Filter *string + + // The maximum number of result items per page. + Maxpagesize *int32 + + // Expressions that specify the order of returned results. + Orderby []string + + // Select the specified fields to be included in the response. + Select []string + + // The number of result items to skip. + Skip *int32 + + // The number of result items to return. + Top *int32 +} + +// ApplicationsClientPatchOptions contains the optional parameters for the ApplicationsClient.Patch method. +type ApplicationsClientPatchOptions struct { + // placeholder for future optional parameters +} + +// ApplicationsClientSaveBusinessProcessDevelopmentArtifactOptions contains the optional parameters for the ApplicationsClient.SaveBusinessProcessDevelopmentArtifact +// method. +type ApplicationsClientSaveBusinessProcessDevelopmentArtifactOptions struct { + // placeholder for future optional parameters +} + +// ApplicationsClientValidateBusinessProcessDevelopmentArtifactOptions contains the optional parameters for the ApplicationsClient.ValidateBusinessProcessDevelopmentArtifact +// method. +type ApplicationsClientValidateBusinessProcessDevelopmentArtifactOptions struct { + // placeholder for future optional parameters +} + +// BusinessProcessVersionsClientGetOptions contains the optional parameters for the BusinessProcessVersionsClient.Get method. +type BusinessProcessVersionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// BusinessProcessVersionsClientListByBusinessProcessOptions contains the optional parameters for the BusinessProcessVersionsClient.NewListByBusinessProcessPager +// method. +type BusinessProcessVersionsClientListByBusinessProcessOptions struct { + // Expand the indicated resources into the response. + Expand []string + + // Filter the result list using the given expression. + Filter *string + + // The maximum number of result items per page. + Maxpagesize *int32 + + // Expressions that specify the order of returned results. + Orderby []string + + // Select the specified fields to be included in the response. + Select []string + + // The number of result items to skip. + Skip *int32 + + // The number of result items to return. + Top *int32 +} + +// BusinessProcessesClientCreateOrUpdateOptions contains the optional parameters for the BusinessProcessesClient.CreateOrUpdate +// method. +type BusinessProcessesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// BusinessProcessesClientDeleteOptions contains the optional parameters for the BusinessProcessesClient.Delete method. +type BusinessProcessesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// BusinessProcessesClientGetOptions contains the optional parameters for the BusinessProcessesClient.Get method. +type BusinessProcessesClientGetOptions struct { + // placeholder for future optional parameters +} + +// BusinessProcessesClientListByApplicationOptions contains the optional parameters for the BusinessProcessesClient.NewListByApplicationPager +// method. +type BusinessProcessesClientListByApplicationOptions struct { + // Expand the indicated resources into the response. + Expand []string + + // Filter the result list using the given expression. + Filter *string + + // The maximum number of result items per page. + Maxpagesize *int32 + + // Expressions that specify the order of returned results. + Orderby []string + + // Select the specified fields to be included in the response. + Select []string + + // The number of result items to skip. + Skip *int32 + + // The number of result items to return. + Top *int32 +} + +// BusinessProcessesClientPatchOptions contains the optional parameters for the BusinessProcessesClient.Patch method. +type BusinessProcessesClientPatchOptions struct { + // placeholder for future optional parameters +} + +// InfrastructureResourcesClientCreateOrUpdateOptions contains the optional parameters for the InfrastructureResourcesClient.CreateOrUpdate +// method. +type InfrastructureResourcesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// InfrastructureResourcesClientDeleteOptions contains the optional parameters for the InfrastructureResourcesClient.Delete +// method. +type InfrastructureResourcesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// InfrastructureResourcesClientGetOptions contains the optional parameters for the InfrastructureResourcesClient.Get method. +type InfrastructureResourcesClientGetOptions struct { + // placeholder for future optional parameters +} + +// InfrastructureResourcesClientListBySpaceOptions contains the optional parameters for the InfrastructureResourcesClient.NewListBySpacePager +// method. +type InfrastructureResourcesClientListBySpaceOptions struct { + // Expand the indicated resources into the response. + Expand []string + + // Filter the result list using the given expression. + Filter *string + + // The maximum number of result items per page. + Maxpagesize *int32 + + // Expressions that specify the order of returned results. + Orderby []string + + // Select the specified fields to be included in the response. + Select []string + + // The number of result items to skip. + Skip *int32 + + // The number of result items to return. + Top *int32 +} + +// InfrastructureResourcesClientPatchOptions contains the optional parameters for the InfrastructureResourcesClient.Patch +// method. +type InfrastructureResourcesClientPatchOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// SpacesClientCreateOrUpdateOptions contains the optional parameters for the SpacesClient.CreateOrUpdate method. +type SpacesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// SpacesClientDeleteOptions contains the optional parameters for the SpacesClient.Delete method. +type SpacesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// SpacesClientGetOptions contains the optional parameters for the SpacesClient.Get method. +type SpacesClientGetOptions struct { + // placeholder for future optional parameters +} + +// SpacesClientListByResourceGroupOptions contains the optional parameters for the SpacesClient.NewListByResourceGroupPager +// method. +type SpacesClientListByResourceGroupOptions struct { + // Expand the indicated resources into the response. + Expand []string + + // Filter the result list using the given expression. + Filter *string + + // The maximum number of result items per page. + Maxpagesize *int32 + + // Expressions that specify the order of returned results. + Orderby []string + + // Select the specified fields to be included in the response. + Select []string + + // The number of result items to skip. + Skip *int32 + + // The number of result items to return. + Top *int32 +} + +// SpacesClientListBySubscriptionOptions contains the optional parameters for the SpacesClient.NewListBySubscriptionPager +// method. +type SpacesClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// SpacesClientPatchOptions contains the optional parameters for the SpacesClient.Patch method. +type SpacesClientPatchOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/response_types.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/response_types.go new file mode 100644 index 000000000000..3c08c46012e2 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/response_types.go @@ -0,0 +1,206 @@ +//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 armintegrationspaces + +// ApplicationResourcesClientCreateOrUpdateResponse contains the response from method ApplicationResourcesClient.CreateOrUpdate. +type ApplicationResourcesClientCreateOrUpdateResponse struct { + // A resource under application. + ApplicationResource +} + +// ApplicationResourcesClientDeleteResponse contains the response from method ApplicationResourcesClient.Delete. +type ApplicationResourcesClientDeleteResponse struct { + // placeholder for future response values +} + +// ApplicationResourcesClientGetResponse contains the response from method ApplicationResourcesClient.Get. +type ApplicationResourcesClientGetResponse struct { + // A resource under application. + ApplicationResource +} + +// ApplicationResourcesClientListByApplicationResponse contains the response from method ApplicationResourcesClient.NewListByApplicationPager. +type ApplicationResourcesClientListByApplicationResponse struct { + // The response of a ApplicationResource list operation. + ApplicationResourceListResult +} + +// ApplicationResourcesClientPatchResponse contains the response from method ApplicationResourcesClient.Patch. +type ApplicationResourcesClientPatchResponse struct { + // A resource under application. + ApplicationResource +} + +// ApplicationsClientCreateOrUpdateResponse contains the response from method ApplicationsClient.CreateOrUpdate. +type ApplicationsClientCreateOrUpdateResponse struct { + // An integration application under space. + Application +} + +// ApplicationsClientDeleteBusinessProcessDevelopmentArtifactResponse contains the response from method ApplicationsClient.DeleteBusinessProcessDevelopmentArtifact. +type ApplicationsClientDeleteBusinessProcessDevelopmentArtifactResponse struct { + // placeholder for future response values +} + +// ApplicationsClientDeleteResponse contains the response from method ApplicationsClient.Delete. +type ApplicationsClientDeleteResponse struct { + // placeholder for future response values +} + +// ApplicationsClientGetBusinessProcessDevelopmentArtifactResponse contains the response from method ApplicationsClient.GetBusinessProcessDevelopmentArtifact. +type ApplicationsClientGetBusinessProcessDevelopmentArtifactResponse struct { + // The business process development artifact save or get response. + SaveOrGetBusinessProcessDevelopmentArtifactResponse +} + +// ApplicationsClientGetResponse contains the response from method ApplicationsClient.Get. +type ApplicationsClientGetResponse struct { + // An integration application under space. + Application +} + +// ApplicationsClientListBusinessProcessDevelopmentArtifactsResponse contains the response from method ApplicationsClient.ListBusinessProcessDevelopmentArtifacts. +type ApplicationsClientListBusinessProcessDevelopmentArtifactsResponse struct { + // The business process development artifact get collection response. + ListBusinessProcessDevelopmentArtifactsResponse +} + +// ApplicationsClientListBySpaceResponse contains the response from method ApplicationsClient.NewListBySpacePager. +type ApplicationsClientListBySpaceResponse struct { + // The response of a Application list operation. + ApplicationListResult +} + +// ApplicationsClientPatchResponse contains the response from method ApplicationsClient.Patch. +type ApplicationsClientPatchResponse struct { + // An integration application under space. + Application +} + +// ApplicationsClientSaveBusinessProcessDevelopmentArtifactResponse contains the response from method ApplicationsClient.SaveBusinessProcessDevelopmentArtifact. +type ApplicationsClientSaveBusinessProcessDevelopmentArtifactResponse struct { + // The business process development artifact save or get response. + SaveOrGetBusinessProcessDevelopmentArtifactResponse +} + +// ApplicationsClientValidateBusinessProcessDevelopmentArtifactResponse contains the response from method ApplicationsClient.ValidateBusinessProcessDevelopmentArtifact. +type ApplicationsClientValidateBusinessProcessDevelopmentArtifactResponse struct { + // placeholder for future response values +} + +// BusinessProcessVersionsClientGetResponse contains the response from method BusinessProcessVersionsClient.Get. +type BusinessProcessVersionsClientGetResponse struct { + // A business process version. + BusinessProcessVersion +} + +// BusinessProcessVersionsClientListByBusinessProcessResponse contains the response from method BusinessProcessVersionsClient.NewListByBusinessProcessPager. +type BusinessProcessVersionsClientListByBusinessProcessResponse struct { + // The response of a BusinessProcessVersion list operation. + BusinessProcessVersionListResult +} + +// BusinessProcessesClientCreateOrUpdateResponse contains the response from method BusinessProcessesClient.CreateOrUpdate. +type BusinessProcessesClientCreateOrUpdateResponse struct { + // A business process under application. + BusinessProcess +} + +// BusinessProcessesClientDeleteResponse contains the response from method BusinessProcessesClient.Delete. +type BusinessProcessesClientDeleteResponse struct { + // placeholder for future response values +} + +// BusinessProcessesClientGetResponse contains the response from method BusinessProcessesClient.Get. +type BusinessProcessesClientGetResponse struct { + // A business process under application. + BusinessProcess +} + +// BusinessProcessesClientListByApplicationResponse contains the response from method BusinessProcessesClient.NewListByApplicationPager. +type BusinessProcessesClientListByApplicationResponse struct { + // The response of a BusinessProcess list operation. + BusinessProcessListResult +} + +// BusinessProcessesClientPatchResponse contains the response from method BusinessProcessesClient.Patch. +type BusinessProcessesClientPatchResponse struct { + // A business process under application. + BusinessProcess +} + +// InfrastructureResourcesClientCreateOrUpdateResponse contains the response from method InfrastructureResourcesClient.CreateOrUpdate. +type InfrastructureResourcesClientCreateOrUpdateResponse struct { + // An infrastructure resource under Space. + InfrastructureResource +} + +// InfrastructureResourcesClientDeleteResponse contains the response from method InfrastructureResourcesClient.Delete. +type InfrastructureResourcesClientDeleteResponse struct { + // placeholder for future response values +} + +// InfrastructureResourcesClientGetResponse contains the response from method InfrastructureResourcesClient.Get. +type InfrastructureResourcesClientGetResponse struct { + // An infrastructure resource under Space. + InfrastructureResource +} + +// InfrastructureResourcesClientListBySpaceResponse contains the response from method InfrastructureResourcesClient.NewListBySpacePager. +type InfrastructureResourcesClientListBySpaceResponse struct { + // The response of a InfrastructureResource list operation. + InfrastructureResourceListResult +} + +// InfrastructureResourcesClientPatchResponse contains the response from method InfrastructureResourcesClient.Patch. +type InfrastructureResourcesClientPatchResponse struct { + // An infrastructure resource under Space. + InfrastructureResource +} + +// 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 +} + +// SpacesClientCreateOrUpdateResponse contains the response from method SpacesClient.CreateOrUpdate. +type SpacesClientCreateOrUpdateResponse struct { + // An integration space. + Space +} + +// SpacesClientDeleteResponse contains the response from method SpacesClient.Delete. +type SpacesClientDeleteResponse struct { + // placeholder for future response values +} + +// SpacesClientGetResponse contains the response from method SpacesClient.Get. +type SpacesClientGetResponse struct { + // An integration space. + Space +} + +// SpacesClientListByResourceGroupResponse contains the response from method SpacesClient.NewListByResourceGroupPager. +type SpacesClientListByResourceGroupResponse struct { + // The response of a Space list operation. + SpaceListResult +} + +// SpacesClientListBySubscriptionResponse contains the response from method SpacesClient.NewListBySubscriptionPager. +type SpacesClientListBySubscriptionResponse struct { + // The response of a Space list operation. + SpaceListResult +} + +// SpacesClientPatchResponse contains the response from method SpacesClient.Patch. +type SpacesClientPatchResponse struct { + // An integration space. + Space +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/spaces_client.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/spaces_client.go new file mode 100644 index 000000000000..47e39bb36b51 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/spaces_client.go @@ -0,0 +1,441 @@ +//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 armintegrationspaces + +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" + "strconv" + "strings" +) + +// SpacesClient contains the methods for the Spaces group. +// Don't use this type directly, use NewSpacesClient() instead. +type SpacesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewSpacesClient creates a new instance of SpacesClient 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 NewSpacesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SpacesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &SpacesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CreateOrUpdate - Create a Space +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - resource - Resource create parameters. +// - options - SpacesClientCreateOrUpdateOptions contains the optional parameters for the SpacesClient.CreateOrUpdate method. +func (client *SpacesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, spaceName string, resource Space, options *SpacesClientCreateOrUpdateOptions) (SpacesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "SpacesClient.CreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, spaceName, resource, options) + if err != nil { + return SpacesClientCreateOrUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SpacesClientCreateOrUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return SpacesClientCreateOrUpdateResponse{}, err + } + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *SpacesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, resource Space, options *SpacesClientCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *SpacesClient) createOrUpdateHandleResponse(resp *http.Response) (SpacesClientCreateOrUpdateResponse, error) { + result := SpacesClientCreateOrUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Space); err != nil { + return SpacesClientCreateOrUpdateResponse{}, err + } + return result, nil +} + +// Delete - Delete a Space +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - options - SpacesClientDeleteOptions contains the optional parameters for the SpacesClient.Delete method. +func (client *SpacesClient) Delete(ctx context.Context, resourceGroupName string, spaceName string, options *SpacesClientDeleteOptions) (SpacesClientDeleteResponse, error) { + var err error + const operationName = "SpacesClient.Delete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, spaceName, options) + if err != nil { + return SpacesClientDeleteResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SpacesClientDeleteResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return SpacesClientDeleteResponse{}, err + } + return SpacesClientDeleteResponse{}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *SpacesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, options *SpacesClientDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a Space +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - options - SpacesClientGetOptions contains the optional parameters for the SpacesClient.Get method. +func (client *SpacesClient) Get(ctx context.Context, resourceGroupName string, spaceName string, options *SpacesClientGetOptions) (SpacesClientGetResponse, error) { + var err error + const operationName = "SpacesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, spaceName, options) + if err != nil { + return SpacesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SpacesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SpacesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *SpacesClient) getCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, options *SpacesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SpacesClient) getHandleResponse(resp *http.Response) (SpacesClientGetResponse, error) { + result := SpacesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Space); err != nil { + return SpacesClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List Space resources by resource group +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - SpacesClientListByResourceGroupOptions contains the optional parameters for the SpacesClient.NewListByResourceGroupPager +// method. +func (client *SpacesClient) NewListByResourceGroupPager(resourceGroupName string, options *SpacesClientListByResourceGroupOptions) *runtime.Pager[SpacesClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[SpacesClientListByResourceGroupResponse]{ + More: func(page SpacesClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SpacesClientListByResourceGroupResponse) (SpacesClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SpacesClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return SpacesClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *SpacesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *SpacesClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + if options != nil && options.Top != nil { + reqQP.Set("top", strconv.FormatInt(int64(*options.Top), 10)) + } + if options != nil && options.Skip != nil { + reqQP.Set("skip", strconv.FormatInt(int64(*options.Skip), 10)) + } + if options != nil && options.Maxpagesize != nil { + reqQP.Set("maxpagesize", strconv.FormatInt(int64(*options.Maxpagesize), 10)) + } + if options != nil && options.Filter != nil { + reqQP.Set("filter", *options.Filter) + } + if options != nil && options.Select != nil { + for _, qv := range options.Select { + reqQP.Add("select", qv) + } + } + if options != nil && options.Expand != nil { + for _, qv := range options.Expand { + reqQP.Add("expand", qv) + } + } + if options != nil && options.Orderby != nil { + for _, qv := range options.Orderby { + reqQP.Add("orderby", qv) + } + } + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *SpacesClient) listByResourceGroupHandleResponse(resp *http.Response) (SpacesClientListByResourceGroupResponse, error) { + result := SpacesClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SpaceListResult); err != nil { + return SpacesClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List Space resources by subscription ID +// +// Generated from API version 2023-11-14-preview +// - options - SpacesClientListBySubscriptionOptions contains the optional parameters for the SpacesClient.NewListBySubscriptionPager +// method. +func (client *SpacesClient) NewListBySubscriptionPager(options *SpacesClientListBySubscriptionOptions) *runtime.Pager[SpacesClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[SpacesClientListBySubscriptionResponse]{ + More: func(page SpacesClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *SpacesClientListBySubscriptionResponse) (SpacesClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SpacesClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return SpacesClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *SpacesClient) listBySubscriptionCreateRequest(ctx context.Context, options *SpacesClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.IntegrationSpaces/spaces" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *SpacesClient) listBySubscriptionHandleResponse(resp *http.Response) (SpacesClientListBySubscriptionResponse, error) { + result := SpacesClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.SpaceListResult); err != nil { + return SpacesClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// Patch - Update a Space +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2023-11-14-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - spaceName - The name of the space +// - properties - The resource properties to be updated. +// - options - SpacesClientPatchOptions contains the optional parameters for the SpacesClient.Patch method. +func (client *SpacesClient) Patch(ctx context.Context, resourceGroupName string, spaceName string, properties SpaceUpdate, options *SpacesClientPatchOptions) (SpacesClientPatchResponse, error) { + var err error + const operationName = "SpacesClient.Patch" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.patchCreateRequest(ctx, resourceGroupName, spaceName, properties, options) + if err != nil { + return SpacesClientPatchResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return SpacesClientPatchResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SpacesClientPatchResponse{}, err + } + resp, err := client.patchHandleResponse(httpResp) + return resp, err +} + +// patchCreateRequest creates the Patch request. +func (client *SpacesClient) patchCreateRequest(ctx context.Context, resourceGroupName string, spaceName string, properties SpaceUpdate, options *SpacesClientPatchOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.IntegrationSpaces/spaces/{spaceName}" + 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 spaceName == "" { + return nil, errors.New("parameter spaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{spaceName}", url.PathEscape(spaceName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2023-11-14-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// patchHandleResponse handles the Patch response. +func (client *SpacesClient) patchHandleResponse(resp *http.Response) (SpacesClientPatchResponse, error) { + result := SpacesClientPatchResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Space); err != nil { + return SpacesClientPatchResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/spaces_client_example_test.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/spaces_client_example_test.go new file mode 100644 index 000000000000..2069fb8f0f2d --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/spaces_client_example_test.go @@ -0,0 +1,239 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// DO NOT EDIT. + +package armintegrationspaces_test + +import ( + "context" + "log" + + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/integrationspaces/armintegrationspaces" +) + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Spaces_ListBySubscription.json +func ExampleSpacesClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSpacesClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SpaceListResult = armintegrationspaces.SpaceListResult{ + // Value: []*armintegrationspaces.Space{ + // { + // Name: to.Ptr("Space1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1"), + // Location: to.Ptr("CentralUS"), + // Tags: map[string]*string{ + // "key1": to.Ptr("Value1"), + // }, + // Properties: &armintegrationspaces.SpaceResourceProperties{ + // Description: to.Ptr("This is the user provided description of the space resource."), + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Spaces_ListByResourceGroup.json +func ExampleSpacesClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewSpacesClient().NewListByResourceGroupPager("testrg", &armintegrationspaces.SpacesClientListByResourceGroupOptions{Top: nil, + Skip: nil, + Maxpagesize: nil, + Filter: nil, + Select: []string{}, + Expand: []string{}, + Orderby: []string{}, + }) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page.SpaceListResult = armintegrationspaces.SpaceListResult{ + // Value: []*armintegrationspaces.Space{ + // { + // Name: to.Ptr("Space1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1"), + // Location: to.Ptr("CentralUS"), + // Tags: map[string]*string{ + // "key1": to.Ptr("Value1"), + // }, + // Properties: &armintegrationspaces.SpaceResourceProperties{ + // Description: to.Ptr("This is the user provided description of the space resource."), + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // }, + // }}, + // } + } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Spaces_Get.json +func ExampleSpacesClient_Get() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSpacesClient().Get(ctx, "testrg", "Space1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Space = armintegrationspaces.Space{ + // Name: to.Ptr("Space1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1"), + // Location: to.Ptr("CentralUS"), + // Tags: map[string]*string{ + // "key1": to.Ptr("Value1"), + // }, + // Properties: &armintegrationspaces.SpaceResourceProperties{ + // Description: to.Ptr("This is the user provided description of the space resource."), + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Spaces_CreateOrUpdate.json +func ExampleSpacesClient_CreateOrUpdate() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSpacesClient().CreateOrUpdate(ctx, "testrg", "Space1", armintegrationspaces.Space{ + Location: to.Ptr("CentralUS"), + Tags: map[string]*string{ + "key1": to.Ptr("Value1"), + }, + Properties: &armintegrationspaces.SpaceResourceProperties{ + Description: to.Ptr("This is the user provided description of the space resource."), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Space = armintegrationspaces.Space{ + // Name: to.Ptr("Space1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1"), + // Location: to.Ptr("CentralUS"), + // Tags: map[string]*string{ + // "key1": to.Ptr("Value1"), + // }, + // Properties: &armintegrationspaces.SpaceResourceProperties{ + // Description: to.Ptr("This is the user provided description of the space resource."), + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Spaces_Patch.json +func ExampleSpacesClient_Patch() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewSpacesClient().Patch(ctx, "testrg", "Space1", armintegrationspaces.SpaceUpdate{ + Properties: &armintegrationspaces.SpaceUpdateProperties{ + Description: to.Ptr("This is the user provided description of the space resource."), + }, + Tags: map[string]*string{ + "key1": to.Ptr("Value1"), + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res.Space = armintegrationspaces.Space{ + // Name: to.Ptr("Space1"), + // Type: to.Ptr("Microsoft.IntegrationSpaces/spaces"), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testrg/providers/Microsoft.IntegrationSpaces/spaces/Space1"), + // Location: to.Ptr("CentralUS"), + // Tags: map[string]*string{ + // "key1": to.Ptr("Value1"), + // }, + // Properties: &armintegrationspaces.SpaceResourceProperties{ + // Description: to.Ptr("This is the user provided description of the space resource."), + // ProvisioningState: to.Ptr(armintegrationspaces.ProvisioningStateSucceeded), + // }, + // } +} + +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/db9788dde7a0c2c0d82e4fdf5f7b4de3843937e3/specification/azureintegrationspaces/resource-manager/Microsoft.IntegrationSpaces/preview/2023-11-14-preview/examples/Spaces_Delete.json +func ExampleSpacesClient_Delete() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armintegrationspaces.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + _, err = clientFactory.NewSpacesClient().Delete(ctx, "testrg", "Space1", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } +} diff --git a/sdk/resourcemanager/integrationspaces/armintegrationspaces/time_rfc3339.go b/sdk/resourcemanager/integrationspaces/armintegrationspaces/time_rfc3339.go new file mode 100644 index 000000000000..ba3688b31249 --- /dev/null +++ b/sdk/resourcemanager/integrationspaces/armintegrationspaces/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 armintegrationspaces + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +}