diff --git a/sdk/resourcemanager/resourceconnector/armresourceconnector/CHANGELOG.md b/sdk/resourcemanager/resourceconnector/armresourceconnector/CHANGELOG.md new file mode 100644 index 000000000000..ab4c3a2a9bd2 --- /dev/null +++ b/sdk/resourcemanager/resourceconnector/armresourceconnector/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (2022-06-10) + +- Init release. \ No newline at end of file diff --git a/sdk/resourcemanager/resourceconnector/armresourceconnector/LICENSE.txt b/sdk/resourcemanager/resourceconnector/armresourceconnector/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/resourceconnector/armresourceconnector/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/resourceconnector/armresourceconnector/README.md b/sdk/resourcemanager/resourceconnector/armresourceconnector/README.md new file mode 100644 index 000000000000..adb22f134fad --- /dev/null +++ b/sdk/resourcemanager/resourceconnector/armresourceconnector/README.md @@ -0,0 +1,77 @@ +# Azure Resourceconnector Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourceconnector/armresourceconnector)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourceconnector/armresourceconnector) + +The `armresourceconnector` module provides operations for working with Azure Resourceconnector. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/resourceconnector/armresourceconnector) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Resourceconnector module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourceconnector/armresourceconnector +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Resourceconnector. 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). + +## Clients + +Azure Resourceconnector modules consist of one or more clients. A client groups a set of related APIs, providing access to its functionality within the specified subscription. Create one or more clients to access the APIs you require using your credential. + +```go +client, err := armresourceconnector.NewAppliancesClient(, 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, + }, +} +client, err := armresourceconnector.NewAppliancesClient(, cred, &options) +``` + +## 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 `Resourceconnector` 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/resourceconnector/armresourceconnector/autorest.md b/sdk/resourcemanager/resourceconnector/armresourceconnector/autorest.md new file mode 100644 index 000000000000..38019935ee3b --- /dev/null +++ b/sdk/resourcemanager/resourceconnector/armresourceconnector/autorest.md @@ -0,0 +1,13 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +azure-arm: true +require: +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resourceconnector/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/resourceconnector/resource-manager/readme.go.md +license-header: MICROSOFT_MIT_NO_VERSION +module-version: 0.1.0 + +``` \ No newline at end of file diff --git a/sdk/resourcemanager/resourceconnector/armresourceconnector/build.go b/sdk/resourcemanager/resourceconnector/armresourceconnector/build.go new file mode 100644 index 000000000000..eff9daf6e5e3 --- /dev/null +++ b/sdk/resourcemanager/resourceconnector/armresourceconnector/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.exe ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate resourcemanager/resourceconnector/armresourceconnector + +package armresourceconnector diff --git a/sdk/resourcemanager/resourceconnector/armresourceconnector/ci.yml b/sdk/resourcemanager/resourceconnector/armresourceconnector/ci.yml new file mode 100644 index 000000000000..369158d32abe --- /dev/null +++ b/sdk/resourcemanager/resourceconnector/armresourceconnector/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/resourceconnector/armresourceconnector/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/resourceconnector/armresourceconnector/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + IncludeRelease: true + ServiceDirectory: 'resourcemanager/resourceconnector/armresourceconnector' diff --git a/sdk/resourcemanager/resourceconnector/armresourceconnector/go.mod b/sdk/resourcemanager/resourceconnector/armresourceconnector/go.mod new file mode 100644 index 000000000000..2229330bbe45 --- /dev/null +++ b/sdk/resourcemanager/resourceconnector/armresourceconnector/go.mod @@ -0,0 +1,11 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourceconnector/armresourceconnector + +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect + golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 // indirect + golang.org/x/text v0.3.7 // indirect +) diff --git a/sdk/resourcemanager/resourceconnector/armresourceconnector/go.sum b/sdk/resourcemanager/resourceconnector/armresourceconnector/go.sum new file mode 100644 index 000000000000..3f874a3bc5a6 --- /dev/null +++ b/sdk/resourcemanager/resourceconnector/armresourceconnector/go.sum @@ -0,0 +1,12 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0 h1:sVPhtT2qjO86rTUaWMr4WoES4TkjGnzcioXcnHV9s5k= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 h1:jp0dGvZ7ZK0mgqnTSClMxa5xuRL7NZgHameVYF6BurY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= diff --git a/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_appliances_client.go b/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_appliances_client.go new file mode 100644 index 000000000000..3ebfdb28b770 --- /dev/null +++ b/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_appliances_client.go @@ -0,0 +1,538 @@ +//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. + +package armresourceconnector + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// AppliancesClient contains the methods for the Appliances group. +// Don't use this type directly, use NewAppliancesClient() instead. +type AppliancesClient struct { + host string + subscriptionID string + pl runtime.Pipeline +} + +// NewAppliancesClient creates a new instance of AppliancesClient 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 NewAppliancesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AppliancesClient, error) { + if options == nil { + options = &arm.ClientOptions{} + } + ep := cloud.AzurePublic.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err + } + client := &AppliancesClient{ + subscriptionID: subscriptionID, + host: ep, + pl: pl, + } + return client, nil +} + +// BeginCreateOrUpdate - Creates or updates an Appliance in the specified Subscription and Resource Group. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-10-31-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - Appliances name. +// parameters - Parameters supplied to create or update an Appliance. +// options - AppliancesClientBeginCreateOrUpdateOptions contains the optional parameters for the AppliancesClient.BeginCreateOrUpdate +// method. +func (client *AppliancesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters Appliance, options *AppliancesClientBeginCreateOrUpdateOptions) (*runtime.Poller[AppliancesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, resourceName, parameters, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AppliancesClientCreateOrUpdateResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[AppliancesClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Creates or updates an Appliance in the specified Subscription and Resource Group. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-10-31-preview +func (client *AppliancesClient) createOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters Appliance, options *AppliancesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AppliancesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters Appliance, options *AppliancesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ResourceConnector/appliances/{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 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-10-31-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// BeginDelete - Deletes an Appliance with the specified Resource Name, Resource Group, and Subscription Id. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-10-31-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - Appliances name. +// options - AppliancesClientBeginDeleteOptions contains the optional parameters for the AppliancesClient.BeginDelete method. +func (client *AppliancesClient) BeginDelete(ctx context.Context, resourceGroupName string, resourceName string, options *AppliancesClientBeginDeleteOptions) (*runtime.Poller[AppliancesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, resourceName, options) + if err != nil { + return nil, err + } + return runtime.NewPoller(resp, client.pl, &runtime.NewPollerOptions[AppliancesClientDeleteResponse]{ + FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + }) + } else { + return runtime.NewPollerFromResumeToken[AppliancesClientDeleteResponse](options.ResumeToken, client.pl, nil) + } +} + +// Delete - Deletes an Appliance with the specified Resource Name, Resource Group, and Subscription Id. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-10-31-preview +func (client *AppliancesClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, options *AppliancesClientBeginDeleteOptions) (*http.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return nil, err + } + resp, err := client.pl.Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) { + return nil, runtime.NewResponseError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AppliancesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *AppliancesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ResourceConnector/appliances/{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 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-10-31-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Gets the details of an Appliance with a specified resource group and name. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-10-31-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - Appliances name. +// options - AppliancesClientGetOptions contains the optional parameters for the AppliancesClient.Get method. +func (client *AppliancesClient) Get(ctx context.Context, resourceGroupName string, resourceName string, options *AppliancesClientGetOptions) (AppliancesClientGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return AppliancesClientGetResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AppliancesClientGetResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AppliancesClientGetResponse{}, runtime.NewResponseError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AppliancesClient) getCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *AppliancesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ResourceConnector/appliances/{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 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-10-31-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AppliancesClient) getHandleResponse(resp *http.Response) (AppliancesClientGetResponse, error) { + result := AppliancesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Appliance); err != nil { + return AppliancesClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - Gets a list of Appliances in the specified subscription and resource group. The operation +// returns properties of each Appliance. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-10-31-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// options - AppliancesClientListByResourceGroupOptions contains the optional parameters for the AppliancesClient.ListByResourceGroup +// method. +func (client *AppliancesClient) NewListByResourceGroupPager(resourceGroupName string, options *AppliancesClientListByResourceGroupOptions) *runtime.Pager[AppliancesClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[AppliancesClientListByResourceGroupResponse]{ + More: func(page AppliancesClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AppliancesClientListByResourceGroupResponse) (AppliancesClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AppliancesClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AppliancesClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AppliancesClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) + }, + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *AppliancesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *AppliancesClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ResourceConnector/appliances" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-10-31-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *AppliancesClient) listByResourceGroupHandleResponse(resp *http.Response) (AppliancesClientListByResourceGroupResponse, error) { + result := AppliancesClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ApplianceListResult); err != nil { + return AppliancesClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - Gets a list of Appliances in the specified subscription. The operation returns properties +// of each Appliance +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-10-31-preview +// options - AppliancesClientListBySubscriptionOptions contains the optional parameters for the AppliancesClient.ListBySubscription +// method. +func (client *AppliancesClient) NewListBySubscriptionPager(options *AppliancesClientListBySubscriptionOptions) *runtime.Pager[AppliancesClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[AppliancesClientListBySubscriptionResponse]{ + More: func(page AppliancesClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AppliancesClientListBySubscriptionResponse) (AppliancesClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AppliancesClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AppliancesClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AppliancesClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) + }, + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *AppliancesClient) listBySubscriptionCreateRequest(ctx context.Context, options *AppliancesClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ResourceConnector/appliances" + 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-10-31-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *AppliancesClient) listBySubscriptionHandleResponse(resp *http.Response) (AppliancesClientListBySubscriptionResponse, error) { + result := AppliancesClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ApplianceListResult); err != nil { + return AppliancesClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// ListClusterUserCredential - Returns the cluster user credentials for the dedicated appliance. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-10-31-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - Appliances name. +// options - AppliancesClientListClusterUserCredentialOptions contains the optional parameters for the AppliancesClient.ListClusterUserCredential +// method. +func (client *AppliancesClient) ListClusterUserCredential(ctx context.Context, resourceGroupName string, resourceName string, options *AppliancesClientListClusterUserCredentialOptions) (AppliancesClientListClusterUserCredentialResponse, error) { + req, err := client.listClusterUserCredentialCreateRequest(ctx, resourceGroupName, resourceName, options) + if err != nil { + return AppliancesClientListClusterUserCredentialResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AppliancesClientListClusterUserCredentialResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AppliancesClientListClusterUserCredentialResponse{}, runtime.NewResponseError(resp) + } + return client.listClusterUserCredentialHandleResponse(resp) +} + +// listClusterUserCredentialCreateRequest creates the ListClusterUserCredential request. +func (client *AppliancesClient) listClusterUserCredentialCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, options *AppliancesClientListClusterUserCredentialOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ResourceConnector/appliances/{resourceName}/listClusterUserCredential" + 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 resourceName == "" { + return nil, errors.New("parameter resourceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceName}", url.PathEscape(resourceName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-10-31-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listClusterUserCredentialHandleResponse handles the ListClusterUserCredential response. +func (client *AppliancesClient) listClusterUserCredentialHandleResponse(resp *http.Response) (AppliancesClientListClusterUserCredentialResponse, error) { + result := AppliancesClientListClusterUserCredentialResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ApplianceListCredentialResults); err != nil { + return AppliancesClientListClusterUserCredentialResponse{}, err + } + return result, nil +} + +// NewListOperationsPager - Lists all available Appliances operations. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-10-31-preview +// options - AppliancesClientListOperationsOptions contains the optional parameters for the AppliancesClient.ListOperations +// method. +func (client *AppliancesClient) NewListOperationsPager(options *AppliancesClientListOperationsOptions) *runtime.Pager[AppliancesClientListOperationsResponse] { + return runtime.NewPager(runtime.PagingHandler[AppliancesClientListOperationsResponse]{ + More: func(page AppliancesClientListOperationsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *AppliancesClientListOperationsResponse) (AppliancesClientListOperationsResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listOperationsCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return AppliancesClientListOperationsResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AppliancesClientListOperationsResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AppliancesClientListOperationsResponse{}, runtime.NewResponseError(resp) + } + return client.listOperationsHandleResponse(resp) + }, + }) +} + +// listOperationsCreateRequest creates the ListOperations request. +func (client *AppliancesClient) listOperationsCreateRequest(ctx context.Context, options *AppliancesClientListOperationsOptions) (*policy.Request, error) { + urlPath := "/providers/Microsoft.ResourceConnector/operations" + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-10-31-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listOperationsHandleResponse handles the ListOperations response. +func (client *AppliancesClient) listOperationsHandleResponse(resp *http.Response) (AppliancesClientListOperationsResponse, error) { + result := AppliancesClientListOperationsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.ApplianceOperationsList); err != nil { + return AppliancesClientListOperationsResponse{}, err + } + return result, nil +} + +// Update - Updates an Appliance with the specified Resource Name in the specified Resource Group and Subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// Generated from API version 2021-10-31-preview +// resourceGroupName - The name of the resource group. The name is case insensitive. +// resourceName - Appliances name. +// parameters - The updatable fields of an existing Appliance. +// options - AppliancesClientUpdateOptions contains the optional parameters for the AppliancesClient.Update method. +func (client *AppliancesClient) Update(ctx context.Context, resourceGroupName string, resourceName string, parameters PatchableAppliance, options *AppliancesClientUpdateOptions) (AppliancesClientUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, resourceName, parameters, options) + if err != nil { + return AppliancesClientUpdateResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return AppliancesClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return AppliancesClientUpdateResponse{}, runtime.NewResponseError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *AppliancesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, resourceName string, parameters PatchableAppliance, options *AppliancesClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ResourceConnector/appliances/{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 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.host, urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2021-10-31-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, runtime.MarshalAsJSON(req, parameters) +} + +// updateHandleResponse handles the Update response. +func (client *AppliancesClient) updateHandleResponse(resp *http.Response) (AppliancesClientUpdateResponse, error) { + result := AppliancesClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Appliance); err != nil { + return AppliancesClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_constants.go b/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_constants.go new file mode 100644 index 000000000000..e05be859510c --- /dev/null +++ b/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_constants.go @@ -0,0 +1,116 @@ +//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. + +package armresourceconnector + +const ( + moduleName = "armresourceconnector" + moduleVersion = "v0.1.0" +) + +// AccessProfileType - Name which contains the role of the kubeconfig. +type AccessProfileType string + +const ( + AccessProfileTypeClusterUser AccessProfileType = "clusterUser" +) + +// PossibleAccessProfileTypeValues returns the possible values for the AccessProfileType const type. +func PossibleAccessProfileTypeValues() []AccessProfileType { + return []AccessProfileType{ + AccessProfileTypeClusterUser, + } +} + +// 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, + } +} + +// Distro - Represents a supported Fabric/Infra. (AKSEdge etc…). +type Distro string + +const ( + DistroAKSEdge Distro = "AKSEdge" +) + +// PossibleDistroValues returns the possible values for the Distro const type. +func PossibleDistroValues() []Distro { + return []Distro{ + DistroAKSEdge, + } +} + +// Provider - Information about the connected appliance. +type Provider string + +const ( + ProviderHCI Provider = "HCI" + ProviderSCVMM Provider = "SCVMM" + ProviderVMWare Provider = "VMWare" +) + +// PossibleProviderValues returns the possible values for the Provider const type. +func PossibleProviderValues() []Provider { + return []Provider{ + ProviderHCI, + ProviderSCVMM, + ProviderVMWare, + } +} + +// ResourceIdentityType - The identity type. +type ResourceIdentityType string + +const ( + ResourceIdentityTypeNone ResourceIdentityType = "None" + ResourceIdentityTypeSystemAssigned ResourceIdentityType = "SystemAssigned" +) + +// PossibleResourceIdentityTypeValues returns the possible values for the ResourceIdentityType const type. +func PossibleResourceIdentityTypeValues() []ResourceIdentityType { + return []ResourceIdentityType{ + ResourceIdentityTypeNone, + ResourceIdentityTypeSystemAssigned, + } +} + +// Status - Appliance’s health and state of connection to on-prem +type Status string + +const ( + StatusConnected Status = "Connected" + StatusRunning Status = "Running" + StatusValidating Status = "Validating" + StatusWaitingForHeartbeat Status = "WaitingForHeartbeat" +) + +// PossibleStatusValues returns the possible values for the Status const type. +func PossibleStatusValues() []Status { + return []Status{ + StatusConnected, + StatusRunning, + StatusValidating, + StatusWaitingForHeartbeat, + } +} diff --git a/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_models.go b/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_models.go new file mode 100644 index 000000000000..b692b439488c --- /dev/null +++ b/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_models.go @@ -0,0 +1,296 @@ +//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. + +package armresourceconnector + +import "time" + +// Appliances definition. +type Appliance struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Identity for the resource. + Identity *Identity `json:"identity,omitempty"` + + // The set of properties specific to an Appliance + Properties *ApplianceProperties `json:"properties,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Metadata pertaining to creation and last modification of the resource + SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ApplianceCredentialKubeconfig - Cluster User Credential appliance. +type ApplianceCredentialKubeconfig struct { + // READ-ONLY; Name which contains the role of the kubeconfig. + Name *AccessProfileType `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Contains the kubeconfig value. + Value *string `json:"value,omitempty" azure:"ro"` +} + +// ApplianceListCredentialResults - The List Cluster User Credential appliance. +type ApplianceListCredentialResults struct { + // READ-ONLY; Contains the REP (rendezvous endpoint) and “Listener” access token from notification service (NS). + HybridConnectionConfig *HybridConnectionConfig `json:"hybridConnectionConfig,omitempty" azure:"ro"` + + // READ-ONLY; The list of appliance kubeconfigs. + Kubeconfigs []*ApplianceCredentialKubeconfig `json:"kubeconfigs,omitempty" azure:"ro"` +} + +// ApplianceListResult - The List Appliances operation response. +type ApplianceListResult struct { + // READ-ONLY; The URL to use for getting the next set of results. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; The list of Appliances. + Value []*Appliance `json:"value,omitempty" azure:"ro"` +} + +// ApplianceOperation - Appliances operation. +type ApplianceOperation struct { + // Describes the properties of an Appliances Operation Value Display. + Display *ApplianceOperationValueDisplay `json:"display,omitempty"` + + // READ-ONLY; Is this Operation a data plane operation + IsDataAction *bool `json:"isDataAction,omitempty" azure:"ro"` + + // READ-ONLY; The name of the compute operation. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The origin of the compute operation. + Origin *string `json:"origin,omitempty" azure:"ro"` +} + +// ApplianceOperationValueDisplay - Describes the properties of an Appliances Operation Value Display. +type ApplianceOperationValueDisplay struct { + // READ-ONLY; The description of the operation. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; The display name of the compute operation. + Operation *string `json:"operation,omitempty" azure:"ro"` + + // READ-ONLY; The resource provider for the operation. + Provider *string `json:"provider,omitempty" azure:"ro"` + + // READ-ONLY; The display name of the resource the operation applies to. + Resource *string `json:"resource,omitempty" azure:"ro"` +} + +// ApplianceOperationsList - Lists of Appliances operations. +type ApplianceOperationsList struct { + // REQUIRED; Array of applianceOperation + Value []*ApplianceOperation `json:"value,omitempty"` + + // Next page of operations. + NextLink *string `json:"nextLink,omitempty"` +} + +// ApplianceProperties - Properties for an appliance. +type ApplianceProperties struct { + // Represents a supported Fabric/Infra. (AKSEdge etc…). + Distro *Distro `json:"distro,omitempty"` + + // Contains infrastructure information about the Appliance + InfrastructureConfig *AppliancePropertiesInfrastructureConfig `json:"infrastructureConfig,omitempty"` + + // Certificates pair used to download MSI certificate from HIS + PublicKey *string `json:"publicKey,omitempty"` + + // READ-ONLY; The current deployment or provisioning state, which only appears in the response. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Appliance’s health and state of connection to on-prem + Status *Status `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; Version of the Appliance + Version *string `json:"version,omitempty" azure:"ro"` +} + +// AppliancePropertiesInfrastructureConfig - Contains infrastructure information about the Appliance +type AppliancePropertiesInfrastructureConfig struct { + // Information about the connected appliance. + Provider *Provider `json:"provider,omitempty"` +} + +// AppliancesClientBeginCreateOrUpdateOptions contains the optional parameters for the AppliancesClient.BeginCreateOrUpdate +// method. +type AppliancesClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AppliancesClientBeginDeleteOptions contains the optional parameters for the AppliancesClient.BeginDelete method. +type AppliancesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// AppliancesClientGetOptions contains the optional parameters for the AppliancesClient.Get method. +type AppliancesClientGetOptions struct { + // placeholder for future optional parameters +} + +// AppliancesClientListByResourceGroupOptions contains the optional parameters for the AppliancesClient.ListByResourceGroup +// method. +type AppliancesClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// AppliancesClientListBySubscriptionOptions contains the optional parameters for the AppliancesClient.ListBySubscription +// method. +type AppliancesClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// AppliancesClientListClusterUserCredentialOptions contains the optional parameters for the AppliancesClient.ListClusterUserCredential +// method. +type AppliancesClientListClusterUserCredentialOptions struct { + // placeholder for future optional parameters +} + +// AppliancesClientListOperationsOptions contains the optional parameters for the AppliancesClient.ListOperations method. +type AppliancesClientListOperationsOptions struct { + // placeholder for future optional parameters +} + +// AppliancesClientUpdateOptions contains the optional parameters for the AppliancesClient.Update method. +type AppliancesClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// ErrorAdditionalInfo - The resource management error additional info. +type ErrorAdditionalInfo struct { + // READ-ONLY; The additional info. + Info interface{} `json:"info,omitempty" azure:"ro"` + + // READ-ONLY; The additional info type. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// ErrorDetail - The error detail. +type ErrorDetail struct { + // READ-ONLY; The error additional info. + AdditionalInfo []*ErrorAdditionalInfo `json:"additionalInfo,omitempty" azure:"ro"` + + // READ-ONLY; The error code. + Code *string `json:"code,omitempty" azure:"ro"` + + // READ-ONLY; The error details. + Details []*ErrorDetail `json:"details,omitempty" azure:"ro"` + + // READ-ONLY; The error message. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; The error target. + Target *string `json:"target,omitempty" azure:"ro"` +} + +// ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. +// (This also follows the OData error response format.). +type ErrorResponse struct { + // The error object. + Error *ErrorDetail `json:"error,omitempty"` +} + +// HybridConnectionConfig - Contains the REP (rendezvous endpoint) and “Listener” access token from notification service (NS). +type HybridConnectionConfig struct { + // READ-ONLY; Timestamp when this token will be expired. + ExpirationTime *int64 `json:"expirationTime,omitempty" azure:"ro"` + + // READ-ONLY; Name of the connection + HybridConnectionName *string `json:"hybridConnectionName,omitempty" azure:"ro"` + + // READ-ONLY; Name of the notification service. + Relay *string `json:"relay,omitempty" azure:"ro"` + + // READ-ONLY; Listener access token + Token *string `json:"token,omitempty" azure:"ro"` +} + +// Identity for the resource. +type Identity struct { + // The identity type. + Type *ResourceIdentityType `json:"type,omitempty"` + + // READ-ONLY; The principal ID of resource identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// PatchableAppliance - The Appliances patchable resource definition. +type PatchableAppliance struct { + // Resource tags + Tags map[string]*string `json:"tags,omitempty"` +} + +// Resource - Common fields that are returned in the response for all Azure Resource Manager resources +type Resource struct { + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time `json:"createdAt,omitempty"` + + // The identity that created the resource. + CreatedBy *string `json:"createdBy,omitempty"` + + // The type of identity that created the resource. + CreatedByType *CreatedByType `json:"createdByType,omitempty"` + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + + // The identity that last modified the resource. + LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` +} + +// TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' +// and a 'location' +type TrackedResource struct { + // REQUIRED; The geo-location where the resource lives + Location *string `json:"location,omitempty"` + + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; The name of the resource + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string `json:"type,omitempty" azure:"ro"` +} diff --git a/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_models_serde.go b/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_models_serde.go new file mode 100644 index 000000000000..11a0a62ded29 --- /dev/null +++ b/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_models_serde.go @@ -0,0 +1,115 @@ +//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. + +package armresourceconnector + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type Appliance. +func (a Appliance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", a.ID) + populate(objectMap, "identity", a.Identity) + 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) +} + +// MarshalJSON implements the json.Marshaller interface for type PatchableAppliance. +func (p PatchableAppliance) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "tags", p.Tags) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +func populate(m map[string]interface{}, k string, v interface{}) { + 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 interface{}) 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/resourceconnector/armresourceconnector/zz_generated_response_types.go b/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_response_types.go new file mode 100644 index 000000000000..ad649bff1222 --- /dev/null +++ b/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_response_types.go @@ -0,0 +1,49 @@ +//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. + +package armresourceconnector + +// AppliancesClientCreateOrUpdateResponse contains the response from method AppliancesClient.CreateOrUpdate. +type AppliancesClientCreateOrUpdateResponse struct { + Appliance +} + +// AppliancesClientDeleteResponse contains the response from method AppliancesClient.Delete. +type AppliancesClientDeleteResponse struct { + // placeholder for future response values +} + +// AppliancesClientGetResponse contains the response from method AppliancesClient.Get. +type AppliancesClientGetResponse struct { + Appliance +} + +// AppliancesClientListByResourceGroupResponse contains the response from method AppliancesClient.ListByResourceGroup. +type AppliancesClientListByResourceGroupResponse struct { + ApplianceListResult +} + +// AppliancesClientListBySubscriptionResponse contains the response from method AppliancesClient.ListBySubscription. +type AppliancesClientListBySubscriptionResponse struct { + ApplianceListResult +} + +// AppliancesClientListClusterUserCredentialResponse contains the response from method AppliancesClient.ListClusterUserCredential. +type AppliancesClientListClusterUserCredentialResponse struct { + ApplianceListCredentialResults +} + +// AppliancesClientListOperationsResponse contains the response from method AppliancesClient.ListOperations. +type AppliancesClientListOperationsResponse struct { + ApplianceOperationsList +} + +// AppliancesClientUpdateResponse contains the response from method AppliancesClient.Update. +type AppliancesClientUpdateResponse struct { + Appliance +} diff --git a/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_time_rfc3339.go b/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..d05d186da381 --- /dev/null +++ b/sdk/resourcemanager/resourceconnector/armresourceconnector/zz_generated_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. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armresourceconnector + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +const ( + utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` + utcLayout = "2006-01-02T15:04:05.999999999" + rfc3339JSON = `"` + time.RFC3339Nano + `"` +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) + +type timeRFC3339 time.Time + +func (t timeRFC3339) MarshalJSON() (json []byte, err error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t timeRFC3339) MarshalText() (text []byte, err error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *timeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcLayoutJSON + if tzOffsetRegex.Match(data) { + layout = rfc3339JSON + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { + layout := utcLayout + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + return t.Parse(layout, string(data)) +} + +func (t *timeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = timeRFC3339(p) + return err +} + +func populateTimeRFC3339(m map[string]interface{}, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*timeRFC3339)(t) +} + +func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +}