diff --git a/sdk/apimanagement/armapimanagement/CHANGELOG.md b/sdk/apimanagement/armapimanagement/CHANGELOG.md new file mode 100644 index 000000000000..c7196df9ed8b --- /dev/null +++ b/sdk/apimanagement/armapimanagement/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## v0.1.0 (released) diff --git a/sdk/apimanagement/armapimanagement/LICENSE.txt b/sdk/apimanagement/armapimanagement/LICENSE.txt new file mode 100644 index 000000000000..ccb63b166732 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2021 Microsoft + +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/apimanagement/armapimanagement/README.md b/sdk/apimanagement/armapimanagement/README.md new file mode 100644 index 000000000000..ab16822f9fa5 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/README.md @@ -0,0 +1,76 @@ +# Azure API Management Module for Go + +[![PkgGoDev](https://pkg.go.dev/badge/github.com/Azure/azure-sdk-for-go/sdk/apimanagement/armapimanagement)](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/apimanagement/armapimanagement) + +The `armapimanagement` module provides operations for working with Azure API Management. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/apimanagement/armapimanagement) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.13 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 API Management module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/apimanagement/armapimanagement +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure API Management. 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). + +## Connecting to Azure API Management + +Once you have a credential, create a connection to the desired ARM endpoint. The `armcore` module provides facilities for connecting with ARM endpoints including public and sovereign clouds as well as Azure Stack. + +```go +con := armcore.NewDefaultConnection(cred, nil) +``` + +For more information on ARM connections, please see the documentation for `armcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/armcore). + +## Clients + +Azure API Management 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 `armcore.Connection`. + +```go +client := armapimanagement.NewAPIClient(con, "") +``` + +## 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 `API Management` 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/apimanagement/armapimanagement/autorest.md b/sdk/apimanagement/armapimanagement/autorest.md new file mode 100644 index 000000000000..0c47526d3e5f --- /dev/null +++ b/sdk/apimanagement/armapimanagement/autorest.md @@ -0,0 +1,10 @@ +### AutoRest Configuration + +> see https://aka.ms/autorest + +``` yaml +require: +- https://github.com/Azure/azure-rest-api-specs/blob/8b708ea0e665144ad1fe691fc7cca33517ac3c7e/specification/apimanagement/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/8b708ea0e665144ad1fe691fc7cca33517ac3c7e/specification/apimanagement/resource-manager/readme.go.md +module-version: 0.1.0 +``` \ No newline at end of file diff --git a/sdk/apimanagement/armapimanagement/build.go b/sdk/apimanagement/armapimanagement/build.go new file mode 100644 index 000000000000..8459581f6948 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/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 -format -tidy -generate armapimanagement + +package armapimanagement diff --git a/sdk/apimanagement/armapimanagement/ci.yml b/sdk/apimanagement/armapimanagement/ci.yml new file mode 100644 index 000000000000..1d66df37dcd7 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/ci.yml @@ -0,0 +1,15 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + paths: + include: + - sdk/apimanagement/armapimanagement/ + +pr: + paths: + include: + - sdk/apimanagement/armapimanagement/ + +stages: +- template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'apimanagement/armapimanagement' diff --git a/sdk/apimanagement/armapimanagement/go.mod b/sdk/apimanagement/armapimanagement/go.mod new file mode 100644 index 000000000000..f581ed894c01 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/go.mod @@ -0,0 +1,9 @@ +module github.com/Azure/azure-sdk-for-go/sdk/apimanagement/armapimanagement + +go 1.13 + +require ( + github.com/Azure/azure-sdk-for-go v56.1.0+incompatible + github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2 +) diff --git a/sdk/apimanagement/armapimanagement/go.sum b/sdk/apimanagement/armapimanagement/go.sum new file mode 100644 index 000000000000..9e02912957fd --- /dev/null +++ b/sdk/apimanagement/armapimanagement/go.sum @@ -0,0 +1,20 @@ +github.com/Azure/azure-sdk-for-go v56.1.0+incompatible h1:Ofcecdw3F1ZqnpDEZcLzH9Hq0P4Y5Si8+EioXJSamJs= +github.com/Azure/azure-sdk-for-go v56.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0 h1:HQQoaSGOh32mpoRkpLDjkngMwYJqkxu93FRx0epdLHE= +github.com/Azure/azure-sdk-for-go/sdk/armcore v0.8.0/go.mod h1:BSKvHb/5cy8j4hahIInXH92X/2zGJ3TxKF6b9pw1Btg= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2 h1:UC4vfOhW2l0f2QOCQpOxJS4/K6oKFy2tQZE+uWU1MEo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.16.2/go.mod h1:MVdrcUC4Hup35qHym3VdzoW+NBgBxrta9Vei97jRtM8= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1 h1:vx8McI56N5oLSQu8xa+xdiE0fjQq8W8Zt49vHP8Rygw= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.5.1/go.mod h1:k4KbFSunV/+0hOHL1vyFaPsiYQ1Vmvy1TBpmtvCDLZM= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb h1:mUVeFHoDKis5nxCAzoAi7E8Ghb86EXh/RK6wtvJIqRY= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/sdk/apimanagement/armapimanagement/go_mod_tidy_hack.go b/sdk/apimanagement/armapimanagement/go_mod_tidy_hack.go new file mode 100644 index 000000000000..1d5c973b5f70 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/go_mod_tidy_hack.go @@ -0,0 +1,12 @@ +// +build modhack + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +// This file, and the github.com/Azure/azure-sdk-for-go import, won't actually become part of +// the resultant binary. + +package armapimanagement + +// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository +import _ "github.com/Azure/azure-sdk-for-go" diff --git a/sdk/apimanagement/armapimanagement/zz_generated_api_client.go b/sdk/apimanagement/armapimanagement/zz_generated_api_client.go new file mode 100644 index 000000000000..d655ab91035e --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_api_client.go @@ -0,0 +1,568 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +// APIClient contains the methods for the API group. +// Don't use this type directly, use NewAPIClient() instead. +type APIClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIClient creates a new instance of APIClient with the specified values. +func NewAPIClient(con *armcore.Connection, subscriptionID string) *APIClient { + return &APIClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreateOrUpdate - Creates new or updates existing specified API of the API Management service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiID string, parameters APICreateOrUpdateParameter, options *APIBeginCreateOrUpdateOptions) (APICreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, serviceName, apiID, parameters, options) + if err != nil { + return APICreateOrUpdatePollerResponse{}, err + } + result := APICreateOrUpdatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("APIClient.CreateOrUpdate", "location", resp, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return APICreateOrUpdatePollerResponse{}, err + } + poller := &apiCreateOrUpdatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APICreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreateOrUpdate creates a new APICreateOrUpdatePoller from the specified resume token. +// token - The value must come from a previous call to APICreateOrUpdatePoller.ResumeToken(). +func (client *APIClient) ResumeCreateOrUpdate(ctx context.Context, token string) (APICreateOrUpdatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("APIClient.CreateOrUpdate", token, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return APICreateOrUpdatePollerResponse{}, err + } + poller := &apiCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return APICreateOrUpdatePollerResponse{}, err + } + result := APICreateOrUpdatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APICreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// CreateOrUpdate - Creates new or updates existing specified API of the API Management service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiID string, parameters APICreateOrUpdateParameter, options *APIBeginCreateOrUpdateOptions) (*azcore.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, apiID, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APIClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, parameters APICreateOrUpdateParameter, options *APIBeginCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *APIClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified API of the API Management service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, options *APIDeleteOptions) (APIDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, apiID, ifMatch, options) + if err != nil { + return APIDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return APIDeleteResponse{}, client.deleteHandleError(resp) + } + return APIDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APIClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, options *APIDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.DeleteRevisions != nil { + reqQP.Set("deleteRevisions", strconv.FormatBool(*options.DeleteRevisions)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *APIClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the API specified by its identifier. +// If the operation fails it returns one of the following error types. +// - *ErrorResponse, *ErrorResponse +func (client *APIClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIGetOptions) (APIGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, apiID, options) + if err != nil { + return APIGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusOK) { + return APIGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *APIClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json, application/vnd.swagger.doc+json, application/vnd.oai.openapi+json, application/vnd.sun.wadl+xml, application/wsdl+xml") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIClient) getHandleResponse(resp *azcore.Response) (APIGetResponse, error) { + result := APIGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.APIContract); err != nil { + return APIGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *APIClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the API specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIGetEntityTagOptions) (APIGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, apiID, options) + if err != nil { + return APIGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *APIClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *APIClient) getEntityTagHandleResponse(resp *azcore.Response) (APIGetEntityTagResponse, error) { + result := APIGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists all APIs of the API Management service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIClient) ListByService(resourceGroupName string, serviceName string, options *APIListByServiceOptions) APIListByServicePager { + return &apiListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp APIListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.APICollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *APIClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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.Tags != nil { + reqQP.Set("tags", *options.Tags) + } + if options != nil && options.ExpandAPIVersionSet != nil { + reqQP.Set("expandApiVersionSet", strconv.FormatBool(*options.ExpandAPIVersionSet)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *APIClient) listByServiceHandleResponse(resp *azcore.Response) (APIListByServiceResponse, error) { + result := APIListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APICollection); err != nil { + return APIListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *APIClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByTags - Lists a collection of apis associated with tags. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIClient) ListByTags(resourceGroupName string, serviceName string, options *APIListByTagsOptions) APIListByTagsPager { + return &apiListByTagsPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByTagsCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp APIListByTagsResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.TagResourceCollection.NextLink) + }, + } +} + +// listByTagsCreateRequest creates the ListByTags request. +func (client *APIClient) listByTagsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIListByTagsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apisByTags" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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.IncludeNotTaggedApis != nil { + reqQP.Set("includeNotTaggedApis", strconv.FormatBool(*options.IncludeNotTaggedApis)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByTagsHandleResponse handles the ListByTags response. +func (client *APIClient) listByTagsHandleResponse(resp *azcore.Response) (APIListByTagsResponse, error) { + result := APIListByTagsResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.TagResourceCollection); err != nil { + return APIListByTagsResponse{}, err + } + return result, nil +} + +// listByTagsHandleError handles the ListByTags error response. +func (client *APIClient) listByTagsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates the specified API of the API Management service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIClient) Update(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, parameters APIUpdateContract, options *APIUpdateOptions) (APIUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, apiID, ifMatch, parameters, options) + if err != nil { + return APIUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *APIClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, ifMatch string, parameters APIUpdateContract, options *APIUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *APIClient) updateHandleResponse(resp *azcore.Response) (APIUpdateResponse, error) { + result := APIUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.APIContract); err != nil { + return APIUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *APIClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apidiagnostic_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apidiagnostic_client.go new file mode 100644 index 000000000000..5a4e7ca19e05 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apidiagnostic_client.go @@ -0,0 +1,470 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// APIDiagnosticClient contains the methods for the APIDiagnostic group. +// Don't use this type directly, use NewAPIDiagnosticClient() instead. +type APIDiagnosticClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIDiagnosticClient creates a new instance of APIDiagnosticClient with the specified values. +func NewAPIDiagnosticClient(con *armcore.Connection, subscriptionID string) *APIDiagnosticClient { + return &APIDiagnosticClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates a new Diagnostic for an API or updates an existing one. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIDiagnosticClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, parameters DiagnosticContract, options *APIDiagnosticCreateOrUpdateOptions) (APIDiagnosticCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, apiID, diagnosticID, parameters, options) + if err != nil { + return APIDiagnosticCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIDiagnosticCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return APIDiagnosticCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APIDiagnosticClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, parameters DiagnosticContract, options *APIDiagnosticCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *APIDiagnosticClient) createOrUpdateHandleResponse(resp *azcore.Response) (APIDiagnosticCreateOrUpdateResponse, error) { + result := APIDiagnosticCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.DiagnosticContract); err != nil { + return APIDiagnosticCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *APIDiagnosticClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified Diagnostic from an API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIDiagnosticClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, ifMatch string, options *APIDiagnosticDeleteOptions) (APIDiagnosticDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, apiID, diagnosticID, ifMatch, options) + if err != nil { + return APIDiagnosticDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIDiagnosticDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return APIDiagnosticDeleteResponse{}, client.deleteHandleError(resp) + } + return APIDiagnosticDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APIDiagnosticClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, ifMatch string, options *APIDiagnosticDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *APIDiagnosticClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the Diagnostic for an API specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIDiagnosticClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, options *APIDiagnosticGetOptions) (APIDiagnosticGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, apiID, diagnosticID, options) + if err != nil { + return APIDiagnosticGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIDiagnosticGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIDiagnosticGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *APIDiagnosticClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, options *APIDiagnosticGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIDiagnosticClient) getHandleResponse(resp *azcore.Response) (APIDiagnosticGetResponse, error) { + result := APIDiagnosticGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.DiagnosticContract); err != nil { + return APIDiagnosticGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *APIDiagnosticClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the Diagnostic for an API specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIDiagnosticClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, options *APIDiagnosticGetEntityTagOptions) (APIDiagnosticGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, apiID, diagnosticID, options) + if err != nil { + return APIDiagnosticGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIDiagnosticGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *APIDiagnosticClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, options *APIDiagnosticGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *APIDiagnosticClient) getEntityTagHandleResponse(resp *azcore.Response) (APIDiagnosticGetEntityTagResponse, error) { + result := APIDiagnosticGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists all diagnostics of an API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIDiagnosticClient) ListByService(resourceGroupName string, serviceName string, apiID string, options *APIDiagnosticListByServiceOptions) APIDiagnosticListByServicePager { + return &apiDiagnosticListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, apiID, options) + }, + advancer: func(ctx context.Context, resp APIDiagnosticListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.DiagnosticCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *APIDiagnosticClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIDiagnosticListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *APIDiagnosticClient) listByServiceHandleResponse(resp *azcore.Response) (APIDiagnosticListByServiceResponse, error) { + result := APIDiagnosticListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.DiagnosticCollection); err != nil { + return APIDiagnosticListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *APIDiagnosticClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates the details of the Diagnostic for an API specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIDiagnosticClient) Update(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, ifMatch string, parameters DiagnosticContract, options *APIDiagnosticUpdateOptions) (APIDiagnosticUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, apiID, diagnosticID, ifMatch, parameters, options) + if err != nil { + return APIDiagnosticUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIDiagnosticUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIDiagnosticUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *APIDiagnosticClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, diagnosticID string, ifMatch string, parameters DiagnosticContract, options *APIDiagnosticUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/diagnostics/{diagnosticId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *APIDiagnosticClient) updateHandleResponse(resp *azcore.Response) (APIDiagnosticUpdateResponse, error) { + result := APIDiagnosticUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.DiagnosticContract); err != nil { + return APIDiagnosticUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *APIDiagnosticClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apiexport_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apiexport_client.go new file mode 100644 index 000000000000..23a96922141a --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apiexport_client.go @@ -0,0 +1,103 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// APIExportClient contains the methods for the APIExport group. +// Don't use this type directly, use NewAPIExportClient() instead. +type APIExportClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIExportClient creates a new instance of APIExportClient with the specified values. +func NewAPIExportClient(con *armcore.Connection, subscriptionID string) *APIExportClient { + return &APIExportClient{con: con, subscriptionID: subscriptionID} +} + +// Get - Gets the details of the API specified by its identifier in the format specified to the Storage Blob with SAS Key valid for 5 minutes. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIExportClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiID string, formatParam ExportFormat, export ExportAPI, options *APIExportGetOptions) (APIExportGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, apiID, formatParam, export, options) + if err != nil { + return APIExportGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIExportGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIExportGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *APIExportClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, formatParam ExportFormat, export ExportAPI, options *APIExportGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("format", string(formatParam)) + reqQP.Set("export", string(export)) + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIExportClient) getHandleResponse(resp *azcore.Response) (APIExportGetResponse, error) { + result := APIExportGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APIExportResult); err != nil { + return APIExportGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *APIExportClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apiissue_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apiissue_client.go new file mode 100644 index 000000000000..8ac9b613a292 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apiissue_client.go @@ -0,0 +1,476 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// APIIssueClient contains the methods for the APIIssue group. +// Don't use this type directly, use NewAPIIssueClient() instead. +type APIIssueClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIIssueClient creates a new instance of APIIssueClient with the specified values. +func NewAPIIssueClient(con *armcore.Connection, subscriptionID string) *APIIssueClient { + return &APIIssueClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates a new Issue for an API or updates an existing one. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, parameters IssueContract, options *APIIssueCreateOrUpdateOptions) (APIIssueCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, apiID, issueID, parameters, options) + if err != nil { + return APIIssueCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIIssueCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return APIIssueCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APIIssueClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, parameters IssueContract, options *APIIssueCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *APIIssueClient) createOrUpdateHandleResponse(resp *azcore.Response) (APIIssueCreateOrUpdateResponse, error) { + result := APIIssueCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.IssueContract); err != nil { + return APIIssueCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *APIIssueClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified Issue from an API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, ifMatch string, options *APIIssueDeleteOptions) (APIIssueDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, apiID, issueID, ifMatch, options) + if err != nil { + return APIIssueDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIIssueDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return APIIssueDeleteResponse{}, client.deleteHandleError(resp) + } + return APIIssueDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APIIssueClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, ifMatch string, options *APIIssueDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *APIIssueClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the Issue for an API specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, options *APIIssueGetOptions) (APIIssueGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, apiID, issueID, options) + if err != nil { + return APIIssueGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIIssueGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIIssueGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *APIIssueClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, options *APIIssueGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.ExpandCommentsAttachments != nil { + reqQP.Set("expandCommentsAttachments", strconv.FormatBool(*options.ExpandCommentsAttachments)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIIssueClient) getHandleResponse(resp *azcore.Response) (APIIssueGetResponse, error) { + result := APIIssueGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.IssueContract); err != nil { + return APIIssueGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *APIIssueClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the Issue for an API specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, options *APIIssueGetEntityTagOptions) (APIIssueGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, apiID, issueID, options) + if err != nil { + return APIIssueGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIIssueGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *APIIssueClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, options *APIIssueGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *APIIssueClient) getEntityTagHandleResponse(resp *azcore.Response) (APIIssueGetEntityTagResponse, error) { + result := APIIssueGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists all issues associated with the specified API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueClient) ListByService(resourceGroupName string, serviceName string, apiID string, options *APIIssueListByServiceOptions) APIIssueListByServicePager { + return &apiIssueListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, apiID, options) + }, + advancer: func(ctx context.Context, resp APIIssueListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.IssueCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *APIIssueClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIIssueListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + if options != nil && options.ExpandCommentsAttachments != nil { + reqQP.Set("expandCommentsAttachments", strconv.FormatBool(*options.ExpandCommentsAttachments)) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *APIIssueClient) listByServiceHandleResponse(resp *azcore.Response) (APIIssueListByServiceResponse, error) { + result := APIIssueListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.IssueCollection); err != nil { + return APIIssueListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *APIIssueClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates an existing issue for an API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueClient) Update(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, ifMatch string, parameters IssueUpdateContract, options *APIIssueUpdateOptions) (APIIssueUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, apiID, issueID, ifMatch, parameters, options) + if err != nil { + return APIIssueUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIIssueUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIIssueUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *APIIssueClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, ifMatch string, parameters IssueUpdateContract, options *APIIssueUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *APIIssueClient) updateHandleResponse(resp *azcore.Response) (APIIssueUpdateResponse, error) { + result := APIIssueUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.IssueContract); err != nil { + return APIIssueUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *APIIssueClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apiissueattachment_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apiissueattachment_client.go new file mode 100644 index 000000000000..46945bfd5c92 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apiissueattachment_client.go @@ -0,0 +1,412 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// APIIssueAttachmentClient contains the methods for the APIIssueAttachment group. +// Don't use this type directly, use NewAPIIssueAttachmentClient() instead. +type APIIssueAttachmentClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIIssueAttachmentClient creates a new instance of APIIssueAttachmentClient with the specified values. +func NewAPIIssueAttachmentClient(con *armcore.Connection, subscriptionID string) *APIIssueAttachmentClient { + return &APIIssueAttachmentClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates a new Attachment for the Issue in an API or updates an existing one. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueAttachmentClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, attachmentID string, parameters IssueAttachmentContract, options *APIIssueAttachmentCreateOrUpdateOptions) (APIIssueAttachmentCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, apiID, issueID, attachmentID, parameters, options) + if err != nil { + return APIIssueAttachmentCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIIssueAttachmentCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return APIIssueAttachmentCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APIIssueAttachmentClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, attachmentID string, parameters IssueAttachmentContract, options *APIIssueAttachmentCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if attachmentID == "" { + return nil, errors.New("parameter attachmentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{attachmentId}", url.PathEscape(attachmentID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *APIIssueAttachmentClient) createOrUpdateHandleResponse(resp *azcore.Response) (APIIssueAttachmentCreateOrUpdateResponse, error) { + result := APIIssueAttachmentCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.IssueAttachmentContract); err != nil { + return APIIssueAttachmentCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *APIIssueAttachmentClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified comment from an Issue. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueAttachmentClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, attachmentID string, ifMatch string, options *APIIssueAttachmentDeleteOptions) (APIIssueAttachmentDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, apiID, issueID, attachmentID, ifMatch, options) + if err != nil { + return APIIssueAttachmentDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIIssueAttachmentDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return APIIssueAttachmentDeleteResponse{}, client.deleteHandleError(resp) + } + return APIIssueAttachmentDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APIIssueAttachmentClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, attachmentID string, ifMatch string, options *APIIssueAttachmentDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if attachmentID == "" { + return nil, errors.New("parameter attachmentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{attachmentId}", url.PathEscape(attachmentID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *APIIssueAttachmentClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the issue Attachment for an API specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueAttachmentClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, attachmentID string, options *APIIssueAttachmentGetOptions) (APIIssueAttachmentGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, apiID, issueID, attachmentID, options) + if err != nil { + return APIIssueAttachmentGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIIssueAttachmentGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIIssueAttachmentGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *APIIssueAttachmentClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, attachmentID string, options *APIIssueAttachmentGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if attachmentID == "" { + return nil, errors.New("parameter attachmentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{attachmentId}", url.PathEscape(attachmentID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIIssueAttachmentClient) getHandleResponse(resp *azcore.Response) (APIIssueAttachmentGetResponse, error) { + result := APIIssueAttachmentGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.IssueAttachmentContract); err != nil { + return APIIssueAttachmentGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *APIIssueAttachmentClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the issue Attachment for an API specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueAttachmentClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, attachmentID string, options *APIIssueAttachmentGetEntityTagOptions) (APIIssueAttachmentGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, apiID, issueID, attachmentID, options) + if err != nil { + return APIIssueAttachmentGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIIssueAttachmentGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *APIIssueAttachmentClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, attachmentID string, options *APIIssueAttachmentGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments/{attachmentId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if attachmentID == "" { + return nil, errors.New("parameter attachmentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{attachmentId}", url.PathEscape(attachmentID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *APIIssueAttachmentClient) getEntityTagHandleResponse(resp *azcore.Response) (APIIssueAttachmentGetEntityTagResponse, error) { + result := APIIssueAttachmentGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists all attachments for the Issue associated with the specified API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueAttachmentClient) ListByService(resourceGroupName string, serviceName string, apiID string, issueID string, options *APIIssueAttachmentListByServiceOptions) APIIssueAttachmentListByServicePager { + return &apiIssueAttachmentListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, apiID, issueID, options) + }, + advancer: func(ctx context.Context, resp APIIssueAttachmentListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.IssueAttachmentCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *APIIssueAttachmentClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, options *APIIssueAttachmentListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/attachments" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *APIIssueAttachmentClient) listByServiceHandleResponse(resp *azcore.Response) (APIIssueAttachmentListByServiceResponse, error) { + result := APIIssueAttachmentListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.IssueAttachmentCollection); err != nil { + return APIIssueAttachmentListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *APIIssueAttachmentClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apiissuecomment_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apiissuecomment_client.go new file mode 100644 index 000000000000..6598ada5777d --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apiissuecomment_client.go @@ -0,0 +1,412 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// APIIssueCommentClient contains the methods for the APIIssueComment group. +// Don't use this type directly, use NewAPIIssueCommentClient() instead. +type APIIssueCommentClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIIssueCommentClient creates a new instance of APIIssueCommentClient with the specified values. +func NewAPIIssueCommentClient(con *armcore.Connection, subscriptionID string) *APIIssueCommentClient { + return &APIIssueCommentClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates a new Comment for the Issue in an API or updates an existing one. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueCommentClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, commentID string, parameters IssueCommentContract, options *APIIssueCommentCreateOrUpdateOptions) (APIIssueCommentCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, apiID, issueID, commentID, parameters, options) + if err != nil { + return APIIssueCommentCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIIssueCommentCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return APIIssueCommentCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APIIssueCommentClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, commentID string, parameters IssueCommentContract, options *APIIssueCommentCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if commentID == "" { + return nil, errors.New("parameter commentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{commentId}", url.PathEscape(commentID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *APIIssueCommentClient) createOrUpdateHandleResponse(resp *azcore.Response) (APIIssueCommentCreateOrUpdateResponse, error) { + result := APIIssueCommentCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.IssueCommentContract); err != nil { + return APIIssueCommentCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *APIIssueCommentClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified comment from an Issue. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueCommentClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, commentID string, ifMatch string, options *APIIssueCommentDeleteOptions) (APIIssueCommentDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, apiID, issueID, commentID, ifMatch, options) + if err != nil { + return APIIssueCommentDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIIssueCommentDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return APIIssueCommentDeleteResponse{}, client.deleteHandleError(resp) + } + return APIIssueCommentDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APIIssueCommentClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, commentID string, ifMatch string, options *APIIssueCommentDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if commentID == "" { + return nil, errors.New("parameter commentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{commentId}", url.PathEscape(commentID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *APIIssueCommentClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the issue Comment for an API specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueCommentClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, commentID string, options *APIIssueCommentGetOptions) (APIIssueCommentGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, apiID, issueID, commentID, options) + if err != nil { + return APIIssueCommentGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIIssueCommentGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIIssueCommentGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *APIIssueCommentClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, commentID string, options *APIIssueCommentGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if commentID == "" { + return nil, errors.New("parameter commentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{commentId}", url.PathEscape(commentID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIIssueCommentClient) getHandleResponse(resp *azcore.Response) (APIIssueCommentGetResponse, error) { + result := APIIssueCommentGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.IssueCommentContract); err != nil { + return APIIssueCommentGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *APIIssueCommentClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the issue Comment for an API specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueCommentClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, commentID string, options *APIIssueCommentGetEntityTagOptions) (APIIssueCommentGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, apiID, issueID, commentID, options) + if err != nil { + return APIIssueCommentGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIIssueCommentGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *APIIssueCommentClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, commentID string, options *APIIssueCommentGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if commentID == "" { + return nil, errors.New("parameter commentID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{commentId}", url.PathEscape(commentID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *APIIssueCommentClient) getEntityTagHandleResponse(resp *azcore.Response) (APIIssueCommentGetEntityTagResponse, error) { + result := APIIssueCommentGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists all comments for the Issue associated with the specified API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIIssueCommentClient) ListByService(resourceGroupName string, serviceName string, apiID string, issueID string, options *APIIssueCommentListByServiceOptions) APIIssueCommentListByServicePager { + return &apiIssueCommentListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, apiID, issueID, options) + }, + advancer: func(ctx context.Context, resp APIIssueCommentListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.IssueCommentCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *APIIssueCommentClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, issueID string, options *APIIssueCommentListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *APIIssueCommentClient) listByServiceHandleResponse(resp *azcore.Response) (APIIssueCommentListByServiceResponse, error) { + result := APIIssueCommentListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.IssueCommentCollection); err != nil { + return APIIssueCommentListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *APIIssueCommentClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apimanagementoperations_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apimanagementoperations_client.go new file mode 100644 index 000000000000..5c21cc039ea9 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apimanagementoperations_client.go @@ -0,0 +1,78 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" +) + +// APIManagementOperationsClient contains the methods for the APIManagementOperations group. +// Don't use this type directly, use NewAPIManagementOperationsClient() instead. +type APIManagementOperationsClient struct { + con *armcore.Connection +} + +// NewAPIManagementOperationsClient creates a new instance of APIManagementOperationsClient with the specified values. +func NewAPIManagementOperationsClient(con *armcore.Connection) *APIManagementOperationsClient { + return &APIManagementOperationsClient{con: con} +} + +// List - Lists all of the available REST API operations of the Microsoft.ApiManagement provider. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementOperationsClient) List(options *APIManagementOperationsListOptions) APIManagementOperationsListPager { + return &apiManagementOperationsListPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp APIManagementOperationsListResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *APIManagementOperationsClient) listCreateRequest(ctx context.Context, options *APIManagementOperationsListOptions) (*azcore.Request, error) { + urlPath := "/providers/Microsoft.ApiManagement/operations" + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *APIManagementOperationsClient) listHandleResponse(resp *azcore.Response) (APIManagementOperationsListResponse, error) { + result := APIManagementOperationsListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.OperationListResult); err != nil { + return APIManagementOperationsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *APIManagementOperationsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apimanagementservice_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apimanagementservice_client.go new file mode 100644 index 000000000000..694931f11e96 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apimanagementservice_client.go @@ -0,0 +1,1033 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// APIManagementServiceClient contains the methods for the APIManagementService group. +// Don't use this type directly, use NewAPIManagementServiceClient() instead. +type APIManagementServiceClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIManagementServiceClient creates a new instance of APIManagementServiceClient with the specified values. +func NewAPIManagementServiceClient(con *armcore.Connection, subscriptionID string) *APIManagementServiceClient { + return &APIManagementServiceClient{con: con, subscriptionID: subscriptionID} +} + +// BeginApplyNetworkConfigurationUpdates - Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated DNS changes. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) BeginApplyNetworkConfigurationUpdates(ctx context.Context, resourceGroupName string, serviceName string, options *APIManagementServiceBeginApplyNetworkConfigurationUpdatesOptions) (APIManagementServiceApplyNetworkConfigurationUpdatesPollerResponse, error) { + resp, err := client.applyNetworkConfigurationUpdates(ctx, resourceGroupName, serviceName, options) + if err != nil { + return APIManagementServiceApplyNetworkConfigurationUpdatesPollerResponse{}, err + } + result := APIManagementServiceApplyNetworkConfigurationUpdatesPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("APIManagementServiceClient.ApplyNetworkConfigurationUpdates", "location", resp, client.con.Pipeline(), client.applyNetworkConfigurationUpdatesHandleError) + if err != nil { + return APIManagementServiceApplyNetworkConfigurationUpdatesPollerResponse{}, err + } + poller := &apiManagementServiceApplyNetworkConfigurationUpdatesPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APIManagementServiceApplyNetworkConfigurationUpdatesResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeApplyNetworkConfigurationUpdates creates a new APIManagementServiceApplyNetworkConfigurationUpdatesPoller from the specified resume token. +// token - The value must come from a previous call to APIManagementServiceApplyNetworkConfigurationUpdatesPoller.ResumeToken(). +func (client *APIManagementServiceClient) ResumeApplyNetworkConfigurationUpdates(ctx context.Context, token string) (APIManagementServiceApplyNetworkConfigurationUpdatesPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("APIManagementServiceClient.ApplyNetworkConfigurationUpdates", token, client.con.Pipeline(), client.applyNetworkConfigurationUpdatesHandleError) + if err != nil { + return APIManagementServiceApplyNetworkConfigurationUpdatesPollerResponse{}, err + } + poller := &apiManagementServiceApplyNetworkConfigurationUpdatesPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return APIManagementServiceApplyNetworkConfigurationUpdatesPollerResponse{}, err + } + result := APIManagementServiceApplyNetworkConfigurationUpdatesPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APIManagementServiceApplyNetworkConfigurationUpdatesResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ApplyNetworkConfigurationUpdates - Updates the Microsoft.ApiManagement resource running in the Virtual network to pick the updated DNS changes. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) applyNetworkConfigurationUpdates(ctx context.Context, resourceGroupName string, serviceName string, options *APIManagementServiceBeginApplyNetworkConfigurationUpdatesOptions) (*azcore.Response, error) { + req, err := client.applyNetworkConfigurationUpdatesCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.applyNetworkConfigurationUpdatesHandleError(resp) + } + return resp, nil +} + +// applyNetworkConfigurationUpdatesCreateRequest creates the ApplyNetworkConfigurationUpdates request. +func (client *APIManagementServiceClient) applyNetworkConfigurationUpdatesCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIManagementServiceBeginApplyNetworkConfigurationUpdatesOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/applynetworkconfigurationupdates" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + if options != nil && options.Parameters != nil { + return req, req.MarshalAsJSON(*options.Parameters) + } + return req, nil +} + +// applyNetworkConfigurationUpdatesHandleError handles the ApplyNetworkConfigurationUpdates error response. +func (client *APIManagementServiceClient) applyNetworkConfigurationUpdatesHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginBackup - Creates a backup of the API Management service to the given Azure Storage Account. This is long running operation and could take several +// minutes to complete. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) BeginBackup(ctx context.Context, resourceGroupName string, serviceName string, parameters APIManagementServiceBackupRestoreParameters, options *APIManagementServiceBeginBackupOptions) (APIManagementServiceBackupPollerResponse, error) { + resp, err := client.backup(ctx, resourceGroupName, serviceName, parameters, options) + if err != nil { + return APIManagementServiceBackupPollerResponse{}, err + } + result := APIManagementServiceBackupPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("APIManagementServiceClient.Backup", "location", resp, client.con.Pipeline(), client.backupHandleError) + if err != nil { + return APIManagementServiceBackupPollerResponse{}, err + } + poller := &apiManagementServiceBackupPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APIManagementServiceBackupResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeBackup creates a new APIManagementServiceBackupPoller from the specified resume token. +// token - The value must come from a previous call to APIManagementServiceBackupPoller.ResumeToken(). +func (client *APIManagementServiceClient) ResumeBackup(ctx context.Context, token string) (APIManagementServiceBackupPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("APIManagementServiceClient.Backup", token, client.con.Pipeline(), client.backupHandleError) + if err != nil { + return APIManagementServiceBackupPollerResponse{}, err + } + poller := &apiManagementServiceBackupPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return APIManagementServiceBackupPollerResponse{}, err + } + result := APIManagementServiceBackupPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APIManagementServiceBackupResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Backup - Creates a backup of the API Management service to the given Azure Storage Account. This is long running operation and could take several minutes +// to complete. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) backup(ctx context.Context, resourceGroupName string, serviceName string, parameters APIManagementServiceBackupRestoreParameters, options *APIManagementServiceBeginBackupOptions) (*azcore.Response, error) { + req, err := client.backupCreateRequest(ctx, resourceGroupName, serviceName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.backupHandleError(resp) + } + return resp, nil +} + +// backupCreateRequest creates the Backup request. +func (client *APIManagementServiceClient) backupCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters APIManagementServiceBackupRestoreParameters, options *APIManagementServiceBeginBackupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backup" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// backupHandleError handles the Backup error response. +func (client *APIManagementServiceClient) backupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// CheckNameAvailability - Checks availability and correctness of a name for an API Management service. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) CheckNameAvailability(ctx context.Context, parameters APIManagementServiceCheckNameAvailabilityParameters, options *APIManagementServiceCheckNameAvailabilityOptions) (APIManagementServiceCheckNameAvailabilityResponse, error) { + req, err := client.checkNameAvailabilityCreateRequest(ctx, parameters, options) + if err != nil { + return APIManagementServiceCheckNameAvailabilityResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIManagementServiceCheckNameAvailabilityResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIManagementServiceCheckNameAvailabilityResponse{}, client.checkNameAvailabilityHandleError(resp) + } + return client.checkNameAvailabilityHandleResponse(resp) +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *APIManagementServiceClient) checkNameAvailabilityCreateRequest(ctx context.Context, parameters APIManagementServiceCheckNameAvailabilityParameters, options *APIManagementServiceCheckNameAvailabilityOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/checkNameAvailability" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *APIManagementServiceClient) checkNameAvailabilityHandleResponse(resp *azcore.Response) (APIManagementServiceCheckNameAvailabilityResponse, error) { + result := APIManagementServiceCheckNameAvailabilityResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APIManagementServiceNameAvailabilityResult); err != nil { + return APIManagementServiceCheckNameAvailabilityResponse{}, err + } + return result, nil +} + +// checkNameAvailabilityHandleError handles the CheckNameAvailability error response. +func (client *APIManagementServiceClient) checkNameAvailabilityHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginCreateOrUpdate - Creates or updates an API Management service. This is long running operation and could take several minutes to complete. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters APIManagementServiceResource, options *APIManagementServiceBeginCreateOrUpdateOptions) (APIManagementServiceCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, serviceName, parameters, options) + if err != nil { + return APIManagementServiceCreateOrUpdatePollerResponse{}, err + } + result := APIManagementServiceCreateOrUpdatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("APIManagementServiceClient.CreateOrUpdate", "", resp, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return APIManagementServiceCreateOrUpdatePollerResponse{}, err + } + poller := &apiManagementServiceCreateOrUpdatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APIManagementServiceCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreateOrUpdate creates a new APIManagementServiceCreateOrUpdatePoller from the specified resume token. +// token - The value must come from a previous call to APIManagementServiceCreateOrUpdatePoller.ResumeToken(). +func (client *APIManagementServiceClient) ResumeCreateOrUpdate(ctx context.Context, token string) (APIManagementServiceCreateOrUpdatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("APIManagementServiceClient.CreateOrUpdate", token, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return APIManagementServiceCreateOrUpdatePollerResponse{}, err + } + poller := &apiManagementServiceCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return APIManagementServiceCreateOrUpdatePollerResponse{}, err + } + result := APIManagementServiceCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APIManagementServiceCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// CreateOrUpdate - Creates or updates an API Management service. This is long running operation and could take several minutes to complete. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters APIManagementServiceResource, options *APIManagementServiceBeginCreateOrUpdateOptions) (*azcore.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APIManagementServiceClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters APIManagementServiceResource, options *APIManagementServiceBeginCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *APIManagementServiceClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginDelete - Deletes an existing API Management service. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) BeginDelete(ctx context.Context, resourceGroupName string, serviceName string, options *APIManagementServiceBeginDeleteOptions) (APIManagementServiceDeletePollerResponse, error) { + resp, err := client.deleteOperation(ctx, resourceGroupName, serviceName, options) + if err != nil { + return APIManagementServiceDeletePollerResponse{}, err + } + result := APIManagementServiceDeletePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("APIManagementServiceClient.Delete", "", resp, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return APIManagementServiceDeletePollerResponse{}, err + } + poller := &apiManagementServiceDeletePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APIManagementServiceDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDelete creates a new APIManagementServiceDeletePoller from the specified resume token. +// token - The value must come from a previous call to APIManagementServiceDeletePoller.ResumeToken(). +func (client *APIManagementServiceClient) ResumeDelete(ctx context.Context, token string) (APIManagementServiceDeletePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("APIManagementServiceClient.Delete", token, client.con.Pipeline(), client.deleteHandleError) + if err != nil { + return APIManagementServiceDeletePollerResponse{}, err + } + poller := &apiManagementServiceDeletePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return APIManagementServiceDeletePollerResponse{}, err + } + result := APIManagementServiceDeletePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APIManagementServiceDeleteResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Delete - Deletes an existing API Management service. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) deleteOperation(ctx context.Context, resourceGroupName string, serviceName string, options *APIManagementServiceBeginDeleteOptions) (*azcore.Response, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.deleteHandleError(resp) + } + return resp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APIManagementServiceClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIManagementServiceBeginDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *APIManagementServiceClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets an API Management service resource description. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) Get(ctx context.Context, resourceGroupName string, serviceName string, options *APIManagementServiceGetOptions) (APIManagementServiceGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return APIManagementServiceGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIManagementServiceGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIManagementServiceGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *APIManagementServiceClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIManagementServiceGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIManagementServiceClient) getHandleResponse(resp *azcore.Response) (APIManagementServiceGetResponse, error) { + result := APIManagementServiceGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APIManagementServiceResource); err != nil { + return APIManagementServiceGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *APIManagementServiceClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetDomainOwnershipIdentifier - Get the custom domain ownership identifier for an API Management service. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) GetDomainOwnershipIdentifier(ctx context.Context, options *APIManagementServiceGetDomainOwnershipIdentifierOptions) (APIManagementServiceGetDomainOwnershipIdentifierResponse, error) { + req, err := client.getDomainOwnershipIdentifierCreateRequest(ctx, options) + if err != nil { + return APIManagementServiceGetDomainOwnershipIdentifierResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIManagementServiceGetDomainOwnershipIdentifierResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIManagementServiceGetDomainOwnershipIdentifierResponse{}, client.getDomainOwnershipIdentifierHandleError(resp) + } + return client.getDomainOwnershipIdentifierHandleResponse(resp) +} + +// getDomainOwnershipIdentifierCreateRequest creates the GetDomainOwnershipIdentifier request. +func (client *APIManagementServiceClient) getDomainOwnershipIdentifierCreateRequest(ctx context.Context, options *APIManagementServiceGetDomainOwnershipIdentifierOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/getDomainOwnershipIdentifier" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getDomainOwnershipIdentifierHandleResponse handles the GetDomainOwnershipIdentifier response. +func (client *APIManagementServiceClient) getDomainOwnershipIdentifierHandleResponse(resp *azcore.Response) (APIManagementServiceGetDomainOwnershipIdentifierResponse, error) { + result := APIManagementServiceGetDomainOwnershipIdentifierResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APIManagementServiceGetDomainOwnershipIdentifierResult); err != nil { + return APIManagementServiceGetDomainOwnershipIdentifierResponse{}, err + } + return result, nil +} + +// getDomainOwnershipIdentifierHandleError handles the GetDomainOwnershipIdentifier error response. +func (client *APIManagementServiceClient) getDomainOwnershipIdentifierHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetSsoToken - Gets the Single-Sign-On token for the API Management Service which is valid for 5 Minutes. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) GetSsoToken(ctx context.Context, resourceGroupName string, serviceName string, options *APIManagementServiceGetSsoTokenOptions) (APIManagementServiceGetSsoTokenResponse, error) { + req, err := client.getSsoTokenCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return APIManagementServiceGetSsoTokenResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIManagementServiceGetSsoTokenResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIManagementServiceGetSsoTokenResponse{}, client.getSsoTokenHandleError(resp) + } + return client.getSsoTokenHandleResponse(resp) +} + +// getSsoTokenCreateRequest creates the GetSsoToken request. +func (client *APIManagementServiceClient) getSsoTokenCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIManagementServiceGetSsoTokenOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/getssotoken" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getSsoTokenHandleResponse handles the GetSsoToken response. +func (client *APIManagementServiceClient) getSsoTokenHandleResponse(resp *azcore.Response) (APIManagementServiceGetSsoTokenResponse, error) { + result := APIManagementServiceGetSsoTokenResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APIManagementServiceGetSsoTokenResult); err != nil { + return APIManagementServiceGetSsoTokenResponse{}, err + } + return result, nil +} + +// getSsoTokenHandleError handles the GetSsoToken error response. +func (client *APIManagementServiceClient) getSsoTokenHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - Lists all API Management services within an Azure subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) List(options *APIManagementServiceListOptions) APIManagementServiceListPager { + return &apiManagementServiceListPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp APIManagementServiceListResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.APIManagementServiceListResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *APIManagementServiceClient) listCreateRequest(ctx context.Context, options *APIManagementServiceListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/service" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *APIManagementServiceClient) listHandleResponse(resp *azcore.Response) (APIManagementServiceListResponse, error) { + result := APIManagementServiceListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APIManagementServiceListResult); err != nil { + return APIManagementServiceListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *APIManagementServiceClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByResourceGroup - List all API Management services within a resource group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) ListByResourceGroup(resourceGroupName string, options *APIManagementServiceListByResourceGroupOptions) APIManagementServiceListByResourceGroupPager { + return &apiManagementServiceListByResourceGroupPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, + advancer: func(ctx context.Context, resp APIManagementServiceListByResourceGroupResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.APIManagementServiceListResult.NextLink) + }, + } +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *APIManagementServiceClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *APIManagementServiceListByResourceGroupOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *APIManagementServiceClient) listByResourceGroupHandleResponse(resp *azcore.Response) (APIManagementServiceListByResourceGroupResponse, error) { + result := APIManagementServiceListByResourceGroupResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APIManagementServiceListResult); err != nil { + return APIManagementServiceListByResourceGroupResponse{}, err + } + return result, nil +} + +// listByResourceGroupHandleError handles the ListByResourceGroup error response. +func (client *APIManagementServiceClient) listByResourceGroupHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginRestore - Restores a backup of an API Management service created using the ApiManagementService_Backup operation on the current service. This is +// a long running operation and could take several minutes to +// complete. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) BeginRestore(ctx context.Context, resourceGroupName string, serviceName string, parameters APIManagementServiceBackupRestoreParameters, options *APIManagementServiceBeginRestoreOptions) (APIManagementServiceRestorePollerResponse, error) { + resp, err := client.restore(ctx, resourceGroupName, serviceName, parameters, options) + if err != nil { + return APIManagementServiceRestorePollerResponse{}, err + } + result := APIManagementServiceRestorePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("APIManagementServiceClient.Restore", "location", resp, client.con.Pipeline(), client.restoreHandleError) + if err != nil { + return APIManagementServiceRestorePollerResponse{}, err + } + poller := &apiManagementServiceRestorePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APIManagementServiceRestoreResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeRestore creates a new APIManagementServiceRestorePoller from the specified resume token. +// token - The value must come from a previous call to APIManagementServiceRestorePoller.ResumeToken(). +func (client *APIManagementServiceClient) ResumeRestore(ctx context.Context, token string) (APIManagementServiceRestorePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("APIManagementServiceClient.Restore", token, client.con.Pipeline(), client.restoreHandleError) + if err != nil { + return APIManagementServiceRestorePollerResponse{}, err + } + poller := &apiManagementServiceRestorePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return APIManagementServiceRestorePollerResponse{}, err + } + result := APIManagementServiceRestorePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APIManagementServiceRestoreResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Restore - Restores a backup of an API Management service created using the ApiManagementService_Backup operation on the current service. This is a long +// running operation and could take several minutes to +// complete. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) restore(ctx context.Context, resourceGroupName string, serviceName string, parameters APIManagementServiceBackupRestoreParameters, options *APIManagementServiceBeginRestoreOptions) (*azcore.Response, error) { + req, err := client.restoreCreateRequest(ctx, resourceGroupName, serviceName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.restoreHandleError(resp) + } + return resp, nil +} + +// restoreCreateRequest creates the Restore request. +func (client *APIManagementServiceClient) restoreCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters APIManagementServiceBackupRestoreParameters, options *APIManagementServiceBeginRestoreOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/restore" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// restoreHandleError handles the Restore error response. +func (client *APIManagementServiceClient) restoreHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginUpdate - Updates an existing API Management service. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) BeginUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters APIManagementServiceUpdateParameters, options *APIManagementServiceBeginUpdateOptions) (APIManagementServiceUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, serviceName, parameters, options) + if err != nil { + return APIManagementServiceUpdatePollerResponse{}, err + } + result := APIManagementServiceUpdatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("APIManagementServiceClient.Update", "", resp, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return APIManagementServiceUpdatePollerResponse{}, err + } + poller := &apiManagementServiceUpdatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APIManagementServiceUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeUpdate creates a new APIManagementServiceUpdatePoller from the specified resume token. +// token - The value must come from a previous call to APIManagementServiceUpdatePoller.ResumeToken(). +func (client *APIManagementServiceClient) ResumeUpdate(ctx context.Context, token string) (APIManagementServiceUpdatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("APIManagementServiceClient.Update", token, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return APIManagementServiceUpdatePollerResponse{}, err + } + poller := &apiManagementServiceUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return APIManagementServiceUpdatePollerResponse{}, err + } + result := APIManagementServiceUpdatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APIManagementServiceUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Update - Updates an existing API Management service. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceClient) update(ctx context.Context, resourceGroupName string, serviceName string, parameters APIManagementServiceUpdateParameters, options *APIManagementServiceBeginUpdateOptions) (*azcore.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *APIManagementServiceClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters APIManagementServiceUpdateParameters, options *APIManagementServiceBeginUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleError handles the Update error response. +func (client *APIManagementServiceClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apimanagementserviceskus_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apimanagementserviceskus_client.go new file mode 100644 index 000000000000..9764411d9e56 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apimanagementserviceskus_client.go @@ -0,0 +1,94 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// APIManagementServiceSKUsClient contains the methods for the APIManagementServiceSKUs group. +// Don't use this type directly, use NewAPIManagementServiceSKUsClient() instead. +type APIManagementServiceSKUsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIManagementServiceSKUsClient creates a new instance of APIManagementServiceSKUsClient with the specified values. +func NewAPIManagementServiceSKUsClient(con *armcore.Connection, subscriptionID string) *APIManagementServiceSKUsClient { + return &APIManagementServiceSKUsClient{con: con, subscriptionID: subscriptionID} +} + +// ListAvailableServiceSKUs - Gets all available SKU for a given API Management service +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementServiceSKUsClient) ListAvailableServiceSKUs(resourceGroupName string, serviceName string, options *APIManagementServiceSKUsListAvailableServiceSKUsOptions) APIManagementServiceSKUsListAvailableServiceSKUsPager { + return &apiManagementServiceSKUsListAvailableServiceSKUsPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listAvailableServiceSKUsCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp APIManagementServiceSKUsListAvailableServiceSKUsResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ResourceSKUResults.NextLink) + }, + } +} + +// listAvailableServiceSKUsCreateRequest creates the ListAvailableServiceSKUs request. +func (client *APIManagementServiceSKUsClient) listAvailableServiceSKUsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIManagementServiceSKUsListAvailableServiceSKUsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/skus" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listAvailableServiceSKUsHandleResponse handles the ListAvailableServiceSKUs response. +func (client *APIManagementServiceSKUsClient) listAvailableServiceSKUsHandleResponse(resp *azcore.Response) (APIManagementServiceSKUsListAvailableServiceSKUsResponse, error) { + result := APIManagementServiceSKUsListAvailableServiceSKUsResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ResourceSKUResults); err != nil { + return APIManagementServiceSKUsListAvailableServiceSKUsResponse{}, err + } + return result, nil +} + +// listAvailableServiceSKUsHandleError handles the ListAvailableServiceSKUs error response. +func (client *APIManagementServiceSKUsClient) listAvailableServiceSKUsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apimanagementskus_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apimanagementskus_client.go new file mode 100644 index 000000000000..37b9892d6780 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apimanagementskus_client.go @@ -0,0 +1,86 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// APIManagementSKUsClient contains the methods for the APIManagementSKUs group. +// Don't use this type directly, use NewAPIManagementSKUsClient() instead. +type APIManagementSKUsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIManagementSKUsClient creates a new instance of APIManagementSKUsClient with the specified values. +func NewAPIManagementSKUsClient(con *armcore.Connection, subscriptionID string) *APIManagementSKUsClient { + return &APIManagementSKUsClient{con: con, subscriptionID: subscriptionID} +} + +// List - Gets the list of Microsoft.ApiManagement SKUs available for your Subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIManagementSKUsClient) List(options *APIManagementSKUsListOptions) APIManagementSKUsListPager { + return &apiManagementSKUsListPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp APIManagementSKUsListResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.APIManagementSKUsResult.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *APIManagementSKUsClient) listCreateRequest(ctx context.Context, options *APIManagementSKUsListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/skus" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *APIManagementSKUsClient) listHandleResponse(resp *azcore.Response) (APIManagementSKUsListResponse, error) { + result := APIManagementSKUsListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APIManagementSKUsResult); err != nil { + return APIManagementSKUsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *APIManagementSKUsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apioperation_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apioperation_client.go new file mode 100644 index 000000000000..0349603f827a --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apioperation_client.go @@ -0,0 +1,473 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// APIOperationClient contains the methods for the APIOperation group. +// Don't use this type directly, use NewAPIOperationClient() instead. +type APIOperationClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIOperationClient creates a new instance of APIOperationClient with the specified values. +func NewAPIOperationClient(con *armcore.Connection, subscriptionID string) *APIOperationClient { + return &APIOperationClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates a new operation in the API or updates an existing one. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIOperationClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, parameters OperationContract, options *APIOperationCreateOrUpdateOptions) (APIOperationCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, apiID, operationID, parameters, options) + if err != nil { + return APIOperationCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIOperationCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return APIOperationCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APIOperationClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, parameters OperationContract, options *APIOperationCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *APIOperationClient) createOrUpdateHandleResponse(resp *azcore.Response) (APIOperationCreateOrUpdateResponse, error) { + result := APIOperationCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.OperationContract); err != nil { + return APIOperationCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *APIOperationClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified operation in the API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIOperationClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, ifMatch string, options *APIOperationDeleteOptions) (APIOperationDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, apiID, operationID, ifMatch, options) + if err != nil { + return APIOperationDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIOperationDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return APIOperationDeleteResponse{}, client.deleteHandleError(resp) + } + return APIOperationDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APIOperationClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, ifMatch string, options *APIOperationDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *APIOperationClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the API Operation specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIOperationClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, options *APIOperationGetOptions) (APIOperationGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, apiID, operationID, options) + if err != nil { + return APIOperationGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIOperationGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIOperationGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *APIOperationClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, options *APIOperationGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIOperationClient) getHandleResponse(resp *azcore.Response) (APIOperationGetResponse, error) { + result := APIOperationGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.OperationContract); err != nil { + return APIOperationGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *APIOperationClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the API operation specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIOperationClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, options *APIOperationGetEntityTagOptions) (APIOperationGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, apiID, operationID, options) + if err != nil { + return APIOperationGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIOperationGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *APIOperationClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, options *APIOperationGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *APIOperationClient) getEntityTagHandleResponse(resp *azcore.Response) (APIOperationGetEntityTagResponse, error) { + result := APIOperationGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByAPI - Lists a collection of the operations for the specified API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIOperationClient) ListByAPI(resourceGroupName string, serviceName string, apiID string, options *APIOperationListByAPIOptions) APIOperationListByAPIPager { + return &apiOperationListByAPIPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByAPICreateRequest(ctx, resourceGroupName, serviceName, apiID, options) + }, + advancer: func(ctx context.Context, resp APIOperationListByAPIResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.OperationCollection.NextLink) + }, + } +} + +// listByAPICreateRequest creates the ListByAPI request. +func (client *APIOperationClient) listByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIOperationListByAPIOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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.Tags != nil { + reqQP.Set("tags", *options.Tags) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByAPIHandleResponse handles the ListByAPI response. +func (client *APIOperationClient) listByAPIHandleResponse(resp *azcore.Response) (APIOperationListByAPIResponse, error) { + result := APIOperationListByAPIResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.OperationCollection); err != nil { + return APIOperationListByAPIResponse{}, err + } + return result, nil +} + +// listByAPIHandleError handles the ListByAPI error response. +func (client *APIOperationClient) listByAPIHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates the details of the operation in the API specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIOperationClient) Update(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, ifMatch string, parameters OperationUpdateContract, options *APIOperationUpdateOptions) (APIOperationUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, apiID, operationID, ifMatch, parameters, options) + if err != nil { + return APIOperationUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIOperationUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIOperationUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *APIOperationClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, ifMatch string, parameters OperationUpdateContract, options *APIOperationUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *APIOperationClient) updateHandleResponse(resp *azcore.Response) (APIOperationUpdateResponse, error) { + result := APIOperationUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.OperationContract); err != nil { + return APIOperationUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *APIOperationClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apioperationpolicy_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apioperationpolicy_client.go new file mode 100644 index 000000000000..d785fc5ce3da --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apioperationpolicy_client.go @@ -0,0 +1,408 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// APIOperationPolicyClient contains the methods for the APIOperationPolicy group. +// Don't use this type directly, use NewAPIOperationPolicyClient() instead. +type APIOperationPolicyClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIOperationPolicyClient creates a new instance of APIOperationPolicyClient with the specified values. +func NewAPIOperationPolicyClient(con *armcore.Connection, subscriptionID string) *APIOperationPolicyClient { + return &APIOperationPolicyClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or updates policy configuration for the API Operation level. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIOperationPolicyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, policyID PolicyIDName, parameters PolicyContract, options *APIOperationPolicyCreateOrUpdateOptions) (APIOperationPolicyCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, apiID, operationID, policyID, parameters, options) + if err != nil { + return APIOperationPolicyCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIOperationPolicyCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return APIOperationPolicyCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APIOperationPolicyClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, policyID PolicyIDName, parameters PolicyContract, options *APIOperationPolicyCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *APIOperationPolicyClient) createOrUpdateHandleResponse(resp *azcore.Response) (APIOperationPolicyCreateOrUpdateResponse, error) { + result := APIOperationPolicyCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.PolicyContract); err != nil { + return APIOperationPolicyCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *APIOperationPolicyClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the policy configuration at the Api Operation. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIOperationPolicyClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, policyID PolicyIDName, ifMatch string, options *APIOperationPolicyDeleteOptions) (APIOperationPolicyDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, apiID, operationID, policyID, ifMatch, options) + if err != nil { + return APIOperationPolicyDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIOperationPolicyDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return APIOperationPolicyDeleteResponse{}, client.deleteHandleError(resp) + } + return APIOperationPolicyDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APIOperationPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, policyID PolicyIDName, ifMatch string, options *APIOperationPolicyDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *APIOperationPolicyClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Get the policy configuration at the API Operation level. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIOperationPolicyClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, policyID PolicyIDName, options *APIOperationPolicyGetOptions) (APIOperationPolicyGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, apiID, operationID, policyID, options) + if err != nil { + return APIOperationPolicyGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIOperationPolicyGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIOperationPolicyGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *APIOperationPolicyClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, policyID PolicyIDName, options *APIOperationPolicyGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Format != nil { + reqQP.Set("format", string(*options.Format)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIOperationPolicyClient) getHandleResponse(resp *azcore.Response) (APIOperationPolicyGetResponse, error) { + result := APIOperationPolicyGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.PolicyContract); err != nil { + return APIOperationPolicyGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *APIOperationPolicyClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the API operation policy specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIOperationPolicyClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, policyID PolicyIDName, options *APIOperationPolicyGetEntityTagOptions) (APIOperationPolicyGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, apiID, operationID, policyID, options) + if err != nil { + return APIOperationPolicyGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIOperationPolicyGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *APIOperationPolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, policyID PolicyIDName, options *APIOperationPolicyGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *APIOperationPolicyClient) getEntityTagHandleResponse(resp *azcore.Response) (APIOperationPolicyGetEntityTagResponse, error) { + result := APIOperationPolicyGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByOperation - Get the list of policy configuration at the API Operation level. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIOperationPolicyClient) ListByOperation(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, options *APIOperationPolicyListByOperationOptions) (APIOperationPolicyListByOperationResponse, error) { + req, err := client.listByOperationCreateRequest(ctx, resourceGroupName, serviceName, apiID, operationID, options) + if err != nil { + return APIOperationPolicyListByOperationResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIOperationPolicyListByOperationResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIOperationPolicyListByOperationResponse{}, client.listByOperationHandleError(resp) + } + return client.listByOperationHandleResponse(resp) +} + +// listByOperationCreateRequest creates the ListByOperation request. +func (client *APIOperationPolicyClient) listByOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, options *APIOperationPolicyListByOperationOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/policies" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByOperationHandleResponse handles the ListByOperation response. +func (client *APIOperationPolicyClient) listByOperationHandleResponse(resp *azcore.Response) (APIOperationPolicyListByOperationResponse, error) { + result := APIOperationPolicyListByOperationResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.PolicyCollection); err != nil { + return APIOperationPolicyListByOperationResponse{}, err + } + return result, nil +} + +// listByOperationHandleError handles the ListByOperation error response. +func (client *APIOperationPolicyClient) listByOperationHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apipolicy_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apipolicy_client.go new file mode 100644 index 000000000000..bd1d70c130da --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apipolicy_client.go @@ -0,0 +1,389 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// APIPolicyClient contains the methods for the APIPolicy group. +// Don't use this type directly, use NewAPIPolicyClient() instead. +type APIPolicyClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIPolicyClient creates a new instance of APIPolicyClient with the specified values. +func NewAPIPolicyClient(con *armcore.Connection, subscriptionID string) *APIPolicyClient { + return &APIPolicyClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or updates policy configuration for the API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIPolicyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiID string, policyID PolicyIDName, parameters PolicyContract, options *APIPolicyCreateOrUpdateOptions) (APIPolicyCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, apiID, policyID, parameters, options) + if err != nil { + return APIPolicyCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIPolicyCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return APIPolicyCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APIPolicyClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, policyID PolicyIDName, parameters PolicyContract, options *APIPolicyCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *APIPolicyClient) createOrUpdateHandleResponse(resp *azcore.Response) (APIPolicyCreateOrUpdateResponse, error) { + result := APIPolicyCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.PolicyContract); err != nil { + return APIPolicyCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *APIPolicyClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the policy configuration at the Api. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIPolicyClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiID string, policyID PolicyIDName, ifMatch string, options *APIPolicyDeleteOptions) (APIPolicyDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, apiID, policyID, ifMatch, options) + if err != nil { + return APIPolicyDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIPolicyDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return APIPolicyDeleteResponse{}, client.deleteHandleError(resp) + } + return APIPolicyDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APIPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, policyID PolicyIDName, ifMatch string, options *APIPolicyDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *APIPolicyClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Get the policy configuration at the API level. +// If the operation fails it returns one of the following error types. +// - *ErrorResponse, *ErrorResponse +func (client *APIPolicyClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiID string, policyID PolicyIDName, options *APIPolicyGetOptions) (APIPolicyGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, apiID, policyID, options) + if err != nil { + return APIPolicyGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIPolicyGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusOK) { + return APIPolicyGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *APIPolicyClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, policyID PolicyIDName, options *APIPolicyGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Format != nil { + reqQP.Set("format", string(*options.Format)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json, application/vnd.ms-azure-apim.policy+xml, application/vnd.ms-azure-apim.policy.raw+xml") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIPolicyClient) getHandleResponse(resp *azcore.Response) (APIPolicyGetResponse, error) { + result := APIPolicyGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.PolicyContract); err != nil { + return APIPolicyGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *APIPolicyClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the API policy specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIPolicyClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiID string, policyID PolicyIDName, options *APIPolicyGetEntityTagOptions) (APIPolicyGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, apiID, policyID, options) + if err != nil { + return APIPolicyGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIPolicyGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *APIPolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, policyID PolicyIDName, options *APIPolicyGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *APIPolicyClient) getEntityTagHandleResponse(resp *azcore.Response) (APIPolicyGetEntityTagResponse, error) { + result := APIPolicyGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByAPI - Get the policy configuration at the API level. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIPolicyClient) ListByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIPolicyListByAPIOptions) (APIPolicyListByAPIResponse, error) { + req, err := client.listByAPICreateRequest(ctx, resourceGroupName, serviceName, apiID, options) + if err != nil { + return APIPolicyListByAPIResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIPolicyListByAPIResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIPolicyListByAPIResponse{}, client.listByAPIHandleError(resp) + } + return client.listByAPIHandleResponse(resp) +} + +// listByAPICreateRequest creates the ListByAPI request. +func (client *APIPolicyClient) listByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIPolicyListByAPIOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/policies" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByAPIHandleResponse handles the ListByAPI response. +func (client *APIPolicyClient) listByAPIHandleResponse(resp *azcore.Response) (APIPolicyListByAPIResponse, error) { + result := APIPolicyListByAPIResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.PolicyCollection); err != nil { + return APIPolicyListByAPIResponse{}, err + } + return result, nil +} + +// listByAPIHandleError handles the ListByAPI error response. +func (client *APIPolicyClient) listByAPIHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apiproduct_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apiproduct_client.go new file mode 100644 index 000000000000..42a9dddb57f4 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apiproduct_client.go @@ -0,0 +1,108 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// APIProductClient contains the methods for the APIProduct group. +// Don't use this type directly, use NewAPIProductClient() instead. +type APIProductClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIProductClient creates a new instance of APIProductClient with the specified values. +func NewAPIProductClient(con *armcore.Connection, subscriptionID string) *APIProductClient { + return &APIProductClient{con: con, subscriptionID: subscriptionID} +} + +// ListByApis - Lists all Products, which the API is part of. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIProductClient) ListByApis(resourceGroupName string, serviceName string, apiID string, options *APIProductListByApisOptions) APIProductListByApisPager { + return &apiProductListByApisPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByApisCreateRequest(ctx, resourceGroupName, serviceName, apiID, options) + }, + advancer: func(ctx context.Context, resp APIProductListByApisResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ProductCollection.NextLink) + }, + } +} + +// listByApisCreateRequest creates the ListByApis request. +func (client *APIProductClient) listByApisCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIProductListByApisOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/products" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByApisHandleResponse handles the ListByApis response. +func (client *APIProductClient) listByApisHandleResponse(resp *azcore.Response) (APIProductListByApisResponse, error) { + result := APIProductListByApisResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ProductCollection); err != nil { + return APIProductListByApisResponse{}, err + } + return result, nil +} + +// listByApisHandleError handles the ListByApis error response. +func (client *APIProductClient) listByApisHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apirelease_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apirelease_client.go new file mode 100644 index 000000000000..13aed7eda2ef --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apirelease_client.go @@ -0,0 +1,472 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// APIReleaseClient contains the methods for the APIRelease group. +// Don't use this type directly, use NewAPIReleaseClient() instead. +type APIReleaseClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIReleaseClient creates a new instance of APIReleaseClient with the specified values. +func NewAPIReleaseClient(con *armcore.Connection, subscriptionID string) *APIReleaseClient { + return &APIReleaseClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates a new Release for the API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIReleaseClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, parameters APIReleaseContract, options *APIReleaseCreateOrUpdateOptions) (APIReleaseCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, apiID, releaseID, parameters, options) + if err != nil { + return APIReleaseCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIReleaseCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return APIReleaseCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APIReleaseClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, parameters APIReleaseContract, options *APIReleaseCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if releaseID == "" { + return nil, errors.New("parameter releaseID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{releaseId}", url.PathEscape(releaseID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *APIReleaseClient) createOrUpdateHandleResponse(resp *azcore.Response) (APIReleaseCreateOrUpdateResponse, error) { + result := APIReleaseCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.APIReleaseContract); err != nil { + return APIReleaseCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *APIReleaseClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified release in the API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIReleaseClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, ifMatch string, options *APIReleaseDeleteOptions) (APIReleaseDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, apiID, releaseID, ifMatch, options) + if err != nil { + return APIReleaseDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIReleaseDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return APIReleaseDeleteResponse{}, client.deleteHandleError(resp) + } + return APIReleaseDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APIReleaseClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, ifMatch string, options *APIReleaseDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if releaseID == "" { + return nil, errors.New("parameter releaseID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{releaseId}", url.PathEscape(releaseID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *APIReleaseClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Returns the details of an API release. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIReleaseClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, options *APIReleaseGetOptions) (APIReleaseGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, apiID, releaseID, options) + if err != nil { + return APIReleaseGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIReleaseGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIReleaseGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *APIReleaseClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, options *APIReleaseGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if releaseID == "" { + return nil, errors.New("parameter releaseID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{releaseId}", url.PathEscape(releaseID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIReleaseClient) getHandleResponse(resp *azcore.Response) (APIReleaseGetResponse, error) { + result := APIReleaseGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.APIReleaseContract); err != nil { + return APIReleaseGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *APIReleaseClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Returns the etag of an API release. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIReleaseClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, options *APIReleaseGetEntityTagOptions) (APIReleaseGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, apiID, releaseID, options) + if err != nil { + return APIReleaseGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIReleaseGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *APIReleaseClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, options *APIReleaseGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if releaseID == "" { + return nil, errors.New("parameter releaseID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{releaseId}", url.PathEscape(releaseID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *APIReleaseClient) getEntityTagHandleResponse(resp *azcore.Response) (APIReleaseGetEntityTagResponse, error) { + result := APIReleaseGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists all releases of an API. An API release is created when making an API Revision current. Releases are also used to rollback to previous +// revisions. Results will be paged and can be constrained by +// the $top and $skip parameters. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIReleaseClient) ListByService(resourceGroupName string, serviceName string, apiID string, options *APIReleaseListByServiceOptions) APIReleaseListByServicePager { + return &apiReleaseListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, apiID, options) + }, + advancer: func(ctx context.Context, resp APIReleaseListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.APIReleaseCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *APIReleaseClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIReleaseListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *APIReleaseClient) listByServiceHandleResponse(resp *azcore.Response) (APIReleaseListByServiceResponse, error) { + result := APIReleaseListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APIReleaseCollection); err != nil { + return APIReleaseListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *APIReleaseClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates the details of the release of the API specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIReleaseClient) Update(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, ifMatch string, parameters APIReleaseContract, options *APIReleaseUpdateOptions) (APIReleaseUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, apiID, releaseID, ifMatch, parameters, options) + if err != nil { + return APIReleaseUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIReleaseUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIReleaseUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *APIReleaseClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, releaseID string, ifMatch string, parameters APIReleaseContract, options *APIReleaseUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/releases/{releaseId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if releaseID == "" { + return nil, errors.New("parameter releaseID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{releaseId}", url.PathEscape(releaseID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *APIReleaseClient) updateHandleResponse(resp *azcore.Response) (APIReleaseUpdateResponse, error) { + result := APIReleaseUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.APIReleaseContract); err != nil { + return APIReleaseUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *APIReleaseClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apirevision_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apirevision_client.go new file mode 100644 index 000000000000..32a86cbc657a --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apirevision_client.go @@ -0,0 +1,108 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// APIRevisionClient contains the methods for the APIRevision group. +// Don't use this type directly, use NewAPIRevisionClient() instead. +type APIRevisionClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIRevisionClient creates a new instance of APIRevisionClient with the specified values. +func NewAPIRevisionClient(con *armcore.Connection, subscriptionID string) *APIRevisionClient { + return &APIRevisionClient{con: con, subscriptionID: subscriptionID} +} + +// ListByService - Lists all revisions of an API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIRevisionClient) ListByService(resourceGroupName string, serviceName string, apiID string, options *APIRevisionListByServiceOptions) APIRevisionListByServicePager { + return &apiRevisionListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, apiID, options) + }, + advancer: func(ctx context.Context, resp APIRevisionListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.APIRevisionCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *APIRevisionClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APIRevisionListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/revisions" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *APIRevisionClient) listByServiceHandleResponse(resp *azcore.Response) (APIRevisionListByServiceResponse, error) { + result := APIRevisionListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APIRevisionCollection); err != nil { + return APIRevisionListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *APIRevisionClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apischema_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apischema_client.go new file mode 100644 index 000000000000..2508f2fe76bc --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apischema_client.go @@ -0,0 +1,432 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +// APISchemaClient contains the methods for the APISchema group. +// Don't use this type directly, use NewAPISchemaClient() instead. +type APISchemaClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPISchemaClient creates a new instance of APISchemaClient with the specified values. +func NewAPISchemaClient(con *armcore.Connection, subscriptionID string) *APISchemaClient { + return &APISchemaClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreateOrUpdate - Creates or updates schema configuration for the API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APISchemaClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiID string, schemaID string, parameters SchemaContract, options *APISchemaBeginCreateOrUpdateOptions) (APISchemaCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, serviceName, apiID, schemaID, parameters, options) + if err != nil { + return APISchemaCreateOrUpdatePollerResponse{}, err + } + result := APISchemaCreateOrUpdatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("APISchemaClient.CreateOrUpdate", "location", resp, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return APISchemaCreateOrUpdatePollerResponse{}, err + } + poller := &apiSchemaCreateOrUpdatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APISchemaCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreateOrUpdate creates a new APISchemaCreateOrUpdatePoller from the specified resume token. +// token - The value must come from a previous call to APISchemaCreateOrUpdatePoller.ResumeToken(). +func (client *APISchemaClient) ResumeCreateOrUpdate(ctx context.Context, token string) (APISchemaCreateOrUpdatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("APISchemaClient.CreateOrUpdate", token, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return APISchemaCreateOrUpdatePollerResponse{}, err + } + poller := &apiSchemaCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return APISchemaCreateOrUpdatePollerResponse{}, err + } + result := APISchemaCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (APISchemaCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// CreateOrUpdate - Creates or updates schema configuration for the API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APISchemaClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiID string, schemaID string, parameters SchemaContract, options *APISchemaBeginCreateOrUpdateOptions) (*azcore.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, apiID, schemaID, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APISchemaClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, schemaID string, parameters SchemaContract, options *APISchemaBeginCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if schemaID == "" { + return nil, errors.New("parameter schemaID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{schemaId}", url.PathEscape(schemaID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *APISchemaClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the schema configuration at the Api. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APISchemaClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiID string, schemaID string, ifMatch string, options *APISchemaDeleteOptions) (APISchemaDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, apiID, schemaID, ifMatch, options) + if err != nil { + return APISchemaDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APISchemaDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return APISchemaDeleteResponse{}, client.deleteHandleError(resp) + } + return APISchemaDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APISchemaClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, schemaID string, ifMatch string, options *APISchemaDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if schemaID == "" { + return nil, errors.New("parameter schemaID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{schemaId}", url.PathEscape(schemaID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Force != nil { + reqQP.Set("force", strconv.FormatBool(*options.Force)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *APISchemaClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Get the schema configuration at the API level. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APISchemaClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiID string, schemaID string, options *APISchemaGetOptions) (APISchemaGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, apiID, schemaID, options) + if err != nil { + return APISchemaGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APISchemaGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APISchemaGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *APISchemaClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, schemaID string, options *APISchemaGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if schemaID == "" { + return nil, errors.New("parameter schemaID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{schemaId}", url.PathEscape(schemaID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APISchemaClient) getHandleResponse(resp *azcore.Response) (APISchemaGetResponse, error) { + result := APISchemaGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.SchemaContract); err != nil { + return APISchemaGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *APISchemaClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the schema specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APISchemaClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiID string, schemaID string, options *APISchemaGetEntityTagOptions) (APISchemaGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, apiID, schemaID, options) + if err != nil { + return APISchemaGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APISchemaGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *APISchemaClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, schemaID string, options *APISchemaGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas/{schemaId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if schemaID == "" { + return nil, errors.New("parameter schemaID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{schemaId}", url.PathEscape(schemaID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *APISchemaClient) getEntityTagHandleResponse(resp *azcore.Response) (APISchemaGetEntityTagResponse, error) { + result := APISchemaGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByAPI - Get the schema configuration at the API level. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APISchemaClient) ListByAPI(resourceGroupName string, serviceName string, apiID string, options *APISchemaListByAPIOptions) APISchemaListByAPIPager { + return &apiSchemaListByAPIPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByAPICreateRequest(ctx, resourceGroupName, serviceName, apiID, options) + }, + advancer: func(ctx context.Context, resp APISchemaListByAPIResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.SchemaCollection.NextLink) + }, + } +} + +// listByAPICreateRequest creates the ListByAPI request. +func (client *APISchemaClient) listByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APISchemaListByAPIOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/schemas" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByAPIHandleResponse handles the ListByAPI response. +func (client *APISchemaClient) listByAPIHandleResponse(resp *azcore.Response) (APISchemaListByAPIResponse, error) { + result := APISchemaListByAPIResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.SchemaCollection); err != nil { + return APISchemaListByAPIResponse{}, err + } + return result, nil +} + +// listByAPIHandleError handles the ListByAPI error response. +func (client *APISchemaClient) listByAPIHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apitagdescription_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apitagdescription_client.go new file mode 100644 index 000000000000..cc2233ad1046 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apitagdescription_client.go @@ -0,0 +1,393 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// APITagDescriptionClient contains the methods for the APITagDescription group. +// Don't use this type directly, use NewAPITagDescriptionClient() instead. +type APITagDescriptionClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPITagDescriptionClient creates a new instance of APITagDescriptionClient with the specified values. +func NewAPITagDescriptionClient(con *armcore.Connection, subscriptionID string) *APITagDescriptionClient { + return &APITagDescriptionClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Create/Update tag description in scope of the Api. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APITagDescriptionClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagDescriptionID string, parameters TagDescriptionCreateParameters, options *APITagDescriptionCreateOrUpdateOptions) (APITagDescriptionCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, apiID, tagDescriptionID, parameters, options) + if err != nil { + return APITagDescriptionCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APITagDescriptionCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return APITagDescriptionCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APITagDescriptionClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagDescriptionID string, parameters TagDescriptionCreateParameters, options *APITagDescriptionCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if tagDescriptionID == "" { + return nil, errors.New("parameter tagDescriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagDescriptionId}", url.PathEscape(tagDescriptionID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *APITagDescriptionClient) createOrUpdateHandleResponse(resp *azcore.Response) (APITagDescriptionCreateOrUpdateResponse, error) { + result := APITagDescriptionCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.TagDescriptionContract); err != nil { + return APITagDescriptionCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *APITagDescriptionClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Delete tag description for the Api. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APITagDescriptionClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagDescriptionID string, ifMatch string, options *APITagDescriptionDeleteOptions) (APITagDescriptionDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, apiID, tagDescriptionID, ifMatch, options) + if err != nil { + return APITagDescriptionDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APITagDescriptionDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return APITagDescriptionDeleteResponse{}, client.deleteHandleError(resp) + } + return APITagDescriptionDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APITagDescriptionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagDescriptionID string, ifMatch string, options *APITagDescriptionDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if tagDescriptionID == "" { + return nil, errors.New("parameter tagDescriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagDescriptionId}", url.PathEscape(tagDescriptionID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *APITagDescriptionClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Get Tag description in scope of API +// If the operation fails it returns the *ErrorResponse error type. +func (client *APITagDescriptionClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagDescriptionID string, options *APITagDescriptionGetOptions) (APITagDescriptionGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, apiID, tagDescriptionID, options) + if err != nil { + return APITagDescriptionGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APITagDescriptionGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APITagDescriptionGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *APITagDescriptionClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagDescriptionID string, options *APITagDescriptionGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if tagDescriptionID == "" { + return nil, errors.New("parameter tagDescriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagDescriptionId}", url.PathEscape(tagDescriptionID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APITagDescriptionClient) getHandleResponse(resp *azcore.Response) (APITagDescriptionGetResponse, error) { + result := APITagDescriptionGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.TagDescriptionContract); err != nil { + return APITagDescriptionGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *APITagDescriptionClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state version of the tag specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APITagDescriptionClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagDescriptionID string, options *APITagDescriptionGetEntityTagOptions) (APITagDescriptionGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, apiID, tagDescriptionID, options) + if err != nil { + return APITagDescriptionGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APITagDescriptionGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *APITagDescriptionClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagDescriptionID string, options *APITagDescriptionGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions/{tagDescriptionId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if tagDescriptionID == "" { + return nil, errors.New("parameter tagDescriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagDescriptionId}", url.PathEscape(tagDescriptionID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *APITagDescriptionClient) getEntityTagHandleResponse(resp *azcore.Response) (APITagDescriptionGetEntityTagResponse, error) { + result := APITagDescriptionGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists all Tags descriptions in scope of API. Model similar to swagger - tagDescription is defined on API level but tag may be assigned +// to the Operations +// If the operation fails it returns the *ErrorResponse error type. +func (client *APITagDescriptionClient) ListByService(resourceGroupName string, serviceName string, apiID string, options *APITagDescriptionListByServiceOptions) APITagDescriptionListByServicePager { + return &apiTagDescriptionListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, apiID, options) + }, + advancer: func(ctx context.Context, resp APITagDescriptionListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.TagDescriptionCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *APITagDescriptionClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *APITagDescriptionListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tagDescriptions" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *APITagDescriptionClient) listByServiceHandleResponse(resp *azcore.Response) (APITagDescriptionListByServiceResponse, error) { + result := APITagDescriptionListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.TagDescriptionCollection); err != nil { + return APITagDescriptionListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *APITagDescriptionClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_apiversionset_client.go b/sdk/apimanagement/armapimanagement/zz_generated_apiversionset_client.go new file mode 100644 index 000000000000..182a8bf198de --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_apiversionset_client.go @@ -0,0 +1,446 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// APIVersionSetClient contains the methods for the APIVersionSet group. +// Don't use this type directly, use NewAPIVersionSetClient() instead. +type APIVersionSetClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAPIVersionSetClient creates a new instance of APIVersionSetClient with the specified values. +func NewAPIVersionSetClient(con *armcore.Connection, subscriptionID string) *APIVersionSetClient { + return &APIVersionSetClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or Updates a Api Version Set. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIVersionSetClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, parameters APIVersionSetContract, options *APIVersionSetCreateOrUpdateOptions) (APIVersionSetCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, versionSetID, parameters, options) + if err != nil { + return APIVersionSetCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIVersionSetCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return APIVersionSetCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *APIVersionSetClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, parameters APIVersionSetContract, options *APIVersionSetCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if versionSetID == "" { + return nil, errors.New("parameter versionSetID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionSetId}", url.PathEscape(versionSetID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *APIVersionSetClient) createOrUpdateHandleResponse(resp *azcore.Response) (APIVersionSetCreateOrUpdateResponse, error) { + result := APIVersionSetCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.APIVersionSetContract); err != nil { + return APIVersionSetCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *APIVersionSetClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes specific Api Version Set. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIVersionSetClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, ifMatch string, options *APIVersionSetDeleteOptions) (APIVersionSetDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, versionSetID, ifMatch, options) + if err != nil { + return APIVersionSetDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIVersionSetDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return APIVersionSetDeleteResponse{}, client.deleteHandleError(resp) + } + return APIVersionSetDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *APIVersionSetClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, ifMatch string, options *APIVersionSetDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if versionSetID == "" { + return nil, errors.New("parameter versionSetID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionSetId}", url.PathEscape(versionSetID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *APIVersionSetClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the Api Version Set specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIVersionSetClient) Get(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, options *APIVersionSetGetOptions) (APIVersionSetGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, versionSetID, options) + if err != nil { + return APIVersionSetGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIVersionSetGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIVersionSetGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *APIVersionSetClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, options *APIVersionSetGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if versionSetID == "" { + return nil, errors.New("parameter versionSetID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionSetId}", url.PathEscape(versionSetID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *APIVersionSetClient) getHandleResponse(resp *azcore.Response) (APIVersionSetGetResponse, error) { + result := APIVersionSetGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.APIVersionSetContract); err != nil { + return APIVersionSetGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *APIVersionSetClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the Api Version Set specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIVersionSetClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, options *APIVersionSetGetEntityTagOptions) (APIVersionSetGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, versionSetID, options) + if err != nil { + return APIVersionSetGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIVersionSetGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *APIVersionSetClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, options *APIVersionSetGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if versionSetID == "" { + return nil, errors.New("parameter versionSetID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionSetId}", url.PathEscape(versionSetID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *APIVersionSetClient) getEntityTagHandleResponse(resp *azcore.Response) (APIVersionSetGetEntityTagResponse, error) { + result := APIVersionSetGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists a collection of API Version Sets in the specified service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIVersionSetClient) ListByService(resourceGroupName string, serviceName string, options *APIVersionSetListByServiceOptions) APIVersionSetListByServicePager { + return &apiVersionSetListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp APIVersionSetListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.APIVersionSetCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *APIVersionSetClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *APIVersionSetListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *APIVersionSetClient) listByServiceHandleResponse(resp *azcore.Response) (APIVersionSetListByServiceResponse, error) { + result := APIVersionSetListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APIVersionSetCollection); err != nil { + return APIVersionSetListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *APIVersionSetClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates the details of the Api VersionSet specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *APIVersionSetClient) Update(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, ifMatch string, parameters APIVersionSetUpdateParameters, options *APIVersionSetUpdateOptions) (APIVersionSetUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, versionSetID, ifMatch, parameters, options) + if err != nil { + return APIVersionSetUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return APIVersionSetUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return APIVersionSetUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *APIVersionSetClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, versionSetID string, ifMatch string, parameters APIVersionSetUpdateParameters, options *APIVersionSetUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apiVersionSets/{versionSetId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if versionSetID == "" { + return nil, errors.New("parameter versionSetID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{versionSetId}", url.PathEscape(versionSetID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *APIVersionSetClient) updateHandleResponse(resp *azcore.Response) (APIVersionSetUpdateResponse, error) { + result := APIVersionSetUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.APIVersionSetContract); err != nil { + return APIVersionSetUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *APIVersionSetClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_authorizationserver_client.go b/sdk/apimanagement/armapimanagement/zz_generated_authorizationserver_client.go new file mode 100644 index 000000000000..9d290d2331c9 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_authorizationserver_client.go @@ -0,0 +1,519 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// AuthorizationServerClient contains the methods for the AuthorizationServer group. +// Don't use this type directly, use NewAuthorizationServerClient() instead. +type AuthorizationServerClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewAuthorizationServerClient creates a new instance of AuthorizationServerClient with the specified values. +func NewAuthorizationServerClient(con *armcore.Connection, subscriptionID string) *AuthorizationServerClient { + return &AuthorizationServerClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates new authorization server or updates an existing authorization server. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AuthorizationServerClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, authsid string, parameters AuthorizationServerContract, options *AuthorizationServerCreateOrUpdateOptions) (AuthorizationServerCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, authsid, parameters, options) + if err != nil { + return AuthorizationServerCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AuthorizationServerCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return AuthorizationServerCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *AuthorizationServerClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, parameters AuthorizationServerContract, options *AuthorizationServerCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if authsid == "" { + return nil, errors.New("parameter authsid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authsid}", url.PathEscape(authsid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *AuthorizationServerClient) createOrUpdateHandleResponse(resp *azcore.Response) (AuthorizationServerCreateOrUpdateResponse, error) { + result := AuthorizationServerCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.AuthorizationServerContract); err != nil { + return AuthorizationServerCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *AuthorizationServerClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes specific authorization server instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AuthorizationServerClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, authsid string, ifMatch string, options *AuthorizationServerDeleteOptions) (AuthorizationServerDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, authsid, ifMatch, options) + if err != nil { + return AuthorizationServerDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AuthorizationServerDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return AuthorizationServerDeleteResponse{}, client.deleteHandleError(resp) + } + return AuthorizationServerDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *AuthorizationServerClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, ifMatch string, options *AuthorizationServerDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if authsid == "" { + return nil, errors.New("parameter authsid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authsid}", url.PathEscape(authsid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *AuthorizationServerClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the authorization server specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AuthorizationServerClient) Get(ctx context.Context, resourceGroupName string, serviceName string, authsid string, options *AuthorizationServerGetOptions) (AuthorizationServerGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, authsid, options) + if err != nil { + return AuthorizationServerGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AuthorizationServerGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return AuthorizationServerGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *AuthorizationServerClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, options *AuthorizationServerGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if authsid == "" { + return nil, errors.New("parameter authsid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authsid}", url.PathEscape(authsid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *AuthorizationServerClient) getHandleResponse(resp *azcore.Response) (AuthorizationServerGetResponse, error) { + result := AuthorizationServerGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.AuthorizationServerContract); err != nil { + return AuthorizationServerGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *AuthorizationServerClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the authorizationServer specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AuthorizationServerClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, authsid string, options *AuthorizationServerGetEntityTagOptions) (AuthorizationServerGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, authsid, options) + if err != nil { + return AuthorizationServerGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AuthorizationServerGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *AuthorizationServerClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, options *AuthorizationServerGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if authsid == "" { + return nil, errors.New("parameter authsid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authsid}", url.PathEscape(authsid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *AuthorizationServerClient) getEntityTagHandleResponse(resp *azcore.Response) (AuthorizationServerGetEntityTagResponse, error) { + result := AuthorizationServerGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists a collection of authorization servers defined within a service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AuthorizationServerClient) ListByService(resourceGroupName string, serviceName string, options *AuthorizationServerListByServiceOptions) AuthorizationServerListByServicePager { + return &authorizationServerListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp AuthorizationServerListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.AuthorizationServerCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *AuthorizationServerClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *AuthorizationServerListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *AuthorizationServerClient) listByServiceHandleResponse(resp *azcore.Response) (AuthorizationServerListByServiceResponse, error) { + result := AuthorizationServerListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.AuthorizationServerCollection); err != nil { + return AuthorizationServerListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *AuthorizationServerClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListSecrets - Gets the client secret details of the authorization server. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AuthorizationServerClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, authsid string, options *AuthorizationServerListSecretsOptions) (AuthorizationServerListSecretsResponse, error) { + req, err := client.listSecretsCreateRequest(ctx, resourceGroupName, serviceName, authsid, options) + if err != nil { + return AuthorizationServerListSecretsResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AuthorizationServerListSecretsResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return AuthorizationServerListSecretsResponse{}, client.listSecretsHandleError(resp) + } + return client.listSecretsHandleResponse(resp) +} + +// listSecretsCreateRequest creates the ListSecrets request. +func (client *AuthorizationServerClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, options *AuthorizationServerListSecretsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}/listSecrets" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if authsid == "" { + return nil, errors.New("parameter authsid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authsid}", url.PathEscape(authsid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listSecretsHandleResponse handles the ListSecrets response. +func (client *AuthorizationServerClient) listSecretsHandleResponse(resp *azcore.Response) (AuthorizationServerListSecretsResponse, error) { + result := AuthorizationServerListSecretsResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.AuthorizationServerSecretsContract); err != nil { + return AuthorizationServerListSecretsResponse{}, err + } + return result, nil +} + +// listSecretsHandleError handles the ListSecrets error response. +func (client *AuthorizationServerClient) listSecretsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates the details of the authorization server specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *AuthorizationServerClient) Update(ctx context.Context, resourceGroupName string, serviceName string, authsid string, ifMatch string, parameters AuthorizationServerUpdateContract, options *AuthorizationServerUpdateOptions) (AuthorizationServerUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, authsid, ifMatch, parameters, options) + if err != nil { + return AuthorizationServerUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return AuthorizationServerUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return AuthorizationServerUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *AuthorizationServerClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, authsid string, ifMatch string, parameters AuthorizationServerUpdateContract, options *AuthorizationServerUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/authorizationServers/{authsid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if authsid == "" { + return nil, errors.New("parameter authsid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{authsid}", url.PathEscape(authsid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *AuthorizationServerClient) updateHandleResponse(resp *azcore.Response) (AuthorizationServerUpdateResponse, error) { + result := AuthorizationServerUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.AuthorizationServerContract); err != nil { + return AuthorizationServerUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *AuthorizationServerClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_backend_client.go b/sdk/apimanagement/armapimanagement/zz_generated_backend_client.go new file mode 100644 index 000000000000..c1ccc66b350c --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_backend_client.go @@ -0,0 +1,511 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// BackendClient contains the methods for the Backend group. +// Don't use this type directly, use NewBackendClient() instead. +type BackendClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewBackendClient creates a new instance of BackendClient with the specified values. +func NewBackendClient(con *armcore.Connection, subscriptionID string) *BackendClient { + return &BackendClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or Updates a backend. +// If the operation fails it returns the *ErrorResponse error type. +func (client *BackendClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, backendID string, parameters BackendContract, options *BackendCreateOrUpdateOptions) (BackendCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, backendID, parameters, options) + if err != nil { + return BackendCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return BackendCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return BackendCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *BackendClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, backendID string, parameters BackendContract, options *BackendCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if backendID == "" { + return nil, errors.New("parameter backendID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{backendId}", url.PathEscape(backendID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *BackendClient) createOrUpdateHandleResponse(resp *azcore.Response) (BackendCreateOrUpdateResponse, error) { + result := BackendCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.BackendContract); err != nil { + return BackendCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *BackendClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified backend. +// If the operation fails it returns the *ErrorResponse error type. +func (client *BackendClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, backendID string, ifMatch string, options *BackendDeleteOptions) (BackendDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, backendID, ifMatch, options) + if err != nil { + return BackendDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return BackendDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return BackendDeleteResponse{}, client.deleteHandleError(resp) + } + return BackendDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *BackendClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, backendID string, ifMatch string, options *BackendDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if backendID == "" { + return nil, errors.New("parameter backendID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{backendId}", url.PathEscape(backendID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *BackendClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the backend specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *BackendClient) Get(ctx context.Context, resourceGroupName string, serviceName string, backendID string, options *BackendGetOptions) (BackendGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, backendID, options) + if err != nil { + return BackendGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return BackendGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return BackendGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *BackendClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, backendID string, options *BackendGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if backendID == "" { + return nil, errors.New("parameter backendID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{backendId}", url.PathEscape(backendID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *BackendClient) getHandleResponse(resp *azcore.Response) (BackendGetResponse, error) { + result := BackendGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.BackendContract); err != nil { + return BackendGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *BackendClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the backend specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *BackendClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, backendID string, options *BackendGetEntityTagOptions) (BackendGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, backendID, options) + if err != nil { + return BackendGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return BackendGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *BackendClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, backendID string, options *BackendGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if backendID == "" { + return nil, errors.New("parameter backendID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{backendId}", url.PathEscape(backendID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *BackendClient) getEntityTagHandleResponse(resp *azcore.Response) (BackendGetEntityTagResponse, error) { + result := BackendGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists a collection of backends in the specified service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *BackendClient) ListByService(resourceGroupName string, serviceName string, options *BackendListByServiceOptions) BackendListByServicePager { + return &backendListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp BackendListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.BackendCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *BackendClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *BackendListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *BackendClient) listByServiceHandleResponse(resp *azcore.Response) (BackendListByServiceResponse, error) { + result := BackendListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.BackendCollection); err != nil { + return BackendListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *BackendClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Reconnect - Notifies the APIM proxy to create a new connection to the backend after the specified timeout. If no timeout was specified, timeout of 2 +// minutes is used. +// If the operation fails it returns the *ErrorResponse error type. +func (client *BackendClient) Reconnect(ctx context.Context, resourceGroupName string, serviceName string, backendID string, options *BackendReconnectOptions) (BackendReconnectResponse, error) { + req, err := client.reconnectCreateRequest(ctx, resourceGroupName, serviceName, backendID, options) + if err != nil { + return BackendReconnectResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return BackendReconnectResponse{}, err + } + if !resp.HasStatusCode(http.StatusAccepted) { + return BackendReconnectResponse{}, client.reconnectHandleError(resp) + } + return BackendReconnectResponse{RawResponse: resp.Response}, nil +} + +// reconnectCreateRequest creates the Reconnect request. +func (client *BackendClient) reconnectCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, backendID string, options *BackendReconnectOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}/reconnect" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if backendID == "" { + return nil, errors.New("parameter backendID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{backendId}", url.PathEscape(backendID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + if options != nil && options.Parameters != nil { + return req, req.MarshalAsJSON(*options.Parameters) + } + return req, nil +} + +// reconnectHandleError handles the Reconnect error response. +func (client *BackendClient) reconnectHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates an existing backend. +// If the operation fails it returns the *ErrorResponse error type. +func (client *BackendClient) Update(ctx context.Context, resourceGroupName string, serviceName string, backendID string, ifMatch string, parameters BackendUpdateParameters, options *BackendUpdateOptions) (BackendUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, backendID, ifMatch, parameters, options) + if err != nil { + return BackendUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return BackendUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return BackendUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *BackendClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, backendID string, ifMatch string, parameters BackendUpdateParameters, options *BackendUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if backendID == "" { + return nil, errors.New("parameter backendID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{backendId}", url.PathEscape(backendID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *BackendClient) updateHandleResponse(resp *azcore.Response) (BackendUpdateResponse, error) { + result := BackendUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.BackendContract); err != nil { + return BackendUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *BackendClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_cache_client.go b/sdk/apimanagement/armapimanagement/zz_generated_cache_client.go new file mode 100644 index 000000000000..e5ad1b2bbcb0 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_cache_client.go @@ -0,0 +1,443 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// CacheClient contains the methods for the Cache group. +// Don't use this type directly, use NewCacheClient() instead. +type CacheClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewCacheClient creates a new instance of CacheClient with the specified values. +func NewCacheClient(con *armcore.Connection, subscriptionID string) *CacheClient { + return &CacheClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or updates an External Cache to be used in Api Management instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CacheClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, parameters CacheContract, options *CacheCreateOrUpdateOptions) (CacheCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, cacheID, parameters, options) + if err != nil { + return CacheCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return CacheCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return CacheCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *CacheClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, parameters CacheContract, options *CacheCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if cacheID == "" { + return nil, errors.New("parameter cacheID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheId}", url.PathEscape(cacheID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *CacheClient) createOrUpdateHandleResponse(resp *azcore.Response) (CacheCreateOrUpdateResponse, error) { + result := CacheCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.CacheContract); err != nil { + return CacheCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *CacheClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes specific Cache. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CacheClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, ifMatch string, options *CacheDeleteOptions) (CacheDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, cacheID, ifMatch, options) + if err != nil { + return CacheDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return CacheDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return CacheDeleteResponse{}, client.deleteHandleError(resp) + } + return CacheDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *CacheClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, ifMatch string, options *CacheDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if cacheID == "" { + return nil, errors.New("parameter cacheID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheId}", url.PathEscape(cacheID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *CacheClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the Cache specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CacheClient) Get(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, options *CacheGetOptions) (CacheGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, cacheID, options) + if err != nil { + return CacheGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return CacheGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return CacheGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *CacheClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, options *CacheGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if cacheID == "" { + return nil, errors.New("parameter cacheID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheId}", url.PathEscape(cacheID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CacheClient) getHandleResponse(resp *azcore.Response) (CacheGetResponse, error) { + result := CacheGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.CacheContract); err != nil { + return CacheGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *CacheClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the Cache specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CacheClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, options *CacheGetEntityTagOptions) (CacheGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, cacheID, options) + if err != nil { + return CacheGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return CacheGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *CacheClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, options *CacheGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if cacheID == "" { + return nil, errors.New("parameter cacheID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheId}", url.PathEscape(cacheID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *CacheClient) getEntityTagHandleResponse(resp *azcore.Response) (CacheGetEntityTagResponse, error) { + result := CacheGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists a collection of all external Caches in the specified service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CacheClient) ListByService(resourceGroupName string, serviceName string, options *CacheListByServiceOptions) CacheListByServicePager { + return &cacheListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp CacheListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.CacheCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *CacheClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *CacheListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *CacheClient) listByServiceHandleResponse(resp *azcore.Response) (CacheListByServiceResponse, error) { + result := CacheListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.CacheCollection); err != nil { + return CacheListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *CacheClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates the details of the cache specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CacheClient) Update(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, ifMatch string, parameters CacheUpdateParameters, options *CacheUpdateOptions) (CacheUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, cacheID, ifMatch, parameters, options) + if err != nil { + return CacheUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return CacheUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return CacheUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *CacheClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, cacheID string, ifMatch string, parameters CacheUpdateParameters, options *CacheUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/caches/{cacheId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if cacheID == "" { + return nil, errors.New("parameter cacheID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{cacheId}", url.PathEscape(cacheID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *CacheClient) updateHandleResponse(resp *azcore.Response) (CacheUpdateResponse, error) { + result := CacheUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.CacheContract); err != nil { + return CacheUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *CacheClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_certificate_client.go b/sdk/apimanagement/armapimanagement/zz_generated_certificate_client.go new file mode 100644 index 000000000000..91416bcbe56e --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_certificate_client.go @@ -0,0 +1,448 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// CertificateClient contains the methods for the Certificate group. +// Don't use this type directly, use NewCertificateClient() instead. +type CertificateClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewCertificateClient creates a new instance of CertificateClient with the specified values. +func NewCertificateClient(con *armcore.Connection, subscriptionID string) *CertificateClient { + return &CertificateClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or updates the certificate being used for authentication with the backend. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CertificateClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, parameters CertificateCreateOrUpdateParameters, options *CertificateCreateOrUpdateOptions) (CertificateCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, certificateID, parameters, options) + if err != nil { + return CertificateCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return CertificateCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return CertificateCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *CertificateClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, parameters CertificateCreateOrUpdateParameters, options *CertificateCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if certificateID == "" { + return nil, errors.New("parameter certificateID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{certificateId}", url.PathEscape(certificateID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *CertificateClient) createOrUpdateHandleResponse(resp *azcore.Response) (CertificateCreateOrUpdateResponse, error) { + result := CertificateCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.CertificateContract); err != nil { + return CertificateCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *CertificateClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes specific certificate. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CertificateClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, ifMatch string, options *CertificateDeleteOptions) (CertificateDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, certificateID, ifMatch, options) + if err != nil { + return CertificateDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return CertificateDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return CertificateDeleteResponse{}, client.deleteHandleError(resp) + } + return CertificateDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *CertificateClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, ifMatch string, options *CertificateDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if certificateID == "" { + return nil, errors.New("parameter certificateID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{certificateId}", url.PathEscape(certificateID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *CertificateClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the certificate specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CertificateClient) Get(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, options *CertificateGetOptions) (CertificateGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, certificateID, options) + if err != nil { + return CertificateGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return CertificateGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return CertificateGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *CertificateClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, options *CertificateGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if certificateID == "" { + return nil, errors.New("parameter certificateID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{certificateId}", url.PathEscape(certificateID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *CertificateClient) getHandleResponse(resp *azcore.Response) (CertificateGetResponse, error) { + result := CertificateGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.CertificateContract); err != nil { + return CertificateGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *CertificateClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the certificate specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CertificateClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, options *CertificateGetEntityTagOptions) (CertificateGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, certificateID, options) + if err != nil { + return CertificateGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return CertificateGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *CertificateClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, options *CertificateGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if certificateID == "" { + return nil, errors.New("parameter certificateID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{certificateId}", url.PathEscape(certificateID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *CertificateClient) getEntityTagHandleResponse(resp *azcore.Response) (CertificateGetEntityTagResponse, error) { + result := CertificateGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists a collection of all certificates in the specified service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CertificateClient) ListByService(resourceGroupName string, serviceName string, options *CertificateListByServiceOptions) CertificateListByServicePager { + return &certificateListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp CertificateListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.CertificateCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *CertificateClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *CertificateListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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.IsKeyVaultRefreshFailed != nil { + reqQP.Set("isKeyVaultRefreshFailed", strconv.FormatBool(*options.IsKeyVaultRefreshFailed)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *CertificateClient) listByServiceHandleResponse(resp *azcore.Response) (CertificateListByServiceResponse, error) { + result := CertificateListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.CertificateCollection); err != nil { + return CertificateListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *CertificateClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// RefreshSecret - From KeyVault, Refresh the certificate being used for authentication with the backend. +// If the operation fails it returns the *ErrorResponse error type. +func (client *CertificateClient) RefreshSecret(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, options *CertificateRefreshSecretOptions) (CertificateRefreshSecretResponse, error) { + req, err := client.refreshSecretCreateRequest(ctx, resourceGroupName, serviceName, certificateID, options) + if err != nil { + return CertificateRefreshSecretResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return CertificateRefreshSecretResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return CertificateRefreshSecretResponse{}, client.refreshSecretHandleError(resp) + } + return client.refreshSecretHandleResponse(resp) +} + +// refreshSecretCreateRequest creates the RefreshSecret request. +func (client *CertificateClient) refreshSecretCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, certificateID string, options *CertificateRefreshSecretOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/certificates/{certificateId}/refreshSecret" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if certificateID == "" { + return nil, errors.New("parameter certificateID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{certificateId}", url.PathEscape(certificateID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// refreshSecretHandleResponse handles the RefreshSecret response. +func (client *CertificateClient) refreshSecretHandleResponse(resp *azcore.Response) (CertificateRefreshSecretResponse, error) { + result := CertificateRefreshSecretResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.CertificateContract); err != nil { + return CertificateRefreshSecretResponse{}, err + } + return result, nil +} + +// refreshSecretHandleError handles the RefreshSecret error response. +func (client *CertificateClient) refreshSecretHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_constants.go b/sdk/apimanagement/armapimanagement/zz_generated_constants.go new file mode 100644 index 000000000000..b01d5cc7ece0 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_constants.go @@ -0,0 +1,1374 @@ +// +build go1.13 + +// 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 armapimanagement + +const telemetryInfo = "azsdk-go-armapimanagement/v0.1.0" + +// APIManagementSKUCapacityScaleType - The scale type applicable to the sku. +type APIManagementSKUCapacityScaleType string + +const ( + APIManagementSKUCapacityScaleTypeAutomatic APIManagementSKUCapacityScaleType = "Automatic" + APIManagementSKUCapacityScaleTypeManual APIManagementSKUCapacityScaleType = "Manual" + APIManagementSKUCapacityScaleTypeNone APIManagementSKUCapacityScaleType = "None" +) + +// PossibleAPIManagementSKUCapacityScaleTypeValues returns the possible values for the APIManagementSKUCapacityScaleType const type. +func PossibleAPIManagementSKUCapacityScaleTypeValues() []APIManagementSKUCapacityScaleType { + return []APIManagementSKUCapacityScaleType{ + APIManagementSKUCapacityScaleTypeAutomatic, + APIManagementSKUCapacityScaleTypeManual, + APIManagementSKUCapacityScaleTypeNone, + } +} + +// ToPtr returns a *APIManagementSKUCapacityScaleType pointing to the current value. +func (c APIManagementSKUCapacityScaleType) ToPtr() *APIManagementSKUCapacityScaleType { + return &c +} + +// APIManagementSKURestrictionsReasonCode - The reason for restriction. +type APIManagementSKURestrictionsReasonCode string + +const ( + APIManagementSKURestrictionsReasonCodeQuotaID APIManagementSKURestrictionsReasonCode = "QuotaId" + APIManagementSKURestrictionsReasonCodeNotAvailableForSubscription APIManagementSKURestrictionsReasonCode = "NotAvailableForSubscription" +) + +// PossibleAPIManagementSKURestrictionsReasonCodeValues returns the possible values for the APIManagementSKURestrictionsReasonCode const type. +func PossibleAPIManagementSKURestrictionsReasonCodeValues() []APIManagementSKURestrictionsReasonCode { + return []APIManagementSKURestrictionsReasonCode{ + APIManagementSKURestrictionsReasonCodeQuotaID, + APIManagementSKURestrictionsReasonCodeNotAvailableForSubscription, + } +} + +// ToPtr returns a *APIManagementSKURestrictionsReasonCode pointing to the current value. +func (c APIManagementSKURestrictionsReasonCode) ToPtr() *APIManagementSKURestrictionsReasonCode { + return &c +} + +// APIManagementSKURestrictionsType - The type of restrictions. +type APIManagementSKURestrictionsType string + +const ( + APIManagementSKURestrictionsTypeLocation APIManagementSKURestrictionsType = "Location" + APIManagementSKURestrictionsTypeZone APIManagementSKURestrictionsType = "Zone" +) + +// PossibleAPIManagementSKURestrictionsTypeValues returns the possible values for the APIManagementSKURestrictionsType const type. +func PossibleAPIManagementSKURestrictionsTypeValues() []APIManagementSKURestrictionsType { + return []APIManagementSKURestrictionsType{ + APIManagementSKURestrictionsTypeLocation, + APIManagementSKURestrictionsTypeZone, + } +} + +// ToPtr returns a *APIManagementSKURestrictionsType pointing to the current value. +func (c APIManagementSKURestrictionsType) ToPtr() *APIManagementSKURestrictionsType { + return &c +} + +// APIType - Type of API. +type APIType string + +const ( + APITypeHTTP APIType = "http" + APITypeSoap APIType = "soap" +) + +// PossibleAPITypeValues returns the possible values for the APIType const type. +func PossibleAPITypeValues() []APIType { + return []APIType{ + APITypeHTTP, + APITypeSoap, + } +} + +// ToPtr returns a *APIType pointing to the current value. +func (c APIType) ToPtr() *APIType { + return &c +} + +// APIVersionSetContractDetailsVersioningScheme - An value that determines where the API Version identifier will be located in a HTTP request. +type APIVersionSetContractDetailsVersioningScheme string + +const ( + APIVersionSetContractDetailsVersioningSchemeHeader APIVersionSetContractDetailsVersioningScheme = "Header" + APIVersionSetContractDetailsVersioningSchemeQuery APIVersionSetContractDetailsVersioningScheme = "Query" + APIVersionSetContractDetailsVersioningSchemeSegment APIVersionSetContractDetailsVersioningScheme = "Segment" +) + +// PossibleAPIVersionSetContractDetailsVersioningSchemeValues returns the possible values for the APIVersionSetContractDetailsVersioningScheme const type. +func PossibleAPIVersionSetContractDetailsVersioningSchemeValues() []APIVersionSetContractDetailsVersioningScheme { + return []APIVersionSetContractDetailsVersioningScheme{ + APIVersionSetContractDetailsVersioningSchemeHeader, + APIVersionSetContractDetailsVersioningSchemeQuery, + APIVersionSetContractDetailsVersioningSchemeSegment, + } +} + +// ToPtr returns a *APIVersionSetContractDetailsVersioningScheme pointing to the current value. +func (c APIVersionSetContractDetailsVersioningScheme) ToPtr() *APIVersionSetContractDetailsVersioningScheme { + return &c +} + +type AccessIDName string + +const ( + AccessIDNameAccess AccessIDName = "access" + AccessIDNameGitAccess AccessIDName = "gitAccess" +) + +// PossibleAccessIDNameValues returns the possible values for the AccessIDName const type. +func PossibleAccessIDNameValues() []AccessIDName { + return []AccessIDName{ + AccessIDNameAccess, + AccessIDNameGitAccess, + } +} + +// ToPtr returns a *AccessIDName pointing to the current value. +func (c AccessIDName) ToPtr() *AccessIDName { + return &c +} + +// AlwaysLog - Specifies for what type of messages sampling settings should not apply. +type AlwaysLog string + +const ( + // AlwaysLogAllErrors - Always log all erroneous request regardless of sampling settings. + AlwaysLogAllErrors AlwaysLog = "allErrors" +) + +// PossibleAlwaysLogValues returns the possible values for the AlwaysLog const type. +func PossibleAlwaysLogValues() []AlwaysLog { + return []AlwaysLog{ + AlwaysLogAllErrors, + } +} + +// ToPtr returns a *AlwaysLog pointing to the current value. +func (c AlwaysLog) ToPtr() *AlwaysLog { + return &c +} + +// ApimIdentityType - The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and +// a set of user assigned identities. The type 'None' will remove any +// identities from the service. +type ApimIdentityType string + +const ( + ApimIdentityTypeNone ApimIdentityType = "None" + ApimIdentityTypeSystemAssigned ApimIdentityType = "SystemAssigned" + ApimIdentityTypeSystemAssignedUserAssigned ApimIdentityType = "SystemAssigned, UserAssigned" + ApimIdentityTypeUserAssigned ApimIdentityType = "UserAssigned" +) + +// PossibleApimIdentityTypeValues returns the possible values for the ApimIdentityType const type. +func PossibleApimIdentityTypeValues() []ApimIdentityType { + return []ApimIdentityType{ + ApimIdentityTypeNone, + ApimIdentityTypeSystemAssigned, + ApimIdentityTypeSystemAssignedUserAssigned, + ApimIdentityTypeUserAssigned, + } +} + +// ToPtr returns a *ApimIdentityType pointing to the current value. +func (c ApimIdentityType) ToPtr() *ApimIdentityType { + return &c +} + +type AppType string + +const ( + // AppTypeDeveloperPortal - User create request was sent by new developer portal. + AppTypeDeveloperPortal AppType = "developerPortal" + // AppTypePortal - User create request was sent by legacy developer portal. + AppTypePortal AppType = "portal" +) + +// PossibleAppTypeValues returns the possible values for the AppType const type. +func PossibleAppTypeValues() []AppType { + return []AppType{ + AppTypeDeveloperPortal, + AppTypePortal, + } +} + +// ToPtr returns a *AppType pointing to the current value. +func (c AppType) ToPtr() *AppType { + return &c +} + +// AsyncOperationStatus - Status of an async operation. +type AsyncOperationStatus string + +const ( + AsyncOperationStatusStarted AsyncOperationStatus = "Started" + AsyncOperationStatusInProgress AsyncOperationStatus = "InProgress" + AsyncOperationStatusSucceeded AsyncOperationStatus = "Succeeded" + AsyncOperationStatusFailed AsyncOperationStatus = "Failed" +) + +// PossibleAsyncOperationStatusValues returns the possible values for the AsyncOperationStatus const type. +func PossibleAsyncOperationStatusValues() []AsyncOperationStatus { + return []AsyncOperationStatus{ + AsyncOperationStatusStarted, + AsyncOperationStatusInProgress, + AsyncOperationStatusSucceeded, + AsyncOperationStatusFailed, + } +} + +// ToPtr returns a *AsyncOperationStatus pointing to the current value. +func (c AsyncOperationStatus) ToPtr() *AsyncOperationStatus { + return &c +} + +type AuthorizationMethod string + +const ( + AuthorizationMethodHEAD AuthorizationMethod = "HEAD" + AuthorizationMethodOPTIONS AuthorizationMethod = "OPTIONS" + AuthorizationMethodTRACE AuthorizationMethod = "TRACE" + AuthorizationMethodGET AuthorizationMethod = "GET" + AuthorizationMethodPOST AuthorizationMethod = "POST" + AuthorizationMethodPUT AuthorizationMethod = "PUT" + AuthorizationMethodPATCH AuthorizationMethod = "PATCH" + AuthorizationMethodDELETE AuthorizationMethod = "DELETE" +) + +// PossibleAuthorizationMethodValues returns the possible values for the AuthorizationMethod const type. +func PossibleAuthorizationMethodValues() []AuthorizationMethod { + return []AuthorizationMethod{ + AuthorizationMethodHEAD, + AuthorizationMethodOPTIONS, + AuthorizationMethodTRACE, + AuthorizationMethodGET, + AuthorizationMethodPOST, + AuthorizationMethodPUT, + AuthorizationMethodPATCH, + AuthorizationMethodDELETE, + } +} + +// ToPtr returns a *AuthorizationMethod pointing to the current value. +func (c AuthorizationMethod) ToPtr() *AuthorizationMethod { + return &c +} + +// BackendProtocol - Backend communication protocol. +type BackendProtocol string + +const ( + // BackendProtocolHTTP - The Backend is a RESTful service. + BackendProtocolHTTP BackendProtocol = "http" + // BackendProtocolSoap - The Backend is a SOAP service. + BackendProtocolSoap BackendProtocol = "soap" +) + +// PossibleBackendProtocolValues returns the possible values for the BackendProtocol const type. +func PossibleBackendProtocolValues() []BackendProtocol { + return []BackendProtocol{ + BackendProtocolHTTP, + BackendProtocolSoap, + } +} + +// ToPtr returns a *BackendProtocol pointing to the current value. +func (c BackendProtocol) ToPtr() *BackendProtocol { + return &c +} + +type BearerTokenSendingMethod string + +const ( + BearerTokenSendingMethodAuthorizationHeader BearerTokenSendingMethod = "authorizationHeader" + BearerTokenSendingMethodQuery BearerTokenSendingMethod = "query" +) + +// PossibleBearerTokenSendingMethodValues returns the possible values for the BearerTokenSendingMethod const type. +func PossibleBearerTokenSendingMethodValues() []BearerTokenSendingMethod { + return []BearerTokenSendingMethod{ + BearerTokenSendingMethodAuthorizationHeader, + BearerTokenSendingMethodQuery, + } +} + +// ToPtr returns a *BearerTokenSendingMethod pointing to the current value. +func (c BearerTokenSendingMethod) ToPtr() *BearerTokenSendingMethod { + return &c +} + +// BearerTokenSendingMethods - Form of an authorization grant, which the client uses to request the access token. +type BearerTokenSendingMethods string + +const ( + // BearerTokenSendingMethodsAuthorizationHeader - Access token will be transmitted in the Authorization header using Bearer schema + BearerTokenSendingMethodsAuthorizationHeader BearerTokenSendingMethods = "authorizationHeader" + // BearerTokenSendingMethodsQuery - Access token will be transmitted as query parameters. + BearerTokenSendingMethodsQuery BearerTokenSendingMethods = "query" +) + +// PossibleBearerTokenSendingMethodsValues returns the possible values for the BearerTokenSendingMethods const type. +func PossibleBearerTokenSendingMethodsValues() []BearerTokenSendingMethods { + return []BearerTokenSendingMethods{ + BearerTokenSendingMethodsAuthorizationHeader, + BearerTokenSendingMethodsQuery, + } +} + +// ToPtr returns a *BearerTokenSendingMethods pointing to the current value. +func (c BearerTokenSendingMethods) ToPtr() *BearerTokenSendingMethods { + return &c +} + +// CertificateConfigurationStoreName - The System.Security.Cryptography.x509certificates.StoreName certificate store location. Only Root and CertificateAuthority +// are valid locations. +type CertificateConfigurationStoreName string + +const ( + CertificateConfigurationStoreNameCertificateAuthority CertificateConfigurationStoreName = "CertificateAuthority" + CertificateConfigurationStoreNameRoot CertificateConfigurationStoreName = "Root" +) + +// PossibleCertificateConfigurationStoreNameValues returns the possible values for the CertificateConfigurationStoreName const type. +func PossibleCertificateConfigurationStoreNameValues() []CertificateConfigurationStoreName { + return []CertificateConfigurationStoreName{ + CertificateConfigurationStoreNameCertificateAuthority, + CertificateConfigurationStoreNameRoot, + } +} + +// ToPtr returns a *CertificateConfigurationStoreName pointing to the current value. +func (c CertificateConfigurationStoreName) ToPtr() *CertificateConfigurationStoreName { + return &c +} + +type ClientAuthenticationMethod string + +const ( + // ClientAuthenticationMethodBasic - Basic Client Authentication method. + ClientAuthenticationMethodBasic ClientAuthenticationMethod = "Basic" + // ClientAuthenticationMethodBody - Body based Authentication method. + ClientAuthenticationMethodBody ClientAuthenticationMethod = "Body" +) + +// PossibleClientAuthenticationMethodValues returns the possible values for the ClientAuthenticationMethod const type. +func PossibleClientAuthenticationMethodValues() []ClientAuthenticationMethod { + return []ClientAuthenticationMethod{ + ClientAuthenticationMethodBasic, + ClientAuthenticationMethodBody, + } +} + +// ToPtr returns a *ClientAuthenticationMethod pointing to the current value. +func (c ClientAuthenticationMethod) ToPtr() *ClientAuthenticationMethod { + return &c +} + +type ConfigurationIDName string + +const ( + ConfigurationIDNameConfiguration ConfigurationIDName = "configuration" +) + +// PossibleConfigurationIDNameValues returns the possible values for the ConfigurationIDName const type. +func PossibleConfigurationIDNameValues() []ConfigurationIDName { + return []ConfigurationIDName{ + ConfigurationIDNameConfiguration, + } +} + +// ToPtr returns a *ConfigurationIDName pointing to the current value. +func (c ConfigurationIDName) ToPtr() *ConfigurationIDName { + return &c +} + +// Confirmation - Determines the type of confirmation e-mail that will be sent to the newly created user. +type Confirmation string + +const ( + // ConfirmationInvite - Send an e-mail inviting the user to sign-up and complete registration. + ConfirmationInvite Confirmation = "invite" + // ConfirmationSignup - Send an e-mail to the user confirming they have successfully signed up. + ConfirmationSignup Confirmation = "signup" +) + +// PossibleConfirmationValues returns the possible values for the Confirmation const type. +func PossibleConfirmationValues() []Confirmation { + return []Confirmation{ + ConfirmationInvite, + ConfirmationSignup, + } +} + +// ToPtr returns a *Confirmation pointing to the current value. +func (c Confirmation) ToPtr() *Confirmation { + return &c +} + +// ConnectivityStatusType - Resource Connectivity Status Type identifier. +type ConnectivityStatusType string + +const ( + ConnectivityStatusTypeFailure ConnectivityStatusType = "failure" + ConnectivityStatusTypeInitializing ConnectivityStatusType = "initializing" + ConnectivityStatusTypeSuccess ConnectivityStatusType = "success" +) + +// PossibleConnectivityStatusTypeValues returns the possible values for the ConnectivityStatusType const type. +func PossibleConnectivityStatusTypeValues() []ConnectivityStatusType { + return []ConnectivityStatusType{ + ConnectivityStatusTypeFailure, + ConnectivityStatusTypeInitializing, + ConnectivityStatusTypeSuccess, + } +} + +// ToPtr returns a *ConnectivityStatusType pointing to the current value. +func (c ConnectivityStatusType) ToPtr() *ConnectivityStatusType { + return &c +} + +// ContentFormat - Format of the Content in which the API is getting imported. +type ContentFormat string + +const ( + // ContentFormatOpenapi - The contents are inline and Content Type is a OpenAPI 3.0 YAML Document. + ContentFormatOpenapi ContentFormat = "openapi" + // ContentFormatOpenapiJSON - The contents are inline and Content Type is a OpenAPI 3.0 JSON Document. + ContentFormatOpenapiJSON ContentFormat = "openapi+json" + // ContentFormatOpenapiJSONLink - The OpenAPI 3.0 JSON document is hosted on a publicly accessible internet address. + ContentFormatOpenapiJSONLink ContentFormat = "openapi+json-link" + // ContentFormatOpenapiLink - The OpenAPI 3.0 YAML document is hosted on a publicly accessible internet address. + ContentFormatOpenapiLink ContentFormat = "openapi-link" + // ContentFormatSwaggerJSON - The contents are inline and Content Type is a OpenAPI 2.0 JSON Document. + ContentFormatSwaggerJSON ContentFormat = "swagger-json" + // ContentFormatSwaggerLinkJSON - The OpenAPI 2.0 JSON document is hosted on a publicly accessible internet address. + ContentFormatSwaggerLinkJSON ContentFormat = "swagger-link-json" + // ContentFormatWadlLinkJSON - The WADL document is hosted on a publicly accessible internet address. + ContentFormatWadlLinkJSON ContentFormat = "wadl-link-json" + // ContentFormatWadlXML - The contents are inline and Content type is a WADL document. + ContentFormatWadlXML ContentFormat = "wadl-xml" + // ContentFormatWsdl - The contents are inline and the document is a WSDL/Soap document. + ContentFormatWsdl ContentFormat = "wsdl" + // ContentFormatWsdlLink - The WSDL document is hosted on a publicly accessible internet address. + ContentFormatWsdlLink ContentFormat = "wsdl-link" +) + +// PossibleContentFormatValues returns the possible values for the ContentFormat const type. +func PossibleContentFormatValues() []ContentFormat { + return []ContentFormat{ + ContentFormatOpenapi, + ContentFormatOpenapiJSON, + ContentFormatOpenapiJSONLink, + ContentFormatOpenapiLink, + ContentFormatSwaggerJSON, + ContentFormatSwaggerLinkJSON, + ContentFormatWadlLinkJSON, + ContentFormatWadlXML, + ContentFormatWsdl, + ContentFormatWsdlLink, + } +} + +// ToPtr returns a *ContentFormat pointing to the current value. +func (c ContentFormat) ToPtr() *ContentFormat { + return &c +} + +// DataMaskingMode - Data masking mode. +type DataMaskingMode string + +const ( + // DataMaskingModeHide - Hide the presence of an entity. + DataMaskingModeHide DataMaskingMode = "Hide" + // DataMaskingModeMask - Mask the value of an entity. + DataMaskingModeMask DataMaskingMode = "Mask" +) + +// PossibleDataMaskingModeValues returns the possible values for the DataMaskingMode const type. +func PossibleDataMaskingModeValues() []DataMaskingMode { + return []DataMaskingMode{ + DataMaskingModeHide, + DataMaskingModeMask, + } +} + +// ToPtr returns a *DataMaskingMode pointing to the current value. +func (c DataMaskingMode) ToPtr() *DataMaskingMode { + return &c +} + +type ExportAPI string + +const ( + ExportAPITrue ExportAPI = "true" +) + +// PossibleExportAPIValues returns the possible values for the ExportAPI const type. +func PossibleExportAPIValues() []ExportAPI { + return []ExportAPI{ + ExportAPITrue, + } +} + +// ToPtr returns a *ExportAPI pointing to the current value. +func (c ExportAPI) ToPtr() *ExportAPI { + return &c +} + +type ExportFormat string + +const ( + // ExportFormatOpenapi - Export the Api Definition in OpenAPI 3.0 Specification as YAML document to Storage Blob. + ExportFormatOpenapi ExportFormat = "openapi-link" + // ExportFormatOpenapiJSON - Export the Api Definition in OpenAPI 3.0 Specification as JSON document to Storage Blob. + ExportFormatOpenapiJSON ExportFormat = "openapi+json-link" + // ExportFormatSwagger - Export the Api Definition in OpenAPI 2.0 Specification as JSON document to the Storage Blob. + ExportFormatSwagger ExportFormat = "swagger-link" + // ExportFormatWadl - Export the Api Definition in WADL Schema to Storage Blob. + ExportFormatWadl ExportFormat = "wadl-link" + // ExportFormatWsdl - Export the Api Definition in WSDL Schema to Storage Blob. This is only supported for APIs of Type `soap` + ExportFormatWsdl ExportFormat = "wsdl-link" +) + +// PossibleExportFormatValues returns the possible values for the ExportFormat const type. +func PossibleExportFormatValues() []ExportFormat { + return []ExportFormat{ + ExportFormatOpenapi, + ExportFormatOpenapiJSON, + ExportFormatSwagger, + ExportFormatWadl, + ExportFormatWsdl, + } +} + +// ToPtr returns a *ExportFormat pointing to the current value. +func (c ExportFormat) ToPtr() *ExportFormat { + return &c +} + +// ExportResultFormat - Format in which the Api Details are exported to the Storage Blob with Sas Key valid for 5 minutes. +type ExportResultFormat string + +const ( + // ExportResultFormatOpenAPI - Export the Api Definition in OpenApi Specification 3.0 to Storage Blob. + ExportResultFormatOpenAPI ExportResultFormat = "openapi-link" + // ExportResultFormatSwagger - The Api Definition is exported in OpenApi Specification 2.0 format to the Storage Blob. + ExportResultFormatSwagger ExportResultFormat = "swagger-link-json" + // ExportResultFormatWadl - Export the Api Definition in WADL Schema to Storage Blob. + ExportResultFormatWadl ExportResultFormat = "wadl-link-json" + // ExportResultFormatWsdl - The Api Definition is exported in WSDL Schema to Storage Blob. This is only supported for APIs of Type `soap` + ExportResultFormatWsdl ExportResultFormat = "wsdl-link+xml" +) + +// PossibleExportResultFormatValues returns the possible values for the ExportResultFormat const type. +func PossibleExportResultFormatValues() []ExportResultFormat { + return []ExportResultFormat{ + ExportResultFormatOpenAPI, + ExportResultFormatSwagger, + ExportResultFormatWadl, + ExportResultFormatWsdl, + } +} + +// ToPtr returns a *ExportResultFormat pointing to the current value. +func (c ExportResultFormat) ToPtr() *ExportResultFormat { + return &c +} + +type GrantType string + +const ( + // GrantTypeAuthorizationCode - Authorization Code Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.1. + GrantTypeAuthorizationCode GrantType = "authorizationCode" + // GrantTypeClientCredentials - Client Credentials Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.4. + GrantTypeClientCredentials GrantType = "clientCredentials" + // GrantTypeImplicit - Implicit Code Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.2. + GrantTypeImplicit GrantType = "implicit" + // GrantTypeResourceOwnerPassword - Resource Owner Password Grant flow as described https://tools.ietf.org/html/rfc6749#section-4.3. + GrantTypeResourceOwnerPassword GrantType = "resourceOwnerPassword" +) + +// PossibleGrantTypeValues returns the possible values for the GrantType const type. +func PossibleGrantTypeValues() []GrantType { + return []GrantType{ + GrantTypeAuthorizationCode, + GrantTypeClientCredentials, + GrantTypeImplicit, + GrantTypeResourceOwnerPassword, + } +} + +// ToPtr returns a *GrantType pointing to the current value. +func (c GrantType) ToPtr() *GrantType { + return &c +} + +// GroupType - Group type. +type GroupType string + +const ( + GroupTypeCustom GroupType = "custom" + GroupTypeSystem GroupType = "system" + GroupTypeExternal GroupType = "external" +) + +// PossibleGroupTypeValues returns the possible values for the GroupType const type. +func PossibleGroupTypeValues() []GroupType { + return []GroupType{ + GroupTypeCustom, + GroupTypeSystem, + GroupTypeExternal, + } +} + +// ToPtr returns a *GroupType pointing to the current value. +func (c GroupType) ToPtr() *GroupType { + return &c +} + +// HTTPCorrelationProtocol - Sets correlation protocol to use for Application Insights diagnostics. +type HTTPCorrelationProtocol string + +const ( + // HTTPCorrelationProtocolLegacy - Inject Request-Id and Request-Context headers with request correlation data. See https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/HttpCorrelationProtocol.md. + HTTPCorrelationProtocolLegacy HTTPCorrelationProtocol = "Legacy" + // HTTPCorrelationProtocolNone - Do not read and inject correlation headers. + HTTPCorrelationProtocolNone HTTPCorrelationProtocol = "None" + // HTTPCorrelationProtocolW3C - Inject Trace Context headers. See https://w3c.github.io/trace-context. + HTTPCorrelationProtocolW3C HTTPCorrelationProtocol = "W3C" +) + +// PossibleHTTPCorrelationProtocolValues returns the possible values for the HTTPCorrelationProtocol const type. +func PossibleHTTPCorrelationProtocolValues() []HTTPCorrelationProtocol { + return []HTTPCorrelationProtocol{ + HTTPCorrelationProtocolLegacy, + HTTPCorrelationProtocolNone, + HTTPCorrelationProtocolW3C, + } +} + +// ToPtr returns a *HTTPCorrelationProtocol pointing to the current value. +func (c HTTPCorrelationProtocol) ToPtr() *HTTPCorrelationProtocol { + return &c +} + +// HostnameType - Hostname type. +type HostnameType string + +const ( + HostnameTypeDeveloperPortal HostnameType = "DeveloperPortal" + HostnameTypeManagement HostnameType = "Management" + HostnameTypePortal HostnameType = "Portal" + HostnameTypeProxy HostnameType = "Proxy" + HostnameTypeScm HostnameType = "Scm" +) + +// PossibleHostnameTypeValues returns the possible values for the HostnameType const type. +func PossibleHostnameTypeValues() []HostnameType { + return []HostnameType{ + HostnameTypeDeveloperPortal, + HostnameTypeManagement, + HostnameTypePortal, + HostnameTypeProxy, + HostnameTypeScm, + } +} + +// ToPtr returns a *HostnameType pointing to the current value. +func (c HostnameType) ToPtr() *HostnameType { + return &c +} + +type IdentityProviderType string + +const ( + // IdentityProviderTypeAAD - Azure Active Directory as Identity provider. + IdentityProviderTypeAAD IdentityProviderType = "aad" + // IdentityProviderTypeAADB2C - Azure Active Directory B2C as Identity provider. + IdentityProviderTypeAADB2C IdentityProviderType = "aadB2C" + // IdentityProviderTypeFacebook - Facebook as Identity provider. + IdentityProviderTypeFacebook IdentityProviderType = "facebook" + // IdentityProviderTypeGoogle - Google as Identity provider. + IdentityProviderTypeGoogle IdentityProviderType = "google" + // IdentityProviderTypeMicrosoft - Microsoft Live as Identity provider. + IdentityProviderTypeMicrosoft IdentityProviderType = "microsoft" + // IdentityProviderTypeTwitter - Twitter as Identity provider. + IdentityProviderTypeTwitter IdentityProviderType = "twitter" +) + +// PossibleIdentityProviderTypeValues returns the possible values for the IdentityProviderType const type. +func PossibleIdentityProviderTypeValues() []IdentityProviderType { + return []IdentityProviderType{ + IdentityProviderTypeAAD, + IdentityProviderTypeAADB2C, + IdentityProviderTypeFacebook, + IdentityProviderTypeGoogle, + IdentityProviderTypeMicrosoft, + IdentityProviderTypeTwitter, + } +} + +// ToPtr returns a *IdentityProviderType pointing to the current value. +func (c IdentityProviderType) ToPtr() *IdentityProviderType { + return &c +} + +// KeyType - The Key to be used to generate token for user. +type KeyType string + +const ( + KeyTypePrimary KeyType = "primary" + KeyTypeSecondary KeyType = "secondary" +) + +// PossibleKeyTypeValues returns the possible values for the KeyType const type. +func PossibleKeyTypeValues() []KeyType { + return []KeyType{ + KeyTypePrimary, + KeyTypeSecondary, + } +} + +// ToPtr returns a *KeyType pointing to the current value. +func (c KeyType) ToPtr() *KeyType { + return &c +} + +// LoggerType - Logger type. +type LoggerType string + +const ( + // LoggerTypeApplicationInsights - Azure Application Insights as log destination. + LoggerTypeApplicationInsights LoggerType = "applicationInsights" + // LoggerTypeAzureEventHub - Azure Event Hub as log destination. + LoggerTypeAzureEventHub LoggerType = "azureEventHub" + // LoggerTypeAzureMonitor - Azure Monitor + LoggerTypeAzureMonitor LoggerType = "azureMonitor" +) + +// PossibleLoggerTypeValues returns the possible values for the LoggerType const type. +func PossibleLoggerTypeValues() []LoggerType { + return []LoggerType{ + LoggerTypeApplicationInsights, + LoggerTypeAzureEventHub, + LoggerTypeAzureMonitor, + } +} + +// ToPtr returns a *LoggerType pointing to the current value. +func (c LoggerType) ToPtr() *LoggerType { + return &c +} + +// NameAvailabilityReason - Invalid indicates the name provided does not match the resource provider’s naming requirements (incorrect length, unsupported +// characters, etc.) AlreadyExists indicates that the name is already in use +// and is therefore unavailable. +type NameAvailabilityReason string + +const ( + NameAvailabilityReasonValid NameAvailabilityReason = "Valid" + NameAvailabilityReasonInvalid NameAvailabilityReason = "Invalid" + NameAvailabilityReasonAlreadyExists NameAvailabilityReason = "AlreadyExists" +) + +// PossibleNameAvailabilityReasonValues returns the possible values for the NameAvailabilityReason const type. +func PossibleNameAvailabilityReasonValues() []NameAvailabilityReason { + return []NameAvailabilityReason{ + NameAvailabilityReasonValid, + NameAvailabilityReasonInvalid, + NameAvailabilityReasonAlreadyExists, + } +} + +// ToPtr returns a *NameAvailabilityReason pointing to the current value. +func (c NameAvailabilityReason) ToPtr() *NameAvailabilityReason { + return &c +} + +type NotificationName string + +const ( + // NotificationNameAccountClosedPublisher - The following email recipients and users will receive email notifications when developer closes his account. + NotificationNameAccountClosedPublisher NotificationName = "AccountClosedPublisher" + // NotificationNameBCC - The following recipients will receive blind carbon copies of all emails sent to developers. + NotificationNameBCC NotificationName = "BCC" + // NotificationNameNewApplicationNotificationMessage - The following email recipients and users will receive email notifications when new applications are + // submitted to the application gallery. + NotificationNameNewApplicationNotificationMessage NotificationName = "NewApplicationNotificationMessage" + // NotificationNameNewIssuePublisherNotificationMessage - The following email recipients and users will receive email notifications when a new issue or + // comment is submitted on the developer portal. + NotificationNameNewIssuePublisherNotificationMessage NotificationName = "NewIssuePublisherNotificationMessage" + // NotificationNamePurchasePublisherNotificationMessage - The following email recipients and users will receive email notifications about new API product + // subscriptions. + NotificationNamePurchasePublisherNotificationMessage NotificationName = "PurchasePublisherNotificationMessage" + // NotificationNameQuotaLimitApproachingPublisherNotificationMessage - The following email recipients and users will receive email notifications when subscription + // usage gets close to usage quota. + NotificationNameQuotaLimitApproachingPublisherNotificationMessage NotificationName = "QuotaLimitApproachingPublisherNotificationMessage" + // NotificationNameRequestPublisherNotificationMessage - The following email recipients and users will receive email notifications about subscription requests + // for API products requiring approval. + NotificationNameRequestPublisherNotificationMessage NotificationName = "RequestPublisherNotificationMessage" +) + +// PossibleNotificationNameValues returns the possible values for the NotificationName const type. +func PossibleNotificationNameValues() []NotificationName { + return []NotificationName{ + NotificationNameAccountClosedPublisher, + NotificationNameBCC, + NotificationNameNewApplicationNotificationMessage, + NotificationNameNewIssuePublisherNotificationMessage, + NotificationNamePurchasePublisherNotificationMessage, + NotificationNameQuotaLimitApproachingPublisherNotificationMessage, + NotificationNameRequestPublisherNotificationMessage, + } +} + +// ToPtr returns a *NotificationName pointing to the current value. +func (c NotificationName) ToPtr() *NotificationName { + return &c +} + +// OperationNameFormat - The format of the Operation Name for Application Insights telemetries. Default is Name. +type OperationNameFormat string + +const ( + // OperationNameFormatName - API_NAME;rev=API_REVISION - OPERATION_NAME + OperationNameFormatName OperationNameFormat = "Name" + // OperationNameFormatURL - HTTP_VERB URL + OperationNameFormatURL OperationNameFormat = "Url" +) + +// PossibleOperationNameFormatValues returns the possible values for the OperationNameFormat const type. +func PossibleOperationNameFormatValues() []OperationNameFormat { + return []OperationNameFormat{ + OperationNameFormatName, + OperationNameFormatURL, + } +} + +// ToPtr returns a *OperationNameFormat pointing to the current value. +func (c OperationNameFormat) ToPtr() *OperationNameFormat { + return &c +} + +// PolicyContentFormat - Format of the policyContent. +type PolicyContentFormat string + +const ( + // PolicyContentFormatRawxml - The contents are inline and Content type is a non XML encoded policy document. + PolicyContentFormatRawxml PolicyContentFormat = "rawxml" + // PolicyContentFormatRawxmlLink - The policy document is not Xml encoded and is hosted on a http endpoint accessible from the API Management service. + PolicyContentFormatRawxmlLink PolicyContentFormat = "rawxml-link" + // PolicyContentFormatXML - The contents are inline and Content type is an XML document. + PolicyContentFormatXML PolicyContentFormat = "xml" + // PolicyContentFormatXMLLink - The policy XML document is hosted on a http endpoint accessible from the API Management service. + PolicyContentFormatXMLLink PolicyContentFormat = "xml-link" +) + +// PossiblePolicyContentFormatValues returns the possible values for the PolicyContentFormat const type. +func PossiblePolicyContentFormatValues() []PolicyContentFormat { + return []PolicyContentFormat{ + PolicyContentFormatRawxml, + PolicyContentFormatRawxmlLink, + PolicyContentFormatXML, + PolicyContentFormatXMLLink, + } +} + +// ToPtr returns a *PolicyContentFormat pointing to the current value. +func (c PolicyContentFormat) ToPtr() *PolicyContentFormat { + return &c +} + +type PolicyExportFormat string + +const ( + // PolicyExportFormatRawxml - The contents are inline and Content type is a non XML encoded policy document. + PolicyExportFormatRawxml PolicyExportFormat = "rawxml" + // PolicyExportFormatXML - The contents are inline and Content type is an XML document. + PolicyExportFormatXML PolicyExportFormat = "xml" +) + +// PossiblePolicyExportFormatValues returns the possible values for the PolicyExportFormat const type. +func PossiblePolicyExportFormatValues() []PolicyExportFormat { + return []PolicyExportFormat{ + PolicyExportFormatRawxml, + PolicyExportFormatXML, + } +} + +// ToPtr returns a *PolicyExportFormat pointing to the current value. +func (c PolicyExportFormat) ToPtr() *PolicyExportFormat { + return &c +} + +type PolicyIDName string + +const ( + PolicyIDNamePolicy PolicyIDName = "policy" +) + +// PossiblePolicyIDNameValues returns the possible values for the PolicyIDName const type. +func PossiblePolicyIDNameValues() []PolicyIDName { + return []PolicyIDName{ + PolicyIDNamePolicy, + } +} + +// ToPtr returns a *PolicyIDName pointing to the current value. +func (c PolicyIDName) ToPtr() *PolicyIDName { + return &c +} + +type PolicyScopeContract string + +const ( + PolicyScopeContractTenant PolicyScopeContract = "Tenant" + PolicyScopeContractProduct PolicyScopeContract = "Product" + PolicyScopeContractAPI PolicyScopeContract = "Api" + PolicyScopeContractOperation PolicyScopeContract = "Operation" + PolicyScopeContractAll PolicyScopeContract = "All" +) + +// PossiblePolicyScopeContractValues returns the possible values for the PolicyScopeContract const type. +func PossiblePolicyScopeContractValues() []PolicyScopeContract { + return []PolicyScopeContract{ + PolicyScopeContractTenant, + PolicyScopeContractProduct, + PolicyScopeContractAPI, + PolicyScopeContractOperation, + PolicyScopeContractAll, + } +} + +// ToPtr returns a *PolicyScopeContract pointing to the current value. +func (c PolicyScopeContract) ToPtr() *PolicyScopeContract { + return &c +} + +// PortalRevisionStatus - Portal revision publishing status +type PortalRevisionStatus string + +const ( + // PortalRevisionStatusCompleted - Portal revision publishing completed + PortalRevisionStatusCompleted PortalRevisionStatus = "completed" + // PortalRevisionStatusFailed - Portal revision publishing failed + PortalRevisionStatusFailed PortalRevisionStatus = "failed" + // PortalRevisionStatusPending - Portal revision publishing is pending + PortalRevisionStatusPending PortalRevisionStatus = "pending" + // PortalRevisionStatusPublishing - Portal revision is publishing + PortalRevisionStatusPublishing PortalRevisionStatus = "publishing" +) + +// PossiblePortalRevisionStatusValues returns the possible values for the PortalRevisionStatus const type. +func PossiblePortalRevisionStatusValues() []PortalRevisionStatus { + return []PortalRevisionStatus{ + PortalRevisionStatusCompleted, + PortalRevisionStatusFailed, + PortalRevisionStatusPending, + PortalRevisionStatusPublishing, + } +} + +// ToPtr returns a *PortalRevisionStatus pointing to the current value. +func (c PortalRevisionStatus) ToPtr() *PortalRevisionStatus { + return &c +} + +// ProductState - whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible +// only to administrators. Default state of Product is +// notPublished. +type ProductState string + +const ( + ProductStateNotPublished ProductState = "notPublished" + ProductStatePublished ProductState = "published" +) + +// PossibleProductStateValues returns the possible values for the ProductState const type. +func PossibleProductStateValues() []ProductState { + return []ProductState{ + ProductStateNotPublished, + ProductStatePublished, + } +} + +// ToPtr returns a *ProductState pointing to the current value. +func (c ProductState) ToPtr() *ProductState { + return &c +} + +type Protocol string + +const ( + ProtocolHTTP Protocol = "http" + ProtocolHTTPS Protocol = "https" +) + +// PossibleProtocolValues returns the possible values for the Protocol const type. +func PossibleProtocolValues() []Protocol { + return []Protocol{ + ProtocolHTTP, + ProtocolHTTPS, + } +} + +// ToPtr returns a *Protocol pointing to the current value. +func (c Protocol) ToPtr() *Protocol { + return &c +} + +// ResourceSKUCapacityScaleType - The scale type applicable to the sku. +type ResourceSKUCapacityScaleType string + +const ( + // ResourceSKUCapacityScaleTypeAutomatic - Supported scale type automatic. + ResourceSKUCapacityScaleTypeAutomatic ResourceSKUCapacityScaleType = "automatic" + // ResourceSKUCapacityScaleTypeManual - Supported scale type manual. + ResourceSKUCapacityScaleTypeManual ResourceSKUCapacityScaleType = "manual" + // ResourceSKUCapacityScaleTypeNone - Scaling not supported. + ResourceSKUCapacityScaleTypeNone ResourceSKUCapacityScaleType = "none" +) + +// PossibleResourceSKUCapacityScaleTypeValues returns the possible values for the ResourceSKUCapacityScaleType const type. +func PossibleResourceSKUCapacityScaleTypeValues() []ResourceSKUCapacityScaleType { + return []ResourceSKUCapacityScaleType{ + ResourceSKUCapacityScaleTypeAutomatic, + ResourceSKUCapacityScaleTypeManual, + ResourceSKUCapacityScaleTypeNone, + } +} + +// ToPtr returns a *ResourceSKUCapacityScaleType pointing to the current value. +func (c ResourceSKUCapacityScaleType) ToPtr() *ResourceSKUCapacityScaleType { + return &c +} + +// SKUType - Name of the Sku. +type SKUType string + +const ( + // SKUTypeBasic - Basic SKU of Api Management. + SKUTypeBasic SKUType = "Basic" + // SKUTypeConsumption - Consumption SKU of Api Management. + SKUTypeConsumption SKUType = "Consumption" + // SKUTypeDeveloper - Developer SKU of Api Management. + SKUTypeDeveloper SKUType = "Developer" + // SKUTypeIsolated - Isolated SKU of Api Management. + SKUTypeIsolated SKUType = "Isolated" + // SKUTypePremium - Premium SKU of Api Management. + SKUTypePremium SKUType = "Premium" + // SKUTypeStandard - Standard SKU of Api Management. + SKUTypeStandard SKUType = "Standard" +) + +// PossibleSKUTypeValues returns the possible values for the SKUType const type. +func PossibleSKUTypeValues() []SKUType { + return []SKUType{ + SKUTypeBasic, + SKUTypeConsumption, + SKUTypeDeveloper, + SKUTypeIsolated, + SKUTypePremium, + SKUTypeStandard, + } +} + +// ToPtr returns a *SKUType pointing to the current value. +func (c SKUType) ToPtr() *SKUType { + return &c +} + +// SamplingType - Sampling type. +type SamplingType string + +const ( + // SamplingTypeFixed - Fixed-rate sampling. + SamplingTypeFixed SamplingType = "fixed" +) + +// PossibleSamplingTypeValues returns the possible values for the SamplingType const type. +func PossibleSamplingTypeValues() []SamplingType { + return []SamplingType{ + SamplingTypeFixed, + } +} + +// ToPtr returns a *SamplingType pointing to the current value. +func (c SamplingType) ToPtr() *SamplingType { + return &c +} + +type SettingsTypeName string + +const ( + SettingsTypeNamePublic SettingsTypeName = "public" +) + +// PossibleSettingsTypeNameValues returns the possible values for the SettingsTypeName const type. +func PossibleSettingsTypeNameValues() []SettingsTypeName { + return []SettingsTypeName{ + SettingsTypeNamePublic, + } +} + +// ToPtr returns a *SettingsTypeName pointing to the current value. +func (c SettingsTypeName) ToPtr() *SettingsTypeName { + return &c +} + +// SoapAPIType - Type of Api to create. +// * http creates a SOAP to REST API +// * soap creates a SOAP pass-through API . +type SoapAPIType string + +const ( + // SoapAPITypeSoapPassThrough - Imports the Soap API having a SOAP front end. + SoapAPITypeSoapPassThrough SoapAPIType = "soap" + // SoapAPITypeSoapToRest - Imports a SOAP API having a RESTful front end. + SoapAPITypeSoapToRest SoapAPIType = "http" +) + +// PossibleSoapAPITypeValues returns the possible values for the SoapAPIType const type. +func PossibleSoapAPITypeValues() []SoapAPIType { + return []SoapAPIType{ + SoapAPITypeSoapPassThrough, + SoapAPITypeSoapToRest, + } +} + +// ToPtr returns a *SoapAPIType pointing to the current value. +func (c SoapAPIType) ToPtr() *SoapAPIType { + return &c +} + +// State - Status of the issue. +type State string + +const ( + // StateClosed - The issue was closed. + StateClosed State = "closed" + // StateOpen - The issue is opened. + StateOpen State = "open" + // StateProposed - The issue is proposed. + StateProposed State = "proposed" + // StateRemoved - The issue was removed. + StateRemoved State = "removed" + // StateResolved - The issue is now resolved. + StateResolved State = "resolved" +) + +// PossibleStateValues returns the possible values for the State const type. +func PossibleStateValues() []State { + return []State{ + StateClosed, + StateOpen, + StateProposed, + StateRemoved, + StateResolved, + } +} + +// ToPtr returns a *State pointing to the current value. +func (c State) ToPtr() *State { + return &c +} + +// SubscriptionState - Subscription state. Possible states are * active – the subscription is active, * suspended – the subscription is blocked, and the +// subscriber cannot call any APIs of the product, * submitted – the +// subscription request has been made by the developer, but has not yet been approved or rejected, * rejected – the subscription request has been denied +// by an administrator, * cancelled – the +// subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated. +type SubscriptionState string + +const ( + SubscriptionStateSuspended SubscriptionState = "suspended" + SubscriptionStateActive SubscriptionState = "active" + SubscriptionStateExpired SubscriptionState = "expired" + SubscriptionStateSubmitted SubscriptionState = "submitted" + SubscriptionStateRejected SubscriptionState = "rejected" + SubscriptionStateCancelled SubscriptionState = "cancelled" +) + +// PossibleSubscriptionStateValues returns the possible values for the SubscriptionState const type. +func PossibleSubscriptionStateValues() []SubscriptionState { + return []SubscriptionState{ + SubscriptionStateSuspended, + SubscriptionStateActive, + SubscriptionStateExpired, + SubscriptionStateSubmitted, + SubscriptionStateRejected, + SubscriptionStateCancelled, + } +} + +// ToPtr returns a *SubscriptionState pointing to the current value. +func (c SubscriptionState) ToPtr() *SubscriptionState { + return &c +} + +type TemplateName string + +const ( + TemplateNameAccountClosedDeveloper TemplateName = "accountClosedDeveloper" + TemplateNameApplicationApprovedNotificationMessage TemplateName = "applicationApprovedNotificationMessage" + TemplateNameConfirmSignUpIdentityDefault TemplateName = "confirmSignUpIdentityDefault" + TemplateNameEmailChangeIdentityDefault TemplateName = "emailChangeIdentityDefault" + TemplateNameInviteUserNotificationMessage TemplateName = "inviteUserNotificationMessage" + TemplateNameNewCommentNotificationMessage TemplateName = "newCommentNotificationMessage" + TemplateNameNewDeveloperNotificationMessage TemplateName = "newDeveloperNotificationMessage" + TemplateNameNewIssueNotificationMessage TemplateName = "newIssueNotificationMessage" + TemplateNamePasswordResetByAdminNotificationMessage TemplateName = "passwordResetByAdminNotificationMessage" + TemplateNamePasswordResetIdentityDefault TemplateName = "passwordResetIdentityDefault" + TemplateNamePurchaseDeveloperNotificationMessage TemplateName = "purchaseDeveloperNotificationMessage" + TemplateNameQuotaLimitApproachingDeveloperNotificationMessage TemplateName = "quotaLimitApproachingDeveloperNotificationMessage" + TemplateNameRejectDeveloperNotificationMessage TemplateName = "rejectDeveloperNotificationMessage" + TemplateNameRequestDeveloperNotificationMessage TemplateName = "requestDeveloperNotificationMessage" +) + +// PossibleTemplateNameValues returns the possible values for the TemplateName const type. +func PossibleTemplateNameValues() []TemplateName { + return []TemplateName{ + TemplateNameAccountClosedDeveloper, + TemplateNameApplicationApprovedNotificationMessage, + TemplateNameConfirmSignUpIdentityDefault, + TemplateNameEmailChangeIdentityDefault, + TemplateNameInviteUserNotificationMessage, + TemplateNameNewCommentNotificationMessage, + TemplateNameNewDeveloperNotificationMessage, + TemplateNameNewIssueNotificationMessage, + TemplateNamePasswordResetByAdminNotificationMessage, + TemplateNamePasswordResetIdentityDefault, + TemplateNamePurchaseDeveloperNotificationMessage, + TemplateNameQuotaLimitApproachingDeveloperNotificationMessage, + TemplateNameRejectDeveloperNotificationMessage, + TemplateNameRequestDeveloperNotificationMessage, + } +} + +// ToPtr returns a *TemplateName pointing to the current value. +func (c TemplateName) ToPtr() *TemplateName { + return &c +} + +// UserState - Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of +// subscribed products. Default state is Active. +type UserState string + +const ( + // UserStateActive - User state is active. + UserStateActive UserState = "active" + // UserStateBlocked - User is blocked. Blocked users cannot authenticate at developer portal or call API. + UserStateBlocked UserState = "blocked" + // UserStateDeleted - User account is closed. All identities and related entities are removed. + UserStateDeleted UserState = "deleted" + // UserStatePending - User account is pending. Requires identity confirmation before it can be made active. + UserStatePending UserState = "pending" +) + +// PossibleUserStateValues returns the possible values for the UserState const type. +func PossibleUserStateValues() []UserState { + return []UserState{ + UserStateActive, + UserStateBlocked, + UserStateDeleted, + UserStatePending, + } +} + +// ToPtr returns a *UserState pointing to the current value. +func (c UserState) ToPtr() *UserState { + return &c +} + +// Verbosity - The verbosity level applied to traces emitted by trace policies. +type Verbosity string + +const ( + // VerbosityError - Only traces with 'severity' set to 'error' will be sent to the logger attached to this diagnostic instance. + VerbosityError Verbosity = "error" + // VerbosityInformation - Traces with 'severity' set to 'information' and 'error' will be sent to the logger attached to this diagnostic instance. + VerbosityInformation Verbosity = "information" + // VerbosityVerbose - All the traces emitted by trace policies will be sent to the logger attached to this diagnostic instance. + VerbosityVerbose Verbosity = "verbose" +) + +// PossibleVerbosityValues returns the possible values for the Verbosity const type. +func PossibleVerbosityValues() []Verbosity { + return []Verbosity{ + VerbosityError, + VerbosityInformation, + VerbosityVerbose, + } +} + +// ToPtr returns a *Verbosity pointing to the current value. +func (c Verbosity) ToPtr() *Verbosity { + return &c +} + +// VersioningScheme - An value that determines where the API Version identifier will be located in a HTTP request. +type VersioningScheme string + +const ( + // VersioningSchemeHeader - The API Version is passed in a HTTP header. + VersioningSchemeHeader VersioningScheme = "Header" + // VersioningSchemeQuery - The API Version is passed in a query parameter. + VersioningSchemeQuery VersioningScheme = "Query" + // VersioningSchemeSegment - The API Version is passed in a path segment. + VersioningSchemeSegment VersioningScheme = "Segment" +) + +// PossibleVersioningSchemeValues returns the possible values for the VersioningScheme const type. +func PossibleVersioningSchemeValues() []VersioningScheme { + return []VersioningScheme{ + VersioningSchemeHeader, + VersioningSchemeQuery, + VersioningSchemeSegment, + } +} + +// ToPtr returns a *VersioningScheme pointing to the current value. +func (c VersioningScheme) ToPtr() *VersioningScheme { + return &c +} + +// VirtualNetworkType - The type of VPN in which API Management service needs to be configured in. None (Default Value) means the API Management service +// is not part of any Virtual Network, External means the API Management +// deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside a +// Virtual Network having an Intranet Facing Endpoint +// only. +type VirtualNetworkType string + +const ( + // VirtualNetworkTypeExternal - The service is part of Virtual Network and it is accessible from Internet. + VirtualNetworkTypeExternal VirtualNetworkType = "External" + // VirtualNetworkTypeInternal - The service is part of Virtual Network and it is only accessible from within the virtual network. + VirtualNetworkTypeInternal VirtualNetworkType = "Internal" + // VirtualNetworkTypeNone - The service is not part of any Virtual Network. + VirtualNetworkTypeNone VirtualNetworkType = "None" +) + +// PossibleVirtualNetworkTypeValues returns the possible values for the VirtualNetworkType const type. +func PossibleVirtualNetworkTypeValues() []VirtualNetworkType { + return []VirtualNetworkType{ + VirtualNetworkTypeExternal, + VirtualNetworkTypeInternal, + VirtualNetworkTypeNone, + } +} + +// ToPtr returns a *VirtualNetworkType pointing to the current value. +func (c VirtualNetworkType) ToPtr() *VirtualNetworkType { + return &c +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_contentitem_client.go b/sdk/apimanagement/armapimanagement/zz_generated_contentitem_client.go new file mode 100644 index 000000000000..277fb1d26aa0 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_contentitem_client.go @@ -0,0 +1,382 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// ContentItemClient contains the methods for the ContentItem group. +// Don't use this type directly, use NewContentItemClient() instead. +type ContentItemClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewContentItemClient creates a new instance of ContentItemClient with the specified values. +func NewContentItemClient(con *armcore.Connection, subscriptionID string) *ContentItemClient { + return &ContentItemClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates a new developer portal's content item specified by the provided content type. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ContentItemClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, options *ContentItemCreateOrUpdateOptions) (ContentItemCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, contentTypeID, contentItemID, options) + if err != nil { + return ContentItemCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ContentItemCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return ContentItemCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ContentItemClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, options *ContentItemCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if contentTypeID == "" { + return nil, errors.New("parameter contentTypeID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contentTypeId}", url.PathEscape(contentTypeID)) + if contentItemID == "" { + return nil, errors.New("parameter contentItemID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contentItemId}", url.PathEscape(contentItemID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ContentItemClient) createOrUpdateHandleResponse(resp *azcore.Response) (ContentItemCreateOrUpdateResponse, error) { + result := ContentItemCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.ContentItemContract); err != nil { + return ContentItemCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ContentItemClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Removes the specified developer portal's content item. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ContentItemClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, ifMatch string, options *ContentItemDeleteOptions) (ContentItemDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, contentTypeID, contentItemID, ifMatch, options) + if err != nil { + return ContentItemDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ContentItemDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return ContentItemDeleteResponse{}, client.deleteHandleError(resp) + } + return ContentItemDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ContentItemClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, ifMatch string, options *ContentItemDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if contentTypeID == "" { + return nil, errors.New("parameter contentTypeID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contentTypeId}", url.PathEscape(contentTypeID)) + if contentItemID == "" { + return nil, errors.New("parameter contentItemID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contentItemId}", url.PathEscape(contentItemID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ContentItemClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Returns the developer portal's content item specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ContentItemClient) Get(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, options *ContentItemGetOptions) (ContentItemGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, contentTypeID, contentItemID, options) + if err != nil { + return ContentItemGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ContentItemGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ContentItemGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ContentItemClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, options *ContentItemGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if contentTypeID == "" { + return nil, errors.New("parameter contentTypeID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contentTypeId}", url.PathEscape(contentTypeID)) + if contentItemID == "" { + return nil, errors.New("parameter contentItemID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contentItemId}", url.PathEscape(contentItemID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ContentItemClient) getHandleResponse(resp *azcore.Response) (ContentItemGetResponse, error) { + result := ContentItemGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.ContentItemContract); err != nil { + return ContentItemGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ContentItemClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Returns the entity state (ETag) version of the developer portal's content item specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ContentItemClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, options *ContentItemGetEntityTagOptions) (ContentItemGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, contentTypeID, contentItemID, options) + if err != nil { + return ContentItemGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ContentItemGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *ContentItemClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, contentItemID string, options *ContentItemGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems/{contentItemId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if contentTypeID == "" { + return nil, errors.New("parameter contentTypeID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contentTypeId}", url.PathEscape(contentTypeID)) + if contentItemID == "" { + return nil, errors.New("parameter contentItemID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contentItemId}", url.PathEscape(contentItemID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *ContentItemClient) getEntityTagHandleResponse(resp *azcore.Response) (ContentItemGetEntityTagResponse, error) { + result := ContentItemGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists developer portal's content items specified by the provided content type. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ContentItemClient) ListByService(resourceGroupName string, serviceName string, contentTypeID string, options *ContentItemListByServiceOptions) ContentItemListByServicePager { + return &contentItemListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, contentTypeID, options) + }, + advancer: func(ctx context.Context, resp ContentItemListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ContentItemCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *ContentItemClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, options *ContentItemListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}/contentItems" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if contentTypeID == "" { + return nil, errors.New("parameter contentTypeID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contentTypeId}", url.PathEscape(contentTypeID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *ContentItemClient) listByServiceHandleResponse(resp *azcore.Response) (ContentItemListByServiceResponse, error) { + result := ContentItemListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ContentItemCollection); err != nil { + return ContentItemListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *ContentItemClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_contenttype_client.go b/sdk/apimanagement/armapimanagement/zz_generated_contenttype_client.go new file mode 100644 index 000000000000..7f4a7909a08f --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_contenttype_client.go @@ -0,0 +1,309 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// ContentTypeClient contains the methods for the ContentType group. +// Don't use this type directly, use NewContentTypeClient() instead. +type ContentTypeClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewContentTypeClient creates a new instance of ContentTypeClient with the specified values. +func NewContentTypeClient(con *armcore.Connection, subscriptionID string) *ContentTypeClient { + return &ContentTypeClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or updates the developer portal's content type. Content types describe content items' properties, validation rules, and constraints. +// Custom content types' identifiers need to start with the c- +// prefix. Built-in content types can't be modified. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ContentTypeClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, options *ContentTypeCreateOrUpdateOptions) (ContentTypeCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, contentTypeID, options) + if err != nil { + return ContentTypeCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ContentTypeCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return ContentTypeCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ContentTypeClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, options *ContentTypeCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if contentTypeID == "" { + return nil, errors.New("parameter contentTypeID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contentTypeId}", url.PathEscape(contentTypeID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ContentTypeClient) createOrUpdateHandleResponse(resp *azcore.Response) (ContentTypeCreateOrUpdateResponse, error) { + result := ContentTypeCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.ContentTypeContract); err != nil { + return ContentTypeCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ContentTypeClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Removes the specified developer portal's content type. Content types describe content items' properties, validation rules, and constraints. +// Built-in content types (with identifiers starting with the +// c- prefix) can't be removed. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ContentTypeClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, ifMatch string, options *ContentTypeDeleteOptions) (ContentTypeDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, contentTypeID, ifMatch, options) + if err != nil { + return ContentTypeDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ContentTypeDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return ContentTypeDeleteResponse{}, client.deleteHandleError(resp) + } + return ContentTypeDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ContentTypeClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, ifMatch string, options *ContentTypeDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if contentTypeID == "" { + return nil, errors.New("parameter contentTypeID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contentTypeId}", url.PathEscape(contentTypeID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ContentTypeClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the developer portal's content type. Content types describe content items' properties, validation rules, and constraints. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ContentTypeClient) Get(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, options *ContentTypeGetOptions) (ContentTypeGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, contentTypeID, options) + if err != nil { + return ContentTypeGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ContentTypeGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ContentTypeGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ContentTypeClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, contentTypeID string, options *ContentTypeGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes/{contentTypeId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if contentTypeID == "" { + return nil, errors.New("parameter contentTypeID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{contentTypeId}", url.PathEscape(contentTypeID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ContentTypeClient) getHandleResponse(resp *azcore.Response) (ContentTypeGetResponse, error) { + result := ContentTypeGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.ContentTypeContract); err != nil { + return ContentTypeGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ContentTypeClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByService - Lists the developer portal's content types. Content types describe content items' properties, validation rules, and constraints. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ContentTypeClient) ListByService(resourceGroupName string, serviceName string, options *ContentTypeListByServiceOptions) ContentTypeListByServicePager { + return &contentTypeListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp ContentTypeListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ContentTypeCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *ContentTypeClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *ContentTypeListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/contentTypes" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *ContentTypeClient) listByServiceHandleResponse(resp *azcore.Response) (ContentTypeListByServiceResponse, error) { + result := ContentTypeListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ContentTypeCollection); err != nil { + return ContentTypeListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *ContentTypeClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_delegationsettings_client.go b/sdk/apimanagement/armapimanagement/zz_generated_delegationsettings_client.go new file mode 100644 index 000000000000..7404e4f68336 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_delegationsettings_client.go @@ -0,0 +1,346 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// DelegationSettingsClient contains the methods for the DelegationSettings group. +// Don't use this type directly, use NewDelegationSettingsClient() instead. +type DelegationSettingsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewDelegationSettingsClient creates a new instance of DelegationSettingsClient with the specified values. +func NewDelegationSettingsClient(con *armcore.Connection, subscriptionID string) *DelegationSettingsClient { + return &DelegationSettingsClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Create or Update Delegation settings. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DelegationSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalDelegationSettings, options *DelegationSettingsCreateOrUpdateOptions) (DelegationSettingsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, parameters, options) + if err != nil { + return DelegationSettingsCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DelegationSettingsCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DelegationSettingsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DelegationSettingsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalDelegationSettings, options *DelegationSettingsCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *DelegationSettingsClient) createOrUpdateHandleResponse(resp *azcore.Response) (DelegationSettingsCreateOrUpdateResponse, error) { + result := DelegationSettingsCreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.PortalDelegationSettings); err != nil { + return DelegationSettingsCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *DelegationSettingsClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Get Delegation Settings for the Portal. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DelegationSettingsClient) Get(ctx context.Context, resourceGroupName string, serviceName string, options *DelegationSettingsGetOptions) (DelegationSettingsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return DelegationSettingsGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DelegationSettingsGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DelegationSettingsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DelegationSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *DelegationSettingsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DelegationSettingsClient) getHandleResponse(resp *azcore.Response) (DelegationSettingsGetResponse, error) { + result := DelegationSettingsGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.PortalDelegationSettings); err != nil { + return DelegationSettingsGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *DelegationSettingsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the DelegationSettings. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DelegationSettingsClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, options *DelegationSettingsGetEntityTagOptions) (DelegationSettingsGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return DelegationSettingsGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DelegationSettingsGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *DelegationSettingsClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *DelegationSettingsGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *DelegationSettingsClient) getEntityTagHandleResponse(resp *azcore.Response) (DelegationSettingsGetEntityTagResponse, error) { + result := DelegationSettingsGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListSecrets - Gets the secret validation key of the DelegationSettings. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DelegationSettingsClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, options *DelegationSettingsListSecretsOptions) (DelegationSettingsListSecretsResponse, error) { + req, err := client.listSecretsCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return DelegationSettingsListSecretsResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DelegationSettingsListSecretsResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DelegationSettingsListSecretsResponse{}, client.listSecretsHandleError(resp) + } + return client.listSecretsHandleResponse(resp) +} + +// listSecretsCreateRequest creates the ListSecrets request. +func (client *DelegationSettingsClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *DelegationSettingsListSecretsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation/listSecrets" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listSecretsHandleResponse handles the ListSecrets response. +func (client *DelegationSettingsClient) listSecretsHandleResponse(resp *azcore.Response) (DelegationSettingsListSecretsResponse, error) { + result := DelegationSettingsListSecretsResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.PortalSettingValidationKeyContract); err != nil { + return DelegationSettingsListSecretsResponse{}, err + } + return result, nil +} + +// listSecretsHandleError handles the ListSecrets error response. +func (client *DelegationSettingsClient) listSecretsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Update Delegation settings. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DelegationSettingsClient) Update(ctx context.Context, resourceGroupName string, serviceName string, ifMatch string, parameters PortalDelegationSettings, options *DelegationSettingsUpdateOptions) (DelegationSettingsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, ifMatch, parameters, options) + if err != nil { + return DelegationSettingsUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DelegationSettingsUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusNoContent) { + return DelegationSettingsUpdateResponse{}, client.updateHandleError(resp) + } + return DelegationSettingsUpdateResponse{RawResponse: resp.Response}, nil +} + +// updateCreateRequest creates the Update request. +func (client *DelegationSettingsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, ifMatch string, parameters PortalDelegationSettings, options *DelegationSettingsUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/delegation" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleError handles the Update error response. +func (client *DelegationSettingsClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_deletedservices_client.go b/sdk/apimanagement/armapimanagement/zz_generated_deletedservices_client.go new file mode 100644 index 000000000000..65d1f07616bc --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_deletedservices_client.go @@ -0,0 +1,258 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// DeletedServicesClient contains the methods for the DeletedServices group. +// Don't use this type directly, use NewDeletedServicesClient() instead. +type DeletedServicesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewDeletedServicesClient creates a new instance of DeletedServicesClient with the specified values. +func NewDeletedServicesClient(con *armcore.Connection, subscriptionID string) *DeletedServicesClient { + return &DeletedServicesClient{con: con, subscriptionID: subscriptionID} +} + +// GetByName - Get soft-deleted Api Management Service by name. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DeletedServicesClient) GetByName(ctx context.Context, serviceName string, location string, options *DeletedServicesGetByNameOptions) (DeletedServicesGetByNameResponse, error) { + req, err := client.getByNameCreateRequest(ctx, serviceName, location, options) + if err != nil { + return DeletedServicesGetByNameResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DeletedServicesGetByNameResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DeletedServicesGetByNameResponse{}, client.getByNameHandleError(resp) + } + return client.getByNameHandleResponse(resp) +} + +// getByNameCreateRequest creates the GetByName request. +func (client *DeletedServicesClient) getByNameCreateRequest(ctx context.Context, serviceName string, location string, options *DeletedServicesGetByNameOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}" + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getByNameHandleResponse handles the GetByName response. +func (client *DeletedServicesClient) getByNameHandleResponse(resp *azcore.Response) (DeletedServicesGetByNameResponse, error) { + result := DeletedServicesGetByNameResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.DeletedServiceContract); err != nil { + return DeletedServicesGetByNameResponse{}, err + } + return result, nil +} + +// getByNameHandleError handles the GetByName error response. +func (client *DeletedServicesClient) getByNameHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListBySubscription - Lists all soft-deleted services available for undelete for the given subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DeletedServicesClient) ListBySubscription(options *DeletedServicesListBySubscriptionOptions) DeletedServicesListBySubscriptionPager { + return &deletedServicesListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, + advancer: func(ctx context.Context, resp DeletedServicesListBySubscriptionResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.DeletedServicesCollection.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *DeletedServicesClient) listBySubscriptionCreateRequest(ctx context.Context, options *DeletedServicesListBySubscriptionOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/deletedservices" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *DeletedServicesClient) listBySubscriptionHandleResponse(resp *azcore.Response) (DeletedServicesListBySubscriptionResponse, error) { + result := DeletedServicesListBySubscriptionResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.DeletedServicesCollection); err != nil { + return DeletedServicesListBySubscriptionResponse{}, err + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *DeletedServicesClient) listBySubscriptionHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginPurge - Purges Api Management Service (deletes it with no option to undelete). +// If the operation fails it returns the *ErrorResponse error type. +func (client *DeletedServicesClient) BeginPurge(ctx context.Context, serviceName string, location string, options *DeletedServicesBeginPurgeOptions) (DeletedServicesPurgePollerResponse, error) { + resp, err := client.purge(ctx, serviceName, location, options) + if err != nil { + return DeletedServicesPurgePollerResponse{}, err + } + result := DeletedServicesPurgePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("DeletedServicesClient.Purge", "location", resp, client.con.Pipeline(), client.purgeHandleError) + if err != nil { + return DeletedServicesPurgePollerResponse{}, err + } + poller := &deletedServicesPurgePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (DeletedServicesPurgeResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumePurge creates a new DeletedServicesPurgePoller from the specified resume token. +// token - The value must come from a previous call to DeletedServicesPurgePoller.ResumeToken(). +func (client *DeletedServicesClient) ResumePurge(ctx context.Context, token string) (DeletedServicesPurgePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("DeletedServicesClient.Purge", token, client.con.Pipeline(), client.purgeHandleError) + if err != nil { + return DeletedServicesPurgePollerResponse{}, err + } + poller := &deletedServicesPurgePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return DeletedServicesPurgePollerResponse{}, err + } + result := DeletedServicesPurgePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (DeletedServicesPurgeResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Purge - Purges Api Management Service (deletes it with no option to undelete). +// If the operation fails it returns the *ErrorResponse error type. +func (client *DeletedServicesClient) purge(ctx context.Context, serviceName string, location string, options *DeletedServicesBeginPurgeOptions) (*azcore.Response, error) { + req, err := client.purgeCreateRequest(ctx, serviceName, location, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + return nil, client.purgeHandleError(resp) + } + return resp, nil +} + +// purgeCreateRequest creates the Purge request. +func (client *DeletedServicesClient) purgeCreateRequest(ctx context.Context, serviceName string, location string, options *DeletedServicesBeginPurgeOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.ApiManagement/locations/{location}/deletedservices/{serviceName}" + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// purgeHandleError handles the Purge error response. +func (client *DeletedServicesClient) purgeHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_diagnostic_client.go b/sdk/apimanagement/armapimanagement/zz_generated_diagnostic_client.go new file mode 100644 index 000000000000..2bf5b964ca13 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_diagnostic_client.go @@ -0,0 +1,446 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// DiagnosticClient contains the methods for the Diagnostic group. +// Don't use this type directly, use NewDiagnosticClient() instead. +type DiagnosticClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewDiagnosticClient creates a new instance of DiagnosticClient with the specified values. +func NewDiagnosticClient(con *armcore.Connection, subscriptionID string) *DiagnosticClient { + return &DiagnosticClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates a new Diagnostic or updates an existing one. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, parameters DiagnosticContract, options *DiagnosticCreateOrUpdateOptions) (DiagnosticCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, diagnosticID, parameters, options) + if err != nil { + return DiagnosticCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DiagnosticCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return DiagnosticCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *DiagnosticClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, parameters DiagnosticContract, options *DiagnosticCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *DiagnosticClient) createOrUpdateHandleResponse(resp *azcore.Response) (DiagnosticCreateOrUpdateResponse, error) { + result := DiagnosticCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.DiagnosticContract); err != nil { + return DiagnosticCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *DiagnosticClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified Diagnostic. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, ifMatch string, options *DiagnosticDeleteOptions) (DiagnosticDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, diagnosticID, ifMatch, options) + if err != nil { + return DiagnosticDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DiagnosticDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return DiagnosticDeleteResponse{}, client.deleteHandleError(resp) + } + return DiagnosticDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *DiagnosticClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, ifMatch string, options *DiagnosticDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *DiagnosticClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the Diagnostic specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticClient) Get(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, options *DiagnosticGetOptions) (DiagnosticGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, diagnosticID, options) + if err != nil { + return DiagnosticGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DiagnosticGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DiagnosticGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *DiagnosticClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, options *DiagnosticGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *DiagnosticClient) getHandleResponse(resp *azcore.Response) (DiagnosticGetResponse, error) { + result := DiagnosticGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.DiagnosticContract); err != nil { + return DiagnosticGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *DiagnosticClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the Diagnostic specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, options *DiagnosticGetEntityTagOptions) (DiagnosticGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, diagnosticID, options) + if err != nil { + return DiagnosticGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DiagnosticGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *DiagnosticClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, options *DiagnosticGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *DiagnosticClient) getEntityTagHandleResponse(resp *azcore.Response) (DiagnosticGetEntityTagResponse, error) { + result := DiagnosticGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists all diagnostics of the API Management service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticClient) ListByService(resourceGroupName string, serviceName string, options *DiagnosticListByServiceOptions) DiagnosticListByServicePager { + return &diagnosticListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp DiagnosticListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.DiagnosticCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *DiagnosticClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *DiagnosticListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *DiagnosticClient) listByServiceHandleResponse(resp *azcore.Response) (DiagnosticListByServiceResponse, error) { + result := DiagnosticListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.DiagnosticCollection); err != nil { + return DiagnosticListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *DiagnosticClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates the details of the Diagnostic specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *DiagnosticClient) Update(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, ifMatch string, parameters DiagnosticContract, options *DiagnosticUpdateOptions) (DiagnosticUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, diagnosticID, ifMatch, parameters, options) + if err != nil { + return DiagnosticUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return DiagnosticUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return DiagnosticUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *DiagnosticClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, diagnosticID string, ifMatch string, parameters DiagnosticContract, options *DiagnosticUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/diagnostics/{diagnosticId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if diagnosticID == "" { + return nil, errors.New("parameter diagnosticID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{diagnosticId}", url.PathEscape(diagnosticID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *DiagnosticClient) updateHandleResponse(resp *azcore.Response) (DiagnosticUpdateResponse, error) { + result := DiagnosticUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.DiagnosticContract); err != nil { + return DiagnosticUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *DiagnosticClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_emailtemplate_client.go b/sdk/apimanagement/armapimanagement/zz_generated_emailtemplate_client.go new file mode 100644 index 000000000000..a123cbe55276 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_emailtemplate_client.go @@ -0,0 +1,443 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// EmailTemplateClient contains the methods for the EmailTemplate group. +// Don't use this type directly, use NewEmailTemplateClient() instead. +type EmailTemplateClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewEmailTemplateClient creates a new instance of EmailTemplateClient with the specified values. +func NewEmailTemplateClient(con *armcore.Connection, subscriptionID string) *EmailTemplateClient { + return &EmailTemplateClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Updates an Email Template. +// If the operation fails it returns the *ErrorResponse error type. +func (client *EmailTemplateClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, parameters EmailTemplateUpdateParameters, options *EmailTemplateCreateOrUpdateOptions) (EmailTemplateCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, templateName, parameters, options) + if err != nil { + return EmailTemplateCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return EmailTemplateCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return EmailTemplateCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *EmailTemplateClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, parameters EmailTemplateUpdateParameters, options *EmailTemplateCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if templateName == "" { + return nil, errors.New("parameter templateName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{templateName}", url.PathEscape(string(templateName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *EmailTemplateClient) createOrUpdateHandleResponse(resp *azcore.Response) (EmailTemplateCreateOrUpdateResponse, error) { + result := EmailTemplateCreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.EmailTemplateContract); err != nil { + return EmailTemplateCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *EmailTemplateClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Reset the Email Template to default template provided by the API Management service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *EmailTemplateClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, ifMatch string, options *EmailTemplateDeleteOptions) (EmailTemplateDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, templateName, ifMatch, options) + if err != nil { + return EmailTemplateDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return EmailTemplateDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return EmailTemplateDeleteResponse{}, client.deleteHandleError(resp) + } + return EmailTemplateDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *EmailTemplateClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, ifMatch string, options *EmailTemplateDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if templateName == "" { + return nil, errors.New("parameter templateName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{templateName}", url.PathEscape(string(templateName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *EmailTemplateClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the email template specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *EmailTemplateClient) Get(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, options *EmailTemplateGetOptions) (EmailTemplateGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, templateName, options) + if err != nil { + return EmailTemplateGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return EmailTemplateGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return EmailTemplateGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *EmailTemplateClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, options *EmailTemplateGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if templateName == "" { + return nil, errors.New("parameter templateName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{templateName}", url.PathEscape(string(templateName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *EmailTemplateClient) getHandleResponse(resp *azcore.Response) (EmailTemplateGetResponse, error) { + result := EmailTemplateGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.EmailTemplateContract); err != nil { + return EmailTemplateGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *EmailTemplateClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the email template specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *EmailTemplateClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, options *EmailTemplateGetEntityTagOptions) (EmailTemplateGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, templateName, options) + if err != nil { + return EmailTemplateGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return EmailTemplateGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *EmailTemplateClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, options *EmailTemplateGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if templateName == "" { + return nil, errors.New("parameter templateName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{templateName}", url.PathEscape(string(templateName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *EmailTemplateClient) getEntityTagHandleResponse(resp *azcore.Response) (EmailTemplateGetEntityTagResponse, error) { + result := EmailTemplateGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Gets all email templates +// If the operation fails it returns the *ErrorResponse error type. +func (client *EmailTemplateClient) ListByService(resourceGroupName string, serviceName string, options *EmailTemplateListByServiceOptions) EmailTemplateListByServicePager { + return &emailTemplateListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp EmailTemplateListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.EmailTemplateCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *EmailTemplateClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *EmailTemplateListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *EmailTemplateClient) listByServiceHandleResponse(resp *azcore.Response) (EmailTemplateListByServiceResponse, error) { + result := EmailTemplateListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.EmailTemplateCollection); err != nil { + return EmailTemplateListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *EmailTemplateClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates API Management email template +// If the operation fails it returns the *ErrorResponse error type. +func (client *EmailTemplateClient) Update(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, ifMatch string, parameters EmailTemplateUpdateParameters, options *EmailTemplateUpdateOptions) (EmailTemplateUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, templateName, ifMatch, parameters, options) + if err != nil { + return EmailTemplateUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return EmailTemplateUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return EmailTemplateUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *EmailTemplateClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, templateName TemplateName, ifMatch string, parameters EmailTemplateUpdateParameters, options *EmailTemplateUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/templates/{templateName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if templateName == "" { + return nil, errors.New("parameter templateName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{templateName}", url.PathEscape(string(templateName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *EmailTemplateClient) updateHandleResponse(resp *azcore.Response) (EmailTemplateUpdateResponse, error) { + result := EmailTemplateUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.EmailTemplateContract); err != nil { + return EmailTemplateUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *EmailTemplateClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_gateway_client.go b/sdk/apimanagement/armapimanagement/zz_generated_gateway_client.go new file mode 100644 index 000000000000..34e8730e392a --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_gateway_client.go @@ -0,0 +1,650 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// GatewayClient contains the methods for the Gateway group. +// Don't use this type directly, use NewGatewayClient() instead. +type GatewayClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewGatewayClient creates a new instance of GatewayClient with the specified values. +func NewGatewayClient(con *armcore.Connection, subscriptionID string) *GatewayClient { + return &GatewayClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or updates a Gateway to be used in Api Management instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayContract, options *GatewayCreateOrUpdateOptions) (GatewayCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, parameters, options) + if err != nil { + return GatewayCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return GatewayCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *GatewayClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayContract, options *GatewayCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *GatewayClient) createOrUpdateHandleResponse(resp *azcore.Response) (GatewayCreateOrUpdateResponse, error) { + result := GatewayCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.GatewayContract); err != nil { + return GatewayCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *GatewayClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes specific Gateway. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, ifMatch string, options *GatewayDeleteOptions) (GatewayDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, ifMatch, options) + if err != nil { + return GatewayDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return GatewayDeleteResponse{}, client.deleteHandleError(resp) + } + return GatewayDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *GatewayClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, ifMatch string, options *GatewayDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *GatewayClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GenerateToken - Gets the Shared Access Authorization Token for the gateway. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayClient) GenerateToken(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayTokenRequestContract, options *GatewayGenerateTokenOptions) (GatewayGenerateTokenResponse, error) { + req, err := client.generateTokenCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, parameters, options) + if err != nil { + return GatewayGenerateTokenResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayGenerateTokenResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return GatewayGenerateTokenResponse{}, client.generateTokenHandleError(resp) + } + return client.generateTokenHandleResponse(resp) +} + +// generateTokenCreateRequest creates the GenerateToken request. +func (client *GatewayClient) generateTokenCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayTokenRequestContract, options *GatewayGenerateTokenOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/generateToken" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// generateTokenHandleResponse handles the GenerateToken response. +func (client *GatewayClient) generateTokenHandleResponse(resp *azcore.Response) (GatewayGenerateTokenResponse, error) { + result := GatewayGenerateTokenResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.GatewayTokenContract); err != nil { + return GatewayGenerateTokenResponse{}, err + } + return result, nil +} + +// generateTokenHandleError handles the GenerateToken error response. +func (client *GatewayClient) generateTokenHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the Gateway specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayClient) Get(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *GatewayGetOptions) (GatewayGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, options) + if err != nil { + return GatewayGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return GatewayGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *GatewayClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *GatewayGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *GatewayClient) getHandleResponse(resp *azcore.Response) (GatewayGetResponse, error) { + result := GatewayGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.GatewayContract); err != nil { + return GatewayGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *GatewayClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the Gateway specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *GatewayGetEntityTagOptions) (GatewayGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, options) + if err != nil { + return GatewayGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *GatewayClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *GatewayGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *GatewayClient) getEntityTagHandleResponse(resp *azcore.Response) (GatewayGetEntityTagResponse, error) { + result := GatewayGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists a collection of gateways registered with service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayClient) ListByService(resourceGroupName string, serviceName string, options *GatewayListByServiceOptions) GatewayListByServicePager { + return &gatewayListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp GatewayListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.GatewayCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *GatewayClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *GatewayListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *GatewayClient) listByServiceHandleResponse(resp *azcore.Response) (GatewayListByServiceResponse, error) { + result := GatewayListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.GatewayCollection); err != nil { + return GatewayListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *GatewayClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListKeys - Retrieves gateway keys. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayClient) ListKeys(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *GatewayListKeysOptions) (GatewayListKeysResponse, error) { + req, err := client.listKeysCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, options) + if err != nil { + return GatewayListKeysResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayListKeysResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return GatewayListKeysResponse{}, client.listKeysHandleError(resp) + } + return client.listKeysHandleResponse(resp) +} + +// listKeysCreateRequest creates the ListKeys request. +func (client *GatewayClient) listKeysCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *GatewayListKeysOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/listKeys" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listKeysHandleResponse handles the ListKeys response. +func (client *GatewayClient) listKeysHandleResponse(resp *azcore.Response) (GatewayListKeysResponse, error) { + result := GatewayListKeysResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.GatewayKeysContract); err != nil { + return GatewayListKeysResponse{}, err + } + return result, nil +} + +// listKeysHandleError handles the ListKeys error response. +func (client *GatewayClient) listKeysHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// RegenerateKey - Regenerates specified gateway key invalidating any tokens created with it. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayClient) RegenerateKey(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayKeyRegenerationRequestContract, options *GatewayRegenerateKeyOptions) (GatewayRegenerateKeyResponse, error) { + req, err := client.regenerateKeyCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, parameters, options) + if err != nil { + return GatewayRegenerateKeyResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayRegenerateKeyResponse{}, err + } + if !resp.HasStatusCode(http.StatusNoContent) { + return GatewayRegenerateKeyResponse{}, client.regenerateKeyHandleError(resp) + } + return GatewayRegenerateKeyResponse{RawResponse: resp.Response}, nil +} + +// regenerateKeyCreateRequest creates the RegenerateKey request. +func (client *GatewayClient) regenerateKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, parameters GatewayKeyRegenerationRequestContract, options *GatewayRegenerateKeyOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/regenerateKey" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// regenerateKeyHandleError handles the RegenerateKey error response. +func (client *GatewayClient) regenerateKeyHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates the details of the gateway specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayClient) Update(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, ifMatch string, parameters GatewayContract, options *GatewayUpdateOptions) (GatewayUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, ifMatch, parameters, options) + if err != nil { + return GatewayUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return GatewayUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *GatewayClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, ifMatch string, parameters GatewayContract, options *GatewayUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *GatewayClient) updateHandleResponse(resp *azcore.Response) (GatewayUpdateResponse, error) { + result := GatewayUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.GatewayContract); err != nil { + return GatewayUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *GatewayClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_gatewayapi_client.go b/sdk/apimanagement/armapimanagement/zz_generated_gatewayapi_client.go new file mode 100644 index 000000000000..01c7a83d71ac --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_gatewayapi_client.go @@ -0,0 +1,311 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// GatewayAPIClient contains the methods for the GatewayAPI group. +// Don't use this type directly, use NewGatewayAPIClient() instead. +type GatewayAPIClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewGatewayAPIClient creates a new instance of GatewayAPIClient with the specified values. +func NewGatewayAPIClient(con *armcore.Connection, subscriptionID string) *GatewayAPIClient { + return &GatewayAPIClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Adds an API to the specified Gateway. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayAPIClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiID string, options *GatewayAPICreateOrUpdateOptions) (GatewayAPICreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, apiID, options) + if err != nil { + return GatewayAPICreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayAPICreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return GatewayAPICreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *GatewayAPIClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiID string, options *GatewayAPICreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + if options != nil && options.Parameters != nil { + return req, req.MarshalAsJSON(*options.Parameters) + } + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *GatewayAPIClient) createOrUpdateHandleResponse(resp *azcore.Response) (GatewayAPICreateOrUpdateResponse, error) { + result := GatewayAPICreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APIContract); err != nil { + return GatewayAPICreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *GatewayAPIClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified API from the specified Gateway. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayAPIClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiID string, options *GatewayAPIDeleteOptions) (GatewayAPIDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, apiID, options) + if err != nil { + return GatewayAPIDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayAPIDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return GatewayAPIDeleteResponse{}, client.deleteHandleError(resp) + } + return GatewayAPIDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *GatewayAPIClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiID string, options *GatewayAPIDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *GatewayAPIClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Checks that API entity specified by identifier is associated with the Gateway entity. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayAPIClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiID string, options *GatewayAPIGetEntityTagOptions) (GatewayAPIGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, apiID, options) + if err != nil { + return GatewayAPIGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayAPIGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *GatewayAPIClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, apiID string, options *GatewayAPIGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis/{apiId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *GatewayAPIClient) getEntityTagHandleResponse(resp *azcore.Response) (GatewayAPIGetEntityTagResponse, error) { + result := GatewayAPIGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists a collection of the APIs associated with a gateway. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayAPIClient) ListByService(resourceGroupName string, serviceName string, gatewayID string, options *GatewayAPIListByServiceOptions) GatewayAPIListByServicePager { + return &gatewayAPIListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, options) + }, + advancer: func(ctx context.Context, resp GatewayAPIListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.APICollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *GatewayAPIClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *GatewayAPIListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/apis" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *GatewayAPIClient) listByServiceHandleResponse(resp *azcore.Response) (GatewayAPIListByServiceResponse, error) { + result := GatewayAPIListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APICollection); err != nil { + return GatewayAPIListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *GatewayAPIClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_gatewaycertificateauthority_client.go b/sdk/apimanagement/armapimanagement/zz_generated_gatewaycertificateauthority_client.go new file mode 100644 index 000000000000..365879106def --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_gatewaycertificateauthority_client.go @@ -0,0 +1,392 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// GatewayCertificateAuthorityClient contains the methods for the GatewayCertificateAuthority group. +// Don't use this type directly, use NewGatewayCertificateAuthorityClient() instead. +type GatewayCertificateAuthorityClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewGatewayCertificateAuthorityClient creates a new instance of GatewayCertificateAuthorityClient with the specified values. +func NewGatewayCertificateAuthorityClient(con *armcore.Connection, subscriptionID string) *GatewayCertificateAuthorityClient { + return &GatewayCertificateAuthorityClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Assign Certificate entity to Gateway entity as Certificate Authority. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayCertificateAuthorityClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, parameters GatewayCertificateAuthorityContract, options *GatewayCertificateAuthorityCreateOrUpdateOptions) (GatewayCertificateAuthorityCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, certificateID, parameters, options) + if err != nil { + return GatewayCertificateAuthorityCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayCertificateAuthorityCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return GatewayCertificateAuthorityCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *GatewayCertificateAuthorityClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, parameters GatewayCertificateAuthorityContract, options *GatewayCertificateAuthorityCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if certificateID == "" { + return nil, errors.New("parameter certificateID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{certificateId}", url.PathEscape(certificateID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *GatewayCertificateAuthorityClient) createOrUpdateHandleResponse(resp *azcore.Response) (GatewayCertificateAuthorityCreateOrUpdateResponse, error) { + result := GatewayCertificateAuthorityCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.GatewayCertificateAuthorityContract); err != nil { + return GatewayCertificateAuthorityCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *GatewayCertificateAuthorityClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Remove relationship between Certificate Authority and Gateway entity. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayCertificateAuthorityClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, ifMatch string, options *GatewayCertificateAuthorityDeleteOptions) (GatewayCertificateAuthorityDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, certificateID, ifMatch, options) + if err != nil { + return GatewayCertificateAuthorityDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayCertificateAuthorityDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return GatewayCertificateAuthorityDeleteResponse{}, client.deleteHandleError(resp) + } + return GatewayCertificateAuthorityDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *GatewayCertificateAuthorityClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, ifMatch string, options *GatewayCertificateAuthorityDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if certificateID == "" { + return nil, errors.New("parameter certificateID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{certificateId}", url.PathEscape(certificateID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *GatewayCertificateAuthorityClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Get assigned Gateway Certificate Authority details. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayCertificateAuthorityClient) Get(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, options *GatewayCertificateAuthorityGetOptions) (GatewayCertificateAuthorityGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, certificateID, options) + if err != nil { + return GatewayCertificateAuthorityGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayCertificateAuthorityGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return GatewayCertificateAuthorityGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *GatewayCertificateAuthorityClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, options *GatewayCertificateAuthorityGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if certificateID == "" { + return nil, errors.New("parameter certificateID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{certificateId}", url.PathEscape(certificateID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *GatewayCertificateAuthorityClient) getHandleResponse(resp *azcore.Response) (GatewayCertificateAuthorityGetResponse, error) { + result := GatewayCertificateAuthorityGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.GatewayCertificateAuthorityContract); err != nil { + return GatewayCertificateAuthorityGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *GatewayCertificateAuthorityClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Checks if Certificate entity is assigned to Gateway entity as Certificate Authority. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayCertificateAuthorityClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, options *GatewayCertificateAuthorityGetEntityTagOptions) (GatewayCertificateAuthorityGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, certificateID, options) + if err != nil { + return GatewayCertificateAuthorityGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayCertificateAuthorityGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *GatewayCertificateAuthorityClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, certificateID string, options *GatewayCertificateAuthorityGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities/{certificateId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if certificateID == "" { + return nil, errors.New("parameter certificateID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{certificateId}", url.PathEscape(certificateID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *GatewayCertificateAuthorityClient) getEntityTagHandleResponse(resp *azcore.Response) (GatewayCertificateAuthorityGetEntityTagResponse, error) { + result := GatewayCertificateAuthorityGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists the collection of Certificate Authorities for the specified Gateway entity. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayCertificateAuthorityClient) ListByService(resourceGroupName string, serviceName string, gatewayID string, options *GatewayCertificateAuthorityListByServiceOptions) GatewayCertificateAuthorityListByServicePager { + return &gatewayCertificateAuthorityListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, options) + }, + advancer: func(ctx context.Context, resp GatewayCertificateAuthorityListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.GatewayCertificateAuthorityCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *GatewayCertificateAuthorityClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *GatewayCertificateAuthorityListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/certificateAuthorities" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *GatewayCertificateAuthorityClient) listByServiceHandleResponse(resp *azcore.Response) (GatewayCertificateAuthorityListByServiceResponse, error) { + result := GatewayCertificateAuthorityListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.GatewayCertificateAuthorityCollection); err != nil { + return GatewayCertificateAuthorityListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *GatewayCertificateAuthorityClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_gatewayhostnameconfiguration_client.go b/sdk/apimanagement/armapimanagement/zz_generated_gatewayhostnameconfiguration_client.go new file mode 100644 index 000000000000..60f13b368d50 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_gatewayhostnameconfiguration_client.go @@ -0,0 +1,392 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// GatewayHostnameConfigurationClient contains the methods for the GatewayHostnameConfiguration group. +// Don't use this type directly, use NewGatewayHostnameConfigurationClient() instead. +type GatewayHostnameConfigurationClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewGatewayHostnameConfigurationClient creates a new instance of GatewayHostnameConfigurationClient with the specified values. +func NewGatewayHostnameConfigurationClient(con *armcore.Connection, subscriptionID string) *GatewayHostnameConfigurationClient { + return &GatewayHostnameConfigurationClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates of updates hostname configuration for a Gateway. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayHostnameConfigurationClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, parameters GatewayHostnameConfigurationContract, options *GatewayHostnameConfigurationCreateOrUpdateOptions) (GatewayHostnameConfigurationCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, hcID, parameters, options) + if err != nil { + return GatewayHostnameConfigurationCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayHostnameConfigurationCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return GatewayHostnameConfigurationCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *GatewayHostnameConfigurationClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, parameters GatewayHostnameConfigurationContract, options *GatewayHostnameConfigurationCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if hcID == "" { + return nil, errors.New("parameter hcID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{hcId}", url.PathEscape(hcID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *GatewayHostnameConfigurationClient) createOrUpdateHandleResponse(resp *azcore.Response) (GatewayHostnameConfigurationCreateOrUpdateResponse, error) { + result := GatewayHostnameConfigurationCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.GatewayHostnameConfigurationContract); err != nil { + return GatewayHostnameConfigurationCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *GatewayHostnameConfigurationClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified hostname configuration from the specified Gateway. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayHostnameConfigurationClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, ifMatch string, options *GatewayHostnameConfigurationDeleteOptions) (GatewayHostnameConfigurationDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, hcID, ifMatch, options) + if err != nil { + return GatewayHostnameConfigurationDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayHostnameConfigurationDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return GatewayHostnameConfigurationDeleteResponse{}, client.deleteHandleError(resp) + } + return GatewayHostnameConfigurationDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *GatewayHostnameConfigurationClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, ifMatch string, options *GatewayHostnameConfigurationDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if hcID == "" { + return nil, errors.New("parameter hcID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{hcId}", url.PathEscape(hcID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *GatewayHostnameConfigurationClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Get details of a hostname configuration +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayHostnameConfigurationClient) Get(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, options *GatewayHostnameConfigurationGetOptions) (GatewayHostnameConfigurationGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, hcID, options) + if err != nil { + return GatewayHostnameConfigurationGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayHostnameConfigurationGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return GatewayHostnameConfigurationGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *GatewayHostnameConfigurationClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, options *GatewayHostnameConfigurationGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if hcID == "" { + return nil, errors.New("parameter hcID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{hcId}", url.PathEscape(hcID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *GatewayHostnameConfigurationClient) getHandleResponse(resp *azcore.Response) (GatewayHostnameConfigurationGetResponse, error) { + result := GatewayHostnameConfigurationGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.GatewayHostnameConfigurationContract); err != nil { + return GatewayHostnameConfigurationGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *GatewayHostnameConfigurationClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Checks that hostname configuration entity specified by identifier exists for specified Gateway entity. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayHostnameConfigurationClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, options *GatewayHostnameConfigurationGetEntityTagOptions) (GatewayHostnameConfigurationGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, hcID, options) + if err != nil { + return GatewayHostnameConfigurationGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GatewayHostnameConfigurationGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *GatewayHostnameConfigurationClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, hcID string, options *GatewayHostnameConfigurationGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations/{hcId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if hcID == "" { + return nil, errors.New("parameter hcID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{hcId}", url.PathEscape(hcID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *GatewayHostnameConfigurationClient) getEntityTagHandleResponse(resp *azcore.Response) (GatewayHostnameConfigurationGetEntityTagResponse, error) { + result := GatewayHostnameConfigurationGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists the collection of hostname configurations for the specified gateway. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GatewayHostnameConfigurationClient) ListByService(resourceGroupName string, serviceName string, gatewayID string, options *GatewayHostnameConfigurationListByServiceOptions) GatewayHostnameConfigurationListByServicePager { + return &gatewayHostnameConfigurationListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, gatewayID, options) + }, + advancer: func(ctx context.Context, resp GatewayHostnameConfigurationListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.GatewayHostnameConfigurationCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *GatewayHostnameConfigurationClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, gatewayID string, options *GatewayHostnameConfigurationListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/{gatewayId}/hostnameConfigurations" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if gatewayID == "" { + return nil, errors.New("parameter gatewayID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{gatewayId}", url.PathEscape(gatewayID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *GatewayHostnameConfigurationClient) listByServiceHandleResponse(resp *azcore.Response) (GatewayHostnameConfigurationListByServiceResponse, error) { + result := GatewayHostnameConfigurationListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.GatewayHostnameConfigurationCollection); err != nil { + return GatewayHostnameConfigurationListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *GatewayHostnameConfigurationClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_group_client.go b/sdk/apimanagement/armapimanagement/zz_generated_group_client.go new file mode 100644 index 000000000000..f8cca542708e --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_group_client.go @@ -0,0 +1,446 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// GroupClient contains the methods for the Group group. +// Don't use this type directly, use NewGroupClient() instead. +type GroupClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewGroupClient creates a new instance of GroupClient with the specified values. +func NewGroupClient(con *armcore.Connection, subscriptionID string) *GroupClient { + return &GroupClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or Updates a group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GroupClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, groupID string, parameters GroupCreateParameters, options *GroupCreateOrUpdateOptions) (GroupCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, groupID, parameters, options) + if err != nil { + return GroupCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GroupCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return GroupCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *GroupClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, parameters GroupCreateParameters, options *GroupCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *GroupClient) createOrUpdateHandleResponse(resp *azcore.Response) (GroupCreateOrUpdateResponse, error) { + result := GroupCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.GroupContract); err != nil { + return GroupCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *GroupClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes specific group of the API Management service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GroupClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, groupID string, ifMatch string, options *GroupDeleteOptions) (GroupDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, groupID, ifMatch, options) + if err != nil { + return GroupDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GroupDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return GroupDeleteResponse{}, client.deleteHandleError(resp) + } + return GroupDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *GroupClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, ifMatch string, options *GroupDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *GroupClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the group specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GroupClient) Get(ctx context.Context, resourceGroupName string, serviceName string, groupID string, options *GroupGetOptions) (GroupGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, groupID, options) + if err != nil { + return GroupGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GroupGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return GroupGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *GroupClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, options *GroupGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *GroupClient) getHandleResponse(resp *azcore.Response) (GroupGetResponse, error) { + result := GroupGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.GroupContract); err != nil { + return GroupGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *GroupClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the group specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GroupClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, groupID string, options *GroupGetEntityTagOptions) (GroupGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, groupID, options) + if err != nil { + return GroupGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GroupGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *GroupClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, options *GroupGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *GroupClient) getEntityTagHandleResponse(resp *azcore.Response) (GroupGetEntityTagResponse, error) { + result := GroupGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists a collection of groups defined within a service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GroupClient) ListByService(resourceGroupName string, serviceName string, options *GroupListByServiceOptions) GroupListByServicePager { + return &groupListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp GroupListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.GroupCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *GroupClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *GroupListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *GroupClient) listByServiceHandleResponse(resp *azcore.Response) (GroupListByServiceResponse, error) { + result := GroupListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.GroupCollection); err != nil { + return GroupListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *GroupClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates the details of the group specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GroupClient) Update(ctx context.Context, resourceGroupName string, serviceName string, groupID string, ifMatch string, parameters GroupUpdateParameters, options *GroupUpdateOptions) (GroupUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, groupID, ifMatch, parameters, options) + if err != nil { + return GroupUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GroupUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return GroupUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *GroupClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, ifMatch string, parameters GroupUpdateParameters, options *GroupUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *GroupClient) updateHandleResponse(resp *azcore.Response) (GroupUpdateResponse, error) { + result := GroupUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.GroupContract); err != nil { + return GroupUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *GroupClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_groupuser_client.go b/sdk/apimanagement/armapimanagement/zz_generated_groupuser_client.go new file mode 100644 index 000000000000..1c6227cd0e62 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_groupuser_client.go @@ -0,0 +1,300 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// GroupUserClient contains the methods for the GroupUser group. +// Don't use this type directly, use NewGroupUserClient() instead. +type GroupUserClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewGroupUserClient creates a new instance of GroupUserClient with the specified values. +func NewGroupUserClient(con *armcore.Connection, subscriptionID string) *GroupUserClient { + return &GroupUserClient{con: con, subscriptionID: subscriptionID} +} + +// CheckEntityExists - Checks that user entity specified by identifier is associated with the group entity. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GroupUserClient) CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string, options *GroupUserCheckEntityExistsOptions) (GroupUserCheckEntityExistsResponse, error) { + req, err := client.checkEntityExistsCreateRequest(ctx, resourceGroupName, serviceName, groupID, userID, options) + if err != nil { + return GroupUserCheckEntityExistsResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GroupUserCheckEntityExistsResponse{}, err + } + result := GroupUserCheckEntityExistsResponse{RawResponse: resp.Response} + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// checkEntityExistsCreateRequest creates the CheckEntityExists request. +func (client *GroupUserClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string, options *GroupUserCheckEntityExistsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// Create - Add existing user to existing group +// If the operation fails it returns the *ErrorResponse error type. +func (client *GroupUserClient) Create(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string, options *GroupUserCreateOptions) (GroupUserCreateResponse, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, serviceName, groupID, userID, options) + if err != nil { + return GroupUserCreateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GroupUserCreateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return GroupUserCreateResponse{}, client.createHandleError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *GroupUserClient) createCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string, options *GroupUserCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// createHandleResponse handles the Create response. +func (client *GroupUserClient) createHandleResponse(resp *azcore.Response) (GroupUserCreateResponse, error) { + result := GroupUserCreateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.UserContract); err != nil { + return GroupUserCreateResponse{}, err + } + return result, nil +} + +// createHandleError handles the Create error response. +func (client *GroupUserClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Remove existing user from existing group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GroupUserClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string, options *GroupUserDeleteOptions) (GroupUserDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, groupID, userID, options) + if err != nil { + return GroupUserDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return GroupUserDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return GroupUserDeleteResponse{}, client.deleteHandleError(resp) + } + return GroupUserDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *GroupUserClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, userID string, options *GroupUserDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users/{userId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *GroupUserClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - Lists a collection of user entities associated with the group. +// If the operation fails it returns the *ErrorResponse error type. +func (client *GroupUserClient) List(resourceGroupName string, serviceName string, groupID string, options *GroupUserListOptions) GroupUserListPager { + return &groupUserListPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, serviceName, groupID, options) + }, + advancer: func(ctx context.Context, resp GroupUserListResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.UserCollection.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *GroupUserClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, groupID string, options *GroupUserListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/groups/{groupId}/users" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *GroupUserClient) listHandleResponse(resp *azcore.Response) (GroupUserListResponse, error) { + result := GroupUserListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.UserCollection); err != nil { + return GroupUserListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *GroupUserClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_identityprovider_client.go b/sdk/apimanagement/armapimanagement/zz_generated_identityprovider_client.go new file mode 100644 index 000000000000..7bbf428f9b6e --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_identityprovider_client.go @@ -0,0 +1,509 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// IdentityProviderClient contains the methods for the IdentityProvider group. +// Don't use this type directly, use NewIdentityProviderClient() instead. +type IdentityProviderClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewIdentityProviderClient creates a new instance of IdentityProviderClient with the specified values. +func NewIdentityProviderClient(con *armcore.Connection, subscriptionID string) *IdentityProviderClient { + return &IdentityProviderClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or Updates the IdentityProvider configuration. +// If the operation fails it returns the *ErrorResponse error type. +func (client *IdentityProviderClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, parameters IdentityProviderCreateContract, options *IdentityProviderCreateOrUpdateOptions) (IdentityProviderCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, identityProviderName, parameters, options) + if err != nil { + return IdentityProviderCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return IdentityProviderCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return IdentityProviderCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *IdentityProviderClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, parameters IdentityProviderCreateContract, options *IdentityProviderCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if identityProviderName == "" { + return nil, errors.New("parameter identityProviderName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{identityProviderName}", url.PathEscape(string(identityProviderName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *IdentityProviderClient) createOrUpdateHandleResponse(resp *azcore.Response) (IdentityProviderCreateOrUpdateResponse, error) { + result := IdentityProviderCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.IdentityProviderContract); err != nil { + return IdentityProviderCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *IdentityProviderClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified identity provider configuration. +// If the operation fails it returns the *ErrorResponse error type. +func (client *IdentityProviderClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, ifMatch string, options *IdentityProviderDeleteOptions) (IdentityProviderDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, identityProviderName, ifMatch, options) + if err != nil { + return IdentityProviderDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return IdentityProviderDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return IdentityProviderDeleteResponse{}, client.deleteHandleError(resp) + } + return IdentityProviderDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *IdentityProviderClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, ifMatch string, options *IdentityProviderDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if identityProviderName == "" { + return nil, errors.New("parameter identityProviderName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{identityProviderName}", url.PathEscape(string(identityProviderName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *IdentityProviderClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the configuration details of the identity Provider configured in specified service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *IdentityProviderClient) Get(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, options *IdentityProviderGetOptions) (IdentityProviderGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, identityProviderName, options) + if err != nil { + return IdentityProviderGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return IdentityProviderGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return IdentityProviderGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *IdentityProviderClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, options *IdentityProviderGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if identityProviderName == "" { + return nil, errors.New("parameter identityProviderName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{identityProviderName}", url.PathEscape(string(identityProviderName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *IdentityProviderClient) getHandleResponse(resp *azcore.Response) (IdentityProviderGetResponse, error) { + result := IdentityProviderGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.IdentityProviderContract); err != nil { + return IdentityProviderGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *IdentityProviderClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the identityProvider specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *IdentityProviderClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, options *IdentityProviderGetEntityTagOptions) (IdentityProviderGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, identityProviderName, options) + if err != nil { + return IdentityProviderGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return IdentityProviderGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *IdentityProviderClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, options *IdentityProviderGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if identityProviderName == "" { + return nil, errors.New("parameter identityProviderName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{identityProviderName}", url.PathEscape(string(identityProviderName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *IdentityProviderClient) getEntityTagHandleResponse(resp *azcore.Response) (IdentityProviderGetEntityTagResponse, error) { + result := IdentityProviderGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists a collection of Identity Provider configured in the specified service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *IdentityProviderClient) ListByService(resourceGroupName string, serviceName string, options *IdentityProviderListByServiceOptions) IdentityProviderListByServicePager { + return &identityProviderListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp IdentityProviderListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.IdentityProviderList.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *IdentityProviderClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *IdentityProviderListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *IdentityProviderClient) listByServiceHandleResponse(resp *azcore.Response) (IdentityProviderListByServiceResponse, error) { + result := IdentityProviderListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.IdentityProviderList); err != nil { + return IdentityProviderListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *IdentityProviderClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListSecrets - Gets the client secret details of the Identity Provider. +// If the operation fails it returns the *ErrorResponse error type. +func (client *IdentityProviderClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, options *IdentityProviderListSecretsOptions) (IdentityProviderListSecretsResponse, error) { + req, err := client.listSecretsCreateRequest(ctx, resourceGroupName, serviceName, identityProviderName, options) + if err != nil { + return IdentityProviderListSecretsResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return IdentityProviderListSecretsResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return IdentityProviderListSecretsResponse{}, client.listSecretsHandleError(resp) + } + return client.listSecretsHandleResponse(resp) +} + +// listSecretsCreateRequest creates the ListSecrets request. +func (client *IdentityProviderClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, options *IdentityProviderListSecretsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}/listSecrets" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if identityProviderName == "" { + return nil, errors.New("parameter identityProviderName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{identityProviderName}", url.PathEscape(string(identityProviderName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listSecretsHandleResponse handles the ListSecrets response. +func (client *IdentityProviderClient) listSecretsHandleResponse(resp *azcore.Response) (IdentityProviderListSecretsResponse, error) { + result := IdentityProviderListSecretsResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.ClientSecretContract); err != nil { + return IdentityProviderListSecretsResponse{}, err + } + return result, nil +} + +// listSecretsHandleError handles the ListSecrets error response. +func (client *IdentityProviderClient) listSecretsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates an existing IdentityProvider configuration. +// If the operation fails it returns the *ErrorResponse error type. +func (client *IdentityProviderClient) Update(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, ifMatch string, parameters IdentityProviderUpdateParameters, options *IdentityProviderUpdateOptions) (IdentityProviderUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, identityProviderName, ifMatch, parameters, options) + if err != nil { + return IdentityProviderUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return IdentityProviderUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return IdentityProviderUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *IdentityProviderClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, identityProviderName IdentityProviderType, ifMatch string, parameters IdentityProviderUpdateParameters, options *IdentityProviderUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/identityProviders/{identityProviderName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if identityProviderName == "" { + return nil, errors.New("parameter identityProviderName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{identityProviderName}", url.PathEscape(string(identityProviderName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *IdentityProviderClient) updateHandleResponse(resp *azcore.Response) (IdentityProviderUpdateResponse, error) { + result := IdentityProviderUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.IdentityProviderContract); err != nil { + return IdentityProviderUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *IdentityProviderClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_issue_client.go b/sdk/apimanagement/armapimanagement/zz_generated_issue_client.go new file mode 100644 index 000000000000..7522534bbc2f --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_issue_client.go @@ -0,0 +1,177 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// IssueClient contains the methods for the Issue group. +// Don't use this type directly, use NewIssueClient() instead. +type IssueClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewIssueClient creates a new instance of IssueClient with the specified values. +func NewIssueClient(con *armcore.Connection, subscriptionID string) *IssueClient { + return &IssueClient{con: con, subscriptionID: subscriptionID} +} + +// Get - Gets API Management issue details +// If the operation fails it returns the *ErrorResponse error type. +func (client *IssueClient) Get(ctx context.Context, resourceGroupName string, serviceName string, issueID string, options *IssueGetOptions) (IssueGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, issueID, options) + if err != nil { + return IssueGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return IssueGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return IssueGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *IssueClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, issueID string, options *IssueGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues/{issueId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if issueID == "" { + return nil, errors.New("parameter issueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{issueId}", url.PathEscape(issueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *IssueClient) getHandleResponse(resp *azcore.Response) (IssueGetResponse, error) { + result := IssueGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.IssueContract); err != nil { + return IssueGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *IssueClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByService - Lists a collection of issues in the specified service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *IssueClient) ListByService(resourceGroupName string, serviceName string, options *IssueListByServiceOptions) IssueListByServicePager { + return &issueListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp IssueListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.IssueCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *IssueClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *IssueListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/issues" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *IssueClient) listByServiceHandleResponse(resp *azcore.Response) (IssueListByServiceResponse, error) { + result := IssueListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.IssueCollection); err != nil { + return IssueListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *IssueClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_logger_client.go b/sdk/apimanagement/armapimanagement/zz_generated_logger_client.go new file mode 100644 index 000000000000..96600461fdd3 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_logger_client.go @@ -0,0 +1,446 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// LoggerClient contains the methods for the Logger group. +// Don't use this type directly, use NewLoggerClient() instead. +type LoggerClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewLoggerClient creates a new instance of LoggerClient with the specified values. +func NewLoggerClient(con *armcore.Connection, subscriptionID string) *LoggerClient { + return &LoggerClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or Updates a logger. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LoggerClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, parameters LoggerContract, options *LoggerCreateOrUpdateOptions) (LoggerCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, loggerID, parameters, options) + if err != nil { + return LoggerCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LoggerCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return LoggerCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *LoggerClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, parameters LoggerContract, options *LoggerCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if loggerID == "" { + return nil, errors.New("parameter loggerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loggerId}", url.PathEscape(loggerID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *LoggerClient) createOrUpdateHandleResponse(resp *azcore.Response) (LoggerCreateOrUpdateResponse, error) { + result := LoggerCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.LoggerContract); err != nil { + return LoggerCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *LoggerClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified logger. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LoggerClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, ifMatch string, options *LoggerDeleteOptions) (LoggerDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, loggerID, ifMatch, options) + if err != nil { + return LoggerDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LoggerDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return LoggerDeleteResponse{}, client.deleteHandleError(resp) + } + return LoggerDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *LoggerClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, ifMatch string, options *LoggerDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if loggerID == "" { + return nil, errors.New("parameter loggerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loggerId}", url.PathEscape(loggerID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *LoggerClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the logger specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LoggerClient) Get(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, options *LoggerGetOptions) (LoggerGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, loggerID, options) + if err != nil { + return LoggerGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LoggerGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LoggerGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *LoggerClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, options *LoggerGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if loggerID == "" { + return nil, errors.New("parameter loggerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loggerId}", url.PathEscape(loggerID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *LoggerClient) getHandleResponse(resp *azcore.Response) (LoggerGetResponse, error) { + result := LoggerGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.LoggerContract); err != nil { + return LoggerGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *LoggerClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the logger specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LoggerClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, options *LoggerGetEntityTagOptions) (LoggerGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, loggerID, options) + if err != nil { + return LoggerGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LoggerGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *LoggerClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, options *LoggerGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if loggerID == "" { + return nil, errors.New("parameter loggerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loggerId}", url.PathEscape(loggerID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *LoggerClient) getEntityTagHandleResponse(resp *azcore.Response) (LoggerGetEntityTagResponse, error) { + result := LoggerGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists a collection of loggers in the specified service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LoggerClient) ListByService(resourceGroupName string, serviceName string, options *LoggerListByServiceOptions) LoggerListByServicePager { + return &loggerListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp LoggerListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.LoggerCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *LoggerClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *LoggerListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *LoggerClient) listByServiceHandleResponse(resp *azcore.Response) (LoggerListByServiceResponse, error) { + result := LoggerListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.LoggerCollection); err != nil { + return LoggerListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *LoggerClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates an existing logger. +// If the operation fails it returns the *ErrorResponse error type. +func (client *LoggerClient) Update(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, ifMatch string, parameters LoggerUpdateContract, options *LoggerUpdateOptions) (LoggerUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, loggerID, ifMatch, parameters, options) + if err != nil { + return LoggerUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return LoggerUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return LoggerUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *LoggerClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, loggerID string, ifMatch string, parameters LoggerUpdateContract, options *LoggerUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/loggers/{loggerId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if loggerID == "" { + return nil, errors.New("parameter loggerID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loggerId}", url.PathEscape(loggerID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *LoggerClient) updateHandleResponse(resp *azcore.Response) (LoggerUpdateResponse, error) { + result := LoggerUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.LoggerContract); err != nil { + return LoggerUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *LoggerClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_models.go b/sdk/apimanagement/armapimanagement/zz_generated_models.go new file mode 100644 index 000000000000..1ec62b102cf3 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_models.go @@ -0,0 +1,8951 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "time" +) + +// APIBeginCreateOrUpdateOptions contains the optional parameters for the API.BeginCreateOrUpdate method. +type APIBeginCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// APICollection - Paged Api list representation. +type APICollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Page values. + Value []*APIContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APICollection. +func (a APICollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", a.Count) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// APIContract - Api details. +type APIContract struct { + Resource + // Api entity contract properties. + Properties *APIContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIContract. +func (a APIContract) MarshalJSON() ([]byte, error) { + objectMap := a.Resource.marshalInternal() + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// APIContractProperties - Api Entity Properties +type APIContractProperties struct { + APIEntityBaseContract + // REQUIRED; Relative URL uniquely identifying this API and all of its resource paths within the API Management service instance. It is appended to the + // API endpoint base URL specified during the service instance + // creation to form a public URL for this API. + Path *string `json:"path,omitempty"` + + // Version set details + APIVersionSet *APIVersionSetContractDetails `json:"apiVersionSet,omitempty"` + + // API name. Must be 1 to 300 characters long. + DisplayName *string `json:"displayName,omitempty"` + + // Describes on which protocols the operations in this API can be invoked. + Protocols []*Protocol `json:"protocols,omitempty"` + + // Absolute URL of the backend service implementing this API. Cannot be more than 2000 characters long. + ServiceURL *string `json:"serviceUrl,omitempty"` + + // API identifier of the source API. + SourceAPIID *string `json:"sourceApiId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIContractProperties. +func (a APIContractProperties) MarshalJSON() ([]byte, error) { + objectMap := a.marshalInternal() + return json.Marshal(objectMap) +} + +func (a APIContractProperties) marshalInternal() map[string]interface{} { + objectMap := a.APIEntityBaseContract.marshalInternal() + populate(objectMap, "apiVersionSet", a.APIVersionSet) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "path", a.Path) + populate(objectMap, "protocols", a.Protocols) + populate(objectMap, "serviceUrl", a.ServiceURL) + populate(objectMap, "sourceApiId", a.SourceAPIID) + return objectMap +} + +// APIContractUpdateProperties - API update contract properties. +type APIContractUpdateProperties struct { + APIEntityBaseContract + // API name. + DisplayName *string `json:"displayName,omitempty"` + + // Relative URL uniquely identifying this API and all of its resource paths within the API Management service instance. It is appended to the API endpoint + // base URL specified during the service instance + // creation to form a public URL for this API. + Path *string `json:"path,omitempty"` + + // Describes on which protocols the operations in this API can be invoked. + Protocols []*Protocol `json:"protocols,omitempty"` + + // Absolute URL of the backend service implementing this API. + ServiceURL *string `json:"serviceUrl,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIContractUpdateProperties. +func (a APIContractUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := a.APIEntityBaseContract.marshalInternal() + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "path", a.Path) + populate(objectMap, "protocols", a.Protocols) + populate(objectMap, "serviceUrl", a.ServiceURL) + return json.Marshal(objectMap) +} + +// APICreateOrUpdateParameter - API Create or Update Parameters. +type APICreateOrUpdateParameter struct { + // Api entity create of update properties. + Properties *APICreateOrUpdateProperties `json:"properties,omitempty"` +} + +// APICreateOrUpdateProperties - Api Create or Update Properties. +type APICreateOrUpdateProperties struct { + APIContractProperties + // Format of the Content in which the API is getting imported. + Format *ContentFormat `json:"format,omitempty"` + + // Type of Api to create. + // * http creates a SOAP to REST API + // * soap creates a SOAP pass-through API . + SoapAPIType *SoapAPIType `json:"apiType,omitempty"` + + // Content value when Importing an API. + Value *string `json:"value,omitempty"` + + // Criteria to limit import of WSDL to a subset of the document. + WsdlSelector *APICreateOrUpdatePropertiesWsdlSelector `json:"wsdlSelector,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type APICreateOrUpdateProperties. +func (a APICreateOrUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := a.APIContractProperties.marshalInternal() + populate(objectMap, "format", a.Format) + populate(objectMap, "apiType", a.SoapAPIType) + populate(objectMap, "value", a.Value) + populate(objectMap, "wsdlSelector", a.WsdlSelector) + return json.Marshal(objectMap) +} + +// APICreateOrUpdatePropertiesWsdlSelector - Criteria to limit import of WSDL to a subset of the document. +type APICreateOrUpdatePropertiesWsdlSelector struct { + // Name of endpoint(port) to import from WSDL + WsdlEndpointName *string `json:"wsdlEndpointName,omitempty"` + + // Name of service to import from WSDL + WsdlServiceName *string `json:"wsdlServiceName,omitempty"` +} + +// APIDeleteOptions contains the optional parameters for the API.Delete method. +type APIDeleteOptions struct { + // Delete all revisions of the Api. + DeleteRevisions *bool +} + +// APIDiagnosticCreateOrUpdateOptions contains the optional parameters for the APIDiagnostic.CreateOrUpdate method. +type APIDiagnosticCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// APIDiagnosticDeleteOptions contains the optional parameters for the APIDiagnostic.Delete method. +type APIDiagnosticDeleteOptions struct { + // placeholder for future optional parameters +} + +// APIDiagnosticGetEntityTagOptions contains the optional parameters for the APIDiagnostic.GetEntityTag method. +type APIDiagnosticGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// APIDiagnosticGetOptions contains the optional parameters for the APIDiagnostic.Get method. +type APIDiagnosticGetOptions struct { + // placeholder for future optional parameters +} + +// APIDiagnosticListByServiceOptions contains the optional parameters for the APIDiagnostic.ListByService method. +type APIDiagnosticListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// APIDiagnosticUpdateOptions contains the optional parameters for the APIDiagnostic.Update method. +type APIDiagnosticUpdateOptions struct { + // placeholder for future optional parameters +} + +// APIEntityBaseContract - API base contract details. +type APIEntityBaseContract struct { + // Describes the Revision of the Api. If no value is provided, default revision 1 is created + APIRevision *string `json:"apiRevision,omitempty"` + + // Description of the Api Revision. + APIRevisionDescription *string `json:"apiRevisionDescription,omitempty"` + + // Type of API. + APIType *APIType `json:"type,omitempty"` + + // Indicates the Version identifier of the API if the API is versioned + APIVersion *string `json:"apiVersion,omitempty"` + + // Description of the Api Version. + APIVersionDescription *string `json:"apiVersionDescription,omitempty"` + + // A resource identifier for the related ApiVersionSet. + APIVersionSetID *string `json:"apiVersionSetId,omitempty"` + + // Collection of authentication settings included into this API. + AuthenticationSettings *AuthenticationSettingsContract `json:"authenticationSettings,omitempty"` + + // Description of the API. May include HTML formatting tags. + Description *string `json:"description,omitempty"` + + // Indicates if API revision is current api revision. + IsCurrent *bool `json:"isCurrent,omitempty"` + + // Protocols over which API is made available. + SubscriptionKeyParameterNames *SubscriptionKeyParameterNamesContract `json:"subscriptionKeyParameterNames,omitempty"` + + // Specifies whether an API or Product subscription is required for accessing the API. + SubscriptionRequired *bool `json:"subscriptionRequired,omitempty"` + + // READ-ONLY; Indicates if API revision is accessible via the gateway. + IsOnline *bool `json:"isOnline,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIEntityBaseContract. +func (a APIEntityBaseContract) MarshalJSON() ([]byte, error) { + objectMap := a.marshalInternal() + return json.Marshal(objectMap) +} + +func (a APIEntityBaseContract) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "apiRevision", a.APIRevision) + populate(objectMap, "apiRevisionDescription", a.APIRevisionDescription) + populate(objectMap, "type", a.APIType) + populate(objectMap, "apiVersion", a.APIVersion) + populate(objectMap, "apiVersionDescription", a.APIVersionDescription) + populate(objectMap, "apiVersionSetId", a.APIVersionSetID) + populate(objectMap, "authenticationSettings", a.AuthenticationSettings) + populate(objectMap, "description", a.Description) + populate(objectMap, "isCurrent", a.IsCurrent) + populate(objectMap, "isOnline", a.IsOnline) + populate(objectMap, "subscriptionKeyParameterNames", a.SubscriptionKeyParameterNames) + populate(objectMap, "subscriptionRequired", a.SubscriptionRequired) + return objectMap +} + +// APIExportGetOptions contains the optional parameters for the APIExport.Get method. +type APIExportGetOptions struct { + // placeholder for future optional parameters +} + +// APIExportResult - API Export result. +type APIExportResult struct { + // Format in which the Api Details are exported to the Storage Blob with Sas Key valid for 5 minutes. + ExportResultFormat *ExportResultFormat `json:"format,omitempty"` + + // ResourceId of the API which was exported. + ID *string `json:"id,omitempty"` + + // The object defining the schema of the exported Api Detail + Value *APIExportResultValue `json:"value,omitempty"` +} + +// APIExportResultValue - The object defining the schema of the exported Api Detail +type APIExportResultValue struct { + // Link to the Storage Blob containing the result of the export operation. The Blob Uri is only valid for 5 minutes. + Link *string `json:"link,omitempty"` +} + +// APIGetEntityTagOptions contains the optional parameters for the API.GetEntityTag method. +type APIGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// APIGetOptions contains the optional parameters for the API.Get method. +type APIGetOptions struct { + // placeholder for future optional parameters +} + +// APIIssueAttachmentCreateOrUpdateOptions contains the optional parameters for the APIIssueAttachment.CreateOrUpdate method. +type APIIssueAttachmentCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// APIIssueAttachmentDeleteOptions contains the optional parameters for the APIIssueAttachment.Delete method. +type APIIssueAttachmentDeleteOptions struct { + // placeholder for future optional parameters +} + +// APIIssueAttachmentGetEntityTagOptions contains the optional parameters for the APIIssueAttachment.GetEntityTag method. +type APIIssueAttachmentGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// APIIssueAttachmentGetOptions contains the optional parameters for the APIIssueAttachment.Get method. +type APIIssueAttachmentGetOptions struct { + // placeholder for future optional parameters +} + +// APIIssueAttachmentListByServiceOptions contains the optional parameters for the APIIssueAttachment.ListByService method. +type APIIssueAttachmentListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// APIIssueCommentCreateOrUpdateOptions contains the optional parameters for the APIIssueComment.CreateOrUpdate method. +type APIIssueCommentCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// APIIssueCommentDeleteOptions contains the optional parameters for the APIIssueComment.Delete method. +type APIIssueCommentDeleteOptions struct { + // placeholder for future optional parameters +} + +// APIIssueCommentGetEntityTagOptions contains the optional parameters for the APIIssueComment.GetEntityTag method. +type APIIssueCommentGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// APIIssueCommentGetOptions contains the optional parameters for the APIIssueComment.Get method. +type APIIssueCommentGetOptions struct { + // placeholder for future optional parameters +} + +// APIIssueCommentListByServiceOptions contains the optional parameters for the APIIssueComment.ListByService method. +type APIIssueCommentListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// APIIssueCreateOrUpdateOptions contains the optional parameters for the APIIssue.CreateOrUpdate method. +type APIIssueCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// APIIssueDeleteOptions contains the optional parameters for the APIIssue.Delete method. +type APIIssueDeleteOptions struct { + // placeholder for future optional parameters +} + +// APIIssueGetEntityTagOptions contains the optional parameters for the APIIssue.GetEntityTag method. +type APIIssueGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// APIIssueGetOptions contains the optional parameters for the APIIssue.Get method. +type APIIssueGetOptions struct { + // Expand the comment attachments. + ExpandCommentsAttachments *bool +} + +// APIIssueListByServiceOptions contains the optional parameters for the APIIssue.ListByService method. +type APIIssueListByServiceOptions struct { + // Expand the comment attachments. + ExpandCommentsAttachments *bool + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| state | filter | eq | |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// APIIssueUpdateOptions contains the optional parameters for the APIIssue.Update method. +type APIIssueUpdateOptions struct { + // placeholder for future optional parameters +} + +// APIListByServiceOptions contains the optional parameters for the API.ListByService method. +type APIListByServiceOptions struct { + // Include full ApiVersionSet resource in response + ExpandAPIVersionSet *bool + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| serviceUrl | filter | ge, le, eq, + // ne, gt, lt | substringof, contains, startswith, endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + // |
| isCurrent | filter | eq, ne | |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Include tags in the response. + Tags *string + // Number of records to return. + Top *int32 +} + +// APIListByTagsOptions contains the optional parameters for the API.ListByTags method. +type APIListByTagsOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| path | filter | ge, le, eq, ne, + // gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + // |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| isCurrent | filter | eq | |
+ Filter *string + // Include not tagged APIs. + IncludeNotTaggedApis *bool + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// APIManagementOperationsListOptions contains the optional parameters for the APIManagementOperations.List method. +type APIManagementOperationsListOptions struct { + // placeholder for future optional parameters +} + +// APIManagementSKU - Describes an available ApiManagement SKU. +type APIManagementSKU struct { + // READ-ONLY; The api versions that support this SKU. + APIVersions []*string `json:"apiVersions,omitempty" azure:"ro"` + + // READ-ONLY; A name value pair to describe the capability. + Capabilities []*APIManagementSKUCapabilities `json:"capabilities,omitempty" azure:"ro"` + + // READ-ONLY; Specifies the number of virtual machines in the scale set. + Capacity *APIManagementSKUCapacity `json:"capacity,omitempty" azure:"ro"` + + // READ-ONLY; Metadata for retrieving price info. + Costs []*APIManagementSKUCosts `json:"costs,omitempty" azure:"ro"` + + // READ-ONLY; The Family of this particular SKU. + Family *string `json:"family,omitempty" azure:"ro"` + + // READ-ONLY; The Kind of resources that are supported in this SKU. + Kind *string `json:"kind,omitempty" azure:"ro"` + + // READ-ONLY; A list of locations and availability zones in those locations where the SKU is available. + LocationInfo []*APIManagementSKULocationInfo `json:"locationInfo,omitempty" azure:"ro"` + + // READ-ONLY; The set of locations that the SKU is available. + Locations []*string `json:"locations,omitempty" azure:"ro"` + + // READ-ONLY; The name of SKU. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; The type of resource the SKU applies to. + ResourceType *string `json:"resourceType,omitempty" azure:"ro"` + + // READ-ONLY; The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. + Restrictions []*APIManagementSKURestrictions `json:"restrictions,omitempty" azure:"ro"` + + // READ-ONLY; The Size of the SKU. + Size *string `json:"size,omitempty" azure:"ro"` + + // READ-ONLY; Specifies the tier of virtual machines in a scale set. + // Possible Values: + // Standard + // Basic + Tier *string `json:"tier,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementSKU. +func (a APIManagementSKU) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "apiVersions", a.APIVersions) + populate(objectMap, "capabilities", a.Capabilities) + populate(objectMap, "capacity", a.Capacity) + populate(objectMap, "costs", a.Costs) + populate(objectMap, "family", a.Family) + populate(objectMap, "kind", a.Kind) + populate(objectMap, "locationInfo", a.LocationInfo) + populate(objectMap, "locations", a.Locations) + populate(objectMap, "name", a.Name) + populate(objectMap, "resourceType", a.ResourceType) + populate(objectMap, "restrictions", a.Restrictions) + populate(objectMap, "size", a.Size) + populate(objectMap, "tier", a.Tier) + return json.Marshal(objectMap) +} + +// APIManagementSKUCapabilities - Describes The SKU capabilities object. +type APIManagementSKUCapabilities struct { + // READ-ONLY; An invariant to describe the feature. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; An invariant if the feature is measured by quantity. + Value *string `json:"value,omitempty" azure:"ro"` +} + +// APIManagementSKUCapacity - Describes scaling information of a SKU. +type APIManagementSKUCapacity struct { + // READ-ONLY; The default capacity. + Default *int32 `json:"default,omitempty" azure:"ro"` + + // READ-ONLY; The maximum capacity that can be set. + Maximum *int32 `json:"maximum,omitempty" azure:"ro"` + + // READ-ONLY; The minimum capacity. + Minimum *int32 `json:"minimum,omitempty" azure:"ro"` + + // READ-ONLY; The scale type applicable to the sku. + ScaleType *APIManagementSKUCapacityScaleType `json:"scaleType,omitempty" azure:"ro"` +} + +// APIManagementSKUCosts - Describes metadata for retrieving price info. +type APIManagementSKUCosts struct { + // READ-ONLY; An invariant to show the extended unit. + ExtendedUnit *string `json:"extendedUnit,omitempty" azure:"ro"` + + // READ-ONLY; Used for querying price from commerce. + MeterID *string `json:"meterID,omitempty" azure:"ro"` + + // READ-ONLY; The multiplier is needed to extend the base metered cost. + Quantity *int64 `json:"quantity,omitempty" azure:"ro"` +} + +type APIManagementSKULocationInfo struct { + // READ-ONLY; Location of the SKU + Location *string `json:"location,omitempty" azure:"ro"` + + // READ-ONLY; Details of capabilities available to a SKU in specific zones. + ZoneDetails []*APIManagementSKUZoneDetails `json:"zoneDetails,omitempty" azure:"ro"` + + // READ-ONLY; List of availability zones where the SKU is supported. + Zones []*string `json:"zones,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementSKULocationInfo. +func (a APIManagementSKULocationInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "location", a.Location) + populate(objectMap, "zoneDetails", a.ZoneDetails) + populate(objectMap, "zones", a.Zones) + return json.Marshal(objectMap) +} + +type APIManagementSKURestrictionInfo struct { + // READ-ONLY; Locations where the SKU is restricted + Locations []*string `json:"locations,omitempty" azure:"ro"` + + // READ-ONLY; List of availability zones where the SKU is restricted. + Zones []*string `json:"zones,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementSKURestrictionInfo. +func (a APIManagementSKURestrictionInfo) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "locations", a.Locations) + populate(objectMap, "zones", a.Zones) + return json.Marshal(objectMap) +} + +// APIManagementSKURestrictions - Describes scaling information of a SKU. +type APIManagementSKURestrictions struct { + // READ-ONLY; The reason for restriction. + ReasonCode *APIManagementSKURestrictionsReasonCode `json:"reasonCode,omitempty" azure:"ro"` + + // READ-ONLY; The information about the restriction where the SKU cannot be used. + RestrictionInfo *APIManagementSKURestrictionInfo `json:"restrictionInfo,omitempty" azure:"ro"` + + // READ-ONLY; The type of restrictions. + Type *APIManagementSKURestrictionsType `json:"type,omitempty" azure:"ro"` + + // READ-ONLY; The value of restrictions. If the restriction type is set to location. This would be different locations where the SKU is restricted. + Values []*string `json:"values,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementSKURestrictions. +func (a APIManagementSKURestrictions) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "reasonCode", a.ReasonCode) + populate(objectMap, "restrictionInfo", a.RestrictionInfo) + populate(objectMap, "type", a.Type) + populate(objectMap, "values", a.Values) + return json.Marshal(objectMap) +} + +// APIManagementSKUZoneDetails - Describes The zonal capabilities of a SKU. +type APIManagementSKUZoneDetails struct { + // READ-ONLY; A list of capabilities that are available for the SKU in the specified list of zones. + Capabilities []*APIManagementSKUCapabilities `json:"capabilities,omitempty" azure:"ro"` + + // READ-ONLY; The set of zones that the SKU is available in with the specified capabilities. + Name []*string `json:"name,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementSKUZoneDetails. +func (a APIManagementSKUZoneDetails) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "capabilities", a.Capabilities) + populate(objectMap, "name", a.Name) + return json.Marshal(objectMap) +} + +// APIManagementSKUsListOptions contains the optional parameters for the APIManagementSKUs.List method. +type APIManagementSKUsListOptions struct { + // placeholder for future optional parameters +} + +// APIManagementSKUsResult - The List Resource Skus operation response. +type APIManagementSKUsResult struct { + // REQUIRED; The list of skus available for the subscription. + Value []*APIManagementSKU `json:"value,omitempty"` + + // READ-ONLY; The URI to fetch the next page of Resource Skus. Call ListNext() with this URI to fetch the next page of Resource Skus + NextLink *string `json:"nextLink,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementSKUsResult. +func (a APIManagementSKUsResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// APIManagementServiceApplyNetworkConfigurationParameters - Parameter supplied to the Apply Network configuration operation. +type APIManagementServiceApplyNetworkConfigurationParameters struct { + // Location of the Api Management service to update for a multi-region service. For a service deployed in a single region, this parameter is not required. + Location *string `json:"location,omitempty"` +} + +// APIManagementServiceBackupRestoreParameters - Parameters supplied to the Backup/Restore of an API Management service operation. +type APIManagementServiceBackupRestoreParameters struct { + // REQUIRED; Azure Cloud Storage account (used to place/retrieve the backup) access key. + AccessKey *string `json:"accessKey,omitempty"` + + // REQUIRED; The name of the backup file to create. + BackupName *string `json:"backupName,omitempty"` + + // REQUIRED; Azure Cloud Storage blob container name used to place/retrieve the backup. + ContainerName *string `json:"containerName,omitempty"` + + // REQUIRED; Azure Cloud Storage account (used to place/retrieve the backup) name. + StorageAccount *string `json:"storageAccount,omitempty"` +} + +// APIManagementServiceBaseProperties - Base Properties of an API Management service resource description. +type APIManagementServiceBaseProperties struct { + // Control Plane Apis version constraint for the API Management service. + APIVersionConstraint *APIVersionConstraint `json:"apiVersionConstraint,omitempty"` + + // Additional datacenter locations of the API Management service. + AdditionalLocations []*AdditionalLocation `json:"additionalLocations,omitempty"` + + // List of Certificates that need to be installed in the API Management service. Max supported certificates that can be installed is 10. + Certificates []*CertificateConfiguration `json:"certificates,omitempty"` + + // Custom properties of the API Management service. + // Setting Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TripleDes168 will disable the cipher TLSRSAWITH3DESEDECBCSHA for all TLS(1.0, 1.1 + // and 1.2). + // Setting Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11 can be used to disable just TLS 1.1. + // Setting Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10 can be used to disable TLS 1.0 on an API Management service. + // Setting Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls11 can be used to disable just TLS 1.1 for communications with backends. + // Setting Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Backend.Protocols.Tls10 can be used to disable TLS 1.0 for communications with backends. + // Setting Microsoft.WindowsAzure.ApiManagement.Gateway.Protocols.Server.Http2 can be used to enable HTTP2 protocol on an API Management service. + // Not specifying any of these properties on PATCH operation will reset omitted properties' values to their defaults. For all the settings except Http2 + // the default value is True if the service was + // created on or before April 1st 2018 and False otherwise. Http2 setting's default value is False. + // You can disable any of next ciphers by using settings Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.[cipher_name]: TLSECDHEECDSAWITHAES256CBCSHA, + // TLSECDHEECDSAWITHAES128CBCSHA, TLS + // ECDHERSAWITHAES256CBCSHA, TLSECDHERSAWITHAES128CBCSHA, TLSRSAWITHAES128GCMSHA256, TLSRSAWITHAES256CBCSHA256, TLSRSAWITHAES128CBCSHA256, TLSRSAWITHAES256CBCSHA, + // TLSRSAWITHAES128CBCSHA. For example, + // Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Ciphers.TLS_RSA_WITH_AES_128_CBC_SHA256:false. The default value is true for them. Note: next ciphers + // can't be disabled since they are required by + // Azure CloudService internal components: TLSECDHEECDSAWITHAES256GCMSHA384,TLSECDHEECDSAWITHAES128GCMSHA256,TLSECDHERSAWITHAES256GCMSHA384,TLSECDHERSAWITHAES128GCMSHA256,TLSECDHEECDSAWITHAES256CBC + // SHA384,TLSECDHEECDSAWITHAES128CBCSHA256,TLSECDHERSAWITHAES256CBCSHA384,TLSECDHERSAWITHAES128CBCSHA256,TLSRSAWITHAES256GCMSHA384 + CustomProperties map[string]*string `json:"customProperties,omitempty"` + + // Property only valid for an Api Management service deployed in multiple locations. This can be used to disable the gateway in master region. + DisableGateway *bool `json:"disableGateway,omitempty"` + + // Property only meant to be used for Consumption SKU Service. This enforces a client certificate to be presented on each request to the gateway. This also + // enables the ability to authenticate the + // certificate in the policy on the gateway. + EnableClientCertificate *bool `json:"enableClientCertificate,omitempty"` + + // Custom hostname configuration of the API Management service. + HostnameConfigurations []*HostnameConfiguration `json:"hostnameConfigurations,omitempty"` + + // Email address from which the notification will be sent. + NotificationSenderEmail *string `json:"notificationSenderEmail,omitempty"` + + // Undelete Api Management Service if it was previously soft-deleted. If this flag is specified and set to True all other properties will be ignored. + Restore *bool `json:"restore,omitempty"` + + // Virtual network configuration of the API Management service. + VirtualNetworkConfiguration *VirtualNetworkConfiguration `json:"virtualNetworkConfiguration,omitempty"` + + // The type of VPN in which API Management service needs to be configured in. None (Default Value) means the API Management service is not part of any Virtual + // Network, External means the API Management + // deployment is set up inside a Virtual Network having an Internet Facing Endpoint, and Internal means that API Management deployment is setup inside a + // Virtual Network having an Intranet Facing Endpoint + // only. + VirtualNetworkType *VirtualNetworkType `json:"virtualNetworkType,omitempty"` + + // READ-ONLY; Creation UTC date of the API Management service.The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 + // standard. + CreatedAtUTC *time.Time `json:"createdAtUtc,omitempty" azure:"ro"` + + // READ-ONLY; DEveloper Portal endpoint URL of the API Management service. + DeveloperPortalURL *string `json:"developerPortalUrl,omitempty" azure:"ro"` + + // READ-ONLY; Gateway URL of the API Management service in the Default Region. + GatewayRegionalURL *string `json:"gatewayRegionalUrl,omitempty" azure:"ro"` + + // READ-ONLY; Gateway URL of the API Management service. + GatewayURL *string `json:"gatewayUrl,omitempty" azure:"ro"` + + // READ-ONLY; Management API endpoint URL of the API Management service. + ManagementAPIURL *string `json:"managementApiUrl,omitempty" azure:"ro"` + + // READ-ONLY; Publisher portal endpoint Url of the API Management service. + PortalURL *string `json:"portalUrl,omitempty" azure:"ro"` + + // READ-ONLY; Private Static Load Balanced IP addresses of the API Management service in Primary region which is deployed in an Internal Virtual Network. + // Available only for Basic, Standard, Premium and Isolated + // SKU. + PrivateIPAddresses []*string `json:"privateIPAddresses,omitempty" azure:"ro"` + + // READ-ONLY; The current provisioning state of the API Management service which can be one of the following: Created/Activating/Succeeded/Updating/Failed/Stopped/Terminating/TerminationFailed/Deleted. + ProvisioningState *string `json:"provisioningState,omitempty" azure:"ro"` + + // READ-ONLY; Public Static Load Balanced IP addresses of the API Management service in Primary region. Available only for Basic, Standard, Premium and + // Isolated SKU. + PublicIPAddresses []*string `json:"publicIPAddresses,omitempty" azure:"ro"` + + // READ-ONLY; SCM endpoint URL of the API Management service. + ScmURL *string `json:"scmUrl,omitempty" azure:"ro"` + + // READ-ONLY; The provisioning state of the API Management service, which is targeted by the long running operation started on the service. + TargetProvisioningState *string `json:"targetProvisioningState,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementServiceBaseProperties. +func (a APIManagementServiceBaseProperties) MarshalJSON() ([]byte, error) { + objectMap := a.marshalInternal() + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementServiceBaseProperties. +func (a *APIManagementServiceBaseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return a.unmarshalInternal(rawMsg) +} + +func (a APIManagementServiceBaseProperties) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "apiVersionConstraint", a.APIVersionConstraint) + populate(objectMap, "additionalLocations", a.AdditionalLocations) + populate(objectMap, "certificates", a.Certificates) + populate(objectMap, "createdAtUtc", (*timeRFC3339)(a.CreatedAtUTC)) + populate(objectMap, "customProperties", a.CustomProperties) + populate(objectMap, "developerPortalUrl", a.DeveloperPortalURL) + populate(objectMap, "disableGateway", a.DisableGateway) + populate(objectMap, "enableClientCertificate", a.EnableClientCertificate) + populate(objectMap, "gatewayRegionalUrl", a.GatewayRegionalURL) + populate(objectMap, "gatewayUrl", a.GatewayURL) + populate(objectMap, "hostnameConfigurations", a.HostnameConfigurations) + populate(objectMap, "managementApiUrl", a.ManagementAPIURL) + populate(objectMap, "notificationSenderEmail", a.NotificationSenderEmail) + populate(objectMap, "portalUrl", a.PortalURL) + populate(objectMap, "privateIPAddresses", a.PrivateIPAddresses) + populate(objectMap, "provisioningState", a.ProvisioningState) + populate(objectMap, "publicIPAddresses", a.PublicIPAddresses) + populate(objectMap, "restore", a.Restore) + populate(objectMap, "scmUrl", a.ScmURL) + populate(objectMap, "targetProvisioningState", a.TargetProvisioningState) + populate(objectMap, "virtualNetworkConfiguration", a.VirtualNetworkConfiguration) + populate(objectMap, "virtualNetworkType", a.VirtualNetworkType) + return objectMap +} + +func (a *APIManagementServiceBaseProperties) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "apiVersionConstraint": + err = unpopulate(val, &a.APIVersionConstraint) + delete(rawMsg, key) + case "additionalLocations": + err = unpopulate(val, &a.AdditionalLocations) + delete(rawMsg, key) + case "certificates": + err = unpopulate(val, &a.Certificates) + delete(rawMsg, key) + case "createdAtUtc": + var aux timeRFC3339 + err = unpopulate(val, &aux) + a.CreatedAtUTC = (*time.Time)(&aux) + delete(rawMsg, key) + case "customProperties": + err = unpopulate(val, &a.CustomProperties) + delete(rawMsg, key) + case "developerPortalUrl": + err = unpopulate(val, &a.DeveloperPortalURL) + delete(rawMsg, key) + case "disableGateway": + err = unpopulate(val, &a.DisableGateway) + delete(rawMsg, key) + case "enableClientCertificate": + err = unpopulate(val, &a.EnableClientCertificate) + delete(rawMsg, key) + case "gatewayRegionalUrl": + err = unpopulate(val, &a.GatewayRegionalURL) + delete(rawMsg, key) + case "gatewayUrl": + err = unpopulate(val, &a.GatewayURL) + delete(rawMsg, key) + case "hostnameConfigurations": + err = unpopulate(val, &a.HostnameConfigurations) + delete(rawMsg, key) + case "managementApiUrl": + err = unpopulate(val, &a.ManagementAPIURL) + delete(rawMsg, key) + case "notificationSenderEmail": + err = unpopulate(val, &a.NotificationSenderEmail) + delete(rawMsg, key) + case "portalUrl": + err = unpopulate(val, &a.PortalURL) + delete(rawMsg, key) + case "privateIPAddresses": + err = unpopulate(val, &a.PrivateIPAddresses) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, &a.ProvisioningState) + delete(rawMsg, key) + case "publicIPAddresses": + err = unpopulate(val, &a.PublicIPAddresses) + delete(rawMsg, key) + case "restore": + err = unpopulate(val, &a.Restore) + delete(rawMsg, key) + case "scmUrl": + err = unpopulate(val, &a.ScmURL) + delete(rawMsg, key) + case "targetProvisioningState": + err = unpopulate(val, &a.TargetProvisioningState) + delete(rawMsg, key) + case "virtualNetworkConfiguration": + err = unpopulate(val, &a.VirtualNetworkConfiguration) + delete(rawMsg, key) + case "virtualNetworkType": + err = unpopulate(val, &a.VirtualNetworkType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// APIManagementServiceBeginApplyNetworkConfigurationUpdatesOptions contains the optional parameters for the APIManagementService.BeginApplyNetworkConfigurationUpdates +// method. +type APIManagementServiceBeginApplyNetworkConfigurationUpdatesOptions struct { + // Parameters supplied to the Apply Network Configuration operation. If the parameters are empty, all the regions in which the Api Management service is + // deployed will be updated sequentially without incurring downtime in the region. + Parameters *APIManagementServiceApplyNetworkConfigurationParameters +} + +// APIManagementServiceBeginBackupOptions contains the optional parameters for the APIManagementService.BeginBackup method. +type APIManagementServiceBeginBackupOptions struct { + // placeholder for future optional parameters +} + +// APIManagementServiceBeginCreateOrUpdateOptions contains the optional parameters for the APIManagementService.BeginCreateOrUpdate method. +type APIManagementServiceBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// APIManagementServiceBeginDeleteOptions contains the optional parameters for the APIManagementService.BeginDelete method. +type APIManagementServiceBeginDeleteOptions struct { + // placeholder for future optional parameters +} + +// APIManagementServiceBeginRestoreOptions contains the optional parameters for the APIManagementService.BeginRestore method. +type APIManagementServiceBeginRestoreOptions struct { + // placeholder for future optional parameters +} + +// APIManagementServiceBeginUpdateOptions contains the optional parameters for the APIManagementService.BeginUpdate method. +type APIManagementServiceBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// APIManagementServiceCheckNameAvailabilityOptions contains the optional parameters for the APIManagementService.CheckNameAvailability method. +type APIManagementServiceCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// APIManagementServiceCheckNameAvailabilityParameters - Parameters supplied to the CheckNameAvailability operation. +type APIManagementServiceCheckNameAvailabilityParameters struct { + // REQUIRED; The name to check for availability. + Name *string `json:"name,omitempty"` +} + +// APIManagementServiceGetDomainOwnershipIdentifierOptions contains the optional parameters for the APIManagementService.GetDomainOwnershipIdentifier method. +type APIManagementServiceGetDomainOwnershipIdentifierOptions struct { + // placeholder for future optional parameters +} + +// APIManagementServiceGetDomainOwnershipIdentifierResult - Response of the GetDomainOwnershipIdentifier operation. +type APIManagementServiceGetDomainOwnershipIdentifierResult struct { + // READ-ONLY; The domain ownership identifier value. + DomainOwnershipIdentifier *string `json:"domainOwnershipIdentifier,omitempty" azure:"ro"` +} + +// APIManagementServiceGetOptions contains the optional parameters for the APIManagementService.Get method. +type APIManagementServiceGetOptions struct { + // placeholder for future optional parameters +} + +// APIManagementServiceGetSsoTokenOptions contains the optional parameters for the APIManagementService.GetSsoToken method. +type APIManagementServiceGetSsoTokenOptions struct { + // placeholder for future optional parameters +} + +// APIManagementServiceGetSsoTokenResult - The response of the GetSsoToken operation. +type APIManagementServiceGetSsoTokenResult struct { + // Redirect URL to the Publisher Portal containing the SSO token. + RedirectURI *string `json:"redirectUri,omitempty"` +} + +// APIManagementServiceIdentity - Identity properties of the Api Management service resource. +type APIManagementServiceIdentity struct { + // REQUIRED; The type of identity used for the resource. The type 'SystemAssigned, UserAssigned' includes both an implicitly created identity and a set + // of user assigned identities. The type 'None' will remove any + // identities from the service. + Type *ApimIdentityType `json:"type,omitempty"` + + // The list of user identities associated with the resource. The user identity dictionary key references will be ARM resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/ providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}'. + UserAssignedIdentities map[string]*UserIdentityProperties `json:"userAssignedIdentities,omitempty"` + + // READ-ONLY; The principal id of the identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The client tenant id of the identity. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementServiceIdentity. +func (a APIManagementServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", a.PrincipalID) + populate(objectMap, "tenantId", a.TenantID) + populate(objectMap, "type", a.Type) + populate(objectMap, "userAssignedIdentities", a.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// APIManagementServiceListByResourceGroupOptions contains the optional parameters for the APIManagementService.ListByResourceGroup method. +type APIManagementServiceListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// APIManagementServiceListOptions contains the optional parameters for the APIManagementService.List method. +type APIManagementServiceListOptions struct { + // placeholder for future optional parameters +} + +// APIManagementServiceListResult - The response of the List API Management services operation. +type APIManagementServiceListResult struct { + // REQUIRED; Result of the List API Management services operation. + Value []*APIManagementServiceResource `json:"value,omitempty"` + + // Link to the next set of results. Not empty if Value contains incomplete list of API Management services. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementServiceListResult. +func (a APIManagementServiceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// APIManagementServiceNameAvailabilityResult - Response of the CheckNameAvailability operation. +type APIManagementServiceNameAvailabilityResult struct { + // Invalid indicates the name provided does not match the resource provider’s naming requirements (incorrect length, unsupported characters, etc.) AlreadyExists + // indicates that the name is already in use + // and is therefore unavailable. + Reason *NameAvailabilityReason `json:"reason,omitempty"` + + // READ-ONLY; If reason == invalid, provide the user with the reason why the given name is invalid, and provide the resource naming requirements so that + // the user can select a valid name. If reason == AlreadyExists, + // explain that is already in use, and direct them to select a different name. + Message *string `json:"message,omitempty" azure:"ro"` + + // READ-ONLY; True if the name is available and can be used to create a new API Management service; otherwise false. + NameAvailable *bool `json:"nameAvailable,omitempty" azure:"ro"` +} + +// APIManagementServiceProperties - Properties of an API Management service resource description. +type APIManagementServiceProperties struct { + APIManagementServiceBaseProperties + // REQUIRED; Publisher email. + PublisherEmail *string `json:"publisherEmail,omitempty"` + + // REQUIRED; Publisher name. + PublisherName *string `json:"publisherName,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementServiceProperties. +func (a APIManagementServiceProperties) MarshalJSON() ([]byte, error) { + objectMap := a.APIManagementServiceBaseProperties.marshalInternal() + populate(objectMap, "publisherEmail", a.PublisherEmail) + populate(objectMap, "publisherName", a.PublisherName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementServiceProperties. +func (a *APIManagementServiceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "publisherEmail": + err = unpopulate(val, &a.PublisherEmail) + delete(rawMsg, key) + case "publisherName": + err = unpopulate(val, &a.PublisherName) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return a.APIManagementServiceBaseProperties.unmarshalInternal(rawMsg) +} + +// APIManagementServiceResource - A single API Management service resource in List or Get response. +type APIManagementServiceResource struct { + ApimResource + // REQUIRED; Resource location. + Location *string `json:"location,omitempty"` + + // REQUIRED; Properties of the API Management service. + Properties *APIManagementServiceProperties `json:"properties,omitempty"` + + // REQUIRED; SKU properties of the API Management service. + SKU *APIManagementServiceSKUProperties `json:"sku,omitempty"` + + // Managed service identity of the Api Management service. + Identity *APIManagementServiceIdentity `json:"identity,omitempty"` + + // A list of availability zones denoting where the resource needs to come from. + Zones []*string `json:"zones,omitempty"` + + // READ-ONLY; ETag of the resource. + Etag *string `json:"etag,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementServiceResource. +func (a APIManagementServiceResource) MarshalJSON() ([]byte, error) { + objectMap := a.ApimResource.marshalInternal() + populate(objectMap, "etag", a.Etag) + populate(objectMap, "identity", a.Identity) + populate(objectMap, "location", a.Location) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "sku", a.SKU) + populate(objectMap, "zones", a.Zones) + return json.Marshal(objectMap) +} + +// APIManagementServiceSKUProperties - API Management service resource SKU properties. +type APIManagementServiceSKUProperties struct { + // REQUIRED; Capacity of the SKU (number of deployed units of the SKU). For Consumption SKU capacity must be specified as 0. + Capacity *int32 `json:"capacity,omitempty"` + + // REQUIRED; Name of the Sku. + Name *SKUType `json:"name,omitempty"` +} + +// APIManagementServiceSKUsListAvailableServiceSKUsOptions contains the optional parameters for the APIManagementServiceSKUs.ListAvailableServiceSKUs method. +type APIManagementServiceSKUsListAvailableServiceSKUsOptions struct { + // placeholder for future optional parameters +} + +// APIManagementServiceUpdateParameters - Parameter supplied to Update Api Management Service. +type APIManagementServiceUpdateParameters struct { + ApimResource + // Managed service identity of the Api Management service. + Identity *APIManagementServiceIdentity `json:"identity,omitempty"` + + // Properties of the API Management service. + Properties *APIManagementServiceUpdateProperties `json:"properties,omitempty"` + + // SKU properties of the API Management service. + SKU *APIManagementServiceSKUProperties `json:"sku,omitempty"` + + // READ-ONLY; ETag of the resource. + Etag *string `json:"etag,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementServiceUpdateParameters. +func (a APIManagementServiceUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := a.ApimResource.marshalInternal() + populate(objectMap, "etag", a.Etag) + populate(objectMap, "identity", a.Identity) + populate(objectMap, "properties", a.Properties) + populate(objectMap, "sku", a.SKU) + return json.Marshal(objectMap) +} + +// APIManagementServiceUpdateProperties - Properties of an API Management service resource description. +type APIManagementServiceUpdateProperties struct { + APIManagementServiceBaseProperties + // Publisher email. + PublisherEmail *string `json:"publisherEmail,omitempty"` + + // Publisher name. + PublisherName *string `json:"publisherName,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIManagementServiceUpdateProperties. +func (a APIManagementServiceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := a.APIManagementServiceBaseProperties.marshalInternal() + populate(objectMap, "publisherEmail", a.PublisherEmail) + populate(objectMap, "publisherName", a.PublisherName) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIManagementServiceUpdateProperties. +func (a *APIManagementServiceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "publisherEmail": + err = unpopulate(val, &a.PublisherEmail) + delete(rawMsg, key) + case "publisherName": + err = unpopulate(val, &a.PublisherName) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return a.APIManagementServiceBaseProperties.unmarshalInternal(rawMsg) +} + +// APIOperationCreateOrUpdateOptions contains the optional parameters for the APIOperation.CreateOrUpdate method. +type APIOperationCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// APIOperationDeleteOptions contains the optional parameters for the APIOperation.Delete method. +type APIOperationDeleteOptions struct { + // placeholder for future optional parameters +} + +// APIOperationGetEntityTagOptions contains the optional parameters for the APIOperation.GetEntityTag method. +type APIOperationGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// APIOperationGetOptions contains the optional parameters for the APIOperation.Get method. +type APIOperationGetOptions struct { + // placeholder for future optional parameters +} + +// APIOperationListByAPIOptions contains the optional parameters for the APIOperation.ListByAPI method. +type APIOperationListByAPIOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| method | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, + // gt, lt | substringof, contains, startswith, endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + // |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Include tags in the response. + Tags *string + // Number of records to return. + Top *int32 +} + +// APIOperationPolicyCreateOrUpdateOptions contains the optional parameters for the APIOperationPolicy.CreateOrUpdate method. +type APIOperationPolicyCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// APIOperationPolicyDeleteOptions contains the optional parameters for the APIOperationPolicy.Delete method. +type APIOperationPolicyDeleteOptions struct { + // placeholder for future optional parameters +} + +// APIOperationPolicyGetEntityTagOptions contains the optional parameters for the APIOperationPolicy.GetEntityTag method. +type APIOperationPolicyGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// APIOperationPolicyGetOptions contains the optional parameters for the APIOperationPolicy.Get method. +type APIOperationPolicyGetOptions struct { + // Policy Export Format. + Format *PolicyExportFormat +} + +// APIOperationPolicyListByOperationOptions contains the optional parameters for the APIOperationPolicy.ListByOperation method. +type APIOperationPolicyListByOperationOptions struct { + // placeholder for future optional parameters +} + +// APIOperationUpdateOptions contains the optional parameters for the APIOperation.Update method. +type APIOperationUpdateOptions struct { + // placeholder for future optional parameters +} + +// APIPolicyCreateOrUpdateOptions contains the optional parameters for the APIPolicy.CreateOrUpdate method. +type APIPolicyCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// APIPolicyDeleteOptions contains the optional parameters for the APIPolicy.Delete method. +type APIPolicyDeleteOptions struct { + // placeholder for future optional parameters +} + +// APIPolicyGetEntityTagOptions contains the optional parameters for the APIPolicy.GetEntityTag method. +type APIPolicyGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// APIPolicyGetOptions contains the optional parameters for the APIPolicy.Get method. +type APIPolicyGetOptions struct { + // Policy Export Format. + Format *PolicyExportFormat +} + +// APIPolicyListByAPIOptions contains the optional parameters for the APIPolicy.ListByAPI method. +type APIPolicyListByAPIOptions struct { + // placeholder for future optional parameters +} + +// APIProductListByApisOptions contains the optional parameters for the APIProduct.ListByApis method. +type APIProductListByApisOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| displayName | filter + // | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// APIReleaseCollection - Paged ApiRelease list representation. +type APIReleaseCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Page values. + Value []*APIReleaseContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIReleaseCollection. +func (a APIReleaseCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", a.Count) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// APIReleaseContract - ApiRelease details. +type APIReleaseContract struct { + Resource + // ApiRelease entity contract properties. + Properties *APIReleaseContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIReleaseContract. +func (a APIReleaseContract) MarshalJSON() ([]byte, error) { + objectMap := a.Resource.marshalInternal() + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// APIReleaseContractProperties - API Release details +type APIReleaseContractProperties struct { + // Identifier of the API the release belongs to. + APIID *string `json:"apiId,omitempty"` + + // Release Notes + Notes *string `json:"notes,omitempty"` + + // READ-ONLY; The time the API was released. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + CreatedDateTime *time.Time `json:"createdDateTime,omitempty" azure:"ro"` + + // READ-ONLY; The time the API release was updated. + UpdatedDateTime *time.Time `json:"updatedDateTime,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIReleaseContractProperties. +func (a APIReleaseContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "apiId", a.APIID) + populate(objectMap, "createdDateTime", (*timeRFC3339)(a.CreatedDateTime)) + populate(objectMap, "notes", a.Notes) + populate(objectMap, "updatedDateTime", (*timeRFC3339)(a.UpdatedDateTime)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIReleaseContractProperties. +func (a *APIReleaseContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "apiId": + err = unpopulate(val, &a.APIID) + delete(rawMsg, key) + case "createdDateTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + a.CreatedDateTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "notes": + err = unpopulate(val, &a.Notes) + delete(rawMsg, key) + case "updatedDateTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + a.UpdatedDateTime = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// APIReleaseCreateOrUpdateOptions contains the optional parameters for the APIRelease.CreateOrUpdate method. +type APIReleaseCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// APIReleaseDeleteOptions contains the optional parameters for the APIRelease.Delete method. +type APIReleaseDeleteOptions struct { + // placeholder for future optional parameters +} + +// APIReleaseGetEntityTagOptions contains the optional parameters for the APIRelease.GetEntityTag method. +type APIReleaseGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// APIReleaseGetOptions contains the optional parameters for the APIRelease.Get method. +type APIReleaseGetOptions struct { + // placeholder for future optional parameters +} + +// APIReleaseListByServiceOptions contains the optional parameters for the APIRelease.ListByService method. +type APIReleaseListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| notes | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// APIReleaseUpdateOptions contains the optional parameters for the APIRelease.Update method. +type APIReleaseUpdateOptions struct { + // placeholder for future optional parameters +} + +// APIRevisionCollection - Paged Api Revision list representation. +type APIRevisionCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Page values. + Value []*APIRevisionContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIRevisionCollection. +func (a APIRevisionCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", a.Count) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// APIRevisionContract - Summary of revision metadata. +type APIRevisionContract struct { + // READ-ONLY; Identifier of the API Revision. + APIID *string `json:"apiId,omitempty" azure:"ro"` + + // READ-ONLY; Revision number of API. + APIRevision *string `json:"apiRevision,omitempty" azure:"ro"` + + // READ-ONLY; The time the API Revision was created. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + CreatedDateTime *time.Time `json:"createdDateTime,omitempty" azure:"ro"` + + // READ-ONLY; Description of the API Revision. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; Indicates if API revision is accessible via the gateway. + IsCurrent *bool `json:"isCurrent,omitempty" azure:"ro"` + + // READ-ONLY; Indicates if API revision is the current api revision. + IsOnline *bool `json:"isOnline,omitempty" azure:"ro"` + + // READ-ONLY; Gateway URL for accessing the non-current API Revision. + PrivateURL *string `json:"privateUrl,omitempty" azure:"ro"` + + // READ-ONLY; The time the API Revision were updated. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + UpdatedDateTime *time.Time `json:"updatedDateTime,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIRevisionContract. +func (a APIRevisionContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "apiId", a.APIID) + populate(objectMap, "apiRevision", a.APIRevision) + populate(objectMap, "createdDateTime", (*timeRFC3339)(a.CreatedDateTime)) + populate(objectMap, "description", a.Description) + populate(objectMap, "isCurrent", a.IsCurrent) + populate(objectMap, "isOnline", a.IsOnline) + populate(objectMap, "privateUrl", a.PrivateURL) + populate(objectMap, "updatedDateTime", (*timeRFC3339)(a.UpdatedDateTime)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type APIRevisionContract. +func (a *APIRevisionContract) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "apiId": + err = unpopulate(val, &a.APIID) + delete(rawMsg, key) + case "apiRevision": + err = unpopulate(val, &a.APIRevision) + delete(rawMsg, key) + case "createdDateTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + a.CreatedDateTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "description": + err = unpopulate(val, &a.Description) + delete(rawMsg, key) + case "isCurrent": + err = unpopulate(val, &a.IsCurrent) + delete(rawMsg, key) + case "isOnline": + err = unpopulate(val, &a.IsOnline) + delete(rawMsg, key) + case "privateUrl": + err = unpopulate(val, &a.PrivateURL) + delete(rawMsg, key) + case "updatedDateTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + a.UpdatedDateTime = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// APIRevisionInfoContract - Object used to create an API Revision or Version based on an existing API Revision +type APIRevisionInfoContract struct { + // Description of new API Revision. + APIRevisionDescription *string `json:"apiRevisionDescription,omitempty"` + + // Version identifier for the new API Version. + APIVersionName *string `json:"apiVersionName,omitempty"` + + // Version set details + APIVersionSet *APIVersionSetContractDetails `json:"apiVersionSet,omitempty"` + + // Resource identifier of API to be used to create the revision from. + SourceAPIID *string `json:"sourceApiId,omitempty"` +} + +// APIRevisionListByServiceOptions contains the optional parameters for the APIRevision.ListByService method. +type APIRevisionListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| apiRevision | filter + // | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// APISchemaBeginCreateOrUpdateOptions contains the optional parameters for the APISchema.BeginCreateOrUpdate method. +type APISchemaBeginCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// APISchemaDeleteOptions contains the optional parameters for the APISchema.Delete method. +type APISchemaDeleteOptions struct { + // If true removes all references to the schema before deleting it. + Force *bool +} + +// APISchemaGetEntityTagOptions contains the optional parameters for the APISchema.GetEntityTag method. +type APISchemaGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// APISchemaGetOptions contains the optional parameters for the APISchema.Get method. +type APISchemaGetOptions struct { + // placeholder for future optional parameters +} + +// APISchemaListByAPIOptions contains the optional parameters for the APISchema.ListByAPI method. +type APISchemaListByAPIOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| contentType | filter + // | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// APITagDescriptionCreateOrUpdateOptions contains the optional parameters for the APITagDescription.CreateOrUpdate method. +type APITagDescriptionCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// APITagDescriptionDeleteOptions contains the optional parameters for the APITagDescription.Delete method. +type APITagDescriptionDeleteOptions struct { + // placeholder for future optional parameters +} + +// APITagDescriptionGetEntityTagOptions contains the optional parameters for the APITagDescription.GetEntityTag method. +type APITagDescriptionGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// APITagDescriptionGetOptions contains the optional parameters for the APITagDescription.Get method. +type APITagDescriptionGetOptions struct { + // placeholder for future optional parameters +} + +// APITagDescriptionListByServiceOptions contains the optional parameters for the APITagDescription.ListByService method. +type APITagDescriptionListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| displayName | filter + // | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// APITagResourceContractProperties - API contract properties for the Tag Resources. +type APITagResourceContractProperties struct { + APIEntityBaseContract + // API identifier in the form /apis/{apiId}. + ID *string `json:"id,omitempty"` + + // API name. + Name *string `json:"name,omitempty"` + + // Relative URL uniquely identifying this API and all of its resource paths within the API Management service instance. It is appended to the API endpoint + // base URL specified during the service instance + // creation to form a public URL for this API. + Path *string `json:"path,omitempty"` + + // Describes on which protocols the operations in this API can be invoked. + Protocols []*Protocol `json:"protocols,omitempty"` + + // Absolute URL of the backend service implementing this API. + ServiceURL *string `json:"serviceUrl,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type APITagResourceContractProperties. +func (a APITagResourceContractProperties) MarshalJSON() ([]byte, error) { + objectMap := a.APIEntityBaseContract.marshalInternal() + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "path", a.Path) + populate(objectMap, "protocols", a.Protocols) + populate(objectMap, "serviceUrl", a.ServiceURL) + return json.Marshal(objectMap) +} + +// APIUpdateContract - API update contract details. +type APIUpdateContract struct { + // Properties of the API entity that can be updated. + Properties *APIContractUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIUpdateContract. +func (a APIUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// APIUpdateOptions contains the optional parameters for the API.Update method. +type APIUpdateOptions struct { + // placeholder for future optional parameters +} + +// APIVersionConstraint - Control Plane Apis version constraint for the API Management service. +type APIVersionConstraint struct { + // Limit control plane API calls to API Management service with version equal to or newer than this value. + MinAPIVersion *string `json:"minApiVersion,omitempty"` +} + +// APIVersionSetCollection - Paged Api Version Set list representation. +type APIVersionSetCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*APIVersionSetContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIVersionSetCollection. +func (a APIVersionSetCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", a.Count) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// APIVersionSetContract - Api Version Set Contract details. +type APIVersionSetContract struct { + Resource + // Api VersionSet contract properties. + Properties *APIVersionSetContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIVersionSetContract. +func (a APIVersionSetContract) MarshalJSON() ([]byte, error) { + objectMap := a.Resource.marshalInternal() + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// APIVersionSetContractDetails - An API Version Set contains the common configuration for a set of API Versions relating +type APIVersionSetContractDetails struct { + // Description of API Version Set. + Description *string `json:"description,omitempty"` + + // Identifier for existing API Version Set. Omit this value to create a new Version Set. + ID *string `json:"id,omitempty"` + + // The display Name of the API Version Set. + Name *string `json:"name,omitempty"` + + // Name of HTTP header parameter that indicates the API Version if versioningScheme is set to header. + VersionHeaderName *string `json:"versionHeaderName,omitempty"` + + // Name of query parameter that indicates the API Version if versioningScheme is set to query. + VersionQueryName *string `json:"versionQueryName,omitempty"` + + // An value that determines where the API Version identifier will be located in a HTTP request. + VersioningScheme *APIVersionSetContractDetailsVersioningScheme `json:"versioningScheme,omitempty"` +} + +// APIVersionSetContractProperties - Properties of an API Version Set. +type APIVersionSetContractProperties struct { + APIVersionSetEntityBase + // REQUIRED; Name of API Version Set + DisplayName *string `json:"displayName,omitempty"` + + // REQUIRED; An value that determines where the API Version identifier will be located in a HTTP request. + VersioningScheme *VersioningScheme `json:"versioningScheme,omitempty"` +} + +// APIVersionSetCreateOrUpdateOptions contains the optional parameters for the APIVersionSet.CreateOrUpdate method. +type APIVersionSetCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// APIVersionSetDeleteOptions contains the optional parameters for the APIVersionSet.Delete method. +type APIVersionSetDeleteOptions struct { + // placeholder for future optional parameters +} + +// APIVersionSetEntityBase - Api Version set base parameters +type APIVersionSetEntityBase struct { + // Description of API Version Set. + Description *string `json:"description,omitempty"` + + // Name of HTTP header parameter that indicates the API Version if versioningScheme is set to header. + VersionHeaderName *string `json:"versionHeaderName,omitempty"` + + // Name of query parameter that indicates the API Version if versioningScheme is set to query. + VersionQueryName *string `json:"versionQueryName,omitempty"` +} + +// APIVersionSetGetEntityTagOptions contains the optional parameters for the APIVersionSet.GetEntityTag method. +type APIVersionSetGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// APIVersionSetGetOptions contains the optional parameters for the APIVersionSet.Get method. +type APIVersionSetGetOptions struct { + // placeholder for future optional parameters +} + +// APIVersionSetListByServiceOptions contains the optional parameters for the APIVersionSet.ListByService method. +type APIVersionSetListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// APIVersionSetUpdateOptions contains the optional parameters for the APIVersionSet.Update method. +type APIVersionSetUpdateOptions struct { + // placeholder for future optional parameters +} + +// APIVersionSetUpdateParameters - Parameters to update or create an Api Version Set Contract. +type APIVersionSetUpdateParameters struct { + // Parameters to update or create an Api Version Set Contract. + Properties *APIVersionSetUpdateParametersProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type APIVersionSetUpdateParameters. +func (a APIVersionSetUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// APIVersionSetUpdateParametersProperties - Properties used to create or update an API Version Set. +type APIVersionSetUpdateParametersProperties struct { + APIVersionSetEntityBase + // Name of API Version Set + DisplayName *string `json:"displayName,omitempty"` + + // An value that determines where the API Version identifier will be located in a HTTP request. + VersioningScheme *VersioningScheme `json:"versioningScheme,omitempty"` +} + +// AccessInformationCollection - Paged AccessInformation list representation. +type AccessInformationCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Page values. + Value []*AccessInformationContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AccessInformationCollection. +func (a AccessInformationCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", a.Count) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// AccessInformationContract - Tenant Settings. +type AccessInformationContract struct { + Resource + // AccessInformation entity contract properties. + Properties *AccessInformationContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AccessInformationContract. +func (a AccessInformationContract) MarshalJSON() ([]byte, error) { + objectMap := a.Resource.marshalInternal() + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// AccessInformationContractProperties - Tenant access information contract of the API Management service. +type AccessInformationContractProperties struct { + // Determines whether direct access is enabled. + Enabled *bool `json:"enabled,omitempty"` + + // Access Information type ('access' or 'gitAccess') + ID *string `json:"id,omitempty"` + + // Principal (User) Identifier. + PrincipalID *string `json:"principalId,omitempty"` +} + +// AccessInformationCreateParameterProperties - Tenant access information update parameters of the API Management service +type AccessInformationCreateParameterProperties struct { + // Determines whether direct access is enabled. + Enabled *bool `json:"enabled,omitempty"` + + // Primary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + PrimaryKey *string `json:"primaryKey,omitempty"` + + // Principal (User) Identifier. + PrincipalID *string `json:"principalId,omitempty"` + + // Secondary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + SecondaryKey *string `json:"secondaryKey,omitempty"` +} + +// AccessInformationCreateParameters - Tenant access information update parameters. +type AccessInformationCreateParameters struct { + // Tenant access information update parameter properties. + Properties *AccessInformationCreateParameterProperties `json:"properties,omitempty"` +} + +// AccessInformationSecretsContract - Tenant access information contract of the API Management service. +type AccessInformationSecretsContract struct { + // Determines whether direct access is enabled. + Enabled *bool `json:"enabled,omitempty"` + + // Access Information type ('access' or 'gitAccess') + ID *string `json:"id,omitempty"` + + // Primary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + PrimaryKey *string `json:"primaryKey,omitempty"` + + // Principal (User) Identifier. + PrincipalID *string `json:"principalId,omitempty"` + + // Secondary access key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + SecondaryKey *string `json:"secondaryKey,omitempty"` +} + +// AccessInformationUpdateParameterProperties - Tenant access information update parameters of the API Management service +type AccessInformationUpdateParameterProperties struct { + // Determines whether direct access is enabled. + Enabled *bool `json:"enabled,omitempty"` +} + +// AccessInformationUpdateParameters - Tenant access information update parameters. +type AccessInformationUpdateParameters struct { + // Tenant access information update parameter properties. + Properties *AccessInformationUpdateParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AccessInformationUpdateParameters. +func (a AccessInformationUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// AdditionalLocation - Description of an additional API Management resource location. +type AdditionalLocation struct { + // REQUIRED; The location name of the additional region among Azure Data center regions. + Location *string `json:"location,omitempty"` + + // REQUIRED; SKU properties of the API Management service. + SKU *APIManagementServiceSKUProperties `json:"sku,omitempty"` + + // Property only valid for an Api Management service deployed in multiple locations. This can be used to disable the gateway in this additional location. + DisableGateway *bool `json:"disableGateway,omitempty"` + + // Virtual network configuration for the location. + VirtualNetworkConfiguration *VirtualNetworkConfiguration `json:"virtualNetworkConfiguration,omitempty"` + + // A list of availability zones denoting where the resource needs to come from. + Zones []*string `json:"zones,omitempty"` + + // READ-ONLY; Gateway URL of the API Management service in the Region. + GatewayRegionalURL *string `json:"gatewayRegionalUrl,omitempty" azure:"ro"` + + // READ-ONLY; Private Static Load Balanced IP addresses of the API Management service which is deployed in an Internal Virtual Network in a particular additional + // location. Available only for Basic, Standard, + // Premium and Isolated SKU. + PrivateIPAddresses []*string `json:"privateIPAddresses,omitempty" azure:"ro"` + + // READ-ONLY; Public Static Load Balanced IP addresses of the API Management service in the additional location. Available only for Basic, Standard, Premium + // and Isolated SKU. + PublicIPAddresses []*string `json:"publicIPAddresses,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type AdditionalLocation. +func (a AdditionalLocation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "disableGateway", a.DisableGateway) + populate(objectMap, "gatewayRegionalUrl", a.GatewayRegionalURL) + populate(objectMap, "location", a.Location) + populate(objectMap, "privateIPAddresses", a.PrivateIPAddresses) + populate(objectMap, "publicIPAddresses", a.PublicIPAddresses) + populate(objectMap, "sku", a.SKU) + populate(objectMap, "virtualNetworkConfiguration", a.VirtualNetworkConfiguration) + populate(objectMap, "zones", a.Zones) + return json.Marshal(objectMap) +} + +// ApimResource - The Resource definition. +type ApimResource struct { + // Resource tags. + Tags map[string]*string `json:"tags,omitempty"` + + // READ-ONLY; Resource ID. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource type for API Management resource is set to Microsoft.ApiManagement. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ApimResource. +func (a ApimResource) MarshalJSON() ([]byte, error) { + objectMap := a.marshalInternal() + return json.Marshal(objectMap) +} + +func (a ApimResource) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", a.ID) + populate(objectMap, "name", a.Name) + populate(objectMap, "tags", a.Tags) + populate(objectMap, "type", a.Type) + return objectMap +} + +// AssociationContract - Association entity details. +type AssociationContract struct { + Resource + // Association entity contract properties. + Properties *AssociationContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AssociationContract. +func (a AssociationContract) MarshalJSON() ([]byte, error) { + objectMap := a.Resource.marshalInternal() + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// AssociationContractProperties - Association entity contract properties. +type AssociationContractProperties struct { + // Provisioning state. + ProvisioningState *string `json:"provisioningState,omitempty"` +} + +// AuthenticationSettingsContract - API Authentication Settings. +type AuthenticationSettingsContract struct { + // OAuth2 Authentication settings + OAuth2 *OAuth2AuthenticationSettingsContract `json:"oAuth2,omitempty"` + + // OpenID Connect Authentication Settings + Openid *OpenIDAuthenticationSettingsContract `json:"openid,omitempty"` +} + +// AuthorizationServerCollection - Paged OAuth2 Authorization Servers list representation. +type AuthorizationServerCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*AuthorizationServerContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AuthorizationServerCollection. +func (a AuthorizationServerCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", a.Count) + populate(objectMap, "nextLink", a.NextLink) + populate(objectMap, "value", a.Value) + return json.Marshal(objectMap) +} + +// AuthorizationServerContract - External OAuth authorization server settings. +type AuthorizationServerContract struct { + Resource + // Properties of the External OAuth authorization server Contract. + Properties *AuthorizationServerContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AuthorizationServerContract. +func (a AuthorizationServerContract) MarshalJSON() ([]byte, error) { + objectMap := a.Resource.marshalInternal() + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// AuthorizationServerContractBaseProperties - External OAuth authorization server Update settings contract. +type AuthorizationServerContractBaseProperties struct { + // HTTP verbs supported by the authorization endpoint. GET must be always present. POST is optional. + AuthorizationMethods []*AuthorizationMethod `json:"authorizationMethods,omitempty"` + + // Specifies the mechanism by which access token is passed to the API. + BearerTokenSendingMethods []*BearerTokenSendingMethod `json:"bearerTokenSendingMethods,omitempty"` + + // Method of authentication supported by the token endpoint of this authorization server. Possible values are Basic and/or Body. When Body is specified, + // client credentials and other parameters are passed + // within the request body in the application/x-www-form-urlencoded format. + ClientAuthenticationMethod []*ClientAuthenticationMethod `json:"clientAuthenticationMethod,omitempty"` + + // Access token scope that is going to be requested by default. Can be overridden at the API level. Should be provided in the form of a string containing + // space-delimited values. + DefaultScope *string `json:"defaultScope,omitempty"` + + // Description of the authorization server. Can contain HTML formatting tags. + Description *string `json:"description,omitempty"` + + // Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner password. + ResourceOwnerPassword *string `json:"resourceOwnerPassword,omitempty"` + + // Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. + ResourceOwnerUsername *string `json:"resourceOwnerUsername,omitempty"` + + // If true, authorization server will include state parameter from the authorization request to its response. Client may use state parameter to raise protocol + // security. + SupportState *bool `json:"supportState,omitempty"` + + // Additional parameters required by the token endpoint of this authorization server represented as an array of JSON objects with name and value string + // properties, i.e. {"name" : "name value", "value": + // "a value"}. + TokenBodyParameters []*TokenBodyParameterContract `json:"tokenBodyParameters,omitempty"` + + // OAuth token endpoint. Contains absolute URI to entity being referenced. + TokenEndpoint *string `json:"tokenEndpoint,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AuthorizationServerContractBaseProperties. +func (a AuthorizationServerContractBaseProperties) MarshalJSON() ([]byte, error) { + objectMap := a.marshalInternal() + return json.Marshal(objectMap) +} + +func (a AuthorizationServerContractBaseProperties) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "authorizationMethods", a.AuthorizationMethods) + populate(objectMap, "bearerTokenSendingMethods", a.BearerTokenSendingMethods) + populate(objectMap, "clientAuthenticationMethod", a.ClientAuthenticationMethod) + populate(objectMap, "defaultScope", a.DefaultScope) + populate(objectMap, "description", a.Description) + populate(objectMap, "resourceOwnerPassword", a.ResourceOwnerPassword) + populate(objectMap, "resourceOwnerUsername", a.ResourceOwnerUsername) + populate(objectMap, "supportState", a.SupportState) + populate(objectMap, "tokenBodyParameters", a.TokenBodyParameters) + populate(objectMap, "tokenEndpoint", a.TokenEndpoint) + return objectMap +} + +// AuthorizationServerContractProperties - External OAuth authorization server settings Properties. +type AuthorizationServerContractProperties struct { + AuthorizationServerContractBaseProperties + // REQUIRED; OAuth authorization endpoint. See http://tools.ietf.org/html/rfc6749#section-3.2. + AuthorizationEndpoint *string `json:"authorizationEndpoint,omitempty"` + + // REQUIRED; Client or app id registered with this authorization server. + ClientID *string `json:"clientId,omitempty"` + + // REQUIRED; Optional reference to a page where client or app registration for this authorization server is performed. Contains absolute URL to entity being + // referenced. + ClientRegistrationEndpoint *string `json:"clientRegistrationEndpoint,omitempty"` + + // REQUIRED; User-friendly authorization server name. + DisplayName *string `json:"displayName,omitempty"` + + // REQUIRED; Form of an authorization grant, which the client uses to request the access token. + GrantTypes []*GrantType `json:"grantTypes,omitempty"` + + // Client or app secret registered with this authorization server. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request + // to get the value. + ClientSecret *string `json:"clientSecret,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AuthorizationServerContractProperties. +func (a AuthorizationServerContractProperties) MarshalJSON() ([]byte, error) { + objectMap := a.AuthorizationServerContractBaseProperties.marshalInternal() + populate(objectMap, "authorizationEndpoint", a.AuthorizationEndpoint) + populate(objectMap, "clientId", a.ClientID) + populate(objectMap, "clientRegistrationEndpoint", a.ClientRegistrationEndpoint) + populate(objectMap, "clientSecret", a.ClientSecret) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "grantTypes", a.GrantTypes) + return json.Marshal(objectMap) +} + +// AuthorizationServerCreateOrUpdateOptions contains the optional parameters for the AuthorizationServer.CreateOrUpdate method. +type AuthorizationServerCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// AuthorizationServerDeleteOptions contains the optional parameters for the AuthorizationServer.Delete method. +type AuthorizationServerDeleteOptions struct { + // placeholder for future optional parameters +} + +// AuthorizationServerGetEntityTagOptions contains the optional parameters for the AuthorizationServer.GetEntityTag method. +type AuthorizationServerGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// AuthorizationServerGetOptions contains the optional parameters for the AuthorizationServer.Get method. +type AuthorizationServerGetOptions struct { + // placeholder for future optional parameters +} + +// AuthorizationServerListByServiceOptions contains the optional parameters for the AuthorizationServer.ListByService method. +type AuthorizationServerListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// AuthorizationServerListSecretsOptions contains the optional parameters for the AuthorizationServer.ListSecrets method. +type AuthorizationServerListSecretsOptions struct { + // placeholder for future optional parameters +} + +// AuthorizationServerSecretsContract - OAuth Server Secrets Contract. +type AuthorizationServerSecretsContract struct { + // oAuth Authorization Server Secrets. + ClientSecret *string `json:"clientSecret,omitempty"` + + // Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner password. + ResourceOwnerPassword *string `json:"resourceOwnerPassword,omitempty"` + + // Can be optionally specified when resource owner password grant type is supported by this authorization server. Default resource owner username. + ResourceOwnerUsername *string `json:"resourceOwnerUsername,omitempty"` +} + +// AuthorizationServerUpdateContract - External OAuth authorization server settings. +type AuthorizationServerUpdateContract struct { + Resource + // Properties of the External OAuth authorization server update Contract. + Properties *AuthorizationServerUpdateContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AuthorizationServerUpdateContract. +func (a AuthorizationServerUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := a.Resource.marshalInternal() + populate(objectMap, "properties", a.Properties) + return json.Marshal(objectMap) +} + +// AuthorizationServerUpdateContractProperties - External OAuth authorization server Update settings contract. +type AuthorizationServerUpdateContractProperties struct { + AuthorizationServerContractBaseProperties + // OAuth authorization endpoint. See http://tools.ietf.org/html/rfc6749#section-3.2. + AuthorizationEndpoint *string `json:"authorizationEndpoint,omitempty"` + + // Client or app id registered with this authorization server. + ClientID *string `json:"clientId,omitempty"` + + // Optional reference to a page where client or app registration for this authorization server is performed. Contains absolute URL to entity being referenced. + ClientRegistrationEndpoint *string `json:"clientRegistrationEndpoint,omitempty"` + + // Client or app secret registered with this authorization server. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request + // to get the value. + ClientSecret *string `json:"clientSecret,omitempty"` + + // User-friendly authorization server name. + DisplayName *string `json:"displayName,omitempty"` + + // Form of an authorization grant, which the client uses to request the access token. + GrantTypes []*GrantType `json:"grantTypes,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type AuthorizationServerUpdateContractProperties. +func (a AuthorizationServerUpdateContractProperties) MarshalJSON() ([]byte, error) { + objectMap := a.AuthorizationServerContractBaseProperties.marshalInternal() + populate(objectMap, "authorizationEndpoint", a.AuthorizationEndpoint) + populate(objectMap, "clientId", a.ClientID) + populate(objectMap, "clientRegistrationEndpoint", a.ClientRegistrationEndpoint) + populate(objectMap, "clientSecret", a.ClientSecret) + populate(objectMap, "displayName", a.DisplayName) + populate(objectMap, "grantTypes", a.GrantTypes) + return json.Marshal(objectMap) +} + +// AuthorizationServerUpdateOptions contains the optional parameters for the AuthorizationServer.Update method. +type AuthorizationServerUpdateOptions struct { + // placeholder for future optional parameters +} + +// BackendAuthorizationHeaderCredentials - Authorization header information. +type BackendAuthorizationHeaderCredentials struct { + // REQUIRED; Authentication Parameter value. + Parameter *string `json:"parameter,omitempty"` + + // REQUIRED; Authentication Scheme name. + Scheme *string `json:"scheme,omitempty"` +} + +// BackendBaseParameters - Backend entity base Parameter set. +type BackendBaseParameters struct { + // Backend Credentials Contract Properties + Credentials *BackendCredentialsContract `json:"credentials,omitempty"` + + // Backend Description. + Description *string `json:"description,omitempty"` + + // Backend Properties contract + Properties *BackendProperties `json:"properties,omitempty"` + + // Backend Proxy Contract Properties + Proxy *BackendProxyContract `json:"proxy,omitempty"` + + // Management Uri of the Resource in External System. This url can be the Arm Resource Id of Logic Apps, Function Apps or Api Apps. + ResourceID *string `json:"resourceId,omitempty"` + + // Backend TLS Properties + TLS *BackendTLSProperties `json:"tls,omitempty"` + + // Backend Title. + Title *string `json:"title,omitempty"` +} + +// BackendCollection - Paged Backend list representation. +type BackendCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Backend values. + Value []*BackendContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type BackendCollection. +func (b BackendCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", b.Count) + populate(objectMap, "nextLink", b.NextLink) + populate(objectMap, "value", b.Value) + return json.Marshal(objectMap) +} + +// BackendContract - Backend details. +type BackendContract struct { + Resource + // Backend entity contract properties. + Properties *BackendContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type BackendContract. +func (b BackendContract) MarshalJSON() ([]byte, error) { + objectMap := b.Resource.marshalInternal() + populate(objectMap, "properties", b.Properties) + return json.Marshal(objectMap) +} + +// BackendContractProperties - Parameters supplied to the Create Backend operation. +type BackendContractProperties struct { + BackendBaseParameters + // REQUIRED; Backend communication protocol. + Protocol *BackendProtocol `json:"protocol,omitempty"` + + // REQUIRED; Runtime Url of the Backend. + URL *string `json:"url,omitempty"` +} + +// BackendCreateOrUpdateOptions contains the optional parameters for the Backend.CreateOrUpdate method. +type BackendCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// BackendCredentialsContract - Details of the Credentials used to connect to Backend. +type BackendCredentialsContract struct { + // Authorization header authentication + Authorization *BackendAuthorizationHeaderCredentials `json:"authorization,omitempty"` + + // List of Client Certificate Thumbprints. Will be ignored if certificatesIds are provided. + Certificate []*string `json:"certificate,omitempty"` + + // List of Client Certificate Ids. + CertificateIDs []*string `json:"certificateIds,omitempty"` + + // Header Parameter description. + Header map[string][]*string `json:"header,omitempty"` + + // Query Parameter description. + Query map[string][]*string `json:"query,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type BackendCredentialsContract. +func (b BackendCredentialsContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "authorization", b.Authorization) + populate(objectMap, "certificate", b.Certificate) + populate(objectMap, "certificateIds", b.CertificateIDs) + populate(objectMap, "header", b.Header) + populate(objectMap, "query", b.Query) + return json.Marshal(objectMap) +} + +// BackendDeleteOptions contains the optional parameters for the Backend.Delete method. +type BackendDeleteOptions struct { + // placeholder for future optional parameters +} + +// BackendGetEntityTagOptions contains the optional parameters for the Backend.GetEntityTag method. +type BackendGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// BackendGetOptions contains the optional parameters for the Backend.Get method. +type BackendGetOptions struct { + // placeholder for future optional parameters +} + +// BackendListByServiceOptions contains the optional parameters for the Backend.ListByService method. +type BackendListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| title | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| url | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// BackendProperties - Properties specific to the Backend Type. +type BackendProperties struct { + // Backend Service Fabric Cluster Properties + ServiceFabricCluster *BackendServiceFabricClusterProperties `json:"serviceFabricCluster,omitempty"` +} + +// BackendProxyContract - Details of the Backend WebProxy Server to use in the Request to Backend. +type BackendProxyContract struct { + // REQUIRED; WebProxy Server AbsoluteUri property which includes the entire URI stored in the Uri instance, including all fragments and query strings. + URL *string `json:"url,omitempty"` + + // Password to connect to the WebProxy Server + Password *string `json:"password,omitempty"` + + // Username to connect to the WebProxy server + Username *string `json:"username,omitempty"` +} + +// BackendReconnectContract - Reconnect request parameters. +type BackendReconnectContract struct { + Resource + // Reconnect request properties. + Properties *BackendReconnectProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type BackendReconnectContract. +func (b BackendReconnectContract) MarshalJSON() ([]byte, error) { + objectMap := b.Resource.marshalInternal() + populate(objectMap, "properties", b.Properties) + return json.Marshal(objectMap) +} + +// BackendReconnectOptions contains the optional parameters for the Backend.Reconnect method. +type BackendReconnectOptions struct { + // Reconnect request parameters. + Parameters *BackendReconnectContract +} + +// BackendReconnectProperties - Properties to control reconnect requests. +type BackendReconnectProperties struct { + // Duration in ISO8601 format after which reconnect will be initiated. Minimum duration of the Reconnect is PT2M. + After *string `json:"after,omitempty"` +} + +// BackendServiceFabricClusterProperties - Properties of the Service Fabric Type Backend. +type BackendServiceFabricClusterProperties struct { + // REQUIRED; The cluster management endpoint. + ManagementEndpoints []*string `json:"managementEndpoints,omitempty"` + + // The client certificate id for the management endpoint. + ClientCertificateID *string `json:"clientCertificateId,omitempty"` + + // The client certificate thumbprint for the management endpoint. Will be ignored if certificatesIds are provided + ClientCertificatethumbprint *string `json:"clientCertificatethumbprint,omitempty"` + + // Maximum number of retries while attempting resolve the partition. + MaxPartitionResolutionRetries *int32 `json:"maxPartitionResolutionRetries,omitempty"` + + // Thumbprints of certificates cluster management service uses for tls communication + ServerCertificateThumbprints []*string `json:"serverCertificateThumbprints,omitempty"` + + // Server X509 Certificate Names Collection + ServerX509Names []*X509CertificateName `json:"serverX509Names,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type BackendServiceFabricClusterProperties. +func (b BackendServiceFabricClusterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "clientCertificateId", b.ClientCertificateID) + populate(objectMap, "clientCertificatethumbprint", b.ClientCertificatethumbprint) + populate(objectMap, "managementEndpoints", b.ManagementEndpoints) + populate(objectMap, "maxPartitionResolutionRetries", b.MaxPartitionResolutionRetries) + populate(objectMap, "serverCertificateThumbprints", b.ServerCertificateThumbprints) + populate(objectMap, "serverX509Names", b.ServerX509Names) + return json.Marshal(objectMap) +} + +// BackendTLSProperties - Properties controlling TLS Certificate Validation. +type BackendTLSProperties struct { + // Flag indicating whether SSL certificate chain validation should be done when using self-signed certificates for this backend host. + ValidateCertificateChain *bool `json:"validateCertificateChain,omitempty"` + + // Flag indicating whether SSL certificate name validation should be done when using self-signed certificates for this backend host. + ValidateCertificateName *bool `json:"validateCertificateName,omitempty"` +} + +// BackendUpdateOptions contains the optional parameters for the Backend.Update method. +type BackendUpdateOptions struct { + // placeholder for future optional parameters +} + +// BackendUpdateParameterProperties - Parameters supplied to the Update Backend operation. +type BackendUpdateParameterProperties struct { + BackendBaseParameters + // Backend communication protocol. + Protocol *BackendProtocol `json:"protocol,omitempty"` + + // Runtime Url of the Backend. + URL *string `json:"url,omitempty"` +} + +// BackendUpdateParameters - Backend update parameters. +type BackendUpdateParameters struct { + // Backend entity update contract properties. + Properties *BackendUpdateParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type BackendUpdateParameters. +func (b BackendUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", b.Properties) + return json.Marshal(objectMap) +} + +// BodyDiagnosticSettings - Body logging settings. +type BodyDiagnosticSettings struct { + // Number of request body bytes to log. + Bytes *int32 `json:"bytes,omitempty"` +} + +// CacheCollection - Paged Caches list representation. +type CacheCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*CacheContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CacheCollection. +func (c CacheCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", c.Count) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// CacheContract - Cache details. +type CacheContract struct { + Resource + // Cache properties details. + Properties *CacheContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CacheContract. +func (c CacheContract) MarshalJSON() ([]byte, error) { + objectMap := c.Resource.marshalInternal() + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// CacheContractProperties - Properties of the Cache contract. +type CacheContractProperties struct { + // REQUIRED; Runtime connection string to cache + ConnectionString *string `json:"connectionString,omitempty"` + + // REQUIRED; Location identifier to use cache from (should be either 'default' or valid Azure region identifier) + UseFromLocation *string `json:"useFromLocation,omitempty"` + + // Cache description + Description *string `json:"description,omitempty"` + + // Original uri of entity in external system cache points to + ResourceID *string `json:"resourceId,omitempty"` +} + +// CacheCreateOrUpdateOptions contains the optional parameters for the Cache.CreateOrUpdate method. +type CacheCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// CacheDeleteOptions contains the optional parameters for the Cache.Delete method. +type CacheDeleteOptions struct { + // placeholder for future optional parameters +} + +// CacheGetEntityTagOptions contains the optional parameters for the Cache.GetEntityTag method. +type CacheGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// CacheGetOptions contains the optional parameters for the Cache.Get method. +type CacheGetOptions struct { + // placeholder for future optional parameters +} + +// CacheListByServiceOptions contains the optional parameters for the Cache.ListByService method. +type CacheListByServiceOptions struct { + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// CacheUpdateOptions contains the optional parameters for the Cache.Update method. +type CacheUpdateOptions struct { + // placeholder for future optional parameters +} + +// CacheUpdateParameters - Cache update details. +type CacheUpdateParameters struct { + // Cache update properties details. + Properties *CacheUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CacheUpdateParameters. +func (c CacheUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// CacheUpdateProperties - Parameters supplied to the Update Cache operation. +type CacheUpdateProperties struct { + // Runtime connection string to cache + ConnectionString *string `json:"connectionString,omitempty"` + + // Cache description + Description *string `json:"description,omitempty"` + + // Original uri of entity in external system cache points to + ResourceID *string `json:"resourceId,omitempty"` + + // Location identifier to use cache from (should be either 'default' or valid Azure region identifier) + UseFromLocation *string `json:"useFromLocation,omitempty"` +} + +// CertificateCollection - Paged Certificates list representation. +type CertificateCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*CertificateContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CertificateCollection. +func (c CertificateCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", c.Count) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// CertificateConfiguration - Certificate configuration which consist of non-trusted intermediates and root certificates. +type CertificateConfiguration struct { + // REQUIRED; The System.Security.Cryptography.x509certificates.StoreName certificate store location. Only Root and CertificateAuthority are valid locations. + StoreName *CertificateConfigurationStoreName `json:"storeName,omitempty"` + + // Certificate information. + Certificate *CertificateInformation `json:"certificate,omitempty"` + + // Certificate Password. + CertificatePassword *string `json:"certificatePassword,omitempty"` + + // Base64 Encoded certificate. + EncodedCertificate *string `json:"encodedCertificate,omitempty"` +} + +// CertificateContract - Certificate details. +type CertificateContract struct { + Resource + // Certificate properties details. + Properties *CertificateContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CertificateContract. +func (c CertificateContract) MarshalJSON() ([]byte, error) { + objectMap := c.Resource.marshalInternal() + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// CertificateContractProperties - Properties of the Certificate contract. +type CertificateContractProperties struct { + // REQUIRED; Expiration date of the certificate. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + ExpirationDate *time.Time `json:"expirationDate,omitempty"` + + // REQUIRED; Subject attribute of the certificate. + Subject *string `json:"subject,omitempty"` + + // REQUIRED; Thumbprint of the certificate. + Thumbprint *string `json:"thumbprint,omitempty"` + + // KeyVault location details of the certificate. + KeyVault *KeyVaultContractProperties `json:"keyVault,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CertificateContractProperties. +func (c CertificateContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "expirationDate", (*timeRFC3339)(c.ExpirationDate)) + populate(objectMap, "keyVault", c.KeyVault) + populate(objectMap, "subject", c.Subject) + populate(objectMap, "thumbprint", c.Thumbprint) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CertificateContractProperties. +func (c *CertificateContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "expirationDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + c.ExpirationDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "keyVault": + err = unpopulate(val, &c.KeyVault) + delete(rawMsg, key) + case "subject": + err = unpopulate(val, &c.Subject) + delete(rawMsg, key) + case "thumbprint": + err = unpopulate(val, &c.Thumbprint) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// CertificateCreateOrUpdateOptions contains the optional parameters for the Certificate.CreateOrUpdate method. +type CertificateCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// CertificateCreateOrUpdateParameters - Certificate create or update details. +type CertificateCreateOrUpdateParameters struct { + // Certificate create or update properties details. + Properties *CertificateCreateOrUpdateProperties `json:"properties,omitempty"` +} + +// CertificateCreateOrUpdateProperties - Parameters supplied to the CreateOrUpdate certificate operation. +type CertificateCreateOrUpdateProperties struct { + // Base 64 encoded certificate using the application/x-pkcs12 representation. + Data *string `json:"data,omitempty"` + + // KeyVault location details of the certificate. + KeyVault *KeyVaultContractCreateProperties `json:"keyVault,omitempty"` + + // Password for the Certificate + Password *string `json:"password,omitempty"` +} + +// CertificateDeleteOptions contains the optional parameters for the Certificate.Delete method. +type CertificateDeleteOptions struct { + // placeholder for future optional parameters +} + +// CertificateGetEntityTagOptions contains the optional parameters for the Certificate.GetEntityTag method. +type CertificateGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// CertificateGetOptions contains the optional parameters for the Certificate.Get method. +type CertificateGetOptions struct { + // placeholder for future optional parameters +} + +// CertificateInformation - SSL certificate information. +type CertificateInformation struct { + // REQUIRED; Expiration date of the certificate. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + Expiry *time.Time `json:"expiry,omitempty"` + + // REQUIRED; Subject of the certificate. + Subject *string `json:"subject,omitempty"` + + // REQUIRED; Thumbprint of the certificate. + Thumbprint *string `json:"thumbprint,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type CertificateInformation. +func (c CertificateInformation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "expiry", (*timeRFC3339)(c.Expiry)) + populate(objectMap, "subject", c.Subject) + populate(objectMap, "thumbprint", c.Thumbprint) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CertificateInformation. +func (c *CertificateInformation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "expiry": + var aux timeRFC3339 + err = unpopulate(val, &aux) + c.Expiry = (*time.Time)(&aux) + delete(rawMsg, key) + case "subject": + err = unpopulate(val, &c.Subject) + delete(rawMsg, key) + case "thumbprint": + err = unpopulate(val, &c.Thumbprint) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// CertificateListByServiceOptions contains the optional parameters for the Certificate.ListByService method. +type CertificateListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| subject | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| thumbprint | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| expirationDate | filter | ge, le, + // eq, ne, gt, lt | |
+ Filter *string + // When set to true, the response contains only certificates entities which failed refresh. + IsKeyVaultRefreshFailed *bool + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// CertificateRefreshSecretOptions contains the optional parameters for the Certificate.RefreshSecret method. +type CertificateRefreshSecretOptions struct { + // placeholder for future optional parameters +} + +// ClientSecretContract - Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. +type ClientSecretContract struct { + // Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. + ClientSecret *string `json:"clientSecret,omitempty"` +} + +// ConnectivityStatusContract - Details about connectivity to a resource. +type ConnectivityStatusContract struct { + // REQUIRED; Whether this is optional. + IsOptional *bool `json:"isOptional,omitempty"` + + // REQUIRED; The date when the resource connectivity status last Changed from success to failure or vice-versa. The date conforms to the following format: + // yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 + // standard. + LastStatusChange *time.Time `json:"lastStatusChange,omitempty"` + + // REQUIRED; The date when the resource connectivity status was last updated. This status should be updated every 15 minutes. If this status has not been + // updated, then it means that the service has lost network + // connectivity to the resource, from inside the Virtual Network.The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO + // 8601 standard. + LastUpdated *time.Time `json:"lastUpdated,omitempty"` + + // REQUIRED; The hostname of the resource which the service depends on. This can be the database, storage or any other azure resource on which the service + // depends upon. + Name *string `json:"name,omitempty"` + + // REQUIRED; Resource Type. + ResourceType *string `json:"resourceType,omitempty"` + + // REQUIRED; Resource Connectivity Status Type identifier. + Status *ConnectivityStatusType `json:"status,omitempty"` + + // Error details of the connectivity to the resource. + Error *string `json:"error,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ConnectivityStatusContract. +func (c ConnectivityStatusContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "error", c.Error) + populate(objectMap, "isOptional", c.IsOptional) + populate(objectMap, "lastStatusChange", (*timeRFC3339)(c.LastStatusChange)) + populate(objectMap, "lastUpdated", (*timeRFC3339)(c.LastUpdated)) + populate(objectMap, "name", c.Name) + populate(objectMap, "resourceType", c.ResourceType) + populate(objectMap, "status", c.Status) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ConnectivityStatusContract. +func (c *ConnectivityStatusContract) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "error": + err = unpopulate(val, &c.Error) + delete(rawMsg, key) + case "isOptional": + err = unpopulate(val, &c.IsOptional) + delete(rawMsg, key) + case "lastStatusChange": + var aux timeRFC3339 + err = unpopulate(val, &aux) + c.LastStatusChange = (*time.Time)(&aux) + delete(rawMsg, key) + case "lastUpdated": + var aux timeRFC3339 + err = unpopulate(val, &aux) + c.LastUpdated = (*time.Time)(&aux) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &c.Name) + delete(rawMsg, key) + case "resourceType": + err = unpopulate(val, &c.ResourceType) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &c.Status) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ContentItemCollection - Paged list of content items. +type ContentItemCollection struct { + // READ-ONLY; Next page link, if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Collection of content items. + Value []*ContentItemContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContentItemCollection. +func (c ContentItemCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// ContentItemContract - Content type contract details. +type ContentItemContract struct { + Resource + // Properties of the content item. + Properties map[string]interface{} `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContentItemContract. +func (c ContentItemContract) MarshalJSON() ([]byte, error) { + objectMap := c.Resource.marshalInternal() + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +// ContentItemCreateOrUpdateOptions contains the optional parameters for the ContentItem.CreateOrUpdate method. +type ContentItemCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// ContentItemDeleteOptions contains the optional parameters for the ContentItem.Delete method. +type ContentItemDeleteOptions struct { + // placeholder for future optional parameters +} + +// ContentItemGetEntityTagOptions contains the optional parameters for the ContentItem.GetEntityTag method. +type ContentItemGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// ContentItemGetOptions contains the optional parameters for the ContentItem.Get method. +type ContentItemGetOptions struct { + // placeholder for future optional parameters +} + +// ContentItemListByServiceOptions contains the optional parameters for the ContentItem.ListByService method. +type ContentItemListByServiceOptions struct { + // placeholder for future optional parameters +} + +// ContentTypeCollection - Paged list of content types. +type ContentTypeCollection struct { + // READ-ONLY; Next page link, if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Collection of content types. + Value []*ContentTypeContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContentTypeCollection. +func (c ContentTypeCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", c.NextLink) + populate(objectMap, "value", c.Value) + return json.Marshal(objectMap) +} + +// ContentTypeContract - Content type contract details. +type ContentTypeContract struct { + Resource + // Properties of the content type. + Properties *ContentTypeContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ContentTypeContract. +func (c ContentTypeContract) MarshalJSON() ([]byte, error) { + objectMap := c.Resource.marshalInternal() + populate(objectMap, "properties", c.Properties) + return json.Marshal(objectMap) +} + +type ContentTypeContractProperties struct { + // Content type description. + Description *string `json:"description,omitempty"` + + // Content type identifier + ID *string `json:"id,omitempty"` + + // Content type name. Must be 1 to 250 characters long. + Name *string `json:"name,omitempty"` + + // Content type schema. + Schema map[string]interface{} `json:"schema,omitempty"` + + // Content type version. + Version *string `json:"version,omitempty"` +} + +// ContentTypeCreateOrUpdateOptions contains the optional parameters for the ContentType.CreateOrUpdate method. +type ContentTypeCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// ContentTypeDeleteOptions contains the optional parameters for the ContentType.Delete method. +type ContentTypeDeleteOptions struct { + // placeholder for future optional parameters +} + +// ContentTypeGetOptions contains the optional parameters for the ContentType.Get method. +type ContentTypeGetOptions struct { + // placeholder for future optional parameters +} + +// ContentTypeListByServiceOptions contains the optional parameters for the ContentType.ListByService method. +type ContentTypeListByServiceOptions struct { + // placeholder for future optional parameters +} + +type DataMasking struct { + // Masking settings for headers + Headers []*DataMaskingEntity `json:"headers,omitempty"` + + // Masking settings for Url query parameters + QueryParams []*DataMaskingEntity `json:"queryParams,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DataMasking. +func (d DataMasking) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "headers", d.Headers) + populate(objectMap, "queryParams", d.QueryParams) + return json.Marshal(objectMap) +} + +type DataMaskingEntity struct { + // Data masking mode. + Mode *DataMaskingMode `json:"mode,omitempty"` + + // The name of an entity to mask (e.g. a name of a header or a query parameter). + Value *string `json:"value,omitempty"` +} + +// DelegationSettingsCreateOrUpdateOptions contains the optional parameters for the DelegationSettings.CreateOrUpdate method. +type DelegationSettingsCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// DelegationSettingsGetEntityTagOptions contains the optional parameters for the DelegationSettings.GetEntityTag method. +type DelegationSettingsGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// DelegationSettingsGetOptions contains the optional parameters for the DelegationSettings.Get method. +type DelegationSettingsGetOptions struct { + // placeholder for future optional parameters +} + +// DelegationSettingsListSecretsOptions contains the optional parameters for the DelegationSettings.ListSecrets method. +type DelegationSettingsListSecretsOptions struct { + // placeholder for future optional parameters +} + +// DelegationSettingsUpdateOptions contains the optional parameters for the DelegationSettings.Update method. +type DelegationSettingsUpdateOptions struct { + // placeholder for future optional parameters +} + +// DeletedServiceContract - Deleted Api Management Service information. +type DeletedServiceContract struct { + Resource + // Deleted Api Management Service details. + Properties *DeletedServiceContractProperties `json:"properties,omitempty"` + + // READ-ONLY; Api Management Service Master Location. + Location *string `json:"location,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type DeletedServiceContract. +func (d DeletedServiceContract) MarshalJSON() ([]byte, error) { + objectMap := d.Resource.marshalInternal() + populate(objectMap, "location", d.Location) + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + +type DeletedServiceContractProperties struct { + // UTC Timestamp when the service was soft-deleted. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + DeletionDate *time.Time `json:"deletionDate,omitempty"` + + // UTC Date and Time when the service will be automatically purged. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the + // ISO 8601 standard. + ScheduledPurgeDate *time.Time `json:"scheduledPurgeDate,omitempty"` + + // Fully-qualified API Management Service Resource ID + ServiceID *string `json:"serviceId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DeletedServiceContractProperties. +func (d DeletedServiceContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "deletionDate", (*timeRFC3339)(d.DeletionDate)) + populate(objectMap, "scheduledPurgeDate", (*timeRFC3339)(d.ScheduledPurgeDate)) + populate(objectMap, "serviceId", d.ServiceID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type DeletedServiceContractProperties. +func (d *DeletedServiceContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "deletionDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + d.DeletionDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "scheduledPurgeDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + d.ScheduledPurgeDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "serviceId": + err = unpopulate(val, &d.ServiceID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// DeletedServicesBeginPurgeOptions contains the optional parameters for the DeletedServices.BeginPurge method. +type DeletedServicesBeginPurgeOptions struct { + // placeholder for future optional parameters +} + +// DeletedServicesCollection - Paged deleted Api Management Services List Representation. +type DeletedServicesCollection struct { + // READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Page values. + Value []*DeletedServiceContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type DeletedServicesCollection. +func (d DeletedServicesCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DeletedServicesGetByNameOptions contains the optional parameters for the DeletedServices.GetByName method. +type DeletedServicesGetByNameOptions struct { + // placeholder for future optional parameters +} + +// DeletedServicesListBySubscriptionOptions contains the optional parameters for the DeletedServices.ListBySubscription method. +type DeletedServicesListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// DeployConfigurationParameterProperties - Parameters supplied to the Deploy Configuration operation. +type DeployConfigurationParameterProperties struct { + // REQUIRED; The name of the Git branch from which the configuration is to be deployed to the configuration database. + Branch *string `json:"branch,omitempty"` + + // The value enforcing deleting subscriptions to products that are deleted in this update. + Force *bool `json:"force,omitempty"` +} + +// DeployConfigurationParameters - Deploy Tenant Configuration Contract. +type DeployConfigurationParameters struct { + // Deploy Configuration Parameter contract properties. + Properties *DeployConfigurationParameterProperties `json:"properties,omitempty"` +} + +// DiagnosticCollection - Paged Diagnostic list representation. +type DiagnosticCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*DiagnosticContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DiagnosticCollection. +func (d DiagnosticCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", d.Count) + populate(objectMap, "nextLink", d.NextLink) + populate(objectMap, "value", d.Value) + return json.Marshal(objectMap) +} + +// DiagnosticContract - Diagnostic details. +type DiagnosticContract struct { + Resource + // Diagnostic entity contract properties. + Properties *DiagnosticContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type DiagnosticContract. +func (d DiagnosticContract) MarshalJSON() ([]byte, error) { + objectMap := d.Resource.marshalInternal() + populate(objectMap, "properties", d.Properties) + return json.Marshal(objectMap) +} + +// DiagnosticContractProperties - Diagnostic Entity Properties +type DiagnosticContractProperties struct { + // REQUIRED; Resource Id of a target logger. + LoggerID *string `json:"loggerId,omitempty"` + + // Specifies for what type of messages sampling settings should not apply. + AlwaysLog *AlwaysLog `json:"alwaysLog,omitempty"` + + // Diagnostic settings for incoming/outgoing HTTP messages to the Backend + Backend *PipelineDiagnosticSettings `json:"backend,omitempty"` + + // Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. + Frontend *PipelineDiagnosticSettings `json:"frontend,omitempty"` + + // Sets correlation protocol to use for Application Insights diagnostics. + HTTPCorrelationProtocol *HTTPCorrelationProtocol `json:"httpCorrelationProtocol,omitempty"` + + // Log the ClientIP. Default is false. + LogClientIP *bool `json:"logClientIp,omitempty"` + + // The format of the Operation Name for Application Insights telemetries. Default is Name. + OperationNameFormat *OperationNameFormat `json:"operationNameFormat,omitempty"` + + // Sampling settings for Diagnostic. + Sampling *SamplingSettings `json:"sampling,omitempty"` + + // The verbosity level applied to traces emitted by trace policies. + Verbosity *Verbosity `json:"verbosity,omitempty"` +} + +// DiagnosticCreateOrUpdateOptions contains the optional parameters for the Diagnostic.CreateOrUpdate method. +type DiagnosticCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// DiagnosticDeleteOptions contains the optional parameters for the Diagnostic.Delete method. +type DiagnosticDeleteOptions struct { + // placeholder for future optional parameters +} + +// DiagnosticGetEntityTagOptions contains the optional parameters for the Diagnostic.GetEntityTag method. +type DiagnosticGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// DiagnosticGetOptions contains the optional parameters for the Diagnostic.Get method. +type DiagnosticGetOptions struct { + // placeholder for future optional parameters +} + +// DiagnosticListByServiceOptions contains the optional parameters for the Diagnostic.ListByService method. +type DiagnosticListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// DiagnosticUpdateOptions contains the optional parameters for the Diagnostic.Update method. +type DiagnosticUpdateOptions struct { + // placeholder for future optional parameters +} + +// EmailTemplateCollection - Paged email template list representation. +type EmailTemplateCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*EmailTemplateContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EmailTemplateCollection. +func (e EmailTemplateCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", e.Count) + populate(objectMap, "nextLink", e.NextLink) + populate(objectMap, "value", e.Value) + return json.Marshal(objectMap) +} + +// EmailTemplateContract - Email Template details. +type EmailTemplateContract struct { + Resource + // Email Template entity contract properties. + Properties *EmailTemplateContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EmailTemplateContract. +func (e EmailTemplateContract) MarshalJSON() ([]byte, error) { + objectMap := e.Resource.marshalInternal() + populate(objectMap, "properties", e.Properties) + return json.Marshal(objectMap) +} + +// EmailTemplateContractProperties - Email Template Contract properties. +type EmailTemplateContractProperties struct { + // REQUIRED; Email Template Body. This should be a valid XDocument + Body *string `json:"body,omitempty"` + + // REQUIRED; Subject of the Template. + Subject *string `json:"subject,omitempty"` + + // Description of the Email Template. + Description *string `json:"description,omitempty"` + + // Email Template Parameter values. + Parameters []*EmailTemplateParametersContractProperties `json:"parameters,omitempty"` + + // Title of the Template. + Title *string `json:"title,omitempty"` + + // READ-ONLY; Whether the template is the default template provided by Api Management or has been edited. + IsDefault *bool `json:"isDefault,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type EmailTemplateContractProperties. +func (e EmailTemplateContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "body", e.Body) + populate(objectMap, "description", e.Description) + populate(objectMap, "isDefault", e.IsDefault) + populate(objectMap, "parameters", e.Parameters) + populate(objectMap, "subject", e.Subject) + populate(objectMap, "title", e.Title) + return json.Marshal(objectMap) +} + +// EmailTemplateCreateOrUpdateOptions contains the optional parameters for the EmailTemplate.CreateOrUpdate method. +type EmailTemplateCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// EmailTemplateDeleteOptions contains the optional parameters for the EmailTemplate.Delete method. +type EmailTemplateDeleteOptions struct { + // placeholder for future optional parameters +} + +// EmailTemplateGetEntityTagOptions contains the optional parameters for the EmailTemplate.GetEntityTag method. +type EmailTemplateGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// EmailTemplateGetOptions contains the optional parameters for the EmailTemplate.Get method. +type EmailTemplateGetOptions struct { + // placeholder for future optional parameters +} + +// EmailTemplateListByServiceOptions contains the optional parameters for the EmailTemplate.ListByService method. +type EmailTemplateListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// EmailTemplateParametersContractProperties - Email Template Parameter contract. +type EmailTemplateParametersContractProperties struct { + // Template parameter description. + Description *string `json:"description,omitempty"` + + // Template parameter name. + Name *string `json:"name,omitempty"` + + // Template parameter title. + Title *string `json:"title,omitempty"` +} + +// EmailTemplateUpdateOptions contains the optional parameters for the EmailTemplate.Update method. +type EmailTemplateUpdateOptions struct { + // placeholder for future optional parameters +} + +// EmailTemplateUpdateParameterProperties - Email Template Update Contract properties. +type EmailTemplateUpdateParameterProperties struct { + // Email Template Body. This should be a valid XDocument + Body *string `json:"body,omitempty"` + + // Description of the Email Template. + Description *string `json:"description,omitempty"` + + // Email Template Parameter values. + Parameters []*EmailTemplateParametersContractProperties `json:"parameters,omitempty"` + + // Subject of the Template. + Subject *string `json:"subject,omitempty"` + + // Title of the Template. + Title *string `json:"title,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EmailTemplateUpdateParameterProperties. +func (e EmailTemplateUpdateParameterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "body", e.Body) + populate(objectMap, "description", e.Description) + populate(objectMap, "parameters", e.Parameters) + populate(objectMap, "subject", e.Subject) + populate(objectMap, "title", e.Title) + return json.Marshal(objectMap) +} + +// EmailTemplateUpdateParameters - Email Template update Parameters. +type EmailTemplateUpdateParameters struct { + // Email Template Update contract properties. + Properties *EmailTemplateUpdateParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type EmailTemplateUpdateParameters. +func (e EmailTemplateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", e.Properties) + return json.Marshal(objectMap) +} + +// ErrorFieldContract - Error Field contract. +type ErrorFieldContract struct { + // Property level error code. + Code *string `json:"code,omitempty"` + + // Human-readable representation of property-level error. + Message *string `json:"message,omitempty"` + + // Property name. + Target *string `json:"target,omitempty"` +} + +// ErrorResponse - Error Response. +// Implements the error and azcore.HTTPResponse interfaces. +type ErrorResponse struct { + raw string + // Properties of the Error Response. + InnerError *ErrorResponseBody `json:"error,omitempty"` +} + +// Error implements the error interface for type ErrorResponse. +// The contents of the error text are not contractual and subject to change. +func (e ErrorResponse) Error() string { + return e.raw +} + +// ErrorResponseBody - Error Body contract. +type ErrorResponseBody struct { + // Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. + Code *string `json:"code,omitempty"` + + // The list of invalid fields send in request, in case of validation error. + Details []*ErrorFieldContract `json:"details,omitempty"` + + // Human-readable representation of the error. + Message *string `json:"message,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ErrorResponseBody. +func (e ErrorResponseBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + return json.Marshal(objectMap) +} + +// GatewayAPICreateOrUpdateOptions contains the optional parameters for the GatewayAPI.CreateOrUpdate method. +type GatewayAPICreateOrUpdateOptions struct { + Parameters *AssociationContract +} + +// GatewayAPIDeleteOptions contains the optional parameters for the GatewayAPI.Delete method. +type GatewayAPIDeleteOptions struct { + // placeholder for future optional parameters +} + +// GatewayAPIGetEntityTagOptions contains the optional parameters for the GatewayAPI.GetEntityTag method. +type GatewayAPIGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// GatewayAPIListByServiceOptions contains the optional parameters for the GatewayAPI.ListByService method. +type GatewayAPIListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// GatewayCertificateAuthorityCollection - Paged Gateway certificate authority list representation. +type GatewayCertificateAuthorityCollection struct { + // READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Page values. + Value []*GatewayCertificateAuthorityContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type GatewayCertificateAuthorityCollection. +func (g GatewayCertificateAuthorityCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// GatewayCertificateAuthorityContract - Gateway certificate authority details. +type GatewayCertificateAuthorityContract struct { + Resource + // Gateway certificate authority details. + Properties *GatewayCertificateAuthorityContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GatewayCertificateAuthorityContract. +func (g GatewayCertificateAuthorityContract) MarshalJSON() ([]byte, error) { + objectMap := g.Resource.marshalInternal() + populate(objectMap, "properties", g.Properties) + return json.Marshal(objectMap) +} + +// GatewayCertificateAuthorityContractProperties - Gateway certificate authority details. +type GatewayCertificateAuthorityContractProperties struct { + // Determines whether certificate authority is trusted. + IsTrusted *bool `json:"isTrusted,omitempty"` +} + +// GatewayCertificateAuthorityCreateOrUpdateOptions contains the optional parameters for the GatewayCertificateAuthority.CreateOrUpdate method. +type GatewayCertificateAuthorityCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// GatewayCertificateAuthorityDeleteOptions contains the optional parameters for the GatewayCertificateAuthority.Delete method. +type GatewayCertificateAuthorityDeleteOptions struct { + // placeholder for future optional parameters +} + +// GatewayCertificateAuthorityGetEntityTagOptions contains the optional parameters for the GatewayCertificateAuthority.GetEntityTag method. +type GatewayCertificateAuthorityGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// GatewayCertificateAuthorityGetOptions contains the optional parameters for the GatewayCertificateAuthority.Get method. +type GatewayCertificateAuthorityGetOptions struct { + // placeholder for future optional parameters +} + +// GatewayCertificateAuthorityListByServiceOptions contains the optional parameters for the GatewayCertificateAuthority.ListByService method. +type GatewayCertificateAuthorityListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | eq, + // ne | |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// GatewayCollection - Paged Gateway list representation. +type GatewayCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Page values. + Value []*GatewayContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type GatewayCollection. +func (g GatewayCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", g.Count) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// GatewayContract - Gateway details. +type GatewayContract struct { + Resource + // Gateway details. + Properties *GatewayContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GatewayContract. +func (g GatewayContract) MarshalJSON() ([]byte, error) { + objectMap := g.Resource.marshalInternal() + populate(objectMap, "properties", g.Properties) + return json.Marshal(objectMap) +} + +// GatewayContractProperties - Properties of the Gateway contract. +type GatewayContractProperties struct { + // Gateway description + Description *string `json:"description,omitempty"` + + // Gateway location. + LocationData *ResourceLocationDataContract `json:"locationData,omitempty"` +} + +// GatewayCreateOrUpdateOptions contains the optional parameters for the Gateway.CreateOrUpdate method. +type GatewayCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// GatewayDeleteOptions contains the optional parameters for the Gateway.Delete method. +type GatewayDeleteOptions struct { + // placeholder for future optional parameters +} + +// GatewayGenerateTokenOptions contains the optional parameters for the Gateway.GenerateToken method. +type GatewayGenerateTokenOptions struct { + // placeholder for future optional parameters +} + +// GatewayGetEntityTagOptions contains the optional parameters for the Gateway.GetEntityTag method. +type GatewayGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// GatewayGetOptions contains the optional parameters for the Gateway.Get method. +type GatewayGetOptions struct { + // placeholder for future optional parameters +} + +// GatewayHostnameConfigurationCollection - Paged Gateway hostname configuration list representation. +type GatewayHostnameConfigurationCollection struct { + // READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Page values. + Value []*GatewayHostnameConfigurationContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type GatewayHostnameConfigurationCollection. +func (g GatewayHostnameConfigurationCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// GatewayHostnameConfigurationContract - Gateway hostname configuration details. +type GatewayHostnameConfigurationContract struct { + Resource + // Gateway hostname configuration details. + Properties *GatewayHostnameConfigurationContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GatewayHostnameConfigurationContract. +func (g GatewayHostnameConfigurationContract) MarshalJSON() ([]byte, error) { + objectMap := g.Resource.marshalInternal() + populate(objectMap, "properties", g.Properties) + return json.Marshal(objectMap) +} + +// GatewayHostnameConfigurationContractProperties - Gateway hostname configuration details. +type GatewayHostnameConfigurationContractProperties struct { + // Identifier of Certificate entity that will be used for TLS connection establishment + CertificateID *string `json:"certificateId,omitempty"` + + // Specifies if HTTP/2.0 is supported + HTTP2Enabled *bool `json:"http2Enabled,omitempty"` + + // Hostname value. Supports valid domain name, partial or full wildcard + Hostname *string `json:"hostname,omitempty"` + + // Determines whether gateway requests client certificate + NegotiateClientCertificate *bool `json:"negotiateClientCertificate,omitempty"` + + // Specifies if TLS 1.0 is supported + Tls10Enabled *bool `json:"tls10Enabled,omitempty"` + + // Specifies if TLS 1.1 is supported + Tls11Enabled *bool `json:"tls11Enabled,omitempty"` +} + +// GatewayHostnameConfigurationCreateOrUpdateOptions contains the optional parameters for the GatewayHostnameConfiguration.CreateOrUpdate method. +type GatewayHostnameConfigurationCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// GatewayHostnameConfigurationDeleteOptions contains the optional parameters for the GatewayHostnameConfiguration.Delete method. +type GatewayHostnameConfigurationDeleteOptions struct { + // placeholder for future optional parameters +} + +// GatewayHostnameConfigurationGetEntityTagOptions contains the optional parameters for the GatewayHostnameConfiguration.GetEntityTag method. +type GatewayHostnameConfigurationGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// GatewayHostnameConfigurationGetOptions contains the optional parameters for the GatewayHostnameConfiguration.Get method. +type GatewayHostnameConfigurationGetOptions struct { + // placeholder for future optional parameters +} + +// GatewayHostnameConfigurationListByServiceOptions contains the optional parameters for the GatewayHostnameConfiguration.ListByService method. +type GatewayHostnameConfigurationListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| hostname | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// GatewayKeyRegenerationRequestContract - Gateway key regeneration request contract properties. +type GatewayKeyRegenerationRequestContract struct { + // REQUIRED; The Key being regenerated. + KeyType *KeyType `json:"keyType,omitempty"` +} + +// GatewayKeysContract - Gateway authentication keys. +type GatewayKeysContract struct { + // Primary gateway key. + Primary *string `json:"primary,omitempty"` + + // Secondary gateway key. + Secondary *string `json:"secondary,omitempty"` +} + +// GatewayListByServiceOptions contains the optional parameters for the Gateway.ListByService method. +type GatewayListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| region | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// GatewayListKeysOptions contains the optional parameters for the Gateway.ListKeys method. +type GatewayListKeysOptions struct { + // placeholder for future optional parameters +} + +// GatewayRegenerateKeyOptions contains the optional parameters for the Gateway.RegenerateKey method. +type GatewayRegenerateKeyOptions struct { + // placeholder for future optional parameters +} + +// GatewayTokenContract - Gateway access token. +type GatewayTokenContract struct { + // Shared Access Authentication token value for the Gateway. + Value *string `json:"value,omitempty"` +} + +// GatewayTokenRequestContract - Gateway token request contract properties. +type GatewayTokenRequestContract struct { + // REQUIRED; The Expiry time of the Token. Maximum token expiry time is set to 30 days. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ + // as specified by the ISO 8601 standard. + Expiry *time.Time `json:"expiry,omitempty"` + + // REQUIRED; The Key to be used to generate gateway token. + KeyType *KeyType `json:"keyType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GatewayTokenRequestContract. +func (g GatewayTokenRequestContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "expiry", (*timeRFC3339)(g.Expiry)) + populate(objectMap, "keyType", g.KeyType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type GatewayTokenRequestContract. +func (g *GatewayTokenRequestContract) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "expiry": + var aux timeRFC3339 + err = unpopulate(val, &aux) + g.Expiry = (*time.Time)(&aux) + delete(rawMsg, key) + case "keyType": + err = unpopulate(val, &g.KeyType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// GatewayUpdateOptions contains the optional parameters for the Gateway.Update method. +type GatewayUpdateOptions struct { + // placeholder for future optional parameters +} + +// GenerateSsoURLResult - Generate SSO Url operations response details. +type GenerateSsoURLResult struct { + // Redirect Url containing the SSO URL value. + Value *string `json:"value,omitempty"` +} + +// GroupCollection - Paged Group list representation. +type GroupCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*GroupContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GroupCollection. +func (g GroupCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", g.Count) + populate(objectMap, "nextLink", g.NextLink) + populate(objectMap, "value", g.Value) + return json.Marshal(objectMap) +} + +// GroupContract - Contract details. +type GroupContract struct { + Resource + // Group entity contract properties. + Properties *GroupContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GroupContract. +func (g GroupContract) MarshalJSON() ([]byte, error) { + objectMap := g.Resource.marshalInternal() + populate(objectMap, "properties", g.Properties) + return json.Marshal(objectMap) +} + +// GroupContractProperties - Group contract Properties. +type GroupContractProperties struct { + // REQUIRED; Group name. + DisplayName *string `json:"displayName,omitempty"` + + // Group description. Can contain HTML formatting tags. + Description *string `json:"description,omitempty"` + + // For external groups, this property contains the id of the group from the external identity provider, e.g. for Azure Active Directory aad://.onmicrosoft.com/groups/; otherwise + // the value is null. + ExternalID *string `json:"externalId,omitempty"` + + // Group type. + Type *GroupType `json:"type,omitempty"` + + // READ-ONLY; true if the group is one of the three system groups (Administrators, Developers, or Guests); otherwise false. + BuiltIn *bool `json:"builtIn,omitempty" azure:"ro"` +} + +// GroupCreateOrUpdateOptions contains the optional parameters for the Group.CreateOrUpdate method. +type GroupCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// GroupCreateParameters - Parameters supplied to the Create Group operation. +type GroupCreateParameters struct { + // Properties supplied to Create Group operation. + Properties *GroupCreateParametersProperties `json:"properties,omitempty"` +} + +// GroupCreateParametersProperties - Parameters supplied to the Create Group operation. +type GroupCreateParametersProperties struct { + // REQUIRED; Group name. + DisplayName *string `json:"displayName,omitempty"` + + // Group description. + Description *string `json:"description,omitempty"` + + // Identifier of the external groups, this property contains the id of the group from the external identity provider, e.g. for Azure Active Directory aad://.onmicrosoft.com/groups/; otherwise the value is null. + ExternalID *string `json:"externalId,omitempty"` + + // Group type. + Type *GroupType `json:"type,omitempty"` +} + +// GroupDeleteOptions contains the optional parameters for the Group.Delete method. +type GroupDeleteOptions struct { + // placeholder for future optional parameters +} + +// GroupGetEntityTagOptions contains the optional parameters for the Group.GetEntityTag method. +type GroupGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// GroupGetOptions contains the optional parameters for the Group.Get method. +type GroupGetOptions struct { + // placeholder for future optional parameters +} + +// GroupListByServiceOptions contains the optional parameters for the Group.ListByService method. +type GroupListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| externalId | filter | eq | |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// GroupUpdateOptions contains the optional parameters for the Group.Update method. +type GroupUpdateOptions struct { + // placeholder for future optional parameters +} + +// GroupUpdateParameters - Parameters supplied to the Update Group operation. +type GroupUpdateParameters struct { + // Group entity update contract properties. + Properties *GroupUpdateParametersProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type GroupUpdateParameters. +func (g GroupUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", g.Properties) + return json.Marshal(objectMap) +} + +// GroupUpdateParametersProperties - Parameters supplied to the Update Group operation. +type GroupUpdateParametersProperties struct { + // Group description. + Description *string `json:"description,omitempty"` + + // Group name. + DisplayName *string `json:"displayName,omitempty"` + + // Identifier of the external groups, this property contains the id of the group from the external identity provider, e.g. for Azure Active Directory aad://.onmicrosoft.com/groups/; otherwise the value is null. + ExternalID *string `json:"externalId,omitempty"` + + // Group type. + Type *GroupType `json:"type,omitempty"` +} + +// GroupUserCheckEntityExistsOptions contains the optional parameters for the GroupUser.CheckEntityExists method. +type GroupUserCheckEntityExistsOptions struct { + // placeholder for future optional parameters +} + +// GroupUserCreateOptions contains the optional parameters for the GroupUser.Create method. +type GroupUserCreateOptions struct { + // placeholder for future optional parameters +} + +// GroupUserDeleteOptions contains the optional parameters for the GroupUser.Delete method. +type GroupUserDeleteOptions struct { + // placeholder for future optional parameters +} + +// GroupUserListOptions contains the optional parameters for the GroupUser.List method. +type GroupUserListOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| firstName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| lastName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| email | filter | ge, le, eq, ne, gt, + // lt | substringof, contains, startswith, endswith |
| registrationDate | filter | ge, le, eq, ne, gt, lt | |
| note | filter | ge, le, eq, ne, + // gt, lt | substringof, contains, startswith, endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// HTTPMessageDiagnostic - Http message diagnostic settings. +type HTTPMessageDiagnostic struct { + // Body logging settings. + Body *BodyDiagnosticSettings `json:"body,omitempty"` + + // Data masking settings. + DataMasking *DataMasking `json:"dataMasking,omitempty"` + + // Array of HTTP Headers to log. + Headers []*string `json:"headers,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type HTTPMessageDiagnostic. +func (h HTTPMessageDiagnostic) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "body", h.Body) + populate(objectMap, "dataMasking", h.DataMasking) + populate(objectMap, "headers", h.Headers) + return json.Marshal(objectMap) +} + +// HostnameConfiguration - Custom hostname configuration. +type HostnameConfiguration struct { + // REQUIRED; Hostname to configure on the Api Management service. + HostName *string `json:"hostName,omitempty"` + + // REQUIRED; Hostname type. + Type *HostnameType `json:"type,omitempty"` + + // Certificate information. + Certificate *CertificateInformation `json:"certificate,omitempty"` + + // Certificate Password. + CertificatePassword *string `json:"certificatePassword,omitempty"` + + // Specify true to setup the certificate associated with this Hostname as the Default SSL Certificate. If a client does not send the SNI header, then this + // will be the certificate that will be challenged. + // The property is useful if a service has multiple custom hostname enabled and it needs to decide on the default ssl certificate. The setting only applied + // to Proxy Hostname Type. + DefaultSSLBinding *bool `json:"defaultSslBinding,omitempty"` + + // Base64 Encoded certificate. + EncodedCertificate *string `json:"encodedCertificate,omitempty"` + + // System or User Assigned Managed identity clientId as generated by Azure AD, which has GET access to the keyVault containing the SSL certificate. + IdentityClientID *string `json:"identityClientId,omitempty"` + + // Url to the KeyVault Secret containing the Ssl Certificate. If absolute Url containing version is provided, auto-update of ssl certificate will not work. + // This requires Api Management service to be + // configured with aka.ms/apimmsi. The secret should be of type application/x-pkcs12 + KeyVaultID *string `json:"keyVaultId,omitempty"` + + // Specify true to always negotiate client certificate on the hostname. Default Value is false. + NegotiateClientCertificate *bool `json:"negotiateClientCertificate,omitempty"` +} + +// IdentityProviderBaseParameters - Identity Provider Base Parameter Properties. +type IdentityProviderBaseParameters struct { + // List of Allowed Tenants when configuring Azure Active Directory login. + AllowedTenants []*string `json:"allowedTenants,omitempty"` + + // OpenID Connect discovery endpoint hostname for AAD or AAD B2C. + Authority *string `json:"authority,omitempty"` + + // Password Reset Policy Name. Only applies to AAD B2C Identity Provider. + PasswordResetPolicyName *string `json:"passwordResetPolicyName,omitempty"` + + // Profile Editing Policy Name. Only applies to AAD B2C Identity Provider. + ProfileEditingPolicyName *string `json:"profileEditingPolicyName,omitempty"` + + // Signin Policy Name. Only applies to AAD B2C Identity Provider. + SigninPolicyName *string `json:"signinPolicyName,omitempty"` + + // The TenantId to use instead of Common when logging into Active Directory + SigninTenant *string `json:"signinTenant,omitempty"` + + // Signup Policy Name. Only applies to AAD B2C Identity Provider. + SignupPolicyName *string `json:"signupPolicyName,omitempty"` + + // Identity Provider Type identifier. + Type *IdentityProviderType `json:"type,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IdentityProviderBaseParameters. +func (i IdentityProviderBaseParameters) MarshalJSON() ([]byte, error) { + objectMap := i.marshalInternal() + return json.Marshal(objectMap) +} + +func (i IdentityProviderBaseParameters) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "allowedTenants", i.AllowedTenants) + populate(objectMap, "authority", i.Authority) + populate(objectMap, "passwordResetPolicyName", i.PasswordResetPolicyName) + populate(objectMap, "profileEditingPolicyName", i.ProfileEditingPolicyName) + populate(objectMap, "signinPolicyName", i.SigninPolicyName) + populate(objectMap, "signinTenant", i.SigninTenant) + populate(objectMap, "signupPolicyName", i.SignupPolicyName) + populate(objectMap, "type", i.Type) + return objectMap +} + +// IdentityProviderContract - Identity Provider details. +type IdentityProviderContract struct { + Resource + // Identity Provider contract properties. + Properties *IdentityProviderContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IdentityProviderContract. +func (i IdentityProviderContract) MarshalJSON() ([]byte, error) { + objectMap := i.Resource.marshalInternal() + populate(objectMap, "properties", i.Properties) + return json.Marshal(objectMap) +} + +// IdentityProviderContractProperties - The external Identity Providers like Facebook, Google, Microsoft, Twitter or Azure Active Directory which can be +// used to enable access to the API Management service developer portal for all users. +type IdentityProviderContractProperties struct { + IdentityProviderBaseParameters + // REQUIRED; Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. + ClientID *string `json:"clientId,omitempty"` + + // Client secret of the Application in external Identity Provider, used to authenticate login request. For example, it is App Secret for Facebook login, + // API Key for Google login, Public Key for + // Microsoft. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + ClientSecret *string `json:"clientSecret,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IdentityProviderContractProperties. +func (i IdentityProviderContractProperties) MarshalJSON() ([]byte, error) { + objectMap := i.IdentityProviderBaseParameters.marshalInternal() + populate(objectMap, "clientId", i.ClientID) + populate(objectMap, "clientSecret", i.ClientSecret) + return json.Marshal(objectMap) +} + +// IdentityProviderCreateContract - Identity Provider details. +type IdentityProviderCreateContract struct { + Resource + // Identity Provider contract properties. + Properties *IdentityProviderCreateContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IdentityProviderCreateContract. +func (i IdentityProviderCreateContract) MarshalJSON() ([]byte, error) { + objectMap := i.Resource.marshalInternal() + populate(objectMap, "properties", i.Properties) + return json.Marshal(objectMap) +} + +// IdentityProviderCreateContractProperties - The external Identity Providers like Facebook, Google, Microsoft, Twitter or Azure Active Directory which +// can be used to enable access to the API Management service developer portal for all users. +type IdentityProviderCreateContractProperties struct { + IdentityProviderBaseParameters + // REQUIRED; Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. + ClientID *string `json:"clientId,omitempty"` + + // REQUIRED; Client secret of the Application in external Identity Provider, used to authenticate login request. For example, it is App Secret for Facebook + // login, API Key for Google login, Public Key for + // Microsoft. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + ClientSecret *string `json:"clientSecret,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IdentityProviderCreateContractProperties. +func (i IdentityProviderCreateContractProperties) MarshalJSON() ([]byte, error) { + objectMap := i.IdentityProviderBaseParameters.marshalInternal() + populate(objectMap, "clientId", i.ClientID) + populate(objectMap, "clientSecret", i.ClientSecret) + return json.Marshal(objectMap) +} + +// IdentityProviderCreateOrUpdateOptions contains the optional parameters for the IdentityProvider.CreateOrUpdate method. +type IdentityProviderCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// IdentityProviderDeleteOptions contains the optional parameters for the IdentityProvider.Delete method. +type IdentityProviderDeleteOptions struct { + // placeholder for future optional parameters +} + +// IdentityProviderGetEntityTagOptions contains the optional parameters for the IdentityProvider.GetEntityTag method. +type IdentityProviderGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// IdentityProviderGetOptions contains the optional parameters for the IdentityProvider.Get method. +type IdentityProviderGetOptions struct { + // placeholder for future optional parameters +} + +// IdentityProviderList - List of all the Identity Providers configured on the service instance. +type IdentityProviderList struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Identity Provider configuration values. + Value []*IdentityProviderContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IdentityProviderList. +func (i IdentityProviderList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", i.Count) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// IdentityProviderListByServiceOptions contains the optional parameters for the IdentityProvider.ListByService method. +type IdentityProviderListByServiceOptions struct { + // placeholder for future optional parameters +} + +// IdentityProviderListSecretsOptions contains the optional parameters for the IdentityProvider.ListSecrets method. +type IdentityProviderListSecretsOptions struct { + // placeholder for future optional parameters +} + +// IdentityProviderUpdateOptions contains the optional parameters for the IdentityProvider.Update method. +type IdentityProviderUpdateOptions struct { + // placeholder for future optional parameters +} + +// IdentityProviderUpdateParameters - Parameters supplied to update Identity Provider +type IdentityProviderUpdateParameters struct { + // Identity Provider update properties. + Properties *IdentityProviderUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IdentityProviderUpdateParameters. +func (i IdentityProviderUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", i.Properties) + return json.Marshal(objectMap) +} + +// IdentityProviderUpdateProperties - Parameters supplied to the Update Identity Provider operation. +type IdentityProviderUpdateProperties struct { + IdentityProviderBaseParameters + // Client Id of the Application in the external Identity Provider. It is App ID for Facebook login, Client ID for Google login, App ID for Microsoft. + ClientID *string `json:"clientId,omitempty"` + + // Client secret of the Application in external Identity Provider, used to authenticate login request. For example, it is App Secret for Facebook login, + // API Key for Google login, Public Key for + // Microsoft. + ClientSecret *string `json:"clientSecret,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IdentityProviderUpdateProperties. +func (i IdentityProviderUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := i.IdentityProviderBaseParameters.marshalInternal() + populate(objectMap, "clientId", i.ClientID) + populate(objectMap, "clientSecret", i.ClientSecret) + return json.Marshal(objectMap) +} + +// IssueAttachmentCollection - Paged Issue Attachment list representation. +type IssueAttachmentCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Issue Attachment values. + Value []*IssueAttachmentContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type IssueAttachmentCollection. +func (i IssueAttachmentCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", i.Count) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// IssueAttachmentContract - Issue Attachment Contract details. +type IssueAttachmentContract struct { + Resource + // Properties of the Issue Attachment. + Properties *IssueAttachmentContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IssueAttachmentContract. +func (i IssueAttachmentContract) MarshalJSON() ([]byte, error) { + objectMap := i.Resource.marshalInternal() + populate(objectMap, "properties", i.Properties) + return json.Marshal(objectMap) +} + +// IssueAttachmentContractProperties - Issue Attachment contract Properties. +type IssueAttachmentContractProperties struct { + // REQUIRED; An HTTP link or Base64-encoded binary data. + Content *string `json:"content,omitempty"` + + // REQUIRED; Either 'link' if content is provided via an HTTP link or the MIME type of the Base64-encoded binary data provided in the 'content' property. + ContentFormat *string `json:"contentFormat,omitempty"` + + // REQUIRED; Filename by which the binary data will be saved. + Title *string `json:"title,omitempty"` +} + +// IssueCollection - Paged Issue list representation. +type IssueCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Issue values. + Value []*IssueContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type IssueCollection. +func (i IssueCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", i.Count) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// IssueCommentCollection - Paged Issue Comment list representation. +type IssueCommentCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Issue Comment values. + Value []*IssueCommentContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type IssueCommentCollection. +func (i IssueCommentCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", i.Count) + populate(objectMap, "nextLink", i.NextLink) + populate(objectMap, "value", i.Value) + return json.Marshal(objectMap) +} + +// IssueCommentContract - Issue Comment Contract details. +type IssueCommentContract struct { + Resource + // Properties of the Issue Comment. + Properties *IssueCommentContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IssueCommentContract. +func (i IssueCommentContract) MarshalJSON() ([]byte, error) { + objectMap := i.Resource.marshalInternal() + populate(objectMap, "properties", i.Properties) + return json.Marshal(objectMap) +} + +// IssueCommentContractProperties - Issue Comment contract Properties. +type IssueCommentContractProperties struct { + // REQUIRED; Comment text. + Text *string `json:"text,omitempty"` + + // REQUIRED; A resource identifier for the user who left the comment. + UserID *string `json:"userId,omitempty"` + + // Date and time when the comment was created. + CreatedDate *time.Time `json:"createdDate,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IssueCommentContractProperties. +func (i IssueCommentContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "createdDate", (*timeRFC3339)(i.CreatedDate)) + populate(objectMap, "text", i.Text) + populate(objectMap, "userId", i.UserID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IssueCommentContractProperties. +func (i *IssueCommentContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + i.CreatedDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "text": + err = unpopulate(val, &i.Text) + delete(rawMsg, key) + case "userId": + err = unpopulate(val, &i.UserID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// IssueContract - Issue Contract details. +type IssueContract struct { + Resource + // Properties of the Issue. + Properties *IssueContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IssueContract. +func (i IssueContract) MarshalJSON() ([]byte, error) { + objectMap := i.Resource.marshalInternal() + populate(objectMap, "properties", i.Properties) + return json.Marshal(objectMap) +} + +// IssueContractBaseProperties - Issue contract Base Properties. +type IssueContractBaseProperties struct { + // A resource identifier for the API the issue was created for. + APIID *string `json:"apiId,omitempty"` + + // Date and time when the issue was created. + CreatedDate *time.Time `json:"createdDate,omitempty"` + + // Status of the issue. + State *State `json:"state,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IssueContractBaseProperties. +func (i IssueContractBaseProperties) MarshalJSON() ([]byte, error) { + objectMap := i.marshalInternal() + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IssueContractBaseProperties. +func (i *IssueContractBaseProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return i.unmarshalInternal(rawMsg) +} + +func (i IssueContractBaseProperties) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "apiId", i.APIID) + populate(objectMap, "createdDate", (*timeRFC3339)(i.CreatedDate)) + populate(objectMap, "state", i.State) + return objectMap +} + +func (i *IssueContractBaseProperties) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "apiId": + err = unpopulate(val, &i.APIID) + delete(rawMsg, key) + case "createdDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + i.CreatedDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "state": + err = unpopulate(val, &i.State) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// IssueContractProperties - Issue contract Properties. +type IssueContractProperties struct { + IssueContractBaseProperties + // REQUIRED; Text describing the issue. + Description *string `json:"description,omitempty"` + + // REQUIRED; The issue title. + Title *string `json:"title,omitempty"` + + // REQUIRED; A resource identifier for the user created the issue. + UserID *string `json:"userId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IssueContractProperties. +func (i IssueContractProperties) MarshalJSON() ([]byte, error) { + objectMap := i.IssueContractBaseProperties.marshalInternal() + populate(objectMap, "description", i.Description) + populate(objectMap, "title", i.Title) + populate(objectMap, "userId", i.UserID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IssueContractProperties. +func (i *IssueContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, &i.Description) + delete(rawMsg, key) + case "title": + err = unpopulate(val, &i.Title) + delete(rawMsg, key) + case "userId": + err = unpopulate(val, &i.UserID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return i.IssueContractBaseProperties.unmarshalInternal(rawMsg) +} + +// IssueGetOptions contains the optional parameters for the Issue.Get method. +type IssueGetOptions struct { + // placeholder for future optional parameters +} + +// IssueListByServiceOptions contains the optional parameters for the Issue.ListByService method. +type IssueListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| apiId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| title | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, + // gt, lt | substringof, contains, startswith, endswith |
| authorName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + // |
| state | filter | eq | |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// IssueUpdateContract - Issue update Parameters. +type IssueUpdateContract struct { + // Issue entity Update contract properties. + Properties *IssueUpdateContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IssueUpdateContract. +func (i IssueUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", i.Properties) + return json.Marshal(objectMap) +} + +// IssueUpdateContractProperties - Issue contract Update Properties. +type IssueUpdateContractProperties struct { + IssueContractBaseProperties + // Text describing the issue. + Description *string `json:"description,omitempty"` + + // The issue title. + Title *string `json:"title,omitempty"` + + // A resource identifier for the user created the issue. + UserID *string `json:"userId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type IssueUpdateContractProperties. +func (i IssueUpdateContractProperties) MarshalJSON() ([]byte, error) { + objectMap := i.IssueContractBaseProperties.marshalInternal() + populate(objectMap, "description", i.Description) + populate(objectMap, "title", i.Title) + populate(objectMap, "userId", i.UserID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type IssueUpdateContractProperties. +func (i *IssueUpdateContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, &i.Description) + delete(rawMsg, key) + case "title": + err = unpopulate(val, &i.Title) + delete(rawMsg, key) + case "userId": + err = unpopulate(val, &i.UserID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return i.IssueContractBaseProperties.unmarshalInternal(rawMsg) +} + +// KeyVaultContractCreateProperties - Create keyVault contract details. +type KeyVaultContractCreateProperties struct { + // SystemAssignedIdentity or UserAssignedIdentity Client Id which will be used to access key vault secret. + IdentityClientID *string `json:"identityClientId,omitempty"` + + // Key vault secret identifier for fetching secret. Providing a versioned secret will prevent auto-refresh. This requires Api Management service to be configured + // with aka.ms/apimmsi + SecretIdentifier *string `json:"secretIdentifier,omitempty"` +} + +// KeyVaultContractProperties - KeyVault contract details. +type KeyVaultContractProperties struct { + KeyVaultContractCreateProperties + // Last time sync and refresh status of secret from key vault. + LastStatus *KeyVaultLastAccessStatusContractProperties `json:"lastStatus,omitempty"` +} + +// KeyVaultLastAccessStatusContractProperties - Issue contract Update Properties. +type KeyVaultLastAccessStatusContractProperties struct { + // Last status code for sync and refresh of secret from key vault. + Code *string `json:"code,omitempty"` + + // Details of the error else empty. + Message *string `json:"message,omitempty"` + + // Last time secret was accessed. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + TimeStampUTC *time.Time `json:"timeStampUtc,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type KeyVaultLastAccessStatusContractProperties. +func (k KeyVaultLastAccessStatusContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "code", k.Code) + populate(objectMap, "message", k.Message) + populate(objectMap, "timeStampUtc", (*timeRFC3339)(k.TimeStampUTC)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type KeyVaultLastAccessStatusContractProperties. +func (k *KeyVaultLastAccessStatusContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "code": + err = unpopulate(val, &k.Code) + delete(rawMsg, key) + case "message": + err = unpopulate(val, &k.Message) + delete(rawMsg, key) + case "timeStampUtc": + var aux timeRFC3339 + err = unpopulate(val, &aux) + k.TimeStampUTC = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// LoggerCollection - Paged Logger list representation. +type LoggerCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Logger values. + Value []*LoggerContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LoggerCollection. +func (l LoggerCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", l.Count) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// LoggerContract - Logger details. +type LoggerContract struct { + Resource + // Logger entity contract properties. + Properties *LoggerContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LoggerContract. +func (l LoggerContract) MarshalJSON() ([]byte, error) { + objectMap := l.Resource.marshalInternal() + populate(objectMap, "properties", l.Properties) + return json.Marshal(objectMap) +} + +// LoggerContractProperties - The Logger entity in API Management represents an event sink that you can use to log API Management events. Currently the +// Logger entity supports logging API Management events to Azure Event Hubs. +type LoggerContractProperties struct { + // REQUIRED; Logger type. + LoggerType *LoggerType `json:"loggerType,omitempty"` + + // The name and SendRule connection string of the event hub for azureEventHub logger. Instrumentation key for applicationInsights logger. + Credentials map[string]*string `json:"credentials,omitempty"` + + // Logger description. + Description *string `json:"description,omitempty"` + + // Whether records are buffered in the logger before publishing. Default is assumed to be true. + IsBuffered *bool `json:"isBuffered,omitempty"` + + // Azure Resource Id of a log target (either Azure Event Hub resource or Azure Application Insights resource). + ResourceID *string `json:"resourceId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LoggerContractProperties. +func (l LoggerContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "credentials", l.Credentials) + populate(objectMap, "description", l.Description) + populate(objectMap, "isBuffered", l.IsBuffered) + populate(objectMap, "loggerType", l.LoggerType) + populate(objectMap, "resourceId", l.ResourceID) + return json.Marshal(objectMap) +} + +// LoggerCreateOrUpdateOptions contains the optional parameters for the Logger.CreateOrUpdate method. +type LoggerCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// LoggerDeleteOptions contains the optional parameters for the Logger.Delete method. +type LoggerDeleteOptions struct { + // placeholder for future optional parameters +} + +// LoggerGetEntityTagOptions contains the optional parameters for the Logger.GetEntityTag method. +type LoggerGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// LoggerGetOptions contains the optional parameters for the Logger.Get method. +type LoggerGetOptions struct { + // placeholder for future optional parameters +} + +// LoggerListByServiceOptions contains the optional parameters for the Logger.ListByService method. +type LoggerListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| loggerType | filter | eq | |
| resourceId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// LoggerUpdateContract - Logger update contract. +type LoggerUpdateContract struct { + // Logger entity update contract properties. + Properties *LoggerUpdateParameters `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LoggerUpdateContract. +func (l LoggerUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", l.Properties) + return json.Marshal(objectMap) +} + +// LoggerUpdateOptions contains the optional parameters for the Logger.Update method. +type LoggerUpdateOptions struct { + // placeholder for future optional parameters +} + +// LoggerUpdateParameters - Parameters supplied to the Update Logger operation. +type LoggerUpdateParameters struct { + // Logger credentials. + Credentials map[string]*string `json:"credentials,omitempty"` + + // Logger description. + Description *string `json:"description,omitempty"` + + // Whether records are buffered in the logger before publishing. Default is assumed to be true. + IsBuffered *bool `json:"isBuffered,omitempty"` + + // Logger type. + LoggerType *LoggerType `json:"loggerType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type LoggerUpdateParameters. +func (l LoggerUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "credentials", l.Credentials) + populate(objectMap, "description", l.Description) + populate(objectMap, "isBuffered", l.IsBuffered) + populate(objectMap, "loggerType", l.LoggerType) + return json.Marshal(objectMap) +} + +// NamedValueBeginCreateOrUpdateOptions contains the optional parameters for the NamedValue.BeginCreateOrUpdate method. +type NamedValueBeginCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// NamedValueBeginRefreshSecretOptions contains the optional parameters for the NamedValue.BeginRefreshSecret method. +type NamedValueBeginRefreshSecretOptions struct { + // placeholder for future optional parameters +} + +// NamedValueBeginUpdateOptions contains the optional parameters for the NamedValue.BeginUpdate method. +type NamedValueBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// NamedValueCollection - Paged NamedValue list representation. +type NamedValueCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*NamedValueContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NamedValueCollection. +func (n NamedValueCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", n.Count) + populate(objectMap, "nextLink", n.NextLink) + populate(objectMap, "value", n.Value) + return json.Marshal(objectMap) +} + +// NamedValueContract - NamedValue details. +type NamedValueContract struct { + Resource + // NamedValue entity contract properties. + Properties *NamedValueContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NamedValueContract. +func (n NamedValueContract) MarshalJSON() ([]byte, error) { + objectMap := n.Resource.marshalInternal() + populate(objectMap, "properties", n.Properties) + return json.Marshal(objectMap) +} + +// NamedValueContractProperties - NamedValue Contract properties. +type NamedValueContractProperties struct { + NamedValueEntityBaseParameters + // REQUIRED; Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore characters. + DisplayName *string `json:"displayName,omitempty"` + + // KeyVault location details of the namedValue. + KeyVault *KeyVaultContractProperties `json:"keyVault,omitempty"` + + // Value of the NamedValue. Can contain policy expressions. It may not be empty or consist only of whitespace. This property will not be filled on 'GET' + // operations! Use '/listSecrets' POST request to get + // the value. + Value *string `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NamedValueContractProperties. +func (n NamedValueContractProperties) MarshalJSON() ([]byte, error) { + objectMap := n.NamedValueEntityBaseParameters.marshalInternal() + populate(objectMap, "displayName", n.DisplayName) + populate(objectMap, "keyVault", n.KeyVault) + populate(objectMap, "value", n.Value) + return json.Marshal(objectMap) +} + +// NamedValueCreateContract - NamedValue details. +type NamedValueCreateContract struct { + Resource + // NamedValue entity contract properties for PUT operation. + Properties *NamedValueCreateContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NamedValueCreateContract. +func (n NamedValueCreateContract) MarshalJSON() ([]byte, error) { + objectMap := n.Resource.marshalInternal() + populate(objectMap, "properties", n.Properties) + return json.Marshal(objectMap) +} + +// NamedValueCreateContractProperties - NamedValue Contract properties. +type NamedValueCreateContractProperties struct { + NamedValueEntityBaseParameters + // REQUIRED; Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore characters. + DisplayName *string `json:"displayName,omitempty"` + + // KeyVault location details of the namedValue. + KeyVault *KeyVaultContractCreateProperties `json:"keyVault,omitempty"` + + // Value of the NamedValue. Can contain policy expressions. It may not be empty or consist only of whitespace. This property will not be filled on 'GET' + // operations! Use '/listSecrets' POST request to get + // the value. + Value *string `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NamedValueCreateContractProperties. +func (n NamedValueCreateContractProperties) MarshalJSON() ([]byte, error) { + objectMap := n.NamedValueEntityBaseParameters.marshalInternal() + populate(objectMap, "displayName", n.DisplayName) + populate(objectMap, "keyVault", n.KeyVault) + populate(objectMap, "value", n.Value) + return json.Marshal(objectMap) +} + +// NamedValueDeleteOptions contains the optional parameters for the NamedValue.Delete method. +type NamedValueDeleteOptions struct { + // placeholder for future optional parameters +} + +// NamedValueEntityBaseParameters - NamedValue Entity Base Parameters set. +type NamedValueEntityBaseParameters struct { + // Determines whether the value is a secret and should be encrypted or not. Default value is false. + Secret *bool `json:"secret,omitempty"` + + // Optional tags that when provided can be used to filter the NamedValue list. + Tags []*string `json:"tags,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NamedValueEntityBaseParameters. +func (n NamedValueEntityBaseParameters) MarshalJSON() ([]byte, error) { + objectMap := n.marshalInternal() + return json.Marshal(objectMap) +} + +func (n NamedValueEntityBaseParameters) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "secret", n.Secret) + populate(objectMap, "tags", n.Tags) + return objectMap +} + +// NamedValueGetEntityTagOptions contains the optional parameters for the NamedValue.GetEntityTag method. +type NamedValueGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// NamedValueGetOptions contains the optional parameters for the NamedValue.Get method. +type NamedValueGetOptions struct { + // placeholder for future optional parameters +} + +// NamedValueListByServiceOptions contains the optional parameters for the NamedValue.ListByService method. +type NamedValueListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| tags | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith, any, all |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, + // startswith, endswith |
+ Filter *string + // When set to true, the response contains only named value entities which failed refresh. + IsKeyVaultRefreshFailed *bool + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// NamedValueListValueOptions contains the optional parameters for the NamedValue.ListValue method. +type NamedValueListValueOptions struct { + // placeholder for future optional parameters +} + +// NamedValueSecretContract - Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. +type NamedValueSecretContract struct { + // This is secret value of the NamedValue entity. + Value *string `json:"value,omitempty"` +} + +// NamedValueUpdateParameterProperties - NamedValue Contract properties. +type NamedValueUpdateParameterProperties struct { + NamedValueEntityBaseParameters + // Unique name of NamedValue. It may contain only letters, digits, period, dash, and underscore characters. + DisplayName *string `json:"displayName,omitempty"` + + // KeyVault location details of the namedValue. + KeyVault *KeyVaultContractCreateProperties `json:"keyVault,omitempty"` + + // Value of the NamedValue. Can contain policy expressions. It may not be empty or consist only of whitespace. + Value *string `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NamedValueUpdateParameterProperties. +func (n NamedValueUpdateParameterProperties) MarshalJSON() ([]byte, error) { + objectMap := n.NamedValueEntityBaseParameters.marshalInternal() + populate(objectMap, "displayName", n.DisplayName) + populate(objectMap, "keyVault", n.KeyVault) + populate(objectMap, "value", n.Value) + return json.Marshal(objectMap) +} + +// NamedValueUpdateParameters - NamedValue update Parameters. +type NamedValueUpdateParameters struct { + // NamedValue entity Update contract properties. + Properties *NamedValueUpdateParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NamedValueUpdateParameters. +func (n NamedValueUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", n.Properties) + return json.Marshal(objectMap) +} + +// NetworkStatusContract - Network Status details. +type NetworkStatusContract struct { + // REQUIRED; Gets the list of Connectivity Status to the Resources on which the service depends upon. + ConnectivityStatus []*ConnectivityStatusContract `json:"connectivityStatus,omitempty"` + + // REQUIRED; Gets the list of DNS servers IPV4 addresses. + DNSServers []*string `json:"dnsServers,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NetworkStatusContract. +func (n NetworkStatusContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "connectivityStatus", n.ConnectivityStatus) + populate(objectMap, "dnsServers", n.DNSServers) + return json.Marshal(objectMap) +} + +// NetworkStatusContractByLocation - Network Status in the Location +type NetworkStatusContractByLocation struct { + // Location of service + Location *string `json:"location,omitempty"` + + // Network status in Location + NetworkStatus *NetworkStatusContract `json:"networkStatus,omitempty"` +} + +// NetworkStatusListByLocationOptions contains the optional parameters for the NetworkStatus.ListByLocation method. +type NetworkStatusListByLocationOptions struct { + // placeholder for future optional parameters +} + +// NetworkStatusListByServiceOptions contains the optional parameters for the NetworkStatus.ListByService method. +type NetworkStatusListByServiceOptions struct { + // placeholder for future optional parameters +} + +// NotificationCollection - Paged Notification list representation. +type NotificationCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*NotificationContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NotificationCollection. +func (n NotificationCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", n.Count) + populate(objectMap, "nextLink", n.NextLink) + populate(objectMap, "value", n.Value) + return json.Marshal(objectMap) +} + +// NotificationContract - Notification details. +type NotificationContract struct { + Resource + // Notification entity contract properties. + Properties *NotificationContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type NotificationContract. +func (n NotificationContract) MarshalJSON() ([]byte, error) { + objectMap := n.Resource.marshalInternal() + populate(objectMap, "properties", n.Properties) + return json.Marshal(objectMap) +} + +// NotificationContractProperties - Notification Contract properties. +type NotificationContractProperties struct { + // REQUIRED; Title of the Notification. + Title *string `json:"title,omitempty"` + + // Description of the Notification. + Description *string `json:"description,omitempty"` + + // Recipient Parameter values. + Recipients *RecipientsContractProperties `json:"recipients,omitempty"` +} + +// NotificationCreateOrUpdateOptions contains the optional parameters for the Notification.CreateOrUpdate method. +type NotificationCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// NotificationGetOptions contains the optional parameters for the Notification.Get method. +type NotificationGetOptions struct { + // placeholder for future optional parameters +} + +// NotificationListByServiceOptions contains the optional parameters for the Notification.ListByService method. +type NotificationListByServiceOptions struct { + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// NotificationRecipientEmailCheckEntityExistsOptions contains the optional parameters for the NotificationRecipientEmail.CheckEntityExists method. +type NotificationRecipientEmailCheckEntityExistsOptions struct { + // placeholder for future optional parameters +} + +// NotificationRecipientEmailCreateOrUpdateOptions contains the optional parameters for the NotificationRecipientEmail.CreateOrUpdate method. +type NotificationRecipientEmailCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// NotificationRecipientEmailDeleteOptions contains the optional parameters for the NotificationRecipientEmail.Delete method. +type NotificationRecipientEmailDeleteOptions struct { + // placeholder for future optional parameters +} + +// NotificationRecipientEmailListByNotificationOptions contains the optional parameters for the NotificationRecipientEmail.ListByNotification method. +type NotificationRecipientEmailListByNotificationOptions struct { + // placeholder for future optional parameters +} + +// NotificationRecipientUserCheckEntityExistsOptions contains the optional parameters for the NotificationRecipientUser.CheckEntityExists method. +type NotificationRecipientUserCheckEntityExistsOptions struct { + // placeholder for future optional parameters +} + +// NotificationRecipientUserCreateOrUpdateOptions contains the optional parameters for the NotificationRecipientUser.CreateOrUpdate method. +type NotificationRecipientUserCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// NotificationRecipientUserDeleteOptions contains the optional parameters for the NotificationRecipientUser.Delete method. +type NotificationRecipientUserDeleteOptions struct { + // placeholder for future optional parameters +} + +// NotificationRecipientUserListByNotificationOptions contains the optional parameters for the NotificationRecipientUser.ListByNotification method. +type NotificationRecipientUserListByNotificationOptions struct { + // placeholder for future optional parameters +} + +// OAuth2AuthenticationSettingsContract - API OAuth2 Authentication settings details. +type OAuth2AuthenticationSettingsContract struct { + // OAuth authorization server identifier. + AuthorizationServerID *string `json:"authorizationServerId,omitempty"` + + // operations scope. + Scope *string `json:"scope,omitempty"` +} + +// OpenIDAuthenticationSettingsContract - API OAuth2 Authentication settings details. +type OpenIDAuthenticationSettingsContract struct { + // How to send token to the server. + BearerTokenSendingMethods []*BearerTokenSendingMethods `json:"bearerTokenSendingMethods,omitempty"` + + // OAuth authorization server identifier. + OpenidProviderID *string `json:"openidProviderId,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OpenIDAuthenticationSettingsContract. +func (o OpenIDAuthenticationSettingsContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "bearerTokenSendingMethods", o.BearerTokenSendingMethods) + populate(objectMap, "openidProviderId", o.OpenidProviderID) + return json.Marshal(objectMap) +} + +// OpenIDConnectProviderCollection - Paged OpenIdProviders list representation. +type OpenIDConnectProviderCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*OpenidConnectProviderContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OpenIDConnectProviderCollection. +func (o OpenIDConnectProviderCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", o.Count) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OpenIDConnectProviderCreateOrUpdateOptions contains the optional parameters for the OpenIDConnectProvider.CreateOrUpdate method. +type OpenIDConnectProviderCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// OpenIDConnectProviderDeleteOptions contains the optional parameters for the OpenIDConnectProvider.Delete method. +type OpenIDConnectProviderDeleteOptions struct { + // placeholder for future optional parameters +} + +// OpenIDConnectProviderGetEntityTagOptions contains the optional parameters for the OpenIDConnectProvider.GetEntityTag method. +type OpenIDConnectProviderGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// OpenIDConnectProviderGetOptions contains the optional parameters for the OpenIDConnectProvider.Get method. +type OpenIDConnectProviderGetOptions struct { + // placeholder for future optional parameters +} + +// OpenIDConnectProviderListByServiceOptions contains the optional parameters for the OpenIDConnectProvider.ListByService method. +type OpenIDConnectProviderListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// OpenIDConnectProviderListSecretsOptions contains the optional parameters for the OpenIDConnectProvider.ListSecrets method. +type OpenIDConnectProviderListSecretsOptions struct { + // placeholder for future optional parameters +} + +// OpenIDConnectProviderUpdateOptions contains the optional parameters for the OpenIDConnectProvider.Update method. +type OpenIDConnectProviderUpdateOptions struct { + // placeholder for future optional parameters +} + +// OpenidConnectProviderContract - OpenId Connect Provider details. +type OpenidConnectProviderContract struct { + Resource + // OpenId Connect Provider contract properties. + Properties *OpenidConnectProviderContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OpenidConnectProviderContract. +func (o OpenidConnectProviderContract) MarshalJSON() ([]byte, error) { + objectMap := o.Resource.marshalInternal() + populate(objectMap, "properties", o.Properties) + return json.Marshal(objectMap) +} + +// OpenidConnectProviderContractProperties - OpenID Connect Providers Contract. +type OpenidConnectProviderContractProperties struct { + // REQUIRED; Client ID of developer console which is the client application. + ClientID *string `json:"clientId,omitempty"` + + // REQUIRED; User-friendly OpenID Connect Provider name. + DisplayName *string `json:"displayName,omitempty"` + + // REQUIRED; Metadata endpoint URI. + MetadataEndpoint *string `json:"metadataEndpoint,omitempty"` + + // Client Secret of developer console which is the client application. + ClientSecret *string `json:"clientSecret,omitempty"` + + // User-friendly description of OpenID Connect Provider. + Description *string `json:"description,omitempty"` +} + +// OpenidConnectProviderUpdateContract - Parameters supplied to the Update OpenID Connect Provider operation. +type OpenidConnectProviderUpdateContract struct { + // OpenId Connect Provider Update contract properties. + Properties *OpenidConnectProviderUpdateContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OpenidConnectProviderUpdateContract. +func (o OpenidConnectProviderUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", o.Properties) + return json.Marshal(objectMap) +} + +// OpenidConnectProviderUpdateContractProperties - Parameters supplied to the Update OpenID Connect Provider operation. +type OpenidConnectProviderUpdateContractProperties struct { + // Client ID of developer console which is the client application. + ClientID *string `json:"clientId,omitempty"` + + // Client Secret of developer console which is the client application. + ClientSecret *string `json:"clientSecret,omitempty"` + + // User-friendly description of OpenID Connect Provider. + Description *string `json:"description,omitempty"` + + // User-friendly OpenID Connect Provider name. + DisplayName *string `json:"displayName,omitempty"` + + // Metadata endpoint URI. + MetadataEndpoint *string `json:"metadataEndpoint,omitempty"` +} + +// Operation - REST API operation +type Operation struct { + // The object that describes the operation. + Display *OperationDisplay `json:"display,omitempty"` + + // Operation name: {provider}/{resource}/{operation} + Name *string `json:"name,omitempty"` + + // The operation origin. + Origin *string `json:"origin,omitempty"` + + // The operation properties. + Properties map[string]interface{} `json:"properties,omitempty"` +} + +// OperationCollection - Paged Operation list representation. +type OperationCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Page values. + Value []*OperationContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationCollection. +func (o OperationCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", o.Count) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationContract - Api Operation details. +type OperationContract struct { + Resource + // Properties of the Operation Contract. + Properties *OperationContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationContract. +func (o OperationContract) MarshalJSON() ([]byte, error) { + objectMap := o.Resource.marshalInternal() + populate(objectMap, "properties", o.Properties) + return json.Marshal(objectMap) +} + +// OperationContractProperties - Operation Contract Properties +type OperationContractProperties struct { + OperationEntityBaseContract + // REQUIRED; Operation Name. + DisplayName *string `json:"displayName,omitempty"` + + // REQUIRED; A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited by only them. + Method *string `json:"method,omitempty"` + + // REQUIRED; Relative URL template identifying the target resource for this operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date} + URLTemplate *string `json:"urlTemplate,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationContractProperties. +func (o OperationContractProperties) MarshalJSON() ([]byte, error) { + objectMap := o.OperationEntityBaseContract.marshalInternal() + populate(objectMap, "displayName", o.DisplayName) + populate(objectMap, "method", o.Method) + populate(objectMap, "urlTemplate", o.URLTemplate) + return json.Marshal(objectMap) +} + +// OperationDisplay - The object that describes the operation. +type OperationDisplay struct { + // Friendly name of the operation + Description *string `json:"description,omitempty"` + + // Operation type: read, write, delete, listKeys/action, etc. + Operation *string `json:"operation,omitempty"` + + // Friendly name of the resource provider + Provider *string `json:"provider,omitempty"` + + // Resource type on which the operation is performed. + Resource *string `json:"resource,omitempty"` +} + +// OperationEntityBaseContract - Api Operation Entity Base Contract details. +type OperationEntityBaseContract struct { + // Description of the operation. May include HTML formatting tags. + Description *string `json:"description,omitempty"` + + // Operation Policies + Policies *string `json:"policies,omitempty"` + + // An entity containing request details. + Request *RequestContract `json:"request,omitempty"` + + // Array of Operation responses. + Responses []*ResponseContract `json:"responses,omitempty"` + + // Collection of URL template parameters. + TemplateParameters []*ParameterContract `json:"templateParameters,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationEntityBaseContract. +func (o OperationEntityBaseContract) MarshalJSON() ([]byte, error) { + objectMap := o.marshalInternal() + return json.Marshal(objectMap) +} + +func (o OperationEntityBaseContract) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", o.Description) + populate(objectMap, "policies", o.Policies) + populate(objectMap, "request", o.Request) + populate(objectMap, "responses", o.Responses) + populate(objectMap, "templateParameters", o.TemplateParameters) + return objectMap +} + +// OperationListByTagsOptions contains the optional parameters for the Operation.ListByTags method. +type OperationListByTagsOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| apiName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, + // gt, lt | substringof, contains, startswith, endswith |
| method | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + // urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
+ Filter *string + // Include not tagged Operations. + IncludeNotTaggedOperations *bool + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// OperationListResult - Result of the request to list REST API operations. It contains a list of operations and a URL nextLink to get the next set of results. +type OperationListResult struct { + // URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` + + // List of operations supported by the resource provider. + Value []*Operation `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// OperationResultContract - Long Running Git Operation Results. +type OperationResultContract struct { + Resource + // Properties of the Operation Contract. + Properties *OperationResultContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationResultContract. +func (o OperationResultContract) MarshalJSON() ([]byte, error) { + objectMap := o.Resource.marshalInternal() + populate(objectMap, "properties", o.Properties) + return json.Marshal(objectMap) +} + +// OperationResultContractProperties - Operation Result. +type OperationResultContractProperties struct { + // Error Body Contract + Error *ErrorResponseBody `json:"error,omitempty"` + + // Operation result identifier. + ID *string `json:"id,omitempty"` + + // Optional result info. + ResultInfo *string `json:"resultInfo,omitempty"` + + // Start time of an async operation. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + Started *time.Time `json:"started,omitempty"` + + // Status of an async operation. + Status *AsyncOperationStatus `json:"status,omitempty"` + + // Last update time of an async operation. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + Updated *time.Time `json:"updated,omitempty"` + + // READ-ONLY; This property if only provided as part of the TenantConfigurationValidate operation. It contains the log the entities which will be updated/created/deleted + // as part of the TenantConfigurationDeploy + // operation. + ActionLog []*OperationResultLogItemContract `json:"actionLog,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationResultContractProperties. +func (o OperationResultContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "actionLog", o.ActionLog) + populate(objectMap, "error", o.Error) + populate(objectMap, "id", o.ID) + populate(objectMap, "resultInfo", o.ResultInfo) + populate(objectMap, "started", (*timeRFC3339)(o.Started)) + populate(objectMap, "status", o.Status) + populate(objectMap, "updated", (*timeRFC3339)(o.Updated)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationResultContractProperties. +func (o *OperationResultContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "actionLog": + err = unpopulate(val, &o.ActionLog) + delete(rawMsg, key) + case "error": + err = unpopulate(val, &o.Error) + delete(rawMsg, key) + case "id": + err = unpopulate(val, &o.ID) + delete(rawMsg, key) + case "resultInfo": + err = unpopulate(val, &o.ResultInfo) + delete(rawMsg, key) + case "started": + var aux timeRFC3339 + err = unpopulate(val, &aux) + o.Started = (*time.Time)(&aux) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &o.Status) + delete(rawMsg, key) + case "updated": + var aux timeRFC3339 + err = unpopulate(val, &aux) + o.Updated = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// OperationResultLogItemContract - Log of the entity being created, updated or deleted. +type OperationResultLogItemContract struct { + // Action like create/update/delete. + Action *string `json:"action,omitempty"` + + // Identifier of the entity being created/updated/deleted. + ObjectKey *string `json:"objectKey,omitempty"` + + // The type of entity contract. + ObjectType *string `json:"objectType,omitempty"` +} + +// OperationTagResourceContractProperties - Operation Entity contract Properties. +type OperationTagResourceContractProperties struct { + // Identifier of the operation in form /operations/{operationId}. + ID *string `json:"id,omitempty"` + + // READ-ONLY; Api Name. + APIName *string `json:"apiName,omitempty" azure:"ro"` + + // READ-ONLY; Api Revision. + APIRevision *string `json:"apiRevision,omitempty" azure:"ro"` + + // READ-ONLY; Api Version. + APIVersion *string `json:"apiVersion,omitempty" azure:"ro"` + + // READ-ONLY; Operation Description. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited by only them. + Method *string `json:"method,omitempty" azure:"ro"` + + // READ-ONLY; Operation name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Relative URL template identifying the target resource for this operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date} + URLTemplate *string `json:"urlTemplate,omitempty" azure:"ro"` +} + +// OperationUpdateContract - Api Operation Update Contract details. +type OperationUpdateContract struct { + // Properties of the API Operation entity that can be updated. + Properties *OperationUpdateContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationUpdateContract. +func (o OperationUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", o.Properties) + return json.Marshal(objectMap) +} + +// OperationUpdateContractProperties - Operation Update Contract Properties. +type OperationUpdateContractProperties struct { + OperationEntityBaseContract + // Operation Name. + DisplayName *string `json:"displayName,omitempty"` + + // A Valid HTTP Operation Method. Typical Http Methods like GET, PUT, POST but not limited by only them. + Method *string `json:"method,omitempty"` + + // Relative URL template identifying the target resource for this operation. May include parameters. Example: /customers/{cid}/orders/{oid}/?date={date} + URLTemplate *string `json:"urlTemplate,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type OperationUpdateContractProperties. +func (o OperationUpdateContractProperties) MarshalJSON() ([]byte, error) { + objectMap := o.OperationEntityBaseContract.marshalInternal() + populate(objectMap, "displayName", o.DisplayName) + populate(objectMap, "method", o.Method) + populate(objectMap, "urlTemplate", o.URLTemplate) + return json.Marshal(objectMap) +} + +// ParameterContract - Operation parameters details. +type ParameterContract struct { + // REQUIRED; Parameter name. + Name *string `json:"name,omitempty"` + + // REQUIRED; Parameter type. + Type *string `json:"type,omitempty"` + + // Default parameter value. + DefaultValue *string `json:"defaultValue,omitempty"` + + // Parameter description. + Description *string `json:"description,omitempty"` + + // Specifies whether parameter is required or not. + Required *bool `json:"required,omitempty"` + + // Parameter values. + Values []*string `json:"values,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ParameterContract. +func (p ParameterContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "defaultValue", p.DefaultValue) + populate(objectMap, "description", p.Description) + populate(objectMap, "name", p.Name) + populate(objectMap, "required", p.Required) + populate(objectMap, "type", p.Type) + populate(objectMap, "values", p.Values) + return json.Marshal(objectMap) +} + +// PipelineDiagnosticSettings - Diagnostic settings for incoming/outgoing HTTP messages to the Gateway. +type PipelineDiagnosticSettings struct { + // Diagnostic settings for request. + Request *HTTPMessageDiagnostic `json:"request,omitempty"` + + // Diagnostic settings for response. + Response *HTTPMessageDiagnostic `json:"response,omitempty"` +} + +// PolicyCollection - The response of the list policy operation. +type PolicyCollection struct { + // Total record count number. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Policy Contract value. + Value []*PolicyContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PolicyCollection. +func (p PolicyCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", p.Count) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PolicyContract - Policy Contract details. +type PolicyContract struct { + Resource + // Properties of the Policy. + Properties *PolicyContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PolicyContract. +func (p PolicyContract) MarshalJSON() ([]byte, error) { + objectMap := p.Resource.marshalInternal() + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PolicyContractProperties - Policy contract Properties. +type PolicyContractProperties struct { + // REQUIRED; Contents of the Policy as defined by the format. + Value *string `json:"value,omitempty"` + + // Format of the policyContent. + Format *PolicyContentFormat `json:"format,omitempty"` +} + +// PolicyCreateOrUpdateOptions contains the optional parameters for the Policy.CreateOrUpdate method. +type PolicyCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// PolicyDeleteOptions contains the optional parameters for the Policy.Delete method. +type PolicyDeleteOptions struct { + // placeholder for future optional parameters +} + +// PolicyDescriptionCollection - Descriptions of APIM policies. +type PolicyDescriptionCollection struct { + // Total record count number. + Count *int64 `json:"count,omitempty"` + + // Descriptions of APIM policies. + Value []*PolicyDescriptionContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PolicyDescriptionCollection. +func (p PolicyDescriptionCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", p.Count) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PolicyDescriptionContract - Policy description details. +type PolicyDescriptionContract struct { + Resource + // Policy description contract properties. + Properties *PolicyDescriptionContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PolicyDescriptionContract. +func (p PolicyDescriptionContract) MarshalJSON() ([]byte, error) { + objectMap := p.Resource.marshalInternal() + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PolicyDescriptionContractProperties - Policy description properties. +type PolicyDescriptionContractProperties struct { + // READ-ONLY; Policy description. + Description *string `json:"description,omitempty" azure:"ro"` + + // READ-ONLY; Binary OR value of the Snippet scope. + Scope *int64 `json:"scope,omitempty" azure:"ro"` +} + +// PolicyDescriptionListByServiceOptions contains the optional parameters for the PolicyDescription.ListByService method. +type PolicyDescriptionListByServiceOptions struct { + // Policy scope. + Scope *PolicyScopeContract +} + +// PolicyGetEntityTagOptions contains the optional parameters for the Policy.GetEntityTag method. +type PolicyGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// PolicyGetOptions contains the optional parameters for the Policy.Get method. +type PolicyGetOptions struct { + // Policy Export Format. + Format *PolicyExportFormat +} + +// PolicyListByServiceOptions contains the optional parameters for the Policy.ListByService method. +type PolicyListByServiceOptions struct { + // placeholder for future optional parameters +} + +// PortalDelegationSettings - Delegation settings for a developer portal. +type PortalDelegationSettings struct { + Resource + // Delegation settings contract properties. + Properties *PortalDelegationSettingsProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PortalDelegationSettings. +func (p PortalDelegationSettings) MarshalJSON() ([]byte, error) { + objectMap := p.Resource.marshalInternal() + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PortalDelegationSettingsProperties - Delegation settings contract properties. +type PortalDelegationSettingsProperties struct { + // Subscriptions delegation settings. + Subscriptions *SubscriptionsDelegationSettingsProperties `json:"subscriptions,omitempty"` + + // A delegation Url. + URL *string `json:"url,omitempty"` + + // User registration delegation settings. + UserRegistration *RegistrationDelegationSettingsProperties `json:"userRegistration,omitempty"` + + // A base64-encoded validation key to validate, that a request is coming from Azure API Management. + ValidationKey *string `json:"validationKey,omitempty"` +} + +// PortalRevisionBeginCreateOrUpdateOptions contains the optional parameters for the PortalRevision.BeginCreateOrUpdate method. +type PortalRevisionBeginCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// PortalRevisionBeginUpdateOptions contains the optional parameters for the PortalRevision.BeginUpdate method. +type PortalRevisionBeginUpdateOptions struct { + // placeholder for future optional parameters +} + +// PortalRevisionCollection - Paged list of portal revisions. +type PortalRevisionCollection struct { + // READ-ONLY; Next page link, if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Collection of portal revisions. + Value []*PortalRevisionContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PortalRevisionCollection. +func (p PortalRevisionCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PortalRevisionContract - Portal revisions contract details. +type PortalRevisionContract struct { + Resource + // Properties of the portal revisions. + Properties *PortalRevisionContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PortalRevisionContract. +func (p PortalRevisionContract) MarshalJSON() ([]byte, error) { + objectMap := p.Resource.marshalInternal() + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +type PortalRevisionContractProperties struct { + // Portal revision description. + Description *string `json:"description,omitempty"` + + // Indicates if the Portal Revision is public. + IsCurrent *bool `json:"isCurrent,omitempty"` + + // READ-ONLY; Portal revision creation date and time. + CreatedDateTime *time.Time `json:"createdDateTime,omitempty" azure:"ro"` + + // READ-ONLY; Portal revision publishing status + Status *PortalRevisionStatus `json:"status,omitempty" azure:"ro"` + + // READ-ONLY; Portal revision publishing status details. + StatusDetails *string `json:"statusDetails,omitempty" azure:"ro"` + + // READ-ONLY; Last updated date and time. + UpdatedDateTime *time.Time `json:"updatedDateTime,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type PortalRevisionContractProperties. +func (p PortalRevisionContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "createdDateTime", (*timeRFC3339)(p.CreatedDateTime)) + populate(objectMap, "description", p.Description) + populate(objectMap, "isCurrent", p.IsCurrent) + populate(objectMap, "status", p.Status) + populate(objectMap, "statusDetails", p.StatusDetails) + populate(objectMap, "updatedDateTime", (*timeRFC3339)(p.UpdatedDateTime)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type PortalRevisionContractProperties. +func (p *PortalRevisionContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdDateTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + p.CreatedDateTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "description": + err = unpopulate(val, &p.Description) + delete(rawMsg, key) + case "isCurrent": + err = unpopulate(val, &p.IsCurrent) + delete(rawMsg, key) + case "status": + err = unpopulate(val, &p.Status) + delete(rawMsg, key) + case "statusDetails": + err = unpopulate(val, &p.StatusDetails) + delete(rawMsg, key) + case "updatedDateTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + p.UpdatedDateTime = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// PortalRevisionGetEntityTagOptions contains the optional parameters for the PortalRevision.GetEntityTag method. +type PortalRevisionGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// PortalRevisionGetOptions contains the optional parameters for the PortalRevision.Get method. +type PortalRevisionGetOptions struct { + // placeholder for future optional parameters +} + +// PortalRevisionListByServiceOptions contains the optional parameters for the PortalRevision.ListByService method. +type PortalRevisionListByServiceOptions struct { + // | Field | Supported operators | Supported functions | + // |-------------|------------------------|-----------------------------------| + // + // |name | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| + // |description | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith| + // |isCurrent | eq, ne | | + Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// PortalSettingValidationKeyContract - Client or app secret used in IdentityProviders, Aad, OpenID or OAuth. +type PortalSettingValidationKeyContract struct { + // This is secret value of the validation key in portal settings. + ValidationKey *string `json:"validationKey,omitempty"` +} + +// PortalSettingsCollection - Descriptions of APIM policies. +type PortalSettingsCollection struct { + // Total record count number. + Count *int64 `json:"count,omitempty"` + + // Descriptions of APIM policies. + Value []*PortalSettingsContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PortalSettingsCollection. +func (p PortalSettingsCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", p.Count) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// PortalSettingsContract - Portal Settings for the Developer Portal. +type PortalSettingsContract struct { + Resource + // Portal Settings contract properties. + Properties *PortalSettingsContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PortalSettingsContract. +func (p PortalSettingsContract) MarshalJSON() ([]byte, error) { + objectMap := p.Resource.marshalInternal() + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PortalSettingsContractProperties - Sign-in settings contract properties. +type PortalSettingsContractProperties struct { + // Redirect Anonymous users to the Sign-In page. + Enabled *bool `json:"enabled,omitempty"` + + // Subscriptions delegation settings. + Subscriptions *SubscriptionsDelegationSettingsProperties `json:"subscriptions,omitempty"` + + // Terms of service contract properties. + TermsOfService *TermsOfServiceProperties `json:"termsOfService,omitempty"` + + // A delegation Url. + URL *string `json:"url,omitempty"` + + // User registration delegation settings. + UserRegistration *RegistrationDelegationSettingsProperties `json:"userRegistration,omitempty"` + + // A base64-encoded validation key to validate, that a request is coming from Azure API Management. + ValidationKey *string `json:"validationKey,omitempty"` +} + +// PortalSettingsListByServiceOptions contains the optional parameters for the PortalSettings.ListByService method. +type PortalSettingsListByServiceOptions struct { + // placeholder for future optional parameters +} + +// PortalSigninSettingProperties - Sign-in settings contract properties. +type PortalSigninSettingProperties struct { + // Redirect Anonymous users to the Sign-In page. + Enabled *bool `json:"enabled,omitempty"` +} + +// PortalSigninSettings - Sign-In settings for the Developer Portal. +type PortalSigninSettings struct { + Resource + // Sign-in settings contract properties. + Properties *PortalSigninSettingProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PortalSigninSettings. +func (p PortalSigninSettings) MarshalJSON() ([]byte, error) { + objectMap := p.Resource.marshalInternal() + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PortalSignupSettings - Sign-Up settings for a developer portal. +type PortalSignupSettings struct { + Resource + // Sign-up settings contract properties. + Properties *PortalSignupSettingsProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type PortalSignupSettings. +func (p PortalSignupSettings) MarshalJSON() ([]byte, error) { + objectMap := p.Resource.marshalInternal() + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// PortalSignupSettingsProperties - Sign-up settings contract properties. +type PortalSignupSettingsProperties struct { + // Allow users to sign up on a developer portal. + Enabled *bool `json:"enabled,omitempty"` + + // Terms of service contract properties. + TermsOfService *TermsOfServiceProperties `json:"termsOfService,omitempty"` +} + +// ProductAPICheckEntityExistsOptions contains the optional parameters for the ProductAPI.CheckEntityExists method. +type ProductAPICheckEntityExistsOptions struct { + // placeholder for future optional parameters +} + +// ProductAPICreateOrUpdateOptions contains the optional parameters for the ProductAPI.CreateOrUpdate method. +type ProductAPICreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ProductAPIDeleteOptions contains the optional parameters for the ProductAPI.Delete method. +type ProductAPIDeleteOptions struct { + // placeholder for future optional parameters +} + +// ProductAPIListByProductOptions contains the optional parameters for the ProductAPI.ListByProduct method. +type ProductAPIListByProductOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| serviceUrl | filter | ge, le, eq, + // ne, gt, lt | substringof, contains, startswith, endswith |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + // |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// ProductCollection - Paged Products list representation. +type ProductCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*ProductContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ProductCollection. +func (p ProductCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", p.Count) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) + return json.Marshal(objectMap) +} + +// ProductContract - Product details. +type ProductContract struct { + Resource + // Product entity contract properties. + Properties *ProductContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ProductContract. +func (p ProductContract) MarshalJSON() ([]byte, error) { + objectMap := p.Resource.marshalInternal() + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// ProductContractProperties - Product profile. +type ProductContractProperties struct { + ProductEntityBaseParameters + // REQUIRED; Product name. + DisplayName *string `json:"displayName,omitempty"` +} + +// ProductCreateOrUpdateOptions contains the optional parameters for the Product.CreateOrUpdate method. +type ProductCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// ProductDeleteOptions contains the optional parameters for the Product.Delete method. +type ProductDeleteOptions struct { + // Delete existing subscriptions associated with the product or not. + DeleteSubscriptions *bool +} + +// ProductEntityBaseParameters - Product Entity Base Parameters +type ProductEntityBaseParameters struct { + // whether subscription approval is required. If false, new subscriptions will be approved automatically enabling developers to call the product’s APIs + // immediately after subscribing. If true, + // administrators must manually approve the subscription before the developer can any of the product’s APIs. Can be present only if subscriptionRequired + // property is present and has a value of false. + ApprovalRequired *bool `json:"approvalRequired,omitempty"` + + // Product description. May include HTML formatting tags. + Description *string `json:"description,omitempty"` + + // whether product is published or not. Published products are discoverable by users of developer portal. Non published products are visible only to administrators. + // Default state of Product is + // notPublished. + State *ProductState `json:"state,omitempty"` + + // Whether a product subscription is required for accessing APIs included in this product. If true, the product is referred to as "protected" and a valid + // subscription key is required for a request to an + // API included in the product to succeed. If false, the product is referred to as "open" and requests to an API included in the product can be made without + // a subscription key. If property is omitted + // when creating a new product it's value is assumed to be true. + SubscriptionRequired *bool `json:"subscriptionRequired,omitempty"` + + // Whether the number of subscriptions a user can have to this product at the same time. Set to null or omit to allow unlimited per user subscriptions. + // Can be present only if subscriptionRequired + // property is present and has a value of false. + SubscriptionsLimit *int32 `json:"subscriptionsLimit,omitempty"` + + // Product terms of use. Developers trying to subscribe to the product will be presented and required to accept these terms before they can complete the + // subscription process. + Terms *string `json:"terms,omitempty"` +} + +// ProductGetEntityTagOptions contains the optional parameters for the Product.GetEntityTag method. +type ProductGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// ProductGetOptions contains the optional parameters for the Product.Get method. +type ProductGetOptions struct { + // placeholder for future optional parameters +} + +// ProductGroupCheckEntityExistsOptions contains the optional parameters for the ProductGroup.CheckEntityExists method. +type ProductGroupCheckEntityExistsOptions struct { + // placeholder for future optional parameters +} + +// ProductGroupCreateOrUpdateOptions contains the optional parameters for the ProductGroup.CreateOrUpdate method. +type ProductGroupCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ProductGroupDeleteOptions contains the optional parameters for the ProductGroup.Delete method. +type ProductGroupDeleteOptions struct { + // placeholder for future optional parameters +} + +// ProductGroupListByProductOptions contains the optional parameters for the ProductGroup.ListByProduct method. +type ProductGroupListByProductOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | |
| displayName | filter | eq, ne | |
| description | filter | eq, ne | |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// ProductListByServiceOptions contains the optional parameters for the Product.ListByService method. +type ProductListByServiceOptions struct { + // When set to true, the response contains an array of groups that have visibility to the product. The default is false. + ExpandGroups *bool + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| terms | filter | ge, le, eq, ne, + // gt, lt | substringof, contains, startswith, endswith |
| state | filter | eq | |
| groups | expand | | |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Products which are part of a specific tag. + Tags *string + // Number of records to return. + Top *int32 +} + +// ProductListByTagsOptions contains the optional parameters for the Product.ListByTags method. +type ProductListByTagsOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| terms | filter | ge, le, eq, ne, + // gt, lt | substringof, contains, startswith, endswith |
| state | filter | eq | substringof, contains, startswith, endswith |
+ Filter *string + // Include not tagged Products. + IncludeNotTaggedProducts *bool + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// ProductPolicyCreateOrUpdateOptions contains the optional parameters for the ProductPolicy.CreateOrUpdate method. +type ProductPolicyCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// ProductPolicyDeleteOptions contains the optional parameters for the ProductPolicy.Delete method. +type ProductPolicyDeleteOptions struct { + // placeholder for future optional parameters +} + +// ProductPolicyGetEntityTagOptions contains the optional parameters for the ProductPolicy.GetEntityTag method. +type ProductPolicyGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// ProductPolicyGetOptions contains the optional parameters for the ProductPolicy.Get method. +type ProductPolicyGetOptions struct { + // Policy Export Format. + Format *PolicyExportFormat +} + +// ProductPolicyListByProductOptions contains the optional parameters for the ProductPolicy.ListByProduct method. +type ProductPolicyListByProductOptions struct { + // placeholder for future optional parameters +} + +// ProductSubscriptionsListOptions contains the optional parameters for the ProductSubscriptions.List method. +type ProductSubscriptionsListOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| stateComment | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| ownerId | filter | ge, le, eq, + // ne, gt, lt | substringof, contains, startswith, endswith |
| scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + // |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| productId | filter | ge, le, eq, ne, gt, lt | + // substringof, contains, startswith, endswith |
| state | filter | eq | |
| user | expand | | |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// ProductTagResourceContractProperties - Product profile. +type ProductTagResourceContractProperties struct { + ProductEntityBaseParameters + // REQUIRED; Product name. + Name *string `json:"name,omitempty"` + + // Identifier of the product in the form of /products/{productId} + ID *string `json:"id,omitempty"` +} + +// ProductUpdateOptions contains the optional parameters for the Product.Update method. +type ProductUpdateOptions struct { + // placeholder for future optional parameters +} + +// ProductUpdateParameters - Product Update parameters. +type ProductUpdateParameters struct { + // Product entity Update contract properties. + Properties *ProductUpdateProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ProductUpdateParameters. +func (p ProductUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", p.Properties) + return json.Marshal(objectMap) +} + +// ProductUpdateProperties - Parameters supplied to the Update Product operation. +type ProductUpdateProperties struct { + ProductEntityBaseParameters + // Product name. + DisplayName *string `json:"displayName,omitempty"` +} + +// QuotaByCounterKeysListByServiceOptions contains the optional parameters for the QuotaByCounterKeys.ListByService method. +type QuotaByCounterKeysListByServiceOptions struct { + // placeholder for future optional parameters +} + +// QuotaByCounterKeysUpdateOptions contains the optional parameters for the QuotaByCounterKeys.Update method. +type QuotaByCounterKeysUpdateOptions struct { + // placeholder for future optional parameters +} + +// QuotaByPeriodKeysGetOptions contains the optional parameters for the QuotaByPeriodKeys.Get method. +type QuotaByPeriodKeysGetOptions struct { + // placeholder for future optional parameters +} + +// QuotaByPeriodKeysUpdateOptions contains the optional parameters for the QuotaByPeriodKeys.Update method. +type QuotaByPeriodKeysUpdateOptions struct { + // placeholder for future optional parameters +} + +// QuotaCounterCollection - Paged Quota Counter list representation. +type QuotaCounterCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Quota counter values. + Value []*QuotaCounterContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaCounterCollection. +func (q QuotaCounterCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", q.Count) + populate(objectMap, "nextLink", q.NextLink) + populate(objectMap, "value", q.Value) + return json.Marshal(objectMap) +} + +// QuotaCounterContract - Quota counter details. +type QuotaCounterContract struct { + // REQUIRED; The Key value of the Counter. Must not be empty. + CounterKey *string `json:"counterKey,omitempty"` + + // REQUIRED; The date of the end of Counter Period. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + PeriodEndTime *time.Time `json:"periodEndTime,omitempty"` + + // REQUIRED; Identifier of the Period for which the counter was collected. Must not be empty. + PeriodKey *string `json:"periodKey,omitempty"` + + // REQUIRED; The date of the start of Counter Period. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + PeriodStartTime *time.Time `json:"periodStartTime,omitempty"` + + // Quota Value Properties + Value *QuotaCounterValueContractProperties `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaCounterContract. +func (q QuotaCounterContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "counterKey", q.CounterKey) + populate(objectMap, "periodEndTime", (*timeRFC3339)(q.PeriodEndTime)) + populate(objectMap, "periodKey", q.PeriodKey) + populate(objectMap, "periodStartTime", (*timeRFC3339)(q.PeriodStartTime)) + populate(objectMap, "value", q.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaCounterContract. +func (q *QuotaCounterContract) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "counterKey": + err = unpopulate(val, &q.CounterKey) + delete(rawMsg, key) + case "periodEndTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + q.PeriodEndTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "periodKey": + err = unpopulate(val, &q.PeriodKey) + delete(rawMsg, key) + case "periodStartTime": + var aux timeRFC3339 + err = unpopulate(val, &aux) + q.PeriodStartTime = (*time.Time)(&aux) + delete(rawMsg, key) + case "value": + err = unpopulate(val, &q.Value) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// QuotaCounterValueContract - Quota counter value details. +type QuotaCounterValueContract struct { + // Quota counter Value Properties. + Value *QuotaCounterValueContractProperties `json:"value,omitempty"` +} + +// QuotaCounterValueContractProperties - Quota counter value details. +type QuotaCounterValueContractProperties struct { + // Number of times Counter was called. + CallsCount *int32 `json:"callsCount,omitempty"` + + // Data Transferred in KiloBytes. + KbTransferred *float64 `json:"kbTransferred,omitempty"` +} + +// QuotaCounterValueUpdateContract - Quota counter value details. +type QuotaCounterValueUpdateContract struct { + // Quota counter value details. + Properties *QuotaCounterValueContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type QuotaCounterValueUpdateContract. +func (q QuotaCounterValueUpdateContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", q.Properties) + return json.Marshal(objectMap) +} + +// RecipientEmailCollection - Paged Recipient User list representation. +type RecipientEmailCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*RecipientEmailContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RecipientEmailCollection. +func (r RecipientEmailCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", r.Count) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// RecipientEmailContract - Recipient Email details. +type RecipientEmailContract struct { + Resource + // Recipient Email contract properties. + Properties *RecipientEmailContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RecipientEmailContract. +func (r RecipientEmailContract) MarshalJSON() ([]byte, error) { + objectMap := r.Resource.marshalInternal() + populate(objectMap, "properties", r.Properties) + return json.Marshal(objectMap) +} + +// RecipientEmailContractProperties - Recipient Email Contract Properties. +type RecipientEmailContractProperties struct { + // User Email subscribed to notification. + Email *string `json:"email,omitempty"` +} + +// RecipientUserCollection - Paged Recipient User list representation. +type RecipientUserCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*RecipientUserContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RecipientUserCollection. +func (r RecipientUserCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", r.Count) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// RecipientUserContract - Recipient User details. +type RecipientUserContract struct { + Resource + // Recipient User entity contract properties. + Properties *RecipientUsersContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RecipientUserContract. +func (r RecipientUserContract) MarshalJSON() ([]byte, error) { + objectMap := r.Resource.marshalInternal() + populate(objectMap, "properties", r.Properties) + return json.Marshal(objectMap) +} + +// RecipientUsersContractProperties - Recipient User Contract Properties. +type RecipientUsersContractProperties struct { + // API Management UserId subscribed to notification. + UserID *string `json:"userId,omitempty"` +} + +// RecipientsContractProperties - Notification Parameter contract. +type RecipientsContractProperties struct { + // List of Emails subscribed for the notification. + Emails []*string `json:"emails,omitempty"` + + // List of Users subscribed for the notification. + Users []*string `json:"users,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RecipientsContractProperties. +func (r RecipientsContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "emails", r.Emails) + populate(objectMap, "users", r.Users) + return json.Marshal(objectMap) +} + +// RegionContract - Region profile. +type RegionContract struct { + // whether Region is deleted. + IsDeleted *bool `json:"isDeleted,omitempty"` + + // whether Region is the master region. + IsMasterRegion *bool `json:"isMasterRegion,omitempty"` + + // READ-ONLY; Region name. + Name *string `json:"name,omitempty" azure:"ro"` +} + +// RegionListByServiceOptions contains the optional parameters for the Region.ListByService method. +type RegionListByServiceOptions struct { + // placeholder for future optional parameters +} + +// RegionListResult - Lists Regions operation response details. +type RegionListResult struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Lists of Regions. + Value []*RegionContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RegionListResult. +func (r RegionListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", r.Count) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// RegistrationDelegationSettingsProperties - User registration delegation settings properties. +type RegistrationDelegationSettingsProperties struct { + // Enable or disable delegation for user registration. + Enabled *bool `json:"enabled,omitempty"` +} + +// ReportCollection - Paged Report records list representation. +type ReportCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*ReportRecordContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ReportCollection. +func (r ReportCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", r.Count) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// ReportRecordContract - Report data. +type ReportRecordContract struct { + // API identifier path. /apis/{apiId} + APIID *string `json:"apiId,omitempty"` + + // API region identifier. + APIRegion *string `json:"apiRegion,omitempty"` + + // Average time it took to process request. + APITimeAvg *float64 `json:"apiTimeAvg,omitempty"` + + // Maximum time it took to process request. + APITimeMax *float64 `json:"apiTimeMax,omitempty"` + + // Minimum time it took to process request. + APITimeMin *float64 `json:"apiTimeMin,omitempty"` + + // Bandwidth consumed. + Bandwidth *int64 `json:"bandwidth,omitempty"` + + // Number of times when content was served from cache policy. + CacheHitCount *int32 `json:"cacheHitCount,omitempty"` + + // Number of times content was fetched from backend. + CacheMissCount *int32 `json:"cacheMissCount,omitempty"` + + // Number of calls blocked due to invalid credentials. This includes calls returning HttpStatusCode.Unauthorized and HttpStatusCode.Forbidden and HttpStatusCode.TooManyRequests + CallCountBlocked *int32 `json:"callCountBlocked,omitempty"` + + // Number of calls failed due to proxy or backend errors. This includes calls returning HttpStatusCode.BadRequest(400) and any Code between HttpStatusCode.InternalServerError + // (500) and 600 + CallCountFailed *int32 `json:"callCountFailed,omitempty"` + + // Number of other calls. + CallCountOther *int32 `json:"callCountOther,omitempty"` + + // Number of successful calls. This includes calls returning HttpStatusCode <= 301 and HttpStatusCode.NotModified and HttpStatusCode.TemporaryRedirect + CallCountSuccess *int32 `json:"callCountSuccess,omitempty"` + + // Total number of calls. + CallCountTotal *int32 `json:"callCountTotal,omitempty"` + + // Country to which this record data is related. + Country *string `json:"country,omitempty"` + + // Length of aggregation period. Interval must be multiple of 15 minutes and may not be zero. The value should be in ISO 8601 format (http://en.wikipedia.org/wiki/ISO_8601#Durations). + Interval *string `json:"interval,omitempty"` + + // Name depending on report endpoint specifies product, API, operation or developer name. + Name *string `json:"name,omitempty"` + + // Operation identifier path. /apis/{apiId}/operations/{operationId} + OperationID *string `json:"operationId,omitempty"` + + // Country region to which this record data is related. + Region *string `json:"region,omitempty"` + + // Average time it took to process request on backend. + ServiceTimeAvg *float64 `json:"serviceTimeAvg,omitempty"` + + // Maximum time it took to process request on backend. + ServiceTimeMax *float64 `json:"serviceTimeMax,omitempty"` + + // Minimum time it took to process request on backend. + ServiceTimeMin *float64 `json:"serviceTimeMin,omitempty"` + + // Subscription identifier path. /subscriptions/{subscriptionId} + SubscriptionID *string `json:"subscriptionId,omitempty"` + + // Start of aggregation period. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + Timestamp *time.Time `json:"timestamp,omitempty"` + + // Zip code to which this record data is related. + Zip *string `json:"zip,omitempty"` + + // READ-ONLY; Product identifier path. /products/{productId} + ProductID *string `json:"productId,omitempty" azure:"ro"` + + // READ-ONLY; User identifier path. /users/{userId} + UserID *string `json:"userId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type ReportRecordContract. +func (r ReportRecordContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "apiId", r.APIID) + populate(objectMap, "apiRegion", r.APIRegion) + populate(objectMap, "apiTimeAvg", r.APITimeAvg) + populate(objectMap, "apiTimeMax", r.APITimeMax) + populate(objectMap, "apiTimeMin", r.APITimeMin) + populate(objectMap, "bandwidth", r.Bandwidth) + populate(objectMap, "cacheHitCount", r.CacheHitCount) + populate(objectMap, "cacheMissCount", r.CacheMissCount) + populate(objectMap, "callCountBlocked", r.CallCountBlocked) + populate(objectMap, "callCountFailed", r.CallCountFailed) + populate(objectMap, "callCountOther", r.CallCountOther) + populate(objectMap, "callCountSuccess", r.CallCountSuccess) + populate(objectMap, "callCountTotal", r.CallCountTotal) + populate(objectMap, "country", r.Country) + populate(objectMap, "interval", r.Interval) + populate(objectMap, "name", r.Name) + populate(objectMap, "operationId", r.OperationID) + populate(objectMap, "productId", r.ProductID) + populate(objectMap, "region", r.Region) + populate(objectMap, "serviceTimeAvg", r.ServiceTimeAvg) + populate(objectMap, "serviceTimeMax", r.ServiceTimeMax) + populate(objectMap, "serviceTimeMin", r.ServiceTimeMin) + populate(objectMap, "subscriptionId", r.SubscriptionID) + populate(objectMap, "timestamp", (*timeRFC3339)(r.Timestamp)) + populate(objectMap, "userId", r.UserID) + populate(objectMap, "zip", r.Zip) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type ReportRecordContract. +func (r *ReportRecordContract) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "apiId": + err = unpopulate(val, &r.APIID) + delete(rawMsg, key) + case "apiRegion": + err = unpopulate(val, &r.APIRegion) + delete(rawMsg, key) + case "apiTimeAvg": + err = unpopulate(val, &r.APITimeAvg) + delete(rawMsg, key) + case "apiTimeMax": + err = unpopulate(val, &r.APITimeMax) + delete(rawMsg, key) + case "apiTimeMin": + err = unpopulate(val, &r.APITimeMin) + delete(rawMsg, key) + case "bandwidth": + err = unpopulate(val, &r.Bandwidth) + delete(rawMsg, key) + case "cacheHitCount": + err = unpopulate(val, &r.CacheHitCount) + delete(rawMsg, key) + case "cacheMissCount": + err = unpopulate(val, &r.CacheMissCount) + delete(rawMsg, key) + case "callCountBlocked": + err = unpopulate(val, &r.CallCountBlocked) + delete(rawMsg, key) + case "callCountFailed": + err = unpopulate(val, &r.CallCountFailed) + delete(rawMsg, key) + case "callCountOther": + err = unpopulate(val, &r.CallCountOther) + delete(rawMsg, key) + case "callCountSuccess": + err = unpopulate(val, &r.CallCountSuccess) + delete(rawMsg, key) + case "callCountTotal": + err = unpopulate(val, &r.CallCountTotal) + delete(rawMsg, key) + case "country": + err = unpopulate(val, &r.Country) + delete(rawMsg, key) + case "interval": + err = unpopulate(val, &r.Interval) + delete(rawMsg, key) + case "name": + err = unpopulate(val, &r.Name) + delete(rawMsg, key) + case "operationId": + err = unpopulate(val, &r.OperationID) + delete(rawMsg, key) + case "productId": + err = unpopulate(val, &r.ProductID) + delete(rawMsg, key) + case "region": + err = unpopulate(val, &r.Region) + delete(rawMsg, key) + case "serviceTimeAvg": + err = unpopulate(val, &r.ServiceTimeAvg) + delete(rawMsg, key) + case "serviceTimeMax": + err = unpopulate(val, &r.ServiceTimeMax) + delete(rawMsg, key) + case "serviceTimeMin": + err = unpopulate(val, &r.ServiceTimeMin) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, &r.SubscriptionID) + delete(rawMsg, key) + case "timestamp": + var aux timeRFC3339 + err = unpopulate(val, &aux) + r.Timestamp = (*time.Time)(&aux) + delete(rawMsg, key) + case "userId": + err = unpopulate(val, &r.UserID) + delete(rawMsg, key) + case "zip": + err = unpopulate(val, &r.Zip) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// ReportsListByAPIOptions contains the optional parameters for the Reports.ListByAPI method. +type ReportsListByAPIOptions struct { + // OData order by query option. + Orderby *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// ReportsListByGeoOptions contains the optional parameters for the Reports.ListByGeo method. +type ReportsListByGeoOptions struct { + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// ReportsListByOperationOptions contains the optional parameters for the Reports.ListByOperation method. +type ReportsListByOperationOptions struct { + // OData order by query option. + Orderby *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// ReportsListByProductOptions contains the optional parameters for the Reports.ListByProduct method. +type ReportsListByProductOptions struct { + // OData order by query option. + Orderby *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// ReportsListByRequestOptions contains the optional parameters for the Reports.ListByRequest method. +type ReportsListByRequestOptions struct { + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// ReportsListBySubscriptionOptions contains the optional parameters for the Reports.ListBySubscription method. +type ReportsListBySubscriptionOptions struct { + // OData order by query option. + Orderby *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// ReportsListByTimeOptions contains the optional parameters for the Reports.ListByTime method. +type ReportsListByTimeOptions struct { + // OData order by query option. + Orderby *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// ReportsListByUserOptions contains the optional parameters for the Reports.ListByUser method. +type ReportsListByUserOptions struct { + // OData order by query option. + Orderby *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// RepresentationContract - Operation request/response representation details. +type RepresentationContract struct { + // REQUIRED; Specifies a registered or custom content type for this representation, e.g. application/xml. + ContentType *string `json:"contentType,omitempty"` + + // Collection of form parameters. Required if 'contentType' value is either 'application/x-www-form-urlencoded' or 'multipart/form-data'.. + FormParameters []*ParameterContract `json:"formParameters,omitempty"` + + // An example of the representation. + Sample *string `json:"sample,omitempty"` + + // Schema identifier. Applicable only if 'contentType' value is neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'. + SchemaID *string `json:"schemaId,omitempty"` + + // Type name defined by the schema. Applicable only if 'contentType' value is neither 'application/x-www-form-urlencoded' nor 'multipart/form-data'. + TypeName *string `json:"typeName,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RepresentationContract. +func (r RepresentationContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "contentType", r.ContentType) + populate(objectMap, "formParameters", r.FormParameters) + populate(objectMap, "sample", r.Sample) + populate(objectMap, "schemaId", r.SchemaID) + populate(objectMap, "typeName", r.TypeName) + return json.Marshal(objectMap) +} + +// RequestContract - Operation request details. +type RequestContract struct { + // Operation request description. + Description *string `json:"description,omitempty"` + + // Collection of operation request headers. + Headers []*ParameterContract `json:"headers,omitempty"` + + // Collection of operation request query parameters. + QueryParameters []*ParameterContract `json:"queryParameters,omitempty"` + + // Collection of operation request representations. + Representations []*RepresentationContract `json:"representations,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RequestContract. +func (r RequestContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", r.Description) + populate(objectMap, "headers", r.Headers) + populate(objectMap, "queryParameters", r.QueryParameters) + populate(objectMap, "representations", r.Representations) + return json.Marshal(objectMap) +} + +// RequestReportCollection - Paged Report records list representation. +type RequestReportCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Page values. + Value []*RequestReportRecordContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type RequestReportCollection. +func (r RequestReportCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", r.Count) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// RequestReportRecordContract - Request Report data. +type RequestReportRecordContract struct { + // API identifier path. /apis/{apiId} + APIID *string `json:"apiId,omitempty"` + + // Azure region where the gateway that processed this request is located. + APIRegion *string `json:"apiRegion,omitempty"` + + // The total time it took to process this request. + APITime *float64 `json:"apiTime,omitempty"` + + // The HTTP status code received by the gateway as a result of forwarding this request to the backend. + BackendResponseCode *string `json:"backendResponseCode,omitempty"` + + // Specifies if response cache was involved in generating the response. If the value is none, the cache was not used. If the value is hit, cached response + // was returned. If the value is miss, the cache + // was used but lookup resulted in a miss and request was fulfilled by the backend. + Cache *string `json:"cache,omitempty"` + + // The client IP address associated with this request. + IPAddress *string `json:"ipAddress,omitempty"` + + // The HTTP method associated with this request.. + Method *string `json:"method,omitempty"` + + // Operation identifier path. /apis/{apiId}/operations/{operationId} + OperationID *string `json:"operationId,omitempty"` + + // Request Identifier. + RequestID *string `json:"requestId,omitempty"` + + // The size of this request.. + RequestSize *int32 `json:"requestSize,omitempty"` + + // The HTTP status code returned by the gateway. + ResponseCode *int32 `json:"responseCode,omitempty"` + + // The size of the response returned by the gateway. + ResponseSize *int32 `json:"responseSize,omitempty"` + + // he time it took to forward this request to the backend and get the response back. + ServiceTime *float64 `json:"serviceTime,omitempty"` + + // Subscription identifier path. /subscriptions/{subscriptionId} + SubscriptionID *string `json:"subscriptionId,omitempty"` + + // The date and time when this request was received by the gateway in ISO 8601 format. + Timestamp *time.Time `json:"timestamp,omitempty"` + + // The full URL associated with this request. + URL *string `json:"url,omitempty"` + + // READ-ONLY; Product identifier path. /products/{productId} + ProductID *string `json:"productId,omitempty" azure:"ro"` + + // READ-ONLY; User identifier path. /users/{userId} + UserID *string `json:"userId,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type RequestReportRecordContract. +func (r RequestReportRecordContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "apiId", r.APIID) + populate(objectMap, "apiRegion", r.APIRegion) + populate(objectMap, "apiTime", r.APITime) + populate(objectMap, "backendResponseCode", r.BackendResponseCode) + populate(objectMap, "cache", r.Cache) + populate(objectMap, "ipAddress", r.IPAddress) + populate(objectMap, "method", r.Method) + populate(objectMap, "operationId", r.OperationID) + populate(objectMap, "productId", r.ProductID) + populate(objectMap, "requestId", r.RequestID) + populate(objectMap, "requestSize", r.RequestSize) + populate(objectMap, "responseCode", r.ResponseCode) + populate(objectMap, "responseSize", r.ResponseSize) + populate(objectMap, "serviceTime", r.ServiceTime) + populate(objectMap, "subscriptionId", r.SubscriptionID) + populate(objectMap, "timestamp", (*timeRFC3339)(r.Timestamp)) + populate(objectMap, "url", r.URL) + populate(objectMap, "userId", r.UserID) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type RequestReportRecordContract. +func (r *RequestReportRecordContract) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "apiId": + err = unpopulate(val, &r.APIID) + delete(rawMsg, key) + case "apiRegion": + err = unpopulate(val, &r.APIRegion) + delete(rawMsg, key) + case "apiTime": + err = unpopulate(val, &r.APITime) + delete(rawMsg, key) + case "backendResponseCode": + err = unpopulate(val, &r.BackendResponseCode) + delete(rawMsg, key) + case "cache": + err = unpopulate(val, &r.Cache) + delete(rawMsg, key) + case "ipAddress": + err = unpopulate(val, &r.IPAddress) + delete(rawMsg, key) + case "method": + err = unpopulate(val, &r.Method) + delete(rawMsg, key) + case "operationId": + err = unpopulate(val, &r.OperationID) + delete(rawMsg, key) + case "productId": + err = unpopulate(val, &r.ProductID) + delete(rawMsg, key) + case "requestId": + err = unpopulate(val, &r.RequestID) + delete(rawMsg, key) + case "requestSize": + err = unpopulate(val, &r.RequestSize) + delete(rawMsg, key) + case "responseCode": + err = unpopulate(val, &r.ResponseCode) + delete(rawMsg, key) + case "responseSize": + err = unpopulate(val, &r.ResponseSize) + delete(rawMsg, key) + case "serviceTime": + err = unpopulate(val, &r.ServiceTime) + delete(rawMsg, key) + case "subscriptionId": + err = unpopulate(val, &r.SubscriptionID) + delete(rawMsg, key) + case "timestamp": + var aux timeRFC3339 + err = unpopulate(val, &aux) + r.Timestamp = (*time.Time)(&aux) + delete(rawMsg, key) + case "url": + err = unpopulate(val, &r.URL) + delete(rawMsg, key) + case "userId": + err = unpopulate(val, &r.UserID) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// Resource - The Resource definition. +type Resource struct { + // READ-ONLY; Resource ID. + ID *string `json:"id,omitempty" azure:"ro"` + + // READ-ONLY; Resource name. + Name *string `json:"name,omitempty" azure:"ro"` + + // READ-ONLY; Resource type for API Management resource. + Type *string `json:"type,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type Resource. +func (r Resource) MarshalJSON() ([]byte, error) { + objectMap := r.marshalInternal() + return json.Marshal(objectMap) +} + +func (r Resource) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", r.ID) + populate(objectMap, "name", r.Name) + populate(objectMap, "type", r.Type) + return objectMap +} + +// ResourceLocationDataContract - Resource location data properties. +type ResourceLocationDataContract struct { + // REQUIRED; A canonical name for the geographic or physical location. + Name *string `json:"name,omitempty"` + + // The city or locality where the resource is located. + City *string `json:"city,omitempty"` + + // The country or region where the resource is located. + CountryOrRegion *string `json:"countryOrRegion,omitempty"` + + // The district, state, or province where the resource is located. + District *string `json:"district,omitempty"` +} + +// ResourceSKU - Describes an available API Management SKU. +type ResourceSKU struct { + // Name of the Sku. + Name *SKUType `json:"name,omitempty"` +} + +// ResourceSKUCapacity - Describes scaling information of a SKU. +type ResourceSKUCapacity struct { + // READ-ONLY; The default capacity. + Default *int32 `json:"default,omitempty" azure:"ro"` + + // READ-ONLY; The maximum capacity that can be set. + Maximum *int32 `json:"maximum,omitempty" azure:"ro"` + + // READ-ONLY; The minimum capacity. + Minimum *int32 `json:"minimum,omitempty" azure:"ro"` + + // READ-ONLY; The scale type applicable to the sku. + ScaleType *ResourceSKUCapacityScaleType `json:"scaleType,omitempty" azure:"ro"` +} + +// ResourceSKUResult - Describes an available API Management service SKU. +type ResourceSKUResult struct { + // READ-ONLY; Specifies the number of API Management units. + Capacity *ResourceSKUCapacity `json:"capacity,omitempty" azure:"ro"` + + // READ-ONLY; The type of resource the SKU applies to. + ResourceType *string `json:"resourceType,omitempty" azure:"ro"` + + // READ-ONLY; Specifies API Management SKU. + SKU *ResourceSKU `json:"sku,omitempty" azure:"ro"` +} + +// ResourceSKUResults - The API Management service SKUs operation response. +type ResourceSKUResults struct { + // REQUIRED; The list of skus available for the service. + Value []*ResourceSKUResult `json:"value,omitempty"` + + // The uri to fetch the next page of API Management service Skus. + NextLink *string `json:"nextLink,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ResourceSKUResults. +func (r ResourceSKUResults) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", r.NextLink) + populate(objectMap, "value", r.Value) + return json.Marshal(objectMap) +} + +// ResponseContract - Operation response details. +type ResponseContract struct { + // REQUIRED; Operation response HTTP status code. + StatusCode *int32 `json:"statusCode,omitempty"` + + // Operation response description. + Description *string `json:"description,omitempty"` + + // Collection of operation response headers. + Headers []*ParameterContract `json:"headers,omitempty"` + + // Collection of operation response representations. + Representations []*RepresentationContract `json:"representations,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type ResponseContract. +func (r ResponseContract) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "description", r.Description) + populate(objectMap, "headers", r.Headers) + populate(objectMap, "representations", r.Representations) + populate(objectMap, "statusCode", r.StatusCode) + return json.Marshal(objectMap) +} + +// SamplingSettings - Sampling settings for Diagnostic. +type SamplingSettings struct { + // Rate of sampling for fixed-rate sampling. + Percentage *float64 `json:"percentage,omitempty"` + + // Sampling type. + SamplingType *SamplingType `json:"samplingType,omitempty"` +} + +// SaveConfigurationParameter - Save Tenant Configuration Contract details. +type SaveConfigurationParameter struct { + // Properties of the Save Configuration Parameters. + Properties *SaveConfigurationParameterProperties `json:"properties,omitempty"` +} + +// SaveConfigurationParameterProperties - Parameters supplied to the Save Tenant Configuration operation. +type SaveConfigurationParameterProperties struct { + // REQUIRED; The name of the Git branch in which to commit the current configuration snapshot. + Branch *string `json:"branch,omitempty"` + + // The value if true, the current configuration database is committed to the Git repository, even if the Git repository has newer changes that would be + // overwritten. + Force *bool `json:"force,omitempty"` +} + +// SchemaCollection - The response of the list schema operation. +type SchemaCollection struct { + // Total record count number. + Count *int64 `json:"count,omitempty"` + + // READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Api Schema Contract value. + Value []*SchemaContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type SchemaCollection. +func (s SchemaCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", s.Count) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// SchemaContract - Schema Contract details. +type SchemaContract struct { + Resource + // Properties of the Schema. + Properties *SchemaContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SchemaContract. +func (s SchemaContract) MarshalJSON() ([]byte, error) { + objectMap := s.Resource.marshalInternal() + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// SchemaContractProperties - API Schema create or update contract Properties. +type SchemaContractProperties struct { + // REQUIRED; Must be a valid a media type used in a Content-Type header as defined in the RFC 2616. Media type of the schema document (e.g. application/json, + // application/xml). + // - Swagger Schema use application/vnd.ms-azure-apim.swagger.definitions+json + // - WSDL Schema use application/vnd.ms-azure-apim.xsd+xml + // - OpenApi Schema use application/vnd.oai.openapi.components+json + // - WADL Schema use application/vnd.ms-azure-apim.wadl.grammars+xml. + ContentType *string `json:"contentType,omitempty"` + + // Create or update Properties of the Schema Document. + Document *SchemaDocumentProperties `json:"document,omitempty"` +} + +// SchemaDocumentProperties - Schema Document Properties. +type SchemaDocumentProperties struct { + // Types definitions. Used for Swagger/OpenAPI schemas only, null otherwise. + Definitions map[string]interface{} `json:"definitions,omitempty"` + + // Json escaped string defining the document representing the Schema. Used for schemas other than Swagger/OpenAPI. + Value *string `json:"value,omitempty"` +} + +// SignInSettingsCreateOrUpdateOptions contains the optional parameters for the SignInSettings.CreateOrUpdate method. +type SignInSettingsCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// SignInSettingsGetEntityTagOptions contains the optional parameters for the SignInSettings.GetEntityTag method. +type SignInSettingsGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// SignInSettingsGetOptions contains the optional parameters for the SignInSettings.Get method. +type SignInSettingsGetOptions struct { + // placeholder for future optional parameters +} + +// SignInSettingsUpdateOptions contains the optional parameters for the SignInSettings.Update method. +type SignInSettingsUpdateOptions struct { + // placeholder for future optional parameters +} + +// SignUpSettingsCreateOrUpdateOptions contains the optional parameters for the SignUpSettings.CreateOrUpdate method. +type SignUpSettingsCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// SignUpSettingsGetEntityTagOptions contains the optional parameters for the SignUpSettings.GetEntityTag method. +type SignUpSettingsGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// SignUpSettingsGetOptions contains the optional parameters for the SignUpSettings.Get method. +type SignUpSettingsGetOptions struct { + // placeholder for future optional parameters +} + +// SignUpSettingsUpdateOptions contains the optional parameters for the SignUpSettings.Update method. +type SignUpSettingsUpdateOptions struct { + // placeholder for future optional parameters +} + +// SubscriptionCollection - Paged Subscriptions list representation. +type SubscriptionCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*SubscriptionContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionCollection. +func (s SubscriptionCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", s.Count) + populate(objectMap, "nextLink", s.NextLink) + populate(objectMap, "value", s.Value) + return json.Marshal(objectMap) +} + +// SubscriptionContract - Subscription details. +type SubscriptionContract struct { + Resource + // Subscription contract properties. + Properties *SubscriptionContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionContract. +func (s SubscriptionContract) MarshalJSON() ([]byte, error) { + objectMap := s.Resource.marshalInternal() + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// SubscriptionContractProperties - Subscription details. +type SubscriptionContractProperties struct { + // REQUIRED; Scope like /products/{productId} or /apis or /apis/{apiId}. + Scope *string `json:"scope,omitempty"` + + // REQUIRED; Subscription state. Possible states are * active – the subscription is active, * suspended – the subscription is blocked, and the subscriber + // cannot call any APIs of the product, * submitted – the + // subscription request has been made by the developer, but has not yet been approved or rejected, * rejected – the subscription request has been denied + // by an administrator, * cancelled – the + // subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated. + State *SubscriptionState `json:"state,omitempty"` + + // Determines whether tracing is enabled + AllowTracing *bool `json:"allowTracing,omitempty"` + + // The name of the subscription, or null if the subscription has no name. + DisplayName *string `json:"displayName,omitempty"` + + // Date when subscription was cancelled or expired. The setting is for audit purposes only and the subscription is not automatically cancelled. The subscription + // lifecycle can be managed by using the + // state property. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + EndDate *time.Time `json:"endDate,omitempty"` + + // Subscription expiration date. The setting is for audit purposes only and the subscription is not automatically expired. The subscription lifecycle can + // be managed by using the state property. The date + // conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + ExpirationDate *time.Time `json:"expirationDate,omitempty"` + + // Upcoming subscription expiration notification date. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + NotificationDate *time.Time `json:"notificationDate,omitempty"` + + // The user resource identifier of the subscription owner. The value is a valid relative URL in the format of /users/{userId} where {userId} is a user identifier. + OwnerID *string `json:"ownerId,omitempty"` + + // Subscription primary key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + PrimaryKey *string `json:"primaryKey,omitempty"` + + // Subscription secondary key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. + SecondaryKey *string `json:"secondaryKey,omitempty"` + + // Subscription activation date. The setting is for audit purposes only and the subscription is not automatically activated. The subscription lifecycle + // can be managed by using the state property. The + // date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + StartDate *time.Time `json:"startDate,omitempty"` + + // Optional subscription comment added by an administrator when the state is changed to the 'rejected'. + StateComment *string `json:"stateComment,omitempty"` + + // READ-ONLY; Subscription creation date. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + CreatedDate *time.Time `json:"createdDate,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionContractProperties. +func (s SubscriptionContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "allowTracing", s.AllowTracing) + populate(objectMap, "createdDate", (*timeRFC3339)(s.CreatedDate)) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "endDate", (*timeRFC3339)(s.EndDate)) + populate(objectMap, "expirationDate", (*timeRFC3339)(s.ExpirationDate)) + populate(objectMap, "notificationDate", (*timeRFC3339)(s.NotificationDate)) + populate(objectMap, "ownerId", s.OwnerID) + populate(objectMap, "primaryKey", s.PrimaryKey) + populate(objectMap, "scope", s.Scope) + populate(objectMap, "secondaryKey", s.SecondaryKey) + populate(objectMap, "startDate", (*timeRFC3339)(s.StartDate)) + populate(objectMap, "state", s.State) + populate(objectMap, "stateComment", s.StateComment) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionContractProperties. +func (s *SubscriptionContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "allowTracing": + err = unpopulate(val, &s.AllowTracing) + delete(rawMsg, key) + case "createdDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.CreatedDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, &s.DisplayName) + delete(rawMsg, key) + case "endDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.EndDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "expirationDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.ExpirationDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "notificationDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.NotificationDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "ownerId": + err = unpopulate(val, &s.OwnerID) + delete(rawMsg, key) + case "primaryKey": + err = unpopulate(val, &s.PrimaryKey) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, &s.Scope) + delete(rawMsg, key) + case "secondaryKey": + err = unpopulate(val, &s.SecondaryKey) + delete(rawMsg, key) + case "startDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.StartDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "state": + err = unpopulate(val, &s.State) + delete(rawMsg, key) + case "stateComment": + err = unpopulate(val, &s.StateComment) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// SubscriptionCreateOrUpdateOptions contains the optional parameters for the Subscription.CreateOrUpdate method. +type SubscriptionCreateOrUpdateOptions struct { + // Determines the type of application which send the create user request. Default is legacy publisher portal. + AppType *AppType + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string + // Notify change in Subscription State. + // - If false, do not send any email notification for change of state of subscription + // - If true, send email notification of change of state of subscription + Notify *bool +} + +// SubscriptionCreateParameterProperties - Parameters supplied to the Create subscription operation. +type SubscriptionCreateParameterProperties struct { + // REQUIRED; Subscription name. + DisplayName *string `json:"displayName,omitempty"` + + // REQUIRED; Scope like /products/{productId} or /apis or /apis/{apiId}. + Scope *string `json:"scope,omitempty"` + + // Determines whether tracing can be enabled + AllowTracing *bool `json:"allowTracing,omitempty"` + + // User (user id path) for whom subscription is being created in form /users/{userId} + OwnerID *string `json:"ownerId,omitempty"` + + // Primary subscription key. If not specified during request key will be generated automatically. + PrimaryKey *string `json:"primaryKey,omitempty"` + + // Secondary subscription key. If not specified during request key will be generated automatically. + SecondaryKey *string `json:"secondaryKey,omitempty"` + + // Initial subscription state. If no value is specified, subscription is created with Submitted state. Possible states are * active – the subscription is + // active, * suspended – the subscription is + // blocked, and the subscriber cannot call any APIs of the product, * submitted – the subscription request has been made by the developer, but has not yet + // been approved or rejected, * rejected – the + // subscription request has been denied by an administrator, * cancelled – the subscription has been cancelled by the developer or administrator, * expired + // – the subscription reached its expiration date + // and was deactivated. + State *SubscriptionState `json:"state,omitempty"` +} + +// SubscriptionCreateParameters - Subscription create details. +type SubscriptionCreateParameters struct { + // Subscription contract properties. + Properties *SubscriptionCreateParameterProperties `json:"properties,omitempty"` +} + +// SubscriptionDeleteOptions contains the optional parameters for the Subscription.Delete method. +type SubscriptionDeleteOptions struct { + // placeholder for future optional parameters +} + +// SubscriptionGetEntityTagOptions contains the optional parameters for the Subscription.GetEntityTag method. +type SubscriptionGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// SubscriptionGetOptions contains the optional parameters for the Subscription.Get method. +type SubscriptionGetOptions struct { + // placeholder for future optional parameters +} + +// SubscriptionKeyParameterNamesContract - Subscription key parameter names details. +type SubscriptionKeyParameterNamesContract struct { + // Subscription key header name. + Header *string `json:"header,omitempty"` + + // Subscription key query string parameter name. + Query *string `json:"query,omitempty"` +} + +// SubscriptionKeysContract - Subscription keys. +type SubscriptionKeysContract struct { + // Subscription primary key. + PrimaryKey *string `json:"primaryKey,omitempty"` + + // Subscription secondary key. + SecondaryKey *string `json:"secondaryKey,omitempty"` +} + +// SubscriptionListOptions contains the optional parameters for the Subscription.List method. +type SubscriptionListOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| stateComment | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| ownerId | filter | ge, le, eq, + // ne, gt, lt | substringof, contains, startswith, endswith |
| scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + // |
| userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| productId | filter | ge, le, eq, ne, gt, lt | + // substringof, contains, startswith, endswith |
| state | filter | eq | |
| user | expand | | |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// SubscriptionListSecretsOptions contains the optional parameters for the Subscription.ListSecrets method. +type SubscriptionListSecretsOptions struct { + // placeholder for future optional parameters +} + +// SubscriptionRegeneratePrimaryKeyOptions contains the optional parameters for the Subscription.RegeneratePrimaryKey method. +type SubscriptionRegeneratePrimaryKeyOptions struct { + // placeholder for future optional parameters +} + +// SubscriptionRegenerateSecondaryKeyOptions contains the optional parameters for the Subscription.RegenerateSecondaryKey method. +type SubscriptionRegenerateSecondaryKeyOptions struct { + // placeholder for future optional parameters +} + +// SubscriptionUpdateOptions contains the optional parameters for the Subscription.Update method. +type SubscriptionUpdateOptions struct { + // Determines the type of application which send the create user request. Default is legacy publisher portal. + AppType *AppType + // Notify change in Subscription State. + // - If false, do not send any email notification for change of state of subscription + // - If true, send email notification of change of state of subscription + Notify *bool +} + +// SubscriptionUpdateParameterProperties - Parameters supplied to the Update subscription operation. +type SubscriptionUpdateParameterProperties struct { + // Determines whether tracing can be enabled + AllowTracing *bool `json:"allowTracing,omitempty"` + + // Subscription name. + DisplayName *string `json:"displayName,omitempty"` + + // Subscription expiration date. The setting is for audit purposes only and the subscription is not automatically expired. The subscription lifecycle can + // be managed by using the state property. The date + // conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + ExpirationDate *time.Time `json:"expirationDate,omitempty"` + + // User identifier path: /users/{userId} + OwnerID *string `json:"ownerId,omitempty"` + + // Primary subscription key. + PrimaryKey *string `json:"primaryKey,omitempty"` + + // Scope like /products/{productId} or /apis or /apis/{apiId} + Scope *string `json:"scope,omitempty"` + + // Secondary subscription key. + SecondaryKey *string `json:"secondaryKey,omitempty"` + + // Subscription state. Possible states are * active – the subscription is active, * suspended – the subscription is blocked, and the subscriber cannot call + // any APIs of the product, * submitted – the + // subscription request has been made by the developer, but has not yet been approved or rejected, * rejected – the subscription request has been denied + // by an administrator, * cancelled – the + // subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated. + State *SubscriptionState `json:"state,omitempty"` + + // Comments describing subscription state change by the administrator when the state is changed to the 'rejected'. + StateComment *string `json:"stateComment,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionUpdateParameterProperties. +func (s SubscriptionUpdateParameterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "allowTracing", s.AllowTracing) + populate(objectMap, "displayName", s.DisplayName) + populate(objectMap, "expirationDate", (*timeRFC3339)(s.ExpirationDate)) + populate(objectMap, "ownerId", s.OwnerID) + populate(objectMap, "primaryKey", s.PrimaryKey) + populate(objectMap, "scope", s.Scope) + populate(objectMap, "secondaryKey", s.SecondaryKey) + populate(objectMap, "state", s.State) + populate(objectMap, "stateComment", s.StateComment) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SubscriptionUpdateParameterProperties. +func (s *SubscriptionUpdateParameterProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "allowTracing": + err = unpopulate(val, &s.AllowTracing) + delete(rawMsg, key) + case "displayName": + err = unpopulate(val, &s.DisplayName) + delete(rawMsg, key) + case "expirationDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + s.ExpirationDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "ownerId": + err = unpopulate(val, &s.OwnerID) + delete(rawMsg, key) + case "primaryKey": + err = unpopulate(val, &s.PrimaryKey) + delete(rawMsg, key) + case "scope": + err = unpopulate(val, &s.Scope) + delete(rawMsg, key) + case "secondaryKey": + err = unpopulate(val, &s.SecondaryKey) + delete(rawMsg, key) + case "state": + err = unpopulate(val, &s.State) + delete(rawMsg, key) + case "stateComment": + err = unpopulate(val, &s.StateComment) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// SubscriptionUpdateParameters - Subscription update details. +type SubscriptionUpdateParameters struct { + // Subscription Update contract properties. + Properties *SubscriptionUpdateParameterProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type SubscriptionUpdateParameters. +func (s SubscriptionUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", s.Properties) + return json.Marshal(objectMap) +} + +// SubscriptionsDelegationSettingsProperties - Subscriptions delegation settings properties. +type SubscriptionsDelegationSettingsProperties struct { + // Enable or disable delegation for subscriptions. + Enabled *bool `json:"enabled,omitempty"` +} + +// TagAssignToAPIOptions contains the optional parameters for the Tag.AssignToAPI method. +type TagAssignToAPIOptions struct { + // placeholder for future optional parameters +} + +// TagAssignToOperationOptions contains the optional parameters for the Tag.AssignToOperation method. +type TagAssignToOperationOptions struct { + // placeholder for future optional parameters +} + +// TagAssignToProductOptions contains the optional parameters for the Tag.AssignToProduct method. +type TagAssignToProductOptions struct { + // placeholder for future optional parameters +} + +// TagCollection - Paged Tag list representation. +type TagCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*TagContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TagCollection. +func (t TagCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", t.Count) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// TagContract - Tag Contract details. +type TagContract struct { + Resource + // Tag entity contract properties. + Properties *TagContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TagContract. +func (t TagContract) MarshalJSON() ([]byte, error) { + objectMap := t.Resource.marshalInternal() + populate(objectMap, "properties", t.Properties) + return json.Marshal(objectMap) +} + +// TagContractProperties - Tag contract Properties. +type TagContractProperties struct { + // REQUIRED; Tag name. + DisplayName *string `json:"displayName,omitempty"` +} + +// TagCreateOrUpdateOptions contains the optional parameters for the Tag.CreateOrUpdate method. +type TagCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string +} + +// TagCreateUpdateParameters - Parameters supplied to Create/Update Tag operations. +type TagCreateUpdateParameters struct { + // Properties supplied to Create Tag operation. + Properties *TagContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TagCreateUpdateParameters. +func (t TagCreateUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", t.Properties) + return json.Marshal(objectMap) +} + +// TagDeleteOptions contains the optional parameters for the Tag.Delete method. +type TagDeleteOptions struct { + // placeholder for future optional parameters +} + +// TagDescriptionBaseProperties - Parameters supplied to the Create TagDescription operation. +type TagDescriptionBaseProperties struct { + // Description of the Tag. + Description *string `json:"description,omitempty"` + + // Description of the external resources describing the tag. + ExternalDocsDescription *string `json:"externalDocsDescription,omitempty"` + + // Absolute URL of external resources describing the tag. + ExternalDocsURL *string `json:"externalDocsUrl,omitempty"` +} + +// TagDescriptionCollection - Paged TagDescription list representation. +type TagDescriptionCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*TagDescriptionContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TagDescriptionCollection. +func (t TagDescriptionCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", t.Count) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// TagDescriptionContract - Contract details. +type TagDescriptionContract struct { + Resource + // TagDescription entity contract properties. + Properties *TagDescriptionContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TagDescriptionContract. +func (t TagDescriptionContract) MarshalJSON() ([]byte, error) { + objectMap := t.Resource.marshalInternal() + populate(objectMap, "properties", t.Properties) + return json.Marshal(objectMap) +} + +// TagDescriptionContractProperties - TagDescription contract Properties. +type TagDescriptionContractProperties struct { + TagDescriptionBaseProperties + // Tag name. + DisplayName *string `json:"displayName,omitempty"` + + // Identifier of the tag in the form of /tags/{tagId} + TagID *string `json:"tagId,omitempty"` +} + +// TagDescriptionCreateParameters - Parameters supplied to the Create TagDescription operation. +type TagDescriptionCreateParameters struct { + // Properties supplied to Create TagDescription operation. + Properties *TagDescriptionBaseProperties `json:"properties,omitempty"` +} + +// TagDetachFromAPIOptions contains the optional parameters for the Tag.DetachFromAPI method. +type TagDetachFromAPIOptions struct { + // placeholder for future optional parameters +} + +// TagDetachFromOperationOptions contains the optional parameters for the Tag.DetachFromOperation method. +type TagDetachFromOperationOptions struct { + // placeholder for future optional parameters +} + +// TagDetachFromProductOptions contains the optional parameters for the Tag.DetachFromProduct method. +type TagDetachFromProductOptions struct { + // placeholder for future optional parameters +} + +// TagGetByAPIOptions contains the optional parameters for the Tag.GetByAPI method. +type TagGetByAPIOptions struct { + // placeholder for future optional parameters +} + +// TagGetByOperationOptions contains the optional parameters for the Tag.GetByOperation method. +type TagGetByOperationOptions struct { + // placeholder for future optional parameters +} + +// TagGetByProductOptions contains the optional parameters for the Tag.GetByProduct method. +type TagGetByProductOptions struct { + // placeholder for future optional parameters +} + +// TagGetEntityStateByAPIOptions contains the optional parameters for the Tag.GetEntityStateByAPI method. +type TagGetEntityStateByAPIOptions struct { + // placeholder for future optional parameters +} + +// TagGetEntityStateByOperationOptions contains the optional parameters for the Tag.GetEntityStateByOperation method. +type TagGetEntityStateByOperationOptions struct { + // placeholder for future optional parameters +} + +// TagGetEntityStateByProductOptions contains the optional parameters for the Tag.GetEntityStateByProduct method. +type TagGetEntityStateByProductOptions struct { + // placeholder for future optional parameters +} + +// TagGetEntityStateOptions contains the optional parameters for the Tag.GetEntityState method. +type TagGetEntityStateOptions struct { + // placeholder for future optional parameters +} + +// TagGetOptions contains the optional parameters for the Tag.Get method. +type TagGetOptions struct { + // placeholder for future optional parameters +} + +// TagListByAPIOptions contains the optional parameters for the Tag.ListByAPI method. +type TagListByAPIOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| displayName | filter + // | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// TagListByOperationOptions contains the optional parameters for the Tag.ListByOperation method. +type TagListByOperationOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| displayName | filter + // | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// TagListByProductOptions contains the optional parameters for the Tag.ListByProduct method. +type TagListByProductOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| displayName | filter + // | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// TagListByServiceOptions contains the optional parameters for the Tag.ListByService method. +type TagListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
+ Filter *string + // Scope like 'apis', 'products' or 'apis/{apiId} + Scope *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// TagResourceCollection - Paged Tag list representation. +type TagResourceCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*TagResourceContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TagResourceCollection. +func (t TagResourceCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", t.Count) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// TagResourceContract - TagResource contract properties. +type TagResourceContract struct { + // REQUIRED; Tag associated with the resource. + Tag *TagResourceContractProperties `json:"tag,omitempty"` + + // Api associated with the tag. + API *APITagResourceContractProperties `json:"api,omitempty"` + + // Operation associated with the tag. + Operation *OperationTagResourceContractProperties `json:"operation,omitempty"` + + // Product associated with the tag. + Product *ProductTagResourceContractProperties `json:"product,omitempty"` +} + +// TagResourceContractProperties - Contract defining the Tag property in the Tag Resource Contract +type TagResourceContractProperties struct { + // Tag identifier + ID *string `json:"id,omitempty"` + + // Tag Name + Name *string `json:"name,omitempty"` +} + +// TagResourceListByServiceOptions contains the optional parameters for the TagResource.ListByService method. +type TagResourceListByServiceOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| aid | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| apiName | filter | ge, le, eq, ne, + // gt, lt | substringof, contains, startswith, endswith |
| apiRevision | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith + // |
| path | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | + // substringof, contains, startswith, endswith |
| serviceUrl | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| + // method | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| urlTemplate | filter | ge, le, eq, ne, gt, lt | substringof, + // contains, startswith, endswith |
| terms | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| state | filter | + // eq | |
| isCurrent | filter | eq | |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// TagUpdateOptions contains the optional parameters for the Tag.Update method. +type TagUpdateOptions struct { + // placeholder for future optional parameters +} + +// TenantAccessCreateOptions contains the optional parameters for the TenantAccess.Create method. +type TenantAccessCreateOptions struct { + // placeholder for future optional parameters +} + +// TenantAccessGetEntityTagOptions contains the optional parameters for the TenantAccess.GetEntityTag method. +type TenantAccessGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// TenantAccessGetOptions contains the optional parameters for the TenantAccess.Get method. +type TenantAccessGetOptions struct { + // placeholder for future optional parameters +} + +// TenantAccessGitRegeneratePrimaryKeyOptions contains the optional parameters for the TenantAccessGit.RegeneratePrimaryKey method. +type TenantAccessGitRegeneratePrimaryKeyOptions struct { + // placeholder for future optional parameters +} + +// TenantAccessGitRegenerateSecondaryKeyOptions contains the optional parameters for the TenantAccessGit.RegenerateSecondaryKey method. +type TenantAccessGitRegenerateSecondaryKeyOptions struct { + // placeholder for future optional parameters +} + +// TenantAccessListByServiceOptions contains the optional parameters for the TenantAccess.ListByService method. +type TenantAccessListByServiceOptions struct { + // Not used + Filter *string +} + +// TenantAccessListSecretsOptions contains the optional parameters for the TenantAccess.ListSecrets method. +type TenantAccessListSecretsOptions struct { + // placeholder for future optional parameters +} + +// TenantAccessRegeneratePrimaryKeyOptions contains the optional parameters for the TenantAccess.RegeneratePrimaryKey method. +type TenantAccessRegeneratePrimaryKeyOptions struct { + // placeholder for future optional parameters +} + +// TenantAccessRegenerateSecondaryKeyOptions contains the optional parameters for the TenantAccess.RegenerateSecondaryKey method. +type TenantAccessRegenerateSecondaryKeyOptions struct { + // placeholder for future optional parameters +} + +// TenantAccessUpdateOptions contains the optional parameters for the TenantAccess.Update method. +type TenantAccessUpdateOptions struct { + // placeholder for future optional parameters +} + +// TenantConfigurationBeginDeployOptions contains the optional parameters for the TenantConfiguration.BeginDeploy method. +type TenantConfigurationBeginDeployOptions struct { + // placeholder for future optional parameters +} + +// TenantConfigurationBeginSaveOptions contains the optional parameters for the TenantConfiguration.BeginSave method. +type TenantConfigurationBeginSaveOptions struct { + // placeholder for future optional parameters +} + +// TenantConfigurationBeginValidateOptions contains the optional parameters for the TenantConfiguration.BeginValidate method. +type TenantConfigurationBeginValidateOptions struct { + // placeholder for future optional parameters +} + +// TenantConfigurationGetSyncStateOptions contains the optional parameters for the TenantConfiguration.GetSyncState method. +type TenantConfigurationGetSyncStateOptions struct { + // placeholder for future optional parameters +} + +// TenantConfigurationSyncStateContract - Result of Tenant Configuration Sync State. +type TenantConfigurationSyncStateContract struct { + // Properties returned Tenant Configuration Sync State check. + Properties *TenantConfigurationSyncStateContractProperties `json:"properties,omitempty"` +} + +// TenantConfigurationSyncStateContractProperties - Tenant Configuration Synchronization State. +type TenantConfigurationSyncStateContractProperties struct { + // The name of Git branch. + Branch *string `json:"branch,omitempty"` + + // The latest commit Id. + CommitID *string `json:"commitId,omitempty"` + + // The date of the latest configuration change. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + ConfigurationChangeDate *time.Time `json:"configurationChangeDate,omitempty"` + + // value indicating if last sync was save (true) or deploy (false) operation. + IsExport *bool `json:"isExport,omitempty"` + + // value indicating whether Git configuration access is enabled. + IsGitEnabled *bool `json:"isGitEnabled,omitempty"` + + // value indicating if last synchronization was later than the configuration change. + IsSynced *bool `json:"isSynced,omitempty"` + + // Most recent tenant configuration operation identifier + LastOperationID *string `json:"lastOperationId,omitempty"` + + // The date of the latest synchronization. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + SyncDate *time.Time `json:"syncDate,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TenantConfigurationSyncStateContractProperties. +func (t TenantConfigurationSyncStateContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "branch", t.Branch) + populate(objectMap, "commitId", t.CommitID) + populate(objectMap, "configurationChangeDate", (*timeRFC3339)(t.ConfigurationChangeDate)) + populate(objectMap, "isExport", t.IsExport) + populate(objectMap, "isGitEnabled", t.IsGitEnabled) + populate(objectMap, "isSynced", t.IsSynced) + populate(objectMap, "lastOperationId", t.LastOperationID) + populate(objectMap, "syncDate", (*timeRFC3339)(t.SyncDate)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type TenantConfigurationSyncStateContractProperties. +func (t *TenantConfigurationSyncStateContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "branch": + err = unpopulate(val, &t.Branch) + delete(rawMsg, key) + case "commitId": + err = unpopulate(val, &t.CommitID) + delete(rawMsg, key) + case "configurationChangeDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + t.ConfigurationChangeDate = (*time.Time)(&aux) + delete(rawMsg, key) + case "isExport": + err = unpopulate(val, &t.IsExport) + delete(rawMsg, key) + case "isGitEnabled": + err = unpopulate(val, &t.IsGitEnabled) + delete(rawMsg, key) + case "isSynced": + err = unpopulate(val, &t.IsSynced) + delete(rawMsg, key) + case "lastOperationId": + err = unpopulate(val, &t.LastOperationID) + delete(rawMsg, key) + case "syncDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + t.SyncDate = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// TenantSettingsCollection - Paged AccessInformation list representation. +type TenantSettingsCollection struct { + // READ-ONLY; Next page link if any. + NextLink *string `json:"nextLink,omitempty" azure:"ro"` + + // READ-ONLY; Page values. + Value []*TenantSettingsContract `json:"value,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type TenantSettingsCollection. +func (t TenantSettingsCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", t.NextLink) + populate(objectMap, "value", t.Value) + return json.Marshal(objectMap) +} + +// TenantSettingsContract - Tenant Settings. +type TenantSettingsContract struct { + Resource + // TenantSettings entity contract properties. + Properties *TenantSettingsContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TenantSettingsContract. +func (t TenantSettingsContract) MarshalJSON() ([]byte, error) { + objectMap := t.Resource.marshalInternal() + populate(objectMap, "properties", t.Properties) + return json.Marshal(objectMap) +} + +// TenantSettingsContractProperties - Tenant access information contract of the API Management service. +type TenantSettingsContractProperties struct { + // Tenant settings + Settings map[string]*string `json:"settings,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type TenantSettingsContractProperties. +func (t TenantSettingsContractProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "settings", t.Settings) + return json.Marshal(objectMap) +} + +// TenantSettingsGetOptions contains the optional parameters for the TenantSettings.Get method. +type TenantSettingsGetOptions struct { + // placeholder for future optional parameters +} + +// TenantSettingsListByServiceOptions contains the optional parameters for the TenantSettings.ListByService method. +type TenantSettingsListByServiceOptions struct { + // Not used + Filter *string +} + +// TermsOfServiceProperties - Terms of service contract properties. +type TermsOfServiceProperties struct { + // Ask user for consent to the terms of service. + ConsentRequired *bool `json:"consentRequired,omitempty"` + + // Display terms of service during a sign-up process. + Enabled *bool `json:"enabled,omitempty"` + + // A terms of service text. + Text *string `json:"text,omitempty"` +} + +// TokenBodyParameterContract - OAuth acquire token request body parameter (www-url-form-encoded). +type TokenBodyParameterContract struct { + // REQUIRED; body parameter name. + Name *string `json:"name,omitempty"` + + // REQUIRED; body parameter value. + Value *string `json:"value,omitempty"` +} + +// UserCollection - Paged Users list representation. +type UserCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // Page values. + Value []*UserContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UserCollection. +func (u UserCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", u.Count) + populate(objectMap, "nextLink", u.NextLink) + populate(objectMap, "value", u.Value) + return json.Marshal(objectMap) +} + +// UserConfirmationPasswordSendOptions contains the optional parameters for the UserConfirmationPassword.Send method. +type UserConfirmationPasswordSendOptions struct { + // Determines the type of application which send the create user request. Default is legacy publisher portal. + AppType *AppType +} + +// UserContract - User details. +type UserContract struct { + Resource + // User entity contract properties. + Properties *UserContractProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UserContract. +func (u UserContract) MarshalJSON() ([]byte, error) { + objectMap := u.Resource.marshalInternal() + populate(objectMap, "properties", u.Properties) + return json.Marshal(objectMap) +} + +// UserContractProperties - User profile. +type UserContractProperties struct { + UserEntityBaseParameters + // Email address. + Email *string `json:"email,omitempty"` + + // First name. + FirstName *string `json:"firstName,omitempty"` + + // Last name. + LastName *string `json:"lastName,omitempty"` + + // Date of user registration. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ as specified by the ISO 8601 standard. + RegistrationDate *time.Time `json:"registrationDate,omitempty"` + + // READ-ONLY; Collection of groups user is part of. + Groups []*GroupContractProperties `json:"groups,omitempty" azure:"ro"` +} + +// MarshalJSON implements the json.Marshaller interface for type UserContractProperties. +func (u UserContractProperties) MarshalJSON() ([]byte, error) { + objectMap := u.UserEntityBaseParameters.marshalInternal() + populate(objectMap, "email", u.Email) + populate(objectMap, "firstName", u.FirstName) + populate(objectMap, "groups", u.Groups) + populate(objectMap, "lastName", u.LastName) + populate(objectMap, "registrationDate", (*timeRFC3339)(u.RegistrationDate)) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserContractProperties. +func (u *UserContractProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "email": + err = unpopulate(val, &u.Email) + delete(rawMsg, key) + case "firstName": + err = unpopulate(val, &u.FirstName) + delete(rawMsg, key) + case "groups": + err = unpopulate(val, &u.Groups) + delete(rawMsg, key) + case "lastName": + err = unpopulate(val, &u.LastName) + delete(rawMsg, key) + case "registrationDate": + var aux timeRFC3339 + err = unpopulate(val, &aux) + u.RegistrationDate = (*time.Time)(&aux) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return u.UserEntityBaseParameters.unmarshalInternal(rawMsg) +} + +// UserCreateOrUpdateOptions contains the optional parameters for the User.CreateOrUpdate method. +type UserCreateOrUpdateOptions struct { + // ETag of the Entity. Not required when creating an entity, but required when updating an entity. + IfMatch *string + // Send an Email notification to the User. + Notify *bool +} + +// UserCreateParameterProperties - Parameters supplied to the Create User operation. +type UserCreateParameterProperties struct { + UserEntityBaseParameters + // REQUIRED; Email address. Must not be empty and must be unique within the service instance. + Email *string `json:"email,omitempty"` + + // REQUIRED; First name. + FirstName *string `json:"firstName,omitempty"` + + // REQUIRED; Last name. + LastName *string `json:"lastName,omitempty"` + + // Determines the type of application which send the create user request. Default is legacy portal. + AppType *AppType `json:"appType,omitempty"` + + // Determines the type of confirmation e-mail that will be sent to the newly created user. + Confirmation *Confirmation `json:"confirmation,omitempty"` + + // User Password. If no value is provided, a default password is generated. + Password *string `json:"password,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UserCreateParameterProperties. +func (u UserCreateParameterProperties) MarshalJSON() ([]byte, error) { + objectMap := u.UserEntityBaseParameters.marshalInternal() + populate(objectMap, "appType", u.AppType) + populate(objectMap, "confirmation", u.Confirmation) + populate(objectMap, "email", u.Email) + populate(objectMap, "firstName", u.FirstName) + populate(objectMap, "lastName", u.LastName) + populate(objectMap, "password", u.Password) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserCreateParameterProperties. +func (u *UserCreateParameterProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "appType": + err = unpopulate(val, &u.AppType) + delete(rawMsg, key) + case "confirmation": + err = unpopulate(val, &u.Confirmation) + delete(rawMsg, key) + case "email": + err = unpopulate(val, &u.Email) + delete(rawMsg, key) + case "firstName": + err = unpopulate(val, &u.FirstName) + delete(rawMsg, key) + case "lastName": + err = unpopulate(val, &u.LastName) + delete(rawMsg, key) + case "password": + err = unpopulate(val, &u.Password) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return u.UserEntityBaseParameters.unmarshalInternal(rawMsg) +} + +// UserCreateParameters - User create details. +type UserCreateParameters struct { + // User entity create contract properties. + Properties *UserCreateParameterProperties `json:"properties,omitempty"` +} + +// UserDeleteOptions contains the optional parameters for the User.Delete method. +type UserDeleteOptions struct { + // Determines the type of application which send the create user request. Default is legacy publisher portal. + AppType *AppType + // Whether to delete user's subscription or not. + DeleteSubscriptions *bool + // Send an Account Closed Email notification to the User. + Notify *bool +} + +// UserEntityBaseParameters - User Entity Base Parameters set. +type UserEntityBaseParameters struct { + // Collection of user identities. + Identities []*UserIdentityContract `json:"identities,omitempty"` + + // Optional note about a user set by the administrator. + Note *string `json:"note,omitempty"` + + // Account state. Specifies whether the user is active or not. Blocked users are unable to sign into the developer portal or call any APIs of subscribed + // products. Default state is Active. + State *UserState `json:"state,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UserEntityBaseParameters. +func (u UserEntityBaseParameters) MarshalJSON() ([]byte, error) { + objectMap := u.marshalInternal() + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserEntityBaseParameters. +func (u *UserEntityBaseParameters) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + return u.unmarshalInternal(rawMsg) +} + +func (u UserEntityBaseParameters) marshalInternal() map[string]interface{} { + objectMap := make(map[string]interface{}) + populate(objectMap, "identities", u.Identities) + populate(objectMap, "note", u.Note) + populate(objectMap, "state", u.State) + return objectMap +} + +func (u *UserEntityBaseParameters) unmarshalInternal(rawMsg map[string]json.RawMessage) error { + for key, val := range rawMsg { + var err error + switch key { + case "identities": + err = unpopulate(val, &u.Identities) + delete(rawMsg, key) + case "note": + err = unpopulate(val, &u.Note) + delete(rawMsg, key) + case "state": + err = unpopulate(val, &u.State) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// UserGenerateSsoURLOptions contains the optional parameters for the User.GenerateSsoURL method. +type UserGenerateSsoURLOptions struct { + // placeholder for future optional parameters +} + +// UserGetEntityTagOptions contains the optional parameters for the User.GetEntityTag method. +type UserGetEntityTagOptions struct { + // placeholder for future optional parameters +} + +// UserGetOptions contains the optional parameters for the User.Get method. +type UserGetOptions struct { + // placeholder for future optional parameters +} + +// UserGetSharedAccessTokenOptions contains the optional parameters for the User.GetSharedAccessToken method. +type UserGetSharedAccessTokenOptions struct { + // placeholder for future optional parameters +} + +// UserGroupListOptions contains the optional parameters for the UserGroup.List method. +type UserGroupListOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|------------------------|-----------------------------------|
| + // name | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| displayName | filter | ge, le, eq, ne, gt, lt | substringof, + // contains, startswith, endswith |
| description | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// UserIdentitiesListOptions contains the optional parameters for the UserIdentities.List method. +type UserIdentitiesListOptions struct { + // placeholder for future optional parameters +} + +// UserIdentityCollection - List of Users Identity list representation. +type UserIdentityCollection struct { + // Total record count number across all pages. + Count *int64 `json:"count,omitempty"` + + // Next page link if any. + NextLink *string `json:"nextLink,omitempty"` + + // User Identity values. + Value []*UserIdentityContract `json:"value,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UserIdentityCollection. +func (u UserIdentityCollection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "count", u.Count) + populate(objectMap, "nextLink", u.NextLink) + populate(objectMap, "value", u.Value) + return json.Marshal(objectMap) +} + +// UserIdentityContract - User identity details. +type UserIdentityContract struct { + // Identifier value within provider. + ID *string `json:"id,omitempty"` + + // Identity provider name. + Provider *string `json:"provider,omitempty"` +} + +type UserIdentityProperties struct { + // The client id of user assigned identity. + ClientID *string `json:"clientId,omitempty"` + + // The principal id of user assigned identity. + PrincipalID *string `json:"principalId,omitempty"` +} + +// UserListByServiceOptions contains the optional parameters for the User.ListByService method. +type UserListByServiceOptions struct { + // Detailed Group in response. + ExpandGroups *bool + // | Field | Usage | Supported operators | Supported functions |
|-------------|-------------|-------------|-------------|
| name | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| firstName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
| lastName | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| email | filter | ge, le, eq, ne, gt, + // lt | substringof, contains, startswith, endswith |
| state | filter | eq | |
| registrationDate | filter | ge, le, eq, ne, gt, lt | |
| note + // | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
| groups | expand | | |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// UserSubscriptionGetOptions contains the optional parameters for the UserSubscription.Get method. +type UserSubscriptionGetOptions struct { + // placeholder for future optional parameters +} + +// UserSubscriptionListOptions contains the optional parameters for the UserSubscription.List method. +type UserSubscriptionListOptions struct { + // | Field | Usage | Supported operators | Supported functions |
|-------------|------------------------|-----------------------------------|
|name + // | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
|displayName | filter | ge, le, eq, ne, gt, lt | substringof, contains, + // startswith, endswith |
|stateComment | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
|ownerId | filter | ge, + // le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
|scope | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, + // endswith |
|userId | filter | ge, le, eq, ne, gt, lt | substringof, contains, startswith, endswith |
|productId | filter | ge, le, eq, ne, gt, + // lt | substringof, contains, startswith, endswith |
+ Filter *string + // Number of records to skip. + Skip *int32 + // Number of records to return. + Top *int32 +} + +// UserTokenParameterProperties - Parameters supplied to the Get User Token operation. +type UserTokenParameterProperties struct { + // REQUIRED; The Expiry time of the Token. Maximum token expiry time is set to 30 days. The date conforms to the following format: yyyy-MM-ddTHH:mm:ssZ + // as specified by the ISO 8601 standard. + Expiry *time.Time `json:"expiry,omitempty"` + + // REQUIRED; The Key to be used to generate token for user. + KeyType *KeyType `json:"keyType,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UserTokenParameterProperties. +func (u UserTokenParameterProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "expiry", (*timeRFC3339)(u.Expiry)) + populate(objectMap, "keyType", u.KeyType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserTokenParameterProperties. +func (u *UserTokenParameterProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "expiry": + var aux timeRFC3339 + err = unpopulate(val, &aux) + u.Expiry = (*time.Time)(&aux) + delete(rawMsg, key) + case "keyType": + err = unpopulate(val, &u.KeyType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// UserTokenParameters - Get User Token parameters. +type UserTokenParameters struct { + // User Token Parameter contract properties. + Properties *UserTokenParameterProperties `json:"properties,omitempty"` +} + +// UserTokenResult - Get User Token response details. +type UserTokenResult struct { + // Shared Access Authorization token for the User. + Value *string `json:"value,omitempty"` +} + +// UserUpdateOptions contains the optional parameters for the User.Update method. +type UserUpdateOptions struct { + // placeholder for future optional parameters +} + +// UserUpdateParameters - User update parameters. +type UserUpdateParameters struct { + // User entity update contract properties. + Properties *UserUpdateParametersProperties `json:"properties,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UserUpdateParameters. +func (u UserUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "properties", u.Properties) + return json.Marshal(objectMap) +} + +// UserUpdateParametersProperties - Parameters supplied to the Update User operation. +type UserUpdateParametersProperties struct { + UserEntityBaseParameters + // Email address. Must not be empty and must be unique within the service instance. + Email *string `json:"email,omitempty"` + + // First name. + FirstName *string `json:"firstName,omitempty"` + + // Last name. + LastName *string `json:"lastName,omitempty"` + + // User Password. + Password *string `json:"password,omitempty"` +} + +// MarshalJSON implements the json.Marshaller interface for type UserUpdateParametersProperties. +func (u UserUpdateParametersProperties) MarshalJSON() ([]byte, error) { + objectMap := u.UserEntityBaseParameters.marshalInternal() + populate(objectMap, "email", u.Email) + populate(objectMap, "firstName", u.FirstName) + populate(objectMap, "lastName", u.LastName) + populate(objectMap, "password", u.Password) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type UserUpdateParametersProperties. +func (u *UserUpdateParametersProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "email": + err = unpopulate(val, &u.Email) + delete(rawMsg, key) + case "firstName": + err = unpopulate(val, &u.FirstName) + delete(rawMsg, key) + case "lastName": + err = unpopulate(val, &u.LastName) + delete(rawMsg, key) + case "password": + err = unpopulate(val, &u.Password) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return u.UserEntityBaseParameters.unmarshalInternal(rawMsg) +} + +// VirtualNetworkConfiguration - Configuration of a virtual network to which API Management service is deployed. +type VirtualNetworkConfiguration struct { + // The full resource ID of a subnet in a virtual network to deploy the API Management service in. + SubnetResourceID *string `json:"subnetResourceId,omitempty"` + + // READ-ONLY; The name of the subnet. + Subnetname *string `json:"subnetname,omitempty" azure:"ro"` + + // READ-ONLY; The virtual network ID. This is typically a GUID. Expect a null GUID by default. + Vnetid *string `json:"vnetid,omitempty" azure:"ro"` +} + +// X509CertificateName - Properties of server X509Names. +type X509CertificateName struct { + // Thumbprint for the Issuer of the Certificate. + IssuerCertificateThumbprint *string `json:"issuerCertificateThumbprint,omitempty"` + + // Common Name of the Certificate. + Name *string `json:"name,omitempty"` +} + +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, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_namedvalue_client.go b/sdk/apimanagement/armapimanagement/zz_generated_namedvalue_client.go new file mode 100644 index 000000000000..5d941108fd45 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_namedvalue_client.go @@ -0,0 +1,704 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +// NamedValueClient contains the methods for the NamedValue group. +// Don't use this type directly, use NewNamedValueClient() instead. +type NamedValueClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewNamedValueClient creates a new instance of NamedValueClient with the specified values. +func NewNamedValueClient(con *armcore.Connection, subscriptionID string) *NamedValueClient { + return &NamedValueClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreateOrUpdate - Creates or updates named value. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NamedValueClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, parameters NamedValueCreateContract, options *NamedValueBeginCreateOrUpdateOptions) (NamedValueCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, serviceName, namedValueID, parameters, options) + if err != nil { + return NamedValueCreateOrUpdatePollerResponse{}, err + } + result := NamedValueCreateOrUpdatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("NamedValueClient.CreateOrUpdate", "location", resp, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return NamedValueCreateOrUpdatePollerResponse{}, err + } + poller := &namedValueCreateOrUpdatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (NamedValueCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreateOrUpdate creates a new NamedValueCreateOrUpdatePoller from the specified resume token. +// token - The value must come from a previous call to NamedValueCreateOrUpdatePoller.ResumeToken(). +func (client *NamedValueClient) ResumeCreateOrUpdate(ctx context.Context, token string) (NamedValueCreateOrUpdatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("NamedValueClient.CreateOrUpdate", token, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return NamedValueCreateOrUpdatePollerResponse{}, err + } + poller := &namedValueCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return NamedValueCreateOrUpdatePollerResponse{}, err + } + result := NamedValueCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (NamedValueCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// CreateOrUpdate - Creates or updates named value. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NamedValueClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, parameters NamedValueCreateContract, options *NamedValueBeginCreateOrUpdateOptions) (*azcore.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, namedValueID, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *NamedValueClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, parameters NamedValueCreateContract, options *NamedValueBeginCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if namedValueID == "" { + return nil, errors.New("parameter namedValueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namedValueId}", url.PathEscape(namedValueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *NamedValueClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes specific named value from the API Management service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NamedValueClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, ifMatch string, options *NamedValueDeleteOptions) (NamedValueDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, namedValueID, ifMatch, options) + if err != nil { + return NamedValueDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NamedValueDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return NamedValueDeleteResponse{}, client.deleteHandleError(resp) + } + return NamedValueDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *NamedValueClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, ifMatch string, options *NamedValueDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if namedValueID == "" { + return nil, errors.New("parameter namedValueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namedValueId}", url.PathEscape(namedValueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *NamedValueClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the named value specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NamedValueClient) Get(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, options *NamedValueGetOptions) (NamedValueGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, namedValueID, options) + if err != nil { + return NamedValueGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NamedValueGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return NamedValueGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *NamedValueClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, options *NamedValueGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if namedValueID == "" { + return nil, errors.New("parameter namedValueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namedValueId}", url.PathEscape(namedValueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *NamedValueClient) getHandleResponse(resp *azcore.Response) (NamedValueGetResponse, error) { + result := NamedValueGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.NamedValueContract); err != nil { + return NamedValueGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *NamedValueClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the named value specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NamedValueClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, options *NamedValueGetEntityTagOptions) (NamedValueGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, namedValueID, options) + if err != nil { + return NamedValueGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NamedValueGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *NamedValueClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, options *NamedValueGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if namedValueID == "" { + return nil, errors.New("parameter namedValueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namedValueId}", url.PathEscape(namedValueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *NamedValueClient) getEntityTagHandleResponse(resp *azcore.Response) (NamedValueGetEntityTagResponse, error) { + result := NamedValueGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists a collection of named values defined within a service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NamedValueClient) ListByService(resourceGroupName string, serviceName string, options *NamedValueListByServiceOptions) NamedValueListByServicePager { + return &namedValueListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp NamedValueListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.NamedValueCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *NamedValueClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *NamedValueListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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.IsKeyVaultRefreshFailed != nil { + reqQP.Set("isKeyVaultRefreshFailed", strconv.FormatBool(*options.IsKeyVaultRefreshFailed)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *NamedValueClient) listByServiceHandleResponse(resp *azcore.Response) (NamedValueListByServiceResponse, error) { + result := NamedValueListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.NamedValueCollection); err != nil { + return NamedValueListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *NamedValueClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListValue - Gets the secret of the named value specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NamedValueClient) ListValue(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, options *NamedValueListValueOptions) (NamedValueListValueResponse, error) { + req, err := client.listValueCreateRequest(ctx, resourceGroupName, serviceName, namedValueID, options) + if err != nil { + return NamedValueListValueResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NamedValueListValueResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return NamedValueListValueResponse{}, client.listValueHandleError(resp) + } + return client.listValueHandleResponse(resp) +} + +// listValueCreateRequest creates the ListValue request. +func (client *NamedValueClient) listValueCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, options *NamedValueListValueOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/listValue" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if namedValueID == "" { + return nil, errors.New("parameter namedValueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namedValueId}", url.PathEscape(namedValueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listValueHandleResponse handles the ListValue response. +func (client *NamedValueClient) listValueHandleResponse(resp *azcore.Response) (NamedValueListValueResponse, error) { + result := NamedValueListValueResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.NamedValueSecretContract); err != nil { + return NamedValueListValueResponse{}, err + } + return result, nil +} + +// listValueHandleError handles the ListValue error response. +func (client *NamedValueClient) listValueHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginRefreshSecret - Refresh the secret of the named value specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NamedValueClient) BeginRefreshSecret(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, options *NamedValueBeginRefreshSecretOptions) (NamedValueRefreshSecretPollerResponse, error) { + resp, err := client.refreshSecret(ctx, resourceGroupName, serviceName, namedValueID, options) + if err != nil { + return NamedValueRefreshSecretPollerResponse{}, err + } + result := NamedValueRefreshSecretPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("NamedValueClient.RefreshSecret", "location", resp, client.con.Pipeline(), client.refreshSecretHandleError) + if err != nil { + return NamedValueRefreshSecretPollerResponse{}, err + } + poller := &namedValueRefreshSecretPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (NamedValueRefreshSecretResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeRefreshSecret creates a new NamedValueRefreshSecretPoller from the specified resume token. +// token - The value must come from a previous call to NamedValueRefreshSecretPoller.ResumeToken(). +func (client *NamedValueClient) ResumeRefreshSecret(ctx context.Context, token string) (NamedValueRefreshSecretPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("NamedValueClient.RefreshSecret", token, client.con.Pipeline(), client.refreshSecretHandleError) + if err != nil { + return NamedValueRefreshSecretPollerResponse{}, err + } + poller := &namedValueRefreshSecretPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return NamedValueRefreshSecretPollerResponse{}, err + } + result := NamedValueRefreshSecretPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (NamedValueRefreshSecretResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// RefreshSecret - Refresh the secret of the named value specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NamedValueClient) refreshSecret(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, options *NamedValueBeginRefreshSecretOptions) (*azcore.Response, error) { + req, err := client.refreshSecretCreateRequest(ctx, resourceGroupName, serviceName, namedValueID, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.refreshSecretHandleError(resp) + } + return resp, nil +} + +// refreshSecretCreateRequest creates the RefreshSecret request. +func (client *NamedValueClient) refreshSecretCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, options *NamedValueBeginRefreshSecretOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}/refreshSecret" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if namedValueID == "" { + return nil, errors.New("parameter namedValueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namedValueId}", url.PathEscape(namedValueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// refreshSecretHandleError handles the RefreshSecret error response. +func (client *NamedValueClient) refreshSecretHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginUpdate - Updates the specific named value. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NamedValueClient) BeginUpdate(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, ifMatch string, parameters NamedValueUpdateParameters, options *NamedValueBeginUpdateOptions) (NamedValueUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, serviceName, namedValueID, ifMatch, parameters, options) + if err != nil { + return NamedValueUpdatePollerResponse{}, err + } + result := NamedValueUpdatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("NamedValueClient.Update", "location", resp, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return NamedValueUpdatePollerResponse{}, err + } + poller := &namedValueUpdatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (NamedValueUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeUpdate creates a new NamedValueUpdatePoller from the specified resume token. +// token - The value must come from a previous call to NamedValueUpdatePoller.ResumeToken(). +func (client *NamedValueClient) ResumeUpdate(ctx context.Context, token string) (NamedValueUpdatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("NamedValueClient.Update", token, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return NamedValueUpdatePollerResponse{}, err + } + poller := &namedValueUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return NamedValueUpdatePollerResponse{}, err + } + result := NamedValueUpdatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (NamedValueUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Update - Updates the specific named value. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NamedValueClient) update(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, ifMatch string, parameters NamedValueUpdateParameters, options *NamedValueBeginUpdateOptions) (*azcore.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, namedValueID, ifMatch, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *NamedValueClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, namedValueID string, ifMatch string, parameters NamedValueUpdateParameters, options *NamedValueBeginUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/namedValues/{namedValueId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if namedValueID == "" { + return nil, errors.New("parameter namedValueID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{namedValueId}", url.PathEscape(namedValueID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleError handles the Update error response. +func (client *NamedValueClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_networkstatus_client.go b/sdk/apimanagement/armapimanagement/zz_generated_networkstatus_client.go new file mode 100644 index 000000000000..a2dcc6521595 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_networkstatus_client.go @@ -0,0 +1,169 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// NetworkStatusClient contains the methods for the NetworkStatus group. +// Don't use this type directly, use NewNetworkStatusClient() instead. +type NetworkStatusClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewNetworkStatusClient creates a new instance of NetworkStatusClient with the specified values. +func NewNetworkStatusClient(con *armcore.Connection, subscriptionID string) *NetworkStatusClient { + return &NetworkStatusClient{con: con, subscriptionID: subscriptionID} +} + +// ListByLocation - Gets the Connectivity Status to the external resources on which the Api Management service depends from inside the Cloud Service. This +// also returns the DNS Servers as visible to the CloudService. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NetworkStatusClient) ListByLocation(ctx context.Context, resourceGroupName string, serviceName string, locationName string, options *NetworkStatusListByLocationOptions) (NetworkStatusListByLocationResponse, error) { + req, err := client.listByLocationCreateRequest(ctx, resourceGroupName, serviceName, locationName, options) + if err != nil { + return NetworkStatusListByLocationResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NetworkStatusListByLocationResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return NetworkStatusListByLocationResponse{}, client.listByLocationHandleError(resp) + } + return client.listByLocationHandleResponse(resp) +} + +// listByLocationCreateRequest creates the ListByLocation request. +func (client *NetworkStatusClient) listByLocationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, locationName string, options *NetworkStatusListByLocationOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/locations/{locationName}/networkstatus" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if locationName == "" { + return nil, errors.New("parameter locationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{locationName}", url.PathEscape(locationName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByLocationHandleResponse handles the ListByLocation response. +func (client *NetworkStatusClient) listByLocationHandleResponse(resp *azcore.Response) (NetworkStatusListByLocationResponse, error) { + result := NetworkStatusListByLocationResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.NetworkStatusContract); err != nil { + return NetworkStatusListByLocationResponse{}, err + } + return result, nil +} + +// listByLocationHandleError handles the ListByLocation error response. +func (client *NetworkStatusClient) listByLocationHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByService - Gets the Connectivity Status to the external resources on which the Api Management service depends from inside the Cloud Service. This +// also returns the DNS Servers as visible to the CloudService. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NetworkStatusClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, options *NetworkStatusListByServiceOptions) (NetworkStatusListByServiceResponse, error) { + req, err := client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return NetworkStatusListByServiceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NetworkStatusListByServiceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return NetworkStatusListByServiceResponse{}, client.listByServiceHandleError(resp) + } + return client.listByServiceHandleResponse(resp) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *NetworkStatusClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *NetworkStatusListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/networkstatus" + 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 serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *NetworkStatusClient) listByServiceHandleResponse(resp *azcore.Response) (NetworkStatusListByServiceResponse, error) { + result := NetworkStatusListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.NetworkStatusContractByLocationArray); err != nil { + return NetworkStatusListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *NetworkStatusClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_notification_client.go b/sdk/apimanagement/armapimanagement/zz_generated_notification_client.go new file mode 100644 index 000000000000..563ed5513f40 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_notification_client.go @@ -0,0 +1,244 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// NotificationClient contains the methods for the Notification group. +// Don't use this type directly, use NewNotificationClient() instead. +type NotificationClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewNotificationClient creates a new instance of NotificationClient with the specified values. +func NewNotificationClient(con *armcore.Connection, subscriptionID string) *NotificationClient { + return &NotificationClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Create or Update API Management publisher notification. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NotificationClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, options *NotificationCreateOrUpdateOptions) (NotificationCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, notificationName, options) + if err != nil { + return NotificationCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NotificationCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return NotificationCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *NotificationClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, options *NotificationCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *NotificationClient) createOrUpdateHandleResponse(resp *azcore.Response) (NotificationCreateOrUpdateResponse, error) { + result := NotificationCreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.NotificationContract); err != nil { + return NotificationCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *NotificationClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the Notification specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NotificationClient) Get(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, options *NotificationGetOptions) (NotificationGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, notificationName, options) + if err != nil { + return NotificationGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NotificationGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return NotificationGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *NotificationClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, options *NotificationGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *NotificationClient) getHandleResponse(resp *azcore.Response) (NotificationGetResponse, error) { + result := NotificationGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.NotificationContract); err != nil { + return NotificationGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *NotificationClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByService - Lists a collection of properties defined within a service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NotificationClient) ListByService(resourceGroupName string, serviceName string, options *NotificationListByServiceOptions) NotificationListByServicePager { + return ¬ificationListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp NotificationListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.NotificationCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *NotificationClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *NotificationListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *NotificationClient) listByServiceHandleResponse(resp *azcore.Response) (NotificationListByServiceResponse, error) { + result := NotificationListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.NotificationCollection); err != nil { + return NotificationListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *NotificationClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_notificationrecipientemail_client.go b/sdk/apimanagement/armapimanagement/zz_generated_notificationrecipientemail_client.go new file mode 100644 index 000000000000..36a216dcfa5b --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_notificationrecipientemail_client.go @@ -0,0 +1,293 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// NotificationRecipientEmailClient contains the methods for the NotificationRecipientEmail group. +// Don't use this type directly, use NewNotificationRecipientEmailClient() instead. +type NotificationRecipientEmailClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewNotificationRecipientEmailClient creates a new instance of NotificationRecipientEmailClient with the specified values. +func NewNotificationRecipientEmailClient(con *armcore.Connection, subscriptionID string) *NotificationRecipientEmailClient { + return &NotificationRecipientEmailClient{con: con, subscriptionID: subscriptionID} +} + +// CheckEntityExists - Determine if Notification Recipient Email subscribed to the notification. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NotificationRecipientEmailClient) CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string, options *NotificationRecipientEmailCheckEntityExistsOptions) (NotificationRecipientEmailCheckEntityExistsResponse, error) { + req, err := client.checkEntityExistsCreateRequest(ctx, resourceGroupName, serviceName, notificationName, email, options) + if err != nil { + return NotificationRecipientEmailCheckEntityExistsResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NotificationRecipientEmailCheckEntityExistsResponse{}, err + } + result := NotificationRecipientEmailCheckEntityExistsResponse{RawResponse: resp.Response} + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// checkEntityExistsCreateRequest creates the CheckEntityExists request. +func (client *NotificationRecipientEmailClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string, options *NotificationRecipientEmailCheckEntityExistsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if email == "" { + return nil, errors.New("parameter email cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{email}", url.PathEscape(email)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// CreateOrUpdate - Adds the Email address to the list of Recipients for the Notification. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NotificationRecipientEmailClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string, options *NotificationRecipientEmailCreateOrUpdateOptions) (NotificationRecipientEmailCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, notificationName, email, options) + if err != nil { + return NotificationRecipientEmailCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NotificationRecipientEmailCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return NotificationRecipientEmailCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *NotificationRecipientEmailClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string, options *NotificationRecipientEmailCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if email == "" { + return nil, errors.New("parameter email cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{email}", url.PathEscape(email)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *NotificationRecipientEmailClient) createOrUpdateHandleResponse(resp *azcore.Response) (NotificationRecipientEmailCreateOrUpdateResponse, error) { + result := NotificationRecipientEmailCreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RecipientEmailContract); err != nil { + return NotificationRecipientEmailCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *NotificationRecipientEmailClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Removes the email from the list of Notification. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NotificationRecipientEmailClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string, options *NotificationRecipientEmailDeleteOptions) (NotificationRecipientEmailDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, notificationName, email, options) + if err != nil { + return NotificationRecipientEmailDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NotificationRecipientEmailDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return NotificationRecipientEmailDeleteResponse{}, client.deleteHandleError(resp) + } + return NotificationRecipientEmailDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *NotificationRecipientEmailClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, email string, options *NotificationRecipientEmailDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails/{email}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if email == "" { + return nil, errors.New("parameter email cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{email}", url.PathEscape(email)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *NotificationRecipientEmailClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByNotification - Gets the list of the Notification Recipient Emails subscribed to a notification. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NotificationRecipientEmailClient) ListByNotification(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, options *NotificationRecipientEmailListByNotificationOptions) (NotificationRecipientEmailListByNotificationResponse, error) { + req, err := client.listByNotificationCreateRequest(ctx, resourceGroupName, serviceName, notificationName, options) + if err != nil { + return NotificationRecipientEmailListByNotificationResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NotificationRecipientEmailListByNotificationResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return NotificationRecipientEmailListByNotificationResponse{}, client.listByNotificationHandleError(resp) + } + return client.listByNotificationHandleResponse(resp) +} + +// listByNotificationCreateRequest creates the ListByNotification request. +func (client *NotificationRecipientEmailClient) listByNotificationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, options *NotificationRecipientEmailListByNotificationOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientEmails" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByNotificationHandleResponse handles the ListByNotification response. +func (client *NotificationRecipientEmailClient) listByNotificationHandleResponse(resp *azcore.Response) (NotificationRecipientEmailListByNotificationResponse, error) { + result := NotificationRecipientEmailListByNotificationResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RecipientEmailCollection); err != nil { + return NotificationRecipientEmailListByNotificationResponse{}, err + } + return result, nil +} + +// listByNotificationHandleError handles the ListByNotification error response. +func (client *NotificationRecipientEmailClient) listByNotificationHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_notificationrecipientuser_client.go b/sdk/apimanagement/armapimanagement/zz_generated_notificationrecipientuser_client.go new file mode 100644 index 000000000000..58d40614c017 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_notificationrecipientuser_client.go @@ -0,0 +1,293 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// NotificationRecipientUserClient contains the methods for the NotificationRecipientUser group. +// Don't use this type directly, use NewNotificationRecipientUserClient() instead. +type NotificationRecipientUserClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewNotificationRecipientUserClient creates a new instance of NotificationRecipientUserClient with the specified values. +func NewNotificationRecipientUserClient(con *armcore.Connection, subscriptionID string) *NotificationRecipientUserClient { + return &NotificationRecipientUserClient{con: con, subscriptionID: subscriptionID} +} + +// CheckEntityExists - Determine if the Notification Recipient User is subscribed to the notification. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NotificationRecipientUserClient) CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string, options *NotificationRecipientUserCheckEntityExistsOptions) (NotificationRecipientUserCheckEntityExistsResponse, error) { + req, err := client.checkEntityExistsCreateRequest(ctx, resourceGroupName, serviceName, notificationName, userID, options) + if err != nil { + return NotificationRecipientUserCheckEntityExistsResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NotificationRecipientUserCheckEntityExistsResponse{}, err + } + result := NotificationRecipientUserCheckEntityExistsResponse{RawResponse: resp.Response} + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// checkEntityExistsCreateRequest creates the CheckEntityExists request. +func (client *NotificationRecipientUserClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string, options *NotificationRecipientUserCheckEntityExistsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// CreateOrUpdate - Adds the API Management User to the list of Recipients for the Notification. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NotificationRecipientUserClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string, options *NotificationRecipientUserCreateOrUpdateOptions) (NotificationRecipientUserCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, notificationName, userID, options) + if err != nil { + return NotificationRecipientUserCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NotificationRecipientUserCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return NotificationRecipientUserCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *NotificationRecipientUserClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string, options *NotificationRecipientUserCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *NotificationRecipientUserClient) createOrUpdateHandleResponse(resp *azcore.Response) (NotificationRecipientUserCreateOrUpdateResponse, error) { + result := NotificationRecipientUserCreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RecipientUserContract); err != nil { + return NotificationRecipientUserCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *NotificationRecipientUserClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Removes the API Management user from the list of Notification. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NotificationRecipientUserClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string, options *NotificationRecipientUserDeleteOptions) (NotificationRecipientUserDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, notificationName, userID, options) + if err != nil { + return NotificationRecipientUserDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NotificationRecipientUserDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return NotificationRecipientUserDeleteResponse{}, client.deleteHandleError(resp) + } + return NotificationRecipientUserDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *NotificationRecipientUserClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, userID string, options *NotificationRecipientUserDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers/{userId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *NotificationRecipientUserClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByNotification - Gets the list of the Notification Recipient User subscribed to the notification. +// If the operation fails it returns the *ErrorResponse error type. +func (client *NotificationRecipientUserClient) ListByNotification(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, options *NotificationRecipientUserListByNotificationOptions) (NotificationRecipientUserListByNotificationResponse, error) { + req, err := client.listByNotificationCreateRequest(ctx, resourceGroupName, serviceName, notificationName, options) + if err != nil { + return NotificationRecipientUserListByNotificationResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return NotificationRecipientUserListByNotificationResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return NotificationRecipientUserListByNotificationResponse{}, client.listByNotificationHandleError(resp) + } + return client.listByNotificationHandleResponse(resp) +} + +// listByNotificationCreateRequest creates the ListByNotification request. +func (client *NotificationRecipientUserClient) listByNotificationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, notificationName NotificationName, options *NotificationRecipientUserListByNotificationOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/notifications/{notificationName}/recipientUsers" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if notificationName == "" { + return nil, errors.New("parameter notificationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{notificationName}", url.PathEscape(string(notificationName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByNotificationHandleResponse handles the ListByNotification response. +func (client *NotificationRecipientUserClient) listByNotificationHandleResponse(resp *azcore.Response) (NotificationRecipientUserListByNotificationResponse, error) { + result := NotificationRecipientUserListByNotificationResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RecipientUserCollection); err != nil { + return NotificationRecipientUserListByNotificationResponse{}, err + } + return result, nil +} + +// listByNotificationHandleError handles the ListByNotification error response. +func (client *NotificationRecipientUserClient) listByNotificationHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_openidconnectprovider_client.go b/sdk/apimanagement/armapimanagement/zz_generated_openidconnectprovider_client.go new file mode 100644 index 000000000000..6c8352084ec2 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_openidconnectprovider_client.go @@ -0,0 +1,519 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// OpenIDConnectProviderClient contains the methods for the OpenIDConnectProvider group. +// Don't use this type directly, use NewOpenIDConnectProviderClient() instead. +type OpenIDConnectProviderClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewOpenIDConnectProviderClient creates a new instance of OpenIDConnectProviderClient with the specified values. +func NewOpenIDConnectProviderClient(con *armcore.Connection, subscriptionID string) *OpenIDConnectProviderClient { + return &OpenIDConnectProviderClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or updates the OpenID Connect Provider. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OpenIDConnectProviderClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, opid string, parameters OpenidConnectProviderContract, options *OpenIDConnectProviderCreateOrUpdateOptions) (OpenIDConnectProviderCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, opid, parameters, options) + if err != nil { + return OpenIDConnectProviderCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return OpenIDConnectProviderCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return OpenIDConnectProviderCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *OpenIDConnectProviderClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, parameters OpenidConnectProviderContract, options *OpenIDConnectProviderCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if opid == "" { + return nil, errors.New("parameter opid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{opid}", url.PathEscape(opid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *OpenIDConnectProviderClient) createOrUpdateHandleResponse(resp *azcore.Response) (OpenIDConnectProviderCreateOrUpdateResponse, error) { + result := OpenIDConnectProviderCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.OpenidConnectProviderContract); err != nil { + return OpenIDConnectProviderCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *OpenIDConnectProviderClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes specific OpenID Connect Provider of the API Management service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OpenIDConnectProviderClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, opid string, ifMatch string, options *OpenIDConnectProviderDeleteOptions) (OpenIDConnectProviderDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, opid, ifMatch, options) + if err != nil { + return OpenIDConnectProviderDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return OpenIDConnectProviderDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return OpenIDConnectProviderDeleteResponse{}, client.deleteHandleError(resp) + } + return OpenIDConnectProviderDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *OpenIDConnectProviderClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, ifMatch string, options *OpenIDConnectProviderDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if opid == "" { + return nil, errors.New("parameter opid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{opid}", url.PathEscape(opid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *OpenIDConnectProviderClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets specific OpenID Connect Provider without secrets. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OpenIDConnectProviderClient) Get(ctx context.Context, resourceGroupName string, serviceName string, opid string, options *OpenIDConnectProviderGetOptions) (OpenIDConnectProviderGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, opid, options) + if err != nil { + return OpenIDConnectProviderGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return OpenIDConnectProviderGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return OpenIDConnectProviderGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *OpenIDConnectProviderClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, options *OpenIDConnectProviderGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if opid == "" { + return nil, errors.New("parameter opid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{opid}", url.PathEscape(opid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *OpenIDConnectProviderClient) getHandleResponse(resp *azcore.Response) (OpenIDConnectProviderGetResponse, error) { + result := OpenIDConnectProviderGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.OpenidConnectProviderContract); err != nil { + return OpenIDConnectProviderGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *OpenIDConnectProviderClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the openIdConnectProvider specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OpenIDConnectProviderClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, opid string, options *OpenIDConnectProviderGetEntityTagOptions) (OpenIDConnectProviderGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, opid, options) + if err != nil { + return OpenIDConnectProviderGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return OpenIDConnectProviderGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *OpenIDConnectProviderClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, options *OpenIDConnectProviderGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if opid == "" { + return nil, errors.New("parameter opid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{opid}", url.PathEscape(opid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *OpenIDConnectProviderClient) getEntityTagHandleResponse(resp *azcore.Response) (OpenIDConnectProviderGetEntityTagResponse, error) { + result := OpenIDConnectProviderGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists of all the OpenId Connect Providers. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OpenIDConnectProviderClient) ListByService(resourceGroupName string, serviceName string, options *OpenIDConnectProviderListByServiceOptions) OpenIDConnectProviderListByServicePager { + return &openIDConnectProviderListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp OpenIDConnectProviderListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.OpenIDConnectProviderCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *OpenIDConnectProviderClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *OpenIDConnectProviderListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *OpenIDConnectProviderClient) listByServiceHandleResponse(resp *azcore.Response) (OpenIDConnectProviderListByServiceResponse, error) { + result := OpenIDConnectProviderListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.OpenIDConnectProviderCollection); err != nil { + return OpenIDConnectProviderListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *OpenIDConnectProviderClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListSecrets - Gets the client secret details of the OpenID Connect Provider. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OpenIDConnectProviderClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, opid string, options *OpenIDConnectProviderListSecretsOptions) (OpenIDConnectProviderListSecretsResponse, error) { + req, err := client.listSecretsCreateRequest(ctx, resourceGroupName, serviceName, opid, options) + if err != nil { + return OpenIDConnectProviderListSecretsResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return OpenIDConnectProviderListSecretsResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return OpenIDConnectProviderListSecretsResponse{}, client.listSecretsHandleError(resp) + } + return client.listSecretsHandleResponse(resp) +} + +// listSecretsCreateRequest creates the ListSecrets request. +func (client *OpenIDConnectProviderClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, options *OpenIDConnectProviderListSecretsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}/listSecrets" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if opid == "" { + return nil, errors.New("parameter opid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{opid}", url.PathEscape(opid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listSecretsHandleResponse handles the ListSecrets response. +func (client *OpenIDConnectProviderClient) listSecretsHandleResponse(resp *azcore.Response) (OpenIDConnectProviderListSecretsResponse, error) { + result := OpenIDConnectProviderListSecretsResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.ClientSecretContract); err != nil { + return OpenIDConnectProviderListSecretsResponse{}, err + } + return result, nil +} + +// listSecretsHandleError handles the ListSecrets error response. +func (client *OpenIDConnectProviderClient) listSecretsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates the specific OpenID Connect Provider. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OpenIDConnectProviderClient) Update(ctx context.Context, resourceGroupName string, serviceName string, opid string, ifMatch string, parameters OpenidConnectProviderUpdateContract, options *OpenIDConnectProviderUpdateOptions) (OpenIDConnectProviderUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, opid, ifMatch, parameters, options) + if err != nil { + return OpenIDConnectProviderUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return OpenIDConnectProviderUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return OpenIDConnectProviderUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *OpenIDConnectProviderClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, opid string, ifMatch string, parameters OpenidConnectProviderUpdateContract, options *OpenIDConnectProviderUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/openidConnectProviders/{opid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if opid == "" { + return nil, errors.New("parameter opid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{opid}", url.PathEscape(opid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *OpenIDConnectProviderClient) updateHandleResponse(resp *azcore.Response) (OpenIDConnectProviderUpdateResponse, error) { + result := OpenIDConnectProviderUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.OpenidConnectProviderContract); err != nil { + return OpenIDConnectProviderUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *OpenIDConnectProviderClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_operation_client.go b/sdk/apimanagement/armapimanagement/zz_generated_operation_client.go new file mode 100644 index 000000000000..c86b8992ffa6 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_operation_client.go @@ -0,0 +1,111 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// OperationClient contains the methods for the Operation group. +// Don't use this type directly, use NewOperationClient() instead. +type OperationClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewOperationClient creates a new instance of OperationClient with the specified values. +func NewOperationClient(con *armcore.Connection, subscriptionID string) *OperationClient { + return &OperationClient{con: con, subscriptionID: subscriptionID} +} + +// ListByTags - Lists a collection of operations associated with tags. +// If the operation fails it returns the *ErrorResponse error type. +func (client *OperationClient) ListByTags(resourceGroupName string, serviceName string, apiID string, options *OperationListByTagsOptions) OperationListByTagsPager { + return &operationListByTagsPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByTagsCreateRequest(ctx, resourceGroupName, serviceName, apiID, options) + }, + advancer: func(ctx context.Context, resp OperationListByTagsResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.TagResourceCollection.NextLink) + }, + } +} + +// listByTagsCreateRequest creates the ListByTags request. +func (client *OperationClient) listByTagsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *OperationListByTagsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operationsByTags" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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.IncludeNotTaggedOperations != nil { + reqQP.Set("includeNotTaggedOperations", strconv.FormatBool(*options.IncludeNotTaggedOperations)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByTagsHandleResponse handles the ListByTags response. +func (client *OperationClient) listByTagsHandleResponse(resp *azcore.Response) (OperationListByTagsResponse, error) { + result := OperationListByTagsResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.TagResourceCollection); err != nil { + return OperationListByTagsResponse{}, err + } + return result, nil +} + +// listByTagsHandleError handles the ListByTags error response. +func (client *OperationClient) listByTagsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_pagers.go b/sdk/apimanagement/armapimanagement/zz_generated_pagers.go new file mode 100644 index 000000000000..585272b3582e --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_pagers.go @@ -0,0 +1,3645 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "reflect" +) + +type APIDiagnosticListByServicePager interface { + azcore.Pager + // PageResponse returns the current APIDiagnosticListByServiceResponse. + PageResponse() APIDiagnosticListByServiceResponse +} + +type apiDiagnosticListByServicePager struct { + client *APIDiagnosticClient + current APIDiagnosticListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIDiagnosticListByServiceResponse) (*azcore.Request, error) +} + +func (p *apiDiagnosticListByServicePager) Err() error { + return p.err +} + +func (p *apiDiagnosticListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.DiagnosticCollection.NextLink == nil || len(*p.current.DiagnosticCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiDiagnosticListByServicePager) PageResponse() APIDiagnosticListByServiceResponse { + return p.current +} + +type APIIssueAttachmentListByServicePager interface { + azcore.Pager + // PageResponse returns the current APIIssueAttachmentListByServiceResponse. + PageResponse() APIIssueAttachmentListByServiceResponse +} + +type apiIssueAttachmentListByServicePager struct { + client *APIIssueAttachmentClient + current APIIssueAttachmentListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIIssueAttachmentListByServiceResponse) (*azcore.Request, error) +} + +func (p *apiIssueAttachmentListByServicePager) Err() error { + return p.err +} + +func (p *apiIssueAttachmentListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.IssueAttachmentCollection.NextLink == nil || len(*p.current.IssueAttachmentCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiIssueAttachmentListByServicePager) PageResponse() APIIssueAttachmentListByServiceResponse { + return p.current +} + +type APIIssueCommentListByServicePager interface { + azcore.Pager + // PageResponse returns the current APIIssueCommentListByServiceResponse. + PageResponse() APIIssueCommentListByServiceResponse +} + +type apiIssueCommentListByServicePager struct { + client *APIIssueCommentClient + current APIIssueCommentListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIIssueCommentListByServiceResponse) (*azcore.Request, error) +} + +func (p *apiIssueCommentListByServicePager) Err() error { + return p.err +} + +func (p *apiIssueCommentListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.IssueCommentCollection.NextLink == nil || len(*p.current.IssueCommentCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiIssueCommentListByServicePager) PageResponse() APIIssueCommentListByServiceResponse { + return p.current +} + +type APIIssueListByServicePager interface { + azcore.Pager + // PageResponse returns the current APIIssueListByServiceResponse. + PageResponse() APIIssueListByServiceResponse +} + +type apiIssueListByServicePager struct { + client *APIIssueClient + current APIIssueListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIIssueListByServiceResponse) (*azcore.Request, error) +} + +func (p *apiIssueListByServicePager) Err() error { + return p.err +} + +func (p *apiIssueListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.IssueCollection.NextLink == nil || len(*p.current.IssueCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiIssueListByServicePager) PageResponse() APIIssueListByServiceResponse { + return p.current +} + +type APIListByServicePager interface { + azcore.Pager + // PageResponse returns the current APIListByServiceResponse. + PageResponse() APIListByServiceResponse +} + +type apiListByServicePager struct { + client *APIClient + current APIListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIListByServiceResponse) (*azcore.Request, error) +} + +func (p *apiListByServicePager) Err() error { + return p.err +} + +func (p *apiListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.APICollection.NextLink == nil || len(*p.current.APICollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiListByServicePager) PageResponse() APIListByServiceResponse { + return p.current +} + +type APIListByTagsPager interface { + azcore.Pager + // PageResponse returns the current APIListByTagsResponse. + PageResponse() APIListByTagsResponse +} + +type apiListByTagsPager struct { + client *APIClient + current APIListByTagsResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIListByTagsResponse) (*azcore.Request, error) +} + +func (p *apiListByTagsPager) Err() error { + return p.err +} + +func (p *apiListByTagsPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.TagResourceCollection.NextLink == nil || len(*p.current.TagResourceCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByTagsHandleError(resp) + return false + } + result, err := p.client.listByTagsHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiListByTagsPager) PageResponse() APIListByTagsResponse { + return p.current +} + +type APIManagementOperationsListPager interface { + azcore.Pager + // PageResponse returns the current APIManagementOperationsListResponse. + PageResponse() APIManagementOperationsListResponse +} + +type apiManagementOperationsListPager struct { + client *APIManagementOperationsClient + current APIManagementOperationsListResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIManagementOperationsListResponse) (*azcore.Request, error) +} + +func (p *apiManagementOperationsListPager) Err() error { + return p.err +} + +func (p *apiManagementOperationsListPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationListResult.NextLink == nil || len(*p.current.OperationListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiManagementOperationsListPager) PageResponse() APIManagementOperationsListResponse { + return p.current +} + +type APIManagementSKUsListPager interface { + azcore.Pager + // PageResponse returns the current APIManagementSKUsListResponse. + PageResponse() APIManagementSKUsListResponse +} + +type apiManagementSKUsListPager struct { + client *APIManagementSKUsClient + current APIManagementSKUsListResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIManagementSKUsListResponse) (*azcore.Request, error) +} + +func (p *apiManagementSKUsListPager) Err() error { + return p.err +} + +func (p *apiManagementSKUsListPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.APIManagementSKUsResult.NextLink == nil || len(*p.current.APIManagementSKUsResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiManagementSKUsListPager) PageResponse() APIManagementSKUsListResponse { + return p.current +} + +type APIManagementServiceListByResourceGroupPager interface { + azcore.Pager + // PageResponse returns the current APIManagementServiceListByResourceGroupResponse. + PageResponse() APIManagementServiceListByResourceGroupResponse +} + +type apiManagementServiceListByResourceGroupPager struct { + client *APIManagementServiceClient + current APIManagementServiceListByResourceGroupResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIManagementServiceListByResourceGroupResponse) (*azcore.Request, error) +} + +func (p *apiManagementServiceListByResourceGroupPager) Err() error { + return p.err +} + +func (p *apiManagementServiceListByResourceGroupPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.APIManagementServiceListResult.NextLink == nil || len(*p.current.APIManagementServiceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByResourceGroupHandleError(resp) + return false + } + result, err := p.client.listByResourceGroupHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiManagementServiceListByResourceGroupPager) PageResponse() APIManagementServiceListByResourceGroupResponse { + return p.current +} + +type APIManagementServiceListPager interface { + azcore.Pager + // PageResponse returns the current APIManagementServiceListResponse. + PageResponse() APIManagementServiceListResponse +} + +type apiManagementServiceListPager struct { + client *APIManagementServiceClient + current APIManagementServiceListResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIManagementServiceListResponse) (*azcore.Request, error) +} + +func (p *apiManagementServiceListPager) Err() error { + return p.err +} + +func (p *apiManagementServiceListPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.APIManagementServiceListResult.NextLink == nil || len(*p.current.APIManagementServiceListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiManagementServiceListPager) PageResponse() APIManagementServiceListResponse { + return p.current +} + +type APIManagementServiceSKUsListAvailableServiceSKUsPager interface { + azcore.Pager + // PageResponse returns the current APIManagementServiceSKUsListAvailableServiceSKUsResponse. + PageResponse() APIManagementServiceSKUsListAvailableServiceSKUsResponse +} + +type apiManagementServiceSKUsListAvailableServiceSKUsPager struct { + client *APIManagementServiceSKUsClient + current APIManagementServiceSKUsListAvailableServiceSKUsResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIManagementServiceSKUsListAvailableServiceSKUsResponse) (*azcore.Request, error) +} + +func (p *apiManagementServiceSKUsListAvailableServiceSKUsPager) Err() error { + return p.err +} + +func (p *apiManagementServiceSKUsListAvailableServiceSKUsPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ResourceSKUResults.NextLink == nil || len(*p.current.ResourceSKUResults.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listAvailableServiceSKUsHandleError(resp) + return false + } + result, err := p.client.listAvailableServiceSKUsHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiManagementServiceSKUsListAvailableServiceSKUsPager) PageResponse() APIManagementServiceSKUsListAvailableServiceSKUsResponse { + return p.current +} + +type APIOperationListByAPIPager interface { + azcore.Pager + // PageResponse returns the current APIOperationListByAPIResponse. + PageResponse() APIOperationListByAPIResponse +} + +type apiOperationListByAPIPager struct { + client *APIOperationClient + current APIOperationListByAPIResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIOperationListByAPIResponse) (*azcore.Request, error) +} + +func (p *apiOperationListByAPIPager) Err() error { + return p.err +} + +func (p *apiOperationListByAPIPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OperationCollection.NextLink == nil || len(*p.current.OperationCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByAPIHandleError(resp) + return false + } + result, err := p.client.listByAPIHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiOperationListByAPIPager) PageResponse() APIOperationListByAPIResponse { + return p.current +} + +type APIProductListByApisPager interface { + azcore.Pager + // PageResponse returns the current APIProductListByApisResponse. + PageResponse() APIProductListByApisResponse +} + +type apiProductListByApisPager struct { + client *APIProductClient + current APIProductListByApisResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIProductListByApisResponse) (*azcore.Request, error) +} + +func (p *apiProductListByApisPager) Err() error { + return p.err +} + +func (p *apiProductListByApisPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ProductCollection.NextLink == nil || len(*p.current.ProductCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByApisHandleError(resp) + return false + } + result, err := p.client.listByApisHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiProductListByApisPager) PageResponse() APIProductListByApisResponse { + return p.current +} + +type APIReleaseListByServicePager interface { + azcore.Pager + // PageResponse returns the current APIReleaseListByServiceResponse. + PageResponse() APIReleaseListByServiceResponse +} + +type apiReleaseListByServicePager struct { + client *APIReleaseClient + current APIReleaseListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIReleaseListByServiceResponse) (*azcore.Request, error) +} + +func (p *apiReleaseListByServicePager) Err() error { + return p.err +} + +func (p *apiReleaseListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.APIReleaseCollection.NextLink == nil || len(*p.current.APIReleaseCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiReleaseListByServicePager) PageResponse() APIReleaseListByServiceResponse { + return p.current +} + +type APIRevisionListByServicePager interface { + azcore.Pager + // PageResponse returns the current APIRevisionListByServiceResponse. + PageResponse() APIRevisionListByServiceResponse +} + +type apiRevisionListByServicePager struct { + client *APIRevisionClient + current APIRevisionListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIRevisionListByServiceResponse) (*azcore.Request, error) +} + +func (p *apiRevisionListByServicePager) Err() error { + return p.err +} + +func (p *apiRevisionListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.APIRevisionCollection.NextLink == nil || len(*p.current.APIRevisionCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiRevisionListByServicePager) PageResponse() APIRevisionListByServiceResponse { + return p.current +} + +type APISchemaListByAPIPager interface { + azcore.Pager + // PageResponse returns the current APISchemaListByAPIResponse. + PageResponse() APISchemaListByAPIResponse +} + +type apiSchemaListByAPIPager struct { + client *APISchemaClient + current APISchemaListByAPIResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APISchemaListByAPIResponse) (*azcore.Request, error) +} + +func (p *apiSchemaListByAPIPager) Err() error { + return p.err +} + +func (p *apiSchemaListByAPIPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.SchemaCollection.NextLink == nil || len(*p.current.SchemaCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByAPIHandleError(resp) + return false + } + result, err := p.client.listByAPIHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiSchemaListByAPIPager) PageResponse() APISchemaListByAPIResponse { + return p.current +} + +type APITagDescriptionListByServicePager interface { + azcore.Pager + // PageResponse returns the current APITagDescriptionListByServiceResponse. + PageResponse() APITagDescriptionListByServiceResponse +} + +type apiTagDescriptionListByServicePager struct { + client *APITagDescriptionClient + current APITagDescriptionListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APITagDescriptionListByServiceResponse) (*azcore.Request, error) +} + +func (p *apiTagDescriptionListByServicePager) Err() error { + return p.err +} + +func (p *apiTagDescriptionListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.TagDescriptionCollection.NextLink == nil || len(*p.current.TagDescriptionCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiTagDescriptionListByServicePager) PageResponse() APITagDescriptionListByServiceResponse { + return p.current +} + +type APIVersionSetListByServicePager interface { + azcore.Pager + // PageResponse returns the current APIVersionSetListByServiceResponse. + PageResponse() APIVersionSetListByServiceResponse +} + +type apiVersionSetListByServicePager struct { + client *APIVersionSetClient + current APIVersionSetListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, APIVersionSetListByServiceResponse) (*azcore.Request, error) +} + +func (p *apiVersionSetListByServicePager) Err() error { + return p.err +} + +func (p *apiVersionSetListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.APIVersionSetCollection.NextLink == nil || len(*p.current.APIVersionSetCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *apiVersionSetListByServicePager) PageResponse() APIVersionSetListByServiceResponse { + return p.current +} + +type AuthorizationServerListByServicePager interface { + azcore.Pager + // PageResponse returns the current AuthorizationServerListByServiceResponse. + PageResponse() AuthorizationServerListByServiceResponse +} + +type authorizationServerListByServicePager struct { + client *AuthorizationServerClient + current AuthorizationServerListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, AuthorizationServerListByServiceResponse) (*azcore.Request, error) +} + +func (p *authorizationServerListByServicePager) Err() error { + return p.err +} + +func (p *authorizationServerListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.AuthorizationServerCollection.NextLink == nil || len(*p.current.AuthorizationServerCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *authorizationServerListByServicePager) PageResponse() AuthorizationServerListByServiceResponse { + return p.current +} + +type BackendListByServicePager interface { + azcore.Pager + // PageResponse returns the current BackendListByServiceResponse. + PageResponse() BackendListByServiceResponse +} + +type backendListByServicePager struct { + client *BackendClient + current BackendListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, BackendListByServiceResponse) (*azcore.Request, error) +} + +func (p *backendListByServicePager) Err() error { + return p.err +} + +func (p *backendListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.BackendCollection.NextLink == nil || len(*p.current.BackendCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *backendListByServicePager) PageResponse() BackendListByServiceResponse { + return p.current +} + +type CacheListByServicePager interface { + azcore.Pager + // PageResponse returns the current CacheListByServiceResponse. + PageResponse() CacheListByServiceResponse +} + +type cacheListByServicePager struct { + client *CacheClient + current CacheListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, CacheListByServiceResponse) (*azcore.Request, error) +} + +func (p *cacheListByServicePager) Err() error { + return p.err +} + +func (p *cacheListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.CacheCollection.NextLink == nil || len(*p.current.CacheCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *cacheListByServicePager) PageResponse() CacheListByServiceResponse { + return p.current +} + +type CertificateListByServicePager interface { + azcore.Pager + // PageResponse returns the current CertificateListByServiceResponse. + PageResponse() CertificateListByServiceResponse +} + +type certificateListByServicePager struct { + client *CertificateClient + current CertificateListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, CertificateListByServiceResponse) (*azcore.Request, error) +} + +func (p *certificateListByServicePager) Err() error { + return p.err +} + +func (p *certificateListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.CertificateCollection.NextLink == nil || len(*p.current.CertificateCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *certificateListByServicePager) PageResponse() CertificateListByServiceResponse { + return p.current +} + +type ContentItemListByServicePager interface { + azcore.Pager + // PageResponse returns the current ContentItemListByServiceResponse. + PageResponse() ContentItemListByServiceResponse +} + +type contentItemListByServicePager struct { + client *ContentItemClient + current ContentItemListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ContentItemListByServiceResponse) (*azcore.Request, error) +} + +func (p *contentItemListByServicePager) Err() error { + return p.err +} + +func (p *contentItemListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ContentItemCollection.NextLink == nil || len(*p.current.ContentItemCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *contentItemListByServicePager) PageResponse() ContentItemListByServiceResponse { + return p.current +} + +type ContentTypeListByServicePager interface { + azcore.Pager + // PageResponse returns the current ContentTypeListByServiceResponse. + PageResponse() ContentTypeListByServiceResponse +} + +type contentTypeListByServicePager struct { + client *ContentTypeClient + current ContentTypeListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ContentTypeListByServiceResponse) (*azcore.Request, error) +} + +func (p *contentTypeListByServicePager) Err() error { + return p.err +} + +func (p *contentTypeListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ContentTypeCollection.NextLink == nil || len(*p.current.ContentTypeCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *contentTypeListByServicePager) PageResponse() ContentTypeListByServiceResponse { + return p.current +} + +type DeletedServicesListBySubscriptionPager interface { + azcore.Pager + // PageResponse returns the current DeletedServicesListBySubscriptionResponse. + PageResponse() DeletedServicesListBySubscriptionResponse +} + +type deletedServicesListBySubscriptionPager struct { + client *DeletedServicesClient + current DeletedServicesListBySubscriptionResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, DeletedServicesListBySubscriptionResponse) (*azcore.Request, error) +} + +func (p *deletedServicesListBySubscriptionPager) Err() error { + return p.err +} + +func (p *deletedServicesListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.DeletedServicesCollection.NextLink == nil || len(*p.current.DeletedServicesCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *deletedServicesListBySubscriptionPager) PageResponse() DeletedServicesListBySubscriptionResponse { + return p.current +} + +type DiagnosticListByServicePager interface { + azcore.Pager + // PageResponse returns the current DiagnosticListByServiceResponse. + PageResponse() DiagnosticListByServiceResponse +} + +type diagnosticListByServicePager struct { + client *DiagnosticClient + current DiagnosticListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, DiagnosticListByServiceResponse) (*azcore.Request, error) +} + +func (p *diagnosticListByServicePager) Err() error { + return p.err +} + +func (p *diagnosticListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.DiagnosticCollection.NextLink == nil || len(*p.current.DiagnosticCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *diagnosticListByServicePager) PageResponse() DiagnosticListByServiceResponse { + return p.current +} + +type EmailTemplateListByServicePager interface { + azcore.Pager + // PageResponse returns the current EmailTemplateListByServiceResponse. + PageResponse() EmailTemplateListByServiceResponse +} + +type emailTemplateListByServicePager struct { + client *EmailTemplateClient + current EmailTemplateListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, EmailTemplateListByServiceResponse) (*azcore.Request, error) +} + +func (p *emailTemplateListByServicePager) Err() error { + return p.err +} + +func (p *emailTemplateListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.EmailTemplateCollection.NextLink == nil || len(*p.current.EmailTemplateCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *emailTemplateListByServicePager) PageResponse() EmailTemplateListByServiceResponse { + return p.current +} + +type GatewayAPIListByServicePager interface { + azcore.Pager + // PageResponse returns the current GatewayAPIListByServiceResponse. + PageResponse() GatewayAPIListByServiceResponse +} + +type gatewayAPIListByServicePager struct { + client *GatewayAPIClient + current GatewayAPIListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, GatewayAPIListByServiceResponse) (*azcore.Request, error) +} + +func (p *gatewayAPIListByServicePager) Err() error { + return p.err +} + +func (p *gatewayAPIListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.APICollection.NextLink == nil || len(*p.current.APICollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *gatewayAPIListByServicePager) PageResponse() GatewayAPIListByServiceResponse { + return p.current +} + +type GatewayCertificateAuthorityListByServicePager interface { + azcore.Pager + // PageResponse returns the current GatewayCertificateAuthorityListByServiceResponse. + PageResponse() GatewayCertificateAuthorityListByServiceResponse +} + +type gatewayCertificateAuthorityListByServicePager struct { + client *GatewayCertificateAuthorityClient + current GatewayCertificateAuthorityListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, GatewayCertificateAuthorityListByServiceResponse) (*azcore.Request, error) +} + +func (p *gatewayCertificateAuthorityListByServicePager) Err() error { + return p.err +} + +func (p *gatewayCertificateAuthorityListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.GatewayCertificateAuthorityCollection.NextLink == nil || len(*p.current.GatewayCertificateAuthorityCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *gatewayCertificateAuthorityListByServicePager) PageResponse() GatewayCertificateAuthorityListByServiceResponse { + return p.current +} + +type GatewayHostnameConfigurationListByServicePager interface { + azcore.Pager + // PageResponse returns the current GatewayHostnameConfigurationListByServiceResponse. + PageResponse() GatewayHostnameConfigurationListByServiceResponse +} + +type gatewayHostnameConfigurationListByServicePager struct { + client *GatewayHostnameConfigurationClient + current GatewayHostnameConfigurationListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, GatewayHostnameConfigurationListByServiceResponse) (*azcore.Request, error) +} + +func (p *gatewayHostnameConfigurationListByServicePager) Err() error { + return p.err +} + +func (p *gatewayHostnameConfigurationListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.GatewayHostnameConfigurationCollection.NextLink == nil || len(*p.current.GatewayHostnameConfigurationCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *gatewayHostnameConfigurationListByServicePager) PageResponse() GatewayHostnameConfigurationListByServiceResponse { + return p.current +} + +type GatewayListByServicePager interface { + azcore.Pager + // PageResponse returns the current GatewayListByServiceResponse. + PageResponse() GatewayListByServiceResponse +} + +type gatewayListByServicePager struct { + client *GatewayClient + current GatewayListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, GatewayListByServiceResponse) (*azcore.Request, error) +} + +func (p *gatewayListByServicePager) Err() error { + return p.err +} + +func (p *gatewayListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.GatewayCollection.NextLink == nil || len(*p.current.GatewayCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *gatewayListByServicePager) PageResponse() GatewayListByServiceResponse { + return p.current +} + +type GroupListByServicePager interface { + azcore.Pager + // PageResponse returns the current GroupListByServiceResponse. + PageResponse() GroupListByServiceResponse +} + +type groupListByServicePager struct { + client *GroupClient + current GroupListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, GroupListByServiceResponse) (*azcore.Request, error) +} + +func (p *groupListByServicePager) Err() error { + return p.err +} + +func (p *groupListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.GroupCollection.NextLink == nil || len(*p.current.GroupCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *groupListByServicePager) PageResponse() GroupListByServiceResponse { + return p.current +} + +type GroupUserListPager interface { + azcore.Pager + // PageResponse returns the current GroupUserListResponse. + PageResponse() GroupUserListResponse +} + +type groupUserListPager struct { + client *GroupUserClient + current GroupUserListResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, GroupUserListResponse) (*azcore.Request, error) +} + +func (p *groupUserListPager) Err() error { + return p.err +} + +func (p *groupUserListPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.UserCollection.NextLink == nil || len(*p.current.UserCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *groupUserListPager) PageResponse() GroupUserListResponse { + return p.current +} + +type IdentityProviderListByServicePager interface { + azcore.Pager + // PageResponse returns the current IdentityProviderListByServiceResponse. + PageResponse() IdentityProviderListByServiceResponse +} + +type identityProviderListByServicePager struct { + client *IdentityProviderClient + current IdentityProviderListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, IdentityProviderListByServiceResponse) (*azcore.Request, error) +} + +func (p *identityProviderListByServicePager) Err() error { + return p.err +} + +func (p *identityProviderListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.IdentityProviderList.NextLink == nil || len(*p.current.IdentityProviderList.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *identityProviderListByServicePager) PageResponse() IdentityProviderListByServiceResponse { + return p.current +} + +type IssueListByServicePager interface { + azcore.Pager + // PageResponse returns the current IssueListByServiceResponse. + PageResponse() IssueListByServiceResponse +} + +type issueListByServicePager struct { + client *IssueClient + current IssueListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, IssueListByServiceResponse) (*azcore.Request, error) +} + +func (p *issueListByServicePager) Err() error { + return p.err +} + +func (p *issueListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.IssueCollection.NextLink == nil || len(*p.current.IssueCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *issueListByServicePager) PageResponse() IssueListByServiceResponse { + return p.current +} + +type LoggerListByServicePager interface { + azcore.Pager + // PageResponse returns the current LoggerListByServiceResponse. + PageResponse() LoggerListByServiceResponse +} + +type loggerListByServicePager struct { + client *LoggerClient + current LoggerListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, LoggerListByServiceResponse) (*azcore.Request, error) +} + +func (p *loggerListByServicePager) Err() error { + return p.err +} + +func (p *loggerListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.LoggerCollection.NextLink == nil || len(*p.current.LoggerCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *loggerListByServicePager) PageResponse() LoggerListByServiceResponse { + return p.current +} + +type NamedValueListByServicePager interface { + azcore.Pager + // PageResponse returns the current NamedValueListByServiceResponse. + PageResponse() NamedValueListByServiceResponse +} + +type namedValueListByServicePager struct { + client *NamedValueClient + current NamedValueListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, NamedValueListByServiceResponse) (*azcore.Request, error) +} + +func (p *namedValueListByServicePager) Err() error { + return p.err +} + +func (p *namedValueListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.NamedValueCollection.NextLink == nil || len(*p.current.NamedValueCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *namedValueListByServicePager) PageResponse() NamedValueListByServiceResponse { + return p.current +} + +type NotificationListByServicePager interface { + azcore.Pager + // PageResponse returns the current NotificationListByServiceResponse. + PageResponse() NotificationListByServiceResponse +} + +type notificationListByServicePager struct { + client *NotificationClient + current NotificationListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, NotificationListByServiceResponse) (*azcore.Request, error) +} + +func (p *notificationListByServicePager) Err() error { + return p.err +} + +func (p *notificationListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.NotificationCollection.NextLink == nil || len(*p.current.NotificationCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *notificationListByServicePager) PageResponse() NotificationListByServiceResponse { + return p.current +} + +type OpenIDConnectProviderListByServicePager interface { + azcore.Pager + // PageResponse returns the current OpenIDConnectProviderListByServiceResponse. + PageResponse() OpenIDConnectProviderListByServiceResponse +} + +type openIDConnectProviderListByServicePager struct { + client *OpenIDConnectProviderClient + current OpenIDConnectProviderListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, OpenIDConnectProviderListByServiceResponse) (*azcore.Request, error) +} + +func (p *openIDConnectProviderListByServicePager) Err() error { + return p.err +} + +func (p *openIDConnectProviderListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.OpenIDConnectProviderCollection.NextLink == nil || len(*p.current.OpenIDConnectProviderCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *openIDConnectProviderListByServicePager) PageResponse() OpenIDConnectProviderListByServiceResponse { + return p.current +} + +type OperationListByTagsPager interface { + azcore.Pager + // PageResponse returns the current OperationListByTagsResponse. + PageResponse() OperationListByTagsResponse +} + +type operationListByTagsPager struct { + client *OperationClient + current OperationListByTagsResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, OperationListByTagsResponse) (*azcore.Request, error) +} + +func (p *operationListByTagsPager) Err() error { + return p.err +} + +func (p *operationListByTagsPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.TagResourceCollection.NextLink == nil || len(*p.current.TagResourceCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByTagsHandleError(resp) + return false + } + result, err := p.client.listByTagsHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *operationListByTagsPager) PageResponse() OperationListByTagsResponse { + return p.current +} + +type PortalRevisionListByServicePager interface { + azcore.Pager + // PageResponse returns the current PortalRevisionListByServiceResponse. + PageResponse() PortalRevisionListByServiceResponse +} + +type portalRevisionListByServicePager struct { + client *PortalRevisionClient + current PortalRevisionListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, PortalRevisionListByServiceResponse) (*azcore.Request, error) +} + +func (p *portalRevisionListByServicePager) Err() error { + return p.err +} + +func (p *portalRevisionListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.PortalRevisionCollection.NextLink == nil || len(*p.current.PortalRevisionCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *portalRevisionListByServicePager) PageResponse() PortalRevisionListByServiceResponse { + return p.current +} + +type ProductAPIListByProductPager interface { + azcore.Pager + // PageResponse returns the current ProductAPIListByProductResponse. + PageResponse() ProductAPIListByProductResponse +} + +type productAPIListByProductPager struct { + client *ProductAPIClient + current ProductAPIListByProductResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ProductAPIListByProductResponse) (*azcore.Request, error) +} + +func (p *productAPIListByProductPager) Err() error { + return p.err +} + +func (p *productAPIListByProductPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.APICollection.NextLink == nil || len(*p.current.APICollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByProductHandleError(resp) + return false + } + result, err := p.client.listByProductHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *productAPIListByProductPager) PageResponse() ProductAPIListByProductResponse { + return p.current +} + +type ProductGroupListByProductPager interface { + azcore.Pager + // PageResponse returns the current ProductGroupListByProductResponse. + PageResponse() ProductGroupListByProductResponse +} + +type productGroupListByProductPager struct { + client *ProductGroupClient + current ProductGroupListByProductResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ProductGroupListByProductResponse) (*azcore.Request, error) +} + +func (p *productGroupListByProductPager) Err() error { + return p.err +} + +func (p *productGroupListByProductPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.GroupCollection.NextLink == nil || len(*p.current.GroupCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByProductHandleError(resp) + return false + } + result, err := p.client.listByProductHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *productGroupListByProductPager) PageResponse() ProductGroupListByProductResponse { + return p.current +} + +type ProductListByServicePager interface { + azcore.Pager + // PageResponse returns the current ProductListByServiceResponse. + PageResponse() ProductListByServiceResponse +} + +type productListByServicePager struct { + client *ProductClient + current ProductListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ProductListByServiceResponse) (*azcore.Request, error) +} + +func (p *productListByServicePager) Err() error { + return p.err +} + +func (p *productListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ProductCollection.NextLink == nil || len(*p.current.ProductCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *productListByServicePager) PageResponse() ProductListByServiceResponse { + return p.current +} + +type ProductListByTagsPager interface { + azcore.Pager + // PageResponse returns the current ProductListByTagsResponse. + PageResponse() ProductListByTagsResponse +} + +type productListByTagsPager struct { + client *ProductClient + current ProductListByTagsResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ProductListByTagsResponse) (*azcore.Request, error) +} + +func (p *productListByTagsPager) Err() error { + return p.err +} + +func (p *productListByTagsPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.TagResourceCollection.NextLink == nil || len(*p.current.TagResourceCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByTagsHandleError(resp) + return false + } + result, err := p.client.listByTagsHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *productListByTagsPager) PageResponse() ProductListByTagsResponse { + return p.current +} + +type ProductSubscriptionsListPager interface { + azcore.Pager + // PageResponse returns the current ProductSubscriptionsListResponse. + PageResponse() ProductSubscriptionsListResponse +} + +type productSubscriptionsListPager struct { + client *ProductSubscriptionsClient + current ProductSubscriptionsListResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ProductSubscriptionsListResponse) (*azcore.Request, error) +} + +func (p *productSubscriptionsListPager) Err() error { + return p.err +} + +func (p *productSubscriptionsListPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.SubscriptionCollection.NextLink == nil || len(*p.current.SubscriptionCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *productSubscriptionsListPager) PageResponse() ProductSubscriptionsListResponse { + return p.current +} + +type RegionListByServicePager interface { + azcore.Pager + // PageResponse returns the current RegionListByServiceResponse. + PageResponse() RegionListByServiceResponse +} + +type regionListByServicePager struct { + client *RegionClient + current RegionListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, RegionListByServiceResponse) (*azcore.Request, error) +} + +func (p *regionListByServicePager) Err() error { + return p.err +} + +func (p *regionListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.RegionListResult.NextLink == nil || len(*p.current.RegionListResult.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *regionListByServicePager) PageResponse() RegionListByServiceResponse { + return p.current +} + +type ReportsListByAPIPager interface { + azcore.Pager + // PageResponse returns the current ReportsListByAPIResponse. + PageResponse() ReportsListByAPIResponse +} + +type reportsListByAPIPager struct { + client *ReportsClient + current ReportsListByAPIResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ReportsListByAPIResponse) (*azcore.Request, error) +} + +func (p *reportsListByAPIPager) Err() error { + return p.err +} + +func (p *reportsListByAPIPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ReportCollection.NextLink == nil || len(*p.current.ReportCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByAPIHandleError(resp) + return false + } + result, err := p.client.listByAPIHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *reportsListByAPIPager) PageResponse() ReportsListByAPIResponse { + return p.current +} + +type ReportsListByGeoPager interface { + azcore.Pager + // PageResponse returns the current ReportsListByGeoResponse. + PageResponse() ReportsListByGeoResponse +} + +type reportsListByGeoPager struct { + client *ReportsClient + current ReportsListByGeoResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ReportsListByGeoResponse) (*azcore.Request, error) +} + +func (p *reportsListByGeoPager) Err() error { + return p.err +} + +func (p *reportsListByGeoPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ReportCollection.NextLink == nil || len(*p.current.ReportCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByGeoHandleError(resp) + return false + } + result, err := p.client.listByGeoHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *reportsListByGeoPager) PageResponse() ReportsListByGeoResponse { + return p.current +} + +type ReportsListByOperationPager interface { + azcore.Pager + // PageResponse returns the current ReportsListByOperationResponse. + PageResponse() ReportsListByOperationResponse +} + +type reportsListByOperationPager struct { + client *ReportsClient + current ReportsListByOperationResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ReportsListByOperationResponse) (*azcore.Request, error) +} + +func (p *reportsListByOperationPager) Err() error { + return p.err +} + +func (p *reportsListByOperationPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ReportCollection.NextLink == nil || len(*p.current.ReportCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByOperationHandleError(resp) + return false + } + result, err := p.client.listByOperationHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *reportsListByOperationPager) PageResponse() ReportsListByOperationResponse { + return p.current +} + +type ReportsListByProductPager interface { + azcore.Pager + // PageResponse returns the current ReportsListByProductResponse. + PageResponse() ReportsListByProductResponse +} + +type reportsListByProductPager struct { + client *ReportsClient + current ReportsListByProductResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ReportsListByProductResponse) (*azcore.Request, error) +} + +func (p *reportsListByProductPager) Err() error { + return p.err +} + +func (p *reportsListByProductPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ReportCollection.NextLink == nil || len(*p.current.ReportCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByProductHandleError(resp) + return false + } + result, err := p.client.listByProductHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *reportsListByProductPager) PageResponse() ReportsListByProductResponse { + return p.current +} + +type ReportsListBySubscriptionPager interface { + azcore.Pager + // PageResponse returns the current ReportsListBySubscriptionResponse. + PageResponse() ReportsListBySubscriptionResponse +} + +type reportsListBySubscriptionPager struct { + client *ReportsClient + current ReportsListBySubscriptionResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ReportsListBySubscriptionResponse) (*azcore.Request, error) +} + +func (p *reportsListBySubscriptionPager) Err() error { + return p.err +} + +func (p *reportsListBySubscriptionPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ReportCollection.NextLink == nil || len(*p.current.ReportCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listBySubscriptionHandleError(resp) + return false + } + result, err := p.client.listBySubscriptionHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *reportsListBySubscriptionPager) PageResponse() ReportsListBySubscriptionResponse { + return p.current +} + +type ReportsListByTimePager interface { + azcore.Pager + // PageResponse returns the current ReportsListByTimeResponse. + PageResponse() ReportsListByTimeResponse +} + +type reportsListByTimePager struct { + client *ReportsClient + current ReportsListByTimeResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ReportsListByTimeResponse) (*azcore.Request, error) +} + +func (p *reportsListByTimePager) Err() error { + return p.err +} + +func (p *reportsListByTimePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ReportCollection.NextLink == nil || len(*p.current.ReportCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByTimeHandleError(resp) + return false + } + result, err := p.client.listByTimeHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *reportsListByTimePager) PageResponse() ReportsListByTimeResponse { + return p.current +} + +type ReportsListByUserPager interface { + azcore.Pager + // PageResponse returns the current ReportsListByUserResponse. + PageResponse() ReportsListByUserResponse +} + +type reportsListByUserPager struct { + client *ReportsClient + current ReportsListByUserResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, ReportsListByUserResponse) (*azcore.Request, error) +} + +func (p *reportsListByUserPager) Err() error { + return p.err +} + +func (p *reportsListByUserPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.ReportCollection.NextLink == nil || len(*p.current.ReportCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByUserHandleError(resp) + return false + } + result, err := p.client.listByUserHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *reportsListByUserPager) PageResponse() ReportsListByUserResponse { + return p.current +} + +type SubscriptionListPager interface { + azcore.Pager + // PageResponse returns the current SubscriptionListResponse. + PageResponse() SubscriptionListResponse +} + +type subscriptionListPager struct { + client *SubscriptionClient + current SubscriptionListResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, SubscriptionListResponse) (*azcore.Request, error) +} + +func (p *subscriptionListPager) Err() error { + return p.err +} + +func (p *subscriptionListPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.SubscriptionCollection.NextLink == nil || len(*p.current.SubscriptionCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *subscriptionListPager) PageResponse() SubscriptionListResponse { + return p.current +} + +type TagListByAPIPager interface { + azcore.Pager + // PageResponse returns the current TagListByAPIResponse. + PageResponse() TagListByAPIResponse +} + +type tagListByAPIPager struct { + client *TagClient + current TagListByAPIResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, TagListByAPIResponse) (*azcore.Request, error) +} + +func (p *tagListByAPIPager) Err() error { + return p.err +} + +func (p *tagListByAPIPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.TagCollection.NextLink == nil || len(*p.current.TagCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByAPIHandleError(resp) + return false + } + result, err := p.client.listByAPIHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *tagListByAPIPager) PageResponse() TagListByAPIResponse { + return p.current +} + +type TagListByOperationPager interface { + azcore.Pager + // PageResponse returns the current TagListByOperationResponse. + PageResponse() TagListByOperationResponse +} + +type tagListByOperationPager struct { + client *TagClient + current TagListByOperationResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, TagListByOperationResponse) (*azcore.Request, error) +} + +func (p *tagListByOperationPager) Err() error { + return p.err +} + +func (p *tagListByOperationPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.TagCollection.NextLink == nil || len(*p.current.TagCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByOperationHandleError(resp) + return false + } + result, err := p.client.listByOperationHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *tagListByOperationPager) PageResponse() TagListByOperationResponse { + return p.current +} + +type TagListByProductPager interface { + azcore.Pager + // PageResponse returns the current TagListByProductResponse. + PageResponse() TagListByProductResponse +} + +type tagListByProductPager struct { + client *TagClient + current TagListByProductResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, TagListByProductResponse) (*azcore.Request, error) +} + +func (p *tagListByProductPager) Err() error { + return p.err +} + +func (p *tagListByProductPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.TagCollection.NextLink == nil || len(*p.current.TagCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByProductHandleError(resp) + return false + } + result, err := p.client.listByProductHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *tagListByProductPager) PageResponse() TagListByProductResponse { + return p.current +} + +type TagListByServicePager interface { + azcore.Pager + // PageResponse returns the current TagListByServiceResponse. + PageResponse() TagListByServiceResponse +} + +type tagListByServicePager struct { + client *TagClient + current TagListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, TagListByServiceResponse) (*azcore.Request, error) +} + +func (p *tagListByServicePager) Err() error { + return p.err +} + +func (p *tagListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.TagCollection.NextLink == nil || len(*p.current.TagCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *tagListByServicePager) PageResponse() TagListByServiceResponse { + return p.current +} + +type TagResourceListByServicePager interface { + azcore.Pager + // PageResponse returns the current TagResourceListByServiceResponse. + PageResponse() TagResourceListByServiceResponse +} + +type tagResourceListByServicePager struct { + client *TagResourceClient + current TagResourceListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, TagResourceListByServiceResponse) (*azcore.Request, error) +} + +func (p *tagResourceListByServicePager) Err() error { + return p.err +} + +func (p *tagResourceListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.TagResourceCollection.NextLink == nil || len(*p.current.TagResourceCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *tagResourceListByServicePager) PageResponse() TagResourceListByServiceResponse { + return p.current +} + +type TenantAccessListByServicePager interface { + azcore.Pager + // PageResponse returns the current TenantAccessListByServiceResponse. + PageResponse() TenantAccessListByServiceResponse +} + +type tenantAccessListByServicePager struct { + client *TenantAccessClient + current TenantAccessListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, TenantAccessListByServiceResponse) (*azcore.Request, error) +} + +func (p *tenantAccessListByServicePager) Err() error { + return p.err +} + +func (p *tenantAccessListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.AccessInformationCollection.NextLink == nil || len(*p.current.AccessInformationCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *tenantAccessListByServicePager) PageResponse() TenantAccessListByServiceResponse { + return p.current +} + +type TenantSettingsListByServicePager interface { + azcore.Pager + // PageResponse returns the current TenantSettingsListByServiceResponse. + PageResponse() TenantSettingsListByServiceResponse +} + +type tenantSettingsListByServicePager struct { + client *TenantSettingsClient + current TenantSettingsListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, TenantSettingsListByServiceResponse) (*azcore.Request, error) +} + +func (p *tenantSettingsListByServicePager) Err() error { + return p.err +} + +func (p *tenantSettingsListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.TenantSettingsCollection.NextLink == nil || len(*p.current.TenantSettingsCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *tenantSettingsListByServicePager) PageResponse() TenantSettingsListByServiceResponse { + return p.current +} + +type UserGroupListPager interface { + azcore.Pager + // PageResponse returns the current UserGroupListResponse. + PageResponse() UserGroupListResponse +} + +type userGroupListPager struct { + client *UserGroupClient + current UserGroupListResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, UserGroupListResponse) (*azcore.Request, error) +} + +func (p *userGroupListPager) Err() error { + return p.err +} + +func (p *userGroupListPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.GroupCollection.NextLink == nil || len(*p.current.GroupCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *userGroupListPager) PageResponse() UserGroupListResponse { + return p.current +} + +type UserIdentitiesListPager interface { + azcore.Pager + // PageResponse returns the current UserIdentitiesListResponse. + PageResponse() UserIdentitiesListResponse +} + +type userIdentitiesListPager struct { + client *UserIdentitiesClient + current UserIdentitiesListResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, UserIdentitiesListResponse) (*azcore.Request, error) +} + +func (p *userIdentitiesListPager) Err() error { + return p.err +} + +func (p *userIdentitiesListPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.UserIdentityCollection.NextLink == nil || len(*p.current.UserIdentityCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *userIdentitiesListPager) PageResponse() UserIdentitiesListResponse { + return p.current +} + +type UserListByServicePager interface { + azcore.Pager + // PageResponse returns the current UserListByServiceResponse. + PageResponse() UserListByServiceResponse +} + +type userListByServicePager struct { + client *UserClient + current UserListByServiceResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, UserListByServiceResponse) (*azcore.Request, error) +} + +func (p *userListByServicePager) Err() error { + return p.err +} + +func (p *userListByServicePager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.UserCollection.NextLink == nil || len(*p.current.UserCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listByServiceHandleError(resp) + return false + } + result, err := p.client.listByServiceHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *userListByServicePager) PageResponse() UserListByServiceResponse { + return p.current +} + +type UserSubscriptionListPager interface { + azcore.Pager + // PageResponse returns the current UserSubscriptionListResponse. + PageResponse() UserSubscriptionListResponse +} + +type userSubscriptionListPager struct { + client *UserSubscriptionClient + current UserSubscriptionListResponse + err error + requester func(context.Context) (*azcore.Request, error) + advancer func(context.Context, UserSubscriptionListResponse) (*azcore.Request, error) +} + +func (p *userSubscriptionListPager) Err() error { + return p.err +} + +func (p *userSubscriptionListPager) NextPage(ctx context.Context) bool { + var req *azcore.Request + var err error + if !reflect.ValueOf(p.current).IsZero() { + if p.current.SubscriptionCollection.NextLink == nil || len(*p.current.SubscriptionCollection.NextLink) == 0 { + return false + } + req, err = p.advancer(ctx, p.current) + } else { + req, err = p.requester(ctx) + } + if err != nil { + p.err = err + return false + } + resp, err := p.client.con.Pipeline().Do(req) + if err != nil { + p.err = err + return false + } + if !resp.HasStatusCode(http.StatusOK) { + p.err = p.client.listHandleError(resp) + return false + } + result, err := p.client.listHandleResponse(resp) + if err != nil { + p.err = err + return false + } + p.current = result + return true +} + +func (p *userSubscriptionListPager) PageResponse() UserSubscriptionListResponse { + return p.current +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_policy_client.go b/sdk/apimanagement/armapimanagement/zz_generated_policy_client.go new file mode 100644 index 000000000000..167ced8772ae --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_policy_client.go @@ -0,0 +1,368 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// PolicyClient contains the methods for the Policy group. +// Don't use this type directly, use NewPolicyClient() instead. +type PolicyClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewPolicyClient creates a new instance of PolicyClient with the specified values. +func NewPolicyClient(con *armcore.Connection, subscriptionID string) *PolicyClient { + return &PolicyClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or updates the global policy configuration of the Api Management service. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PolicyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, policyID PolicyIDName, parameters PolicyContract, options *PolicyCreateOrUpdateOptions) (PolicyCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, policyID, parameters, options) + if err != nil { + return PolicyCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PolicyCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return PolicyCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PolicyClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, policyID PolicyIDName, parameters PolicyContract, options *PolicyCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *PolicyClient) createOrUpdateHandleResponse(resp *azcore.Response) (PolicyCreateOrUpdateResponse, error) { + result := PolicyCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.PolicyContract); err != nil { + return PolicyCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PolicyClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the global policy configuration of the Api Management Service. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PolicyClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, policyID PolicyIDName, ifMatch string, options *PolicyDeleteOptions) (PolicyDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, policyID, ifMatch, options) + if err != nil { + return PolicyDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PolicyDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return PolicyDeleteResponse{}, client.deleteHandleError(resp) + } + return PolicyDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *PolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, policyID PolicyIDName, ifMatch string, options *PolicyDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *PolicyClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Get the Global policy definition of the Api Management service. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PolicyClient) Get(ctx context.Context, resourceGroupName string, serviceName string, policyID PolicyIDName, options *PolicyGetOptions) (PolicyGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, policyID, options) + if err != nil { + return PolicyGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PolicyGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PolicyGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PolicyClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, policyID PolicyIDName, options *PolicyGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Format != nil { + reqQP.Set("format", string(*options.Format)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PolicyClient) getHandleResponse(resp *azcore.Response) (PolicyGetResponse, error) { + result := PolicyGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.PolicyContract); err != nil { + return PolicyGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PolicyClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the Global policy definition in the Api Management service. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PolicyClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, policyID PolicyIDName, options *PolicyGetEntityTagOptions) (PolicyGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, policyID, options) + if err != nil { + return PolicyGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PolicyGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *PolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, policyID PolicyIDName, options *PolicyGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *PolicyClient) getEntityTagHandleResponse(resp *azcore.Response) (PolicyGetEntityTagResponse, error) { + result := PolicyGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists all the Global Policy definitions of the Api Management service. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PolicyClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, options *PolicyListByServiceOptions) (PolicyListByServiceResponse, error) { + req, err := client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return PolicyListByServiceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PolicyListByServiceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PolicyListByServiceResponse{}, client.listByServiceHandleError(resp) + } + return client.listByServiceHandleResponse(resp) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *PolicyClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *PolicyListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policies" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *PolicyClient) listByServiceHandleResponse(resp *azcore.Response) (PolicyListByServiceResponse, error) { + result := PolicyListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.PolicyCollection); err != nil { + return PolicyListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *PolicyClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_policydescription_client.go b/sdk/apimanagement/armapimanagement/zz_generated_policydescription_client.go new file mode 100644 index 000000000000..e2a50071e97d --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_policydescription_client.go @@ -0,0 +1,100 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// PolicyDescriptionClient contains the methods for the PolicyDescription group. +// Don't use this type directly, use NewPolicyDescriptionClient() instead. +type PolicyDescriptionClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewPolicyDescriptionClient creates a new instance of PolicyDescriptionClient with the specified values. +func NewPolicyDescriptionClient(con *armcore.Connection, subscriptionID string) *PolicyDescriptionClient { + return &PolicyDescriptionClient{con: con, subscriptionID: subscriptionID} +} + +// ListByService - Lists all policy descriptions. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PolicyDescriptionClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, options *PolicyDescriptionListByServiceOptions) (PolicyDescriptionListByServiceResponse, error) { + req, err := client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return PolicyDescriptionListByServiceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PolicyDescriptionListByServiceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PolicyDescriptionListByServiceResponse{}, client.listByServiceHandleError(resp) + } + return client.listByServiceHandleResponse(resp) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *PolicyDescriptionClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *PolicyDescriptionListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/policyDescriptions" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Scope != nil { + reqQP.Set("scope", string(*options.Scope)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *PolicyDescriptionClient) listByServiceHandleResponse(resp *azcore.Response) (PolicyDescriptionListByServiceResponse, error) { + result := PolicyDescriptionListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.PolicyDescriptionCollection); err != nil { + return PolicyDescriptionListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *PolicyDescriptionClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_pollers.go b/sdk/apimanagement/armapimanagement/zz_generated_pollers.go new file mode 100644 index 000000000000..116eea274453 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_pollers.go @@ -0,0 +1,781 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "time" +) + +// APICreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type APICreateOrUpdatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final APICreateOrUpdateResponse will be returned. + FinalResponse(ctx context.Context) (APICreateOrUpdateResponse, error) +} + +type apiCreateOrUpdatePoller struct { + pt *armcore.LROPoller +} + +func (p *apiCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +func (p *apiCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *apiCreateOrUpdatePoller) FinalResponse(ctx context.Context) (APICreateOrUpdateResponse, error) { + respType := APICreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.APIContract) + if err != nil { + return APICreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *apiCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *apiCreateOrUpdatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (APICreateOrUpdateResponse, error) { + respType := APICreateOrUpdateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.APIContract) + if err != nil { + return APICreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// APIManagementServiceApplyNetworkConfigurationUpdatesPoller provides polling facilities until the operation reaches a terminal state. +type APIManagementServiceApplyNetworkConfigurationUpdatesPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final APIManagementServiceApplyNetworkConfigurationUpdatesResponse will be returned. + FinalResponse(ctx context.Context) (APIManagementServiceApplyNetworkConfigurationUpdatesResponse, error) +} + +type apiManagementServiceApplyNetworkConfigurationUpdatesPoller struct { + pt *armcore.LROPoller +} + +func (p *apiManagementServiceApplyNetworkConfigurationUpdatesPoller) Done() bool { + return p.pt.Done() +} + +func (p *apiManagementServiceApplyNetworkConfigurationUpdatesPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *apiManagementServiceApplyNetworkConfigurationUpdatesPoller) FinalResponse(ctx context.Context) (APIManagementServiceApplyNetworkConfigurationUpdatesResponse, error) { + respType := APIManagementServiceApplyNetworkConfigurationUpdatesResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.APIManagementServiceResource) + if err != nil { + return APIManagementServiceApplyNetworkConfigurationUpdatesResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *apiManagementServiceApplyNetworkConfigurationUpdatesPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *apiManagementServiceApplyNetworkConfigurationUpdatesPoller) pollUntilDone(ctx context.Context, freq time.Duration) (APIManagementServiceApplyNetworkConfigurationUpdatesResponse, error) { + respType := APIManagementServiceApplyNetworkConfigurationUpdatesResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.APIManagementServiceResource) + if err != nil { + return APIManagementServiceApplyNetworkConfigurationUpdatesResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// APIManagementServiceBackupPoller provides polling facilities until the operation reaches a terminal state. +type APIManagementServiceBackupPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final APIManagementServiceBackupResponse will be returned. + FinalResponse(ctx context.Context) (APIManagementServiceBackupResponse, error) +} + +type apiManagementServiceBackupPoller struct { + pt *armcore.LROPoller +} + +func (p *apiManagementServiceBackupPoller) Done() bool { + return p.pt.Done() +} + +func (p *apiManagementServiceBackupPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *apiManagementServiceBackupPoller) FinalResponse(ctx context.Context) (APIManagementServiceBackupResponse, error) { + respType := APIManagementServiceBackupResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.APIManagementServiceResource) + if err != nil { + return APIManagementServiceBackupResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *apiManagementServiceBackupPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *apiManagementServiceBackupPoller) pollUntilDone(ctx context.Context, freq time.Duration) (APIManagementServiceBackupResponse, error) { + respType := APIManagementServiceBackupResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.APIManagementServiceResource) + if err != nil { + return APIManagementServiceBackupResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// APIManagementServiceCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type APIManagementServiceCreateOrUpdatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final APIManagementServiceCreateOrUpdateResponse will be returned. + FinalResponse(ctx context.Context) (APIManagementServiceCreateOrUpdateResponse, error) +} + +type apiManagementServiceCreateOrUpdatePoller struct { + pt *armcore.LROPoller +} + +func (p *apiManagementServiceCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +func (p *apiManagementServiceCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *apiManagementServiceCreateOrUpdatePoller) FinalResponse(ctx context.Context) (APIManagementServiceCreateOrUpdateResponse, error) { + respType := APIManagementServiceCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.APIManagementServiceResource) + if err != nil { + return APIManagementServiceCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *apiManagementServiceCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *apiManagementServiceCreateOrUpdatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (APIManagementServiceCreateOrUpdateResponse, error) { + respType := APIManagementServiceCreateOrUpdateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.APIManagementServiceResource) + if err != nil { + return APIManagementServiceCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// APIManagementServiceDeletePoller provides polling facilities until the operation reaches a terminal state. +type APIManagementServiceDeletePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final APIManagementServiceDeleteResponse will be returned. + FinalResponse(ctx context.Context) (APIManagementServiceDeleteResponse, error) +} + +type apiManagementServiceDeletePoller struct { + pt *armcore.LROPoller +} + +func (p *apiManagementServiceDeletePoller) Done() bool { + return p.pt.Done() +} + +func (p *apiManagementServiceDeletePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *apiManagementServiceDeletePoller) FinalResponse(ctx context.Context) (APIManagementServiceDeleteResponse, error) { + respType := APIManagementServiceDeleteResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.APIManagementServiceResource) + if err != nil { + return APIManagementServiceDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *apiManagementServiceDeletePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *apiManagementServiceDeletePoller) pollUntilDone(ctx context.Context, freq time.Duration) (APIManagementServiceDeleteResponse, error) { + respType := APIManagementServiceDeleteResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.APIManagementServiceResource) + if err != nil { + return APIManagementServiceDeleteResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// APIManagementServiceRestorePoller provides polling facilities until the operation reaches a terminal state. +type APIManagementServiceRestorePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final APIManagementServiceRestoreResponse will be returned. + FinalResponse(ctx context.Context) (APIManagementServiceRestoreResponse, error) +} + +type apiManagementServiceRestorePoller struct { + pt *armcore.LROPoller +} + +func (p *apiManagementServiceRestorePoller) Done() bool { + return p.pt.Done() +} + +func (p *apiManagementServiceRestorePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *apiManagementServiceRestorePoller) FinalResponse(ctx context.Context) (APIManagementServiceRestoreResponse, error) { + respType := APIManagementServiceRestoreResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.APIManagementServiceResource) + if err != nil { + return APIManagementServiceRestoreResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *apiManagementServiceRestorePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *apiManagementServiceRestorePoller) pollUntilDone(ctx context.Context, freq time.Duration) (APIManagementServiceRestoreResponse, error) { + respType := APIManagementServiceRestoreResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.APIManagementServiceResource) + if err != nil { + return APIManagementServiceRestoreResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// APIManagementServiceUpdatePoller provides polling facilities until the operation reaches a terminal state. +type APIManagementServiceUpdatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final APIManagementServiceUpdateResponse will be returned. + FinalResponse(ctx context.Context) (APIManagementServiceUpdateResponse, error) +} + +type apiManagementServiceUpdatePoller struct { + pt *armcore.LROPoller +} + +func (p *apiManagementServiceUpdatePoller) Done() bool { + return p.pt.Done() +} + +func (p *apiManagementServiceUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *apiManagementServiceUpdatePoller) FinalResponse(ctx context.Context) (APIManagementServiceUpdateResponse, error) { + respType := APIManagementServiceUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.APIManagementServiceResource) + if err != nil { + return APIManagementServiceUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *apiManagementServiceUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *apiManagementServiceUpdatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (APIManagementServiceUpdateResponse, error) { + respType := APIManagementServiceUpdateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.APIManagementServiceResource) + if err != nil { + return APIManagementServiceUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// APISchemaCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type APISchemaCreateOrUpdatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final APISchemaCreateOrUpdateResponse will be returned. + FinalResponse(ctx context.Context) (APISchemaCreateOrUpdateResponse, error) +} + +type apiSchemaCreateOrUpdatePoller struct { + pt *armcore.LROPoller +} + +func (p *apiSchemaCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +func (p *apiSchemaCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *apiSchemaCreateOrUpdatePoller) FinalResponse(ctx context.Context) (APISchemaCreateOrUpdateResponse, error) { + respType := APISchemaCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.SchemaContract) + if err != nil { + return APISchemaCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *apiSchemaCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *apiSchemaCreateOrUpdatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (APISchemaCreateOrUpdateResponse, error) { + respType := APISchemaCreateOrUpdateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.SchemaContract) + if err != nil { + return APISchemaCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// DeletedServicesPurgePoller provides polling facilities until the operation reaches a terminal state. +type DeletedServicesPurgePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final DeletedServicesPurgeResponse will be returned. + FinalResponse(ctx context.Context) (DeletedServicesPurgeResponse, error) +} + +type deletedServicesPurgePoller struct { + pt *armcore.LROPoller +} + +func (p *deletedServicesPurgePoller) Done() bool { + return p.pt.Done() +} + +func (p *deletedServicesPurgePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *deletedServicesPurgePoller) FinalResponse(ctx context.Context) (DeletedServicesPurgeResponse, error) { + respType := DeletedServicesPurgeResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.DeletedServiceContract) + if err != nil { + return DeletedServicesPurgeResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *deletedServicesPurgePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *deletedServicesPurgePoller) pollUntilDone(ctx context.Context, freq time.Duration) (DeletedServicesPurgeResponse, error) { + respType := DeletedServicesPurgeResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.DeletedServiceContract) + if err != nil { + return DeletedServicesPurgeResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// NamedValueCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type NamedValueCreateOrUpdatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final NamedValueCreateOrUpdateResponse will be returned. + FinalResponse(ctx context.Context) (NamedValueCreateOrUpdateResponse, error) +} + +type namedValueCreateOrUpdatePoller struct { + pt *armcore.LROPoller +} + +func (p *namedValueCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +func (p *namedValueCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *namedValueCreateOrUpdatePoller) FinalResponse(ctx context.Context) (NamedValueCreateOrUpdateResponse, error) { + respType := NamedValueCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.NamedValueContract) + if err != nil { + return NamedValueCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *namedValueCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *namedValueCreateOrUpdatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (NamedValueCreateOrUpdateResponse, error) { + respType := NamedValueCreateOrUpdateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.NamedValueContract) + if err != nil { + return NamedValueCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// NamedValueRefreshSecretPoller provides polling facilities until the operation reaches a terminal state. +type NamedValueRefreshSecretPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final NamedValueRefreshSecretResponse will be returned. + FinalResponse(ctx context.Context) (NamedValueRefreshSecretResponse, error) +} + +type namedValueRefreshSecretPoller struct { + pt *armcore.LROPoller +} + +func (p *namedValueRefreshSecretPoller) Done() bool { + return p.pt.Done() +} + +func (p *namedValueRefreshSecretPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *namedValueRefreshSecretPoller) FinalResponse(ctx context.Context) (NamedValueRefreshSecretResponse, error) { + respType := NamedValueRefreshSecretResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.NamedValueContract) + if err != nil { + return NamedValueRefreshSecretResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *namedValueRefreshSecretPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *namedValueRefreshSecretPoller) pollUntilDone(ctx context.Context, freq time.Duration) (NamedValueRefreshSecretResponse, error) { + respType := NamedValueRefreshSecretResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.NamedValueContract) + if err != nil { + return NamedValueRefreshSecretResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// NamedValueUpdatePoller provides polling facilities until the operation reaches a terminal state. +type NamedValueUpdatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final NamedValueUpdateResponse will be returned. + FinalResponse(ctx context.Context) (NamedValueUpdateResponse, error) +} + +type namedValueUpdatePoller struct { + pt *armcore.LROPoller +} + +func (p *namedValueUpdatePoller) Done() bool { + return p.pt.Done() +} + +func (p *namedValueUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *namedValueUpdatePoller) FinalResponse(ctx context.Context) (NamedValueUpdateResponse, error) { + respType := NamedValueUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.NamedValueContract) + if err != nil { + return NamedValueUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *namedValueUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *namedValueUpdatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (NamedValueUpdateResponse, error) { + respType := NamedValueUpdateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.NamedValueContract) + if err != nil { + return NamedValueUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// PortalRevisionCreateOrUpdatePoller provides polling facilities until the operation reaches a terminal state. +type PortalRevisionCreateOrUpdatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final PortalRevisionCreateOrUpdateResponse will be returned. + FinalResponse(ctx context.Context) (PortalRevisionCreateOrUpdateResponse, error) +} + +type portalRevisionCreateOrUpdatePoller struct { + pt *armcore.LROPoller +} + +func (p *portalRevisionCreateOrUpdatePoller) Done() bool { + return p.pt.Done() +} + +func (p *portalRevisionCreateOrUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *portalRevisionCreateOrUpdatePoller) FinalResponse(ctx context.Context) (PortalRevisionCreateOrUpdateResponse, error) { + respType := PortalRevisionCreateOrUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.PortalRevisionContract) + if err != nil { + return PortalRevisionCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *portalRevisionCreateOrUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *portalRevisionCreateOrUpdatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (PortalRevisionCreateOrUpdateResponse, error) { + respType := PortalRevisionCreateOrUpdateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.PortalRevisionContract) + if err != nil { + return PortalRevisionCreateOrUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// PortalRevisionUpdatePoller provides polling facilities until the operation reaches a terminal state. +type PortalRevisionUpdatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final PortalRevisionUpdateResponse will be returned. + FinalResponse(ctx context.Context) (PortalRevisionUpdateResponse, error) +} + +type portalRevisionUpdatePoller struct { + pt *armcore.LROPoller +} + +func (p *portalRevisionUpdatePoller) Done() bool { + return p.pt.Done() +} + +func (p *portalRevisionUpdatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *portalRevisionUpdatePoller) FinalResponse(ctx context.Context) (PortalRevisionUpdateResponse, error) { + respType := PortalRevisionUpdateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.PortalRevisionContract) + if err != nil { + return PortalRevisionUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *portalRevisionUpdatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *portalRevisionUpdatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (PortalRevisionUpdateResponse, error) { + respType := PortalRevisionUpdateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.PortalRevisionContract) + if err != nil { + return PortalRevisionUpdateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// TenantConfigurationDeployPoller provides polling facilities until the operation reaches a terminal state. +type TenantConfigurationDeployPoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final TenantConfigurationDeployResponse will be returned. + FinalResponse(ctx context.Context) (TenantConfigurationDeployResponse, error) +} + +type tenantConfigurationDeployPoller struct { + pt *armcore.LROPoller +} + +func (p *tenantConfigurationDeployPoller) Done() bool { + return p.pt.Done() +} + +func (p *tenantConfigurationDeployPoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *tenantConfigurationDeployPoller) FinalResponse(ctx context.Context) (TenantConfigurationDeployResponse, error) { + respType := TenantConfigurationDeployResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.OperationResultContract) + if err != nil { + return TenantConfigurationDeployResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *tenantConfigurationDeployPoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *tenantConfigurationDeployPoller) pollUntilDone(ctx context.Context, freq time.Duration) (TenantConfigurationDeployResponse, error) { + respType := TenantConfigurationDeployResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.OperationResultContract) + if err != nil { + return TenantConfigurationDeployResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// TenantConfigurationSavePoller provides polling facilities until the operation reaches a terminal state. +type TenantConfigurationSavePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final TenantConfigurationSaveResponse will be returned. + FinalResponse(ctx context.Context) (TenantConfigurationSaveResponse, error) +} + +type tenantConfigurationSavePoller struct { + pt *armcore.LROPoller +} + +func (p *tenantConfigurationSavePoller) Done() bool { + return p.pt.Done() +} + +func (p *tenantConfigurationSavePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *tenantConfigurationSavePoller) FinalResponse(ctx context.Context) (TenantConfigurationSaveResponse, error) { + respType := TenantConfigurationSaveResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.OperationResultContract) + if err != nil { + return TenantConfigurationSaveResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *tenantConfigurationSavePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *tenantConfigurationSavePoller) pollUntilDone(ctx context.Context, freq time.Duration) (TenantConfigurationSaveResponse, error) { + respType := TenantConfigurationSaveResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.OperationResultContract) + if err != nil { + return TenantConfigurationSaveResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +// TenantConfigurationValidatePoller provides polling facilities until the operation reaches a terminal state. +type TenantConfigurationValidatePoller interface { + azcore.Poller + // FinalResponse performs a final GET to the service and returns the final response + // for the polling operation. If there is an error performing the final GET then an error is returned. + // If the final GET succeeded then the final TenantConfigurationValidateResponse will be returned. + FinalResponse(ctx context.Context) (TenantConfigurationValidateResponse, error) +} + +type tenantConfigurationValidatePoller struct { + pt *armcore.LROPoller +} + +func (p *tenantConfigurationValidatePoller) Done() bool { + return p.pt.Done() +} + +func (p *tenantConfigurationValidatePoller) Poll(ctx context.Context) (*http.Response, error) { + return p.pt.Poll(ctx) +} + +func (p *tenantConfigurationValidatePoller) FinalResponse(ctx context.Context) (TenantConfigurationValidateResponse, error) { + respType := TenantConfigurationValidateResponse{} + resp, err := p.pt.FinalResponse(ctx, &respType.OperationResultContract) + if err != nil { + return TenantConfigurationValidateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} + +func (p *tenantConfigurationValidatePoller) ResumeToken() (string, error) { + return p.pt.ResumeToken() +} + +func (p *tenantConfigurationValidatePoller) pollUntilDone(ctx context.Context, freq time.Duration) (TenantConfigurationValidateResponse, error) { + respType := TenantConfigurationValidateResponse{} + resp, err := p.pt.PollUntilDone(ctx, freq, &respType.OperationResultContract) + if err != nil { + return TenantConfigurationValidateResponse{}, err + } + respType.RawResponse = resp + return respType, nil +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_portalrevision_client.go b/sdk/apimanagement/armapimanagement/zz_generated_portalrevision_client.go new file mode 100644 index 000000000000..871eef5af593 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_portalrevision_client.go @@ -0,0 +1,456 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + +// PortalRevisionClient contains the methods for the PortalRevision group. +// Don't use this type directly, use NewPortalRevisionClient() instead. +type PortalRevisionClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewPortalRevisionClient creates a new instance of PortalRevisionClient with the specified values. +func NewPortalRevisionClient(con *armcore.Connection, subscriptionID string) *PortalRevisionClient { + return &PortalRevisionClient{con: con, subscriptionID: subscriptionID} +} + +// BeginCreateOrUpdate - Creates a new developer portal's revision by running the portal's publishing. The isCurrent property indicates if the revision +// is publicly accessible. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PortalRevisionClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters PortalRevisionContract, options *PortalRevisionBeginCreateOrUpdateOptions) (PortalRevisionCreateOrUpdatePollerResponse, error) { + resp, err := client.createOrUpdate(ctx, resourceGroupName, serviceName, portalRevisionID, parameters, options) + if err != nil { + return PortalRevisionCreateOrUpdatePollerResponse{}, err + } + result := PortalRevisionCreateOrUpdatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("PortalRevisionClient.CreateOrUpdate", "location", resp, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return PortalRevisionCreateOrUpdatePollerResponse{}, err + } + poller := &portalRevisionCreateOrUpdatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (PortalRevisionCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeCreateOrUpdate creates a new PortalRevisionCreateOrUpdatePoller from the specified resume token. +// token - The value must come from a previous call to PortalRevisionCreateOrUpdatePoller.ResumeToken(). +func (client *PortalRevisionClient) ResumeCreateOrUpdate(ctx context.Context, token string) (PortalRevisionCreateOrUpdatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("PortalRevisionClient.CreateOrUpdate", token, client.con.Pipeline(), client.createOrUpdateHandleError) + if err != nil { + return PortalRevisionCreateOrUpdatePollerResponse{}, err + } + poller := &portalRevisionCreateOrUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return PortalRevisionCreateOrUpdatePollerResponse{}, err + } + result := PortalRevisionCreateOrUpdatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (PortalRevisionCreateOrUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// CreateOrUpdate - Creates a new developer portal's revision by running the portal's publishing. The isCurrent property indicates if the revision is publicly +// accessible. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PortalRevisionClient) createOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters PortalRevisionContract, options *PortalRevisionBeginCreateOrUpdateOptions) (*azcore.Response, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, portalRevisionID, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusCreated, http.StatusAccepted) { + return nil, client.createOrUpdateHandleError(resp) + } + return resp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *PortalRevisionClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, parameters PortalRevisionContract, options *PortalRevisionBeginCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if portalRevisionID == "" { + return nil, errors.New("parameter portalRevisionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{portalRevisionId}", url.PathEscape(portalRevisionID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *PortalRevisionClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the developer portal's revision specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PortalRevisionClient) Get(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, options *PortalRevisionGetOptions) (PortalRevisionGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, portalRevisionID, options) + if err != nil { + return PortalRevisionGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PortalRevisionGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PortalRevisionGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *PortalRevisionClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, options *PortalRevisionGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if portalRevisionID == "" { + return nil, errors.New("parameter portalRevisionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{portalRevisionId}", url.PathEscape(portalRevisionID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *PortalRevisionClient) getHandleResponse(resp *azcore.Response) (PortalRevisionGetResponse, error) { + result := PortalRevisionGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.PortalRevisionContract); err != nil { + return PortalRevisionGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *PortalRevisionClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the developer portal revision specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PortalRevisionClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, options *PortalRevisionGetEntityTagOptions) (PortalRevisionGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, portalRevisionID, options) + if err != nil { + return PortalRevisionGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PortalRevisionGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *PortalRevisionClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, options *PortalRevisionGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if portalRevisionID == "" { + return nil, errors.New("parameter portalRevisionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{portalRevisionId}", url.PathEscape(portalRevisionID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *PortalRevisionClient) getEntityTagHandleResponse(resp *azcore.Response) (PortalRevisionGetEntityTagResponse, error) { + result := PortalRevisionGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists developer portal's revisions. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PortalRevisionClient) ListByService(resourceGroupName string, serviceName string, options *PortalRevisionListByServiceOptions) PortalRevisionListByServicePager { + return &portalRevisionListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp PortalRevisionListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.PortalRevisionCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *PortalRevisionClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *PortalRevisionListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *PortalRevisionClient) listByServiceHandleResponse(resp *azcore.Response) (PortalRevisionListByServiceResponse, error) { + result := PortalRevisionListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.PortalRevisionCollection); err != nil { + return PortalRevisionListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *PortalRevisionClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginUpdate - Updates the description of specified portal revision or makes it current. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PortalRevisionClient) BeginUpdate(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, ifMatch string, parameters PortalRevisionContract, options *PortalRevisionBeginUpdateOptions) (PortalRevisionUpdatePollerResponse, error) { + resp, err := client.update(ctx, resourceGroupName, serviceName, portalRevisionID, ifMatch, parameters, options) + if err != nil { + return PortalRevisionUpdatePollerResponse{}, err + } + result := PortalRevisionUpdatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("PortalRevisionClient.Update", "location", resp, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return PortalRevisionUpdatePollerResponse{}, err + } + poller := &portalRevisionUpdatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (PortalRevisionUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeUpdate creates a new PortalRevisionUpdatePoller from the specified resume token. +// token - The value must come from a previous call to PortalRevisionUpdatePoller.ResumeToken(). +func (client *PortalRevisionClient) ResumeUpdate(ctx context.Context, token string) (PortalRevisionUpdatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("PortalRevisionClient.Update", token, client.con.Pipeline(), client.updateHandleError) + if err != nil { + return PortalRevisionUpdatePollerResponse{}, err + } + poller := &portalRevisionUpdatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return PortalRevisionUpdatePollerResponse{}, err + } + result := PortalRevisionUpdatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (PortalRevisionUpdateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Update - Updates the description of specified portal revision or makes it current. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PortalRevisionClient) update(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, ifMatch string, parameters PortalRevisionContract, options *PortalRevisionBeginUpdateOptions) (*azcore.Response, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, portalRevisionID, ifMatch, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.updateHandleError(resp) + } + return resp, nil +} + +// updateCreateRequest creates the Update request. +func (client *PortalRevisionClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, portalRevisionID string, ifMatch string, parameters PortalRevisionContract, options *PortalRevisionBeginUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalRevisions/{portalRevisionId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if portalRevisionID == "" { + return nil, errors.New("parameter portalRevisionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{portalRevisionId}", url.PathEscape(portalRevisionID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleError handles the Update error response. +func (client *PortalRevisionClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_portalsettings_client.go b/sdk/apimanagement/armapimanagement/zz_generated_portalsettings_client.go new file mode 100644 index 000000000000..4b683e81043b --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_portalsettings_client.go @@ -0,0 +1,97 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// PortalSettingsClient contains the methods for the PortalSettings group. +// Don't use this type directly, use NewPortalSettingsClient() instead. +type PortalSettingsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewPortalSettingsClient creates a new instance of PortalSettingsClient with the specified values. +func NewPortalSettingsClient(con *armcore.Connection, subscriptionID string) *PortalSettingsClient { + return &PortalSettingsClient{con: con, subscriptionID: subscriptionID} +} + +// ListByService - Lists a collection of portalsettings defined within a service instance.. +// If the operation fails it returns the *ErrorResponse error type. +func (client *PortalSettingsClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, options *PortalSettingsListByServiceOptions) (PortalSettingsListByServiceResponse, error) { + req, err := client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return PortalSettingsListByServiceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return PortalSettingsListByServiceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return PortalSettingsListByServiceResponse{}, client.listByServiceHandleError(resp) + } + return client.listByServiceHandleResponse(resp) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *PortalSettingsClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *PortalSettingsListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *PortalSettingsClient) listByServiceHandleResponse(resp *azcore.Response) (PortalSettingsListByServiceResponse, error) { + result := PortalSettingsListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.PortalSettingsCollection); err != nil { + return PortalSettingsListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *PortalSettingsClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_product_client.go b/sdk/apimanagement/armapimanagement/zz_generated_product_client.go new file mode 100644 index 000000000000..2579ef54c34e --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_product_client.go @@ -0,0 +1,530 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// ProductClient contains the methods for the Product group. +// Don't use this type directly, use NewProductClient() instead. +type ProductClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewProductClient creates a new instance of ProductClient with the specified values. +func NewProductClient(con *armcore.Connection, subscriptionID string) *ProductClient { + return &ProductClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or Updates a product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, productID string, parameters ProductContract, options *ProductCreateOrUpdateOptions) (ProductCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, productID, parameters, options) + if err != nil { + return ProductCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return ProductCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ProductClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, parameters ProductContract, options *ProductCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ProductClient) createOrUpdateHandleResponse(resp *azcore.Response) (ProductCreateOrUpdateResponse, error) { + result := ProductCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.ProductContract); err != nil { + return ProductCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ProductClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Delete product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string, options *ProductDeleteOptions) (ProductDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, productID, ifMatch, options) + if err != nil { + return ProductDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return ProductDeleteResponse{}, client.deleteHandleError(resp) + } + return ProductDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ProductClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string, options *ProductDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.DeleteSubscriptions != nil { + reqQP.Set("deleteSubscriptions", strconv.FormatBool(*options.DeleteSubscriptions)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ProductClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the product specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductClient) Get(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductGetOptions) (ProductGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, productID, options) + if err != nil { + return ProductGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ProductGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ProductClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ProductClient) getHandleResponse(resp *azcore.Response) (ProductGetResponse, error) { + result := ProductGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.ProductContract); err != nil { + return ProductGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ProductClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the product specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductGetEntityTagOptions) (ProductGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, productID, options) + if err != nil { + return ProductGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *ProductClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *ProductClient) getEntityTagHandleResponse(resp *azcore.Response) (ProductGetEntityTagResponse, error) { + result := ProductGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Lists a collection of products in the specified service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductClient) ListByService(resourceGroupName string, serviceName string, options *ProductListByServiceOptions) ProductListByServicePager { + return &productListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp ProductListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ProductCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *ProductClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *ProductListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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.ExpandGroups != nil { + reqQP.Set("expandGroups", strconv.FormatBool(*options.ExpandGroups)) + } + if options != nil && options.Tags != nil { + reqQP.Set("tags", *options.Tags) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *ProductClient) listByServiceHandleResponse(resp *azcore.Response) (ProductListByServiceResponse, error) { + result := ProductListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ProductCollection); err != nil { + return ProductListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *ProductClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByTags - Lists a collection of products associated with tags. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductClient) ListByTags(resourceGroupName string, serviceName string, options *ProductListByTagsOptions) ProductListByTagsPager { + return &productListByTagsPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByTagsCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp ProductListByTagsResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.TagResourceCollection.NextLink) + }, + } +} + +// listByTagsCreateRequest creates the ListByTags request. +func (client *ProductClient) listByTagsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *ProductListByTagsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/productsByTags" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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.IncludeNotTaggedProducts != nil { + reqQP.Set("includeNotTaggedProducts", strconv.FormatBool(*options.IncludeNotTaggedProducts)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByTagsHandleResponse handles the ListByTags response. +func (client *ProductClient) listByTagsHandleResponse(resp *azcore.Response) (ProductListByTagsResponse, error) { + result := ProductListByTagsResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.TagResourceCollection); err != nil { + return ProductListByTagsResponse{}, err + } + return result, nil +} + +// listByTagsHandleError handles the ListByTags error response. +func (client *ProductClient) listByTagsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Update existing product details. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductClient) Update(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string, parameters ProductUpdateParameters, options *ProductUpdateOptions) (ProductUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, productID, ifMatch, parameters, options) + if err != nil { + return ProductUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ProductUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *ProductClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, ifMatch string, parameters ProductUpdateParameters, options *ProductUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *ProductClient) updateHandleResponse(resp *azcore.Response) (ProductUpdateResponse, error) { + result := ProductUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.ProductContract); err != nil { + return ProductUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *ProductClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_productapi_client.go b/sdk/apimanagement/armapimanagement/zz_generated_productapi_client.go new file mode 100644 index 000000000000..d425c327c5f8 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_productapi_client.go @@ -0,0 +1,300 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// ProductAPIClient contains the methods for the ProductAPI group. +// Don't use this type directly, use NewProductAPIClient() instead. +type ProductAPIClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewProductAPIClient creates a new instance of ProductAPIClient with the specified values. +func NewProductAPIClient(con *armcore.Connection, subscriptionID string) *ProductAPIClient { + return &ProductAPIClient{con: con, subscriptionID: subscriptionID} +} + +// CheckEntityExists - Checks that API entity specified by identifier is associated with the Product entity. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductAPIClient) CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiID string, options *ProductAPICheckEntityExistsOptions) (ProductAPICheckEntityExistsResponse, error) { + req, err := client.checkEntityExistsCreateRequest(ctx, resourceGroupName, serviceName, productID, apiID, options) + if err != nil { + return ProductAPICheckEntityExistsResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductAPICheckEntityExistsResponse{}, err + } + result := ProductAPICheckEntityExistsResponse{RawResponse: resp.Response} + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// checkEntityExistsCreateRequest creates the CheckEntityExists request. +func (client *ProductAPIClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiID string, options *ProductAPICheckEntityExistsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// CreateOrUpdate - Adds an API to the specified product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductAPIClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiID string, options *ProductAPICreateOrUpdateOptions) (ProductAPICreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, productID, apiID, options) + if err != nil { + return ProductAPICreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductAPICreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return ProductAPICreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ProductAPIClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiID string, options *ProductAPICreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ProductAPIClient) createOrUpdateHandleResponse(resp *azcore.Response) (ProductAPICreateOrUpdateResponse, error) { + result := ProductAPICreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APIContract); err != nil { + return ProductAPICreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ProductAPIClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified API from the specified product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductAPIClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiID string, options *ProductAPIDeleteOptions) (ProductAPIDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, productID, apiID, options) + if err != nil { + return ProductAPIDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductAPIDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return ProductAPIDeleteResponse{}, client.deleteHandleError(resp) + } + return ProductAPIDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ProductAPIClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, apiID string, options *ProductAPIDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis/{apiId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ProductAPIClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByProduct - Lists a collection of the APIs associated with a product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductAPIClient) ListByProduct(resourceGroupName string, serviceName string, productID string, options *ProductAPIListByProductOptions) ProductAPIListByProductPager { + return &productAPIListByProductPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, productID, options) + }, + advancer: func(ctx context.Context, resp ProductAPIListByProductResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.APICollection.NextLink) + }, + } +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *ProductAPIClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductAPIListByProductOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/apis" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *ProductAPIClient) listByProductHandleResponse(resp *azcore.Response) (ProductAPIListByProductResponse, error) { + result := ProductAPIListByProductResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.APICollection); err != nil { + return ProductAPIListByProductResponse{}, err + } + return result, nil +} + +// listByProductHandleError handles the ListByProduct error response. +func (client *ProductAPIClient) listByProductHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_productgroup_client.go b/sdk/apimanagement/armapimanagement/zz_generated_productgroup_client.go new file mode 100644 index 000000000000..bc91d7c1172b --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_productgroup_client.go @@ -0,0 +1,300 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// ProductGroupClient contains the methods for the ProductGroup group. +// Don't use this type directly, use NewProductGroupClient() instead. +type ProductGroupClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewProductGroupClient creates a new instance of ProductGroupClient with the specified values. +func NewProductGroupClient(con *armcore.Connection, subscriptionID string) *ProductGroupClient { + return &ProductGroupClient{con: con, subscriptionID: subscriptionID} +} + +// CheckEntityExists - Checks that Group entity specified by identifier is associated with the Product entity. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductGroupClient) CheckEntityExists(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string, options *ProductGroupCheckEntityExistsOptions) (ProductGroupCheckEntityExistsResponse, error) { + req, err := client.checkEntityExistsCreateRequest(ctx, resourceGroupName, serviceName, productID, groupID, options) + if err != nil { + return ProductGroupCheckEntityExistsResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductGroupCheckEntityExistsResponse{}, err + } + result := ProductGroupCheckEntityExistsResponse{RawResponse: resp.Response} + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// checkEntityExistsCreateRequest creates the CheckEntityExists request. +func (client *ProductGroupClient) checkEntityExistsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string, options *ProductGroupCheckEntityExistsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// CreateOrUpdate - Adds the association between the specified developer group with the specified product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductGroupClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string, options *ProductGroupCreateOrUpdateOptions) (ProductGroupCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, productID, groupID, options) + if err != nil { + return ProductGroupCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductGroupCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return ProductGroupCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ProductGroupClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string, options *ProductGroupCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ProductGroupClient) createOrUpdateHandleResponse(resp *azcore.Response) (ProductGroupCreateOrUpdateResponse, error) { + result := ProductGroupCreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.GroupContract); err != nil { + return ProductGroupCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ProductGroupClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the association between the specified group and product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductGroupClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string, options *ProductGroupDeleteOptions) (ProductGroupDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, productID, groupID, options) + if err != nil { + return ProductGroupDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductGroupDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return ProductGroupDeleteResponse{}, client.deleteHandleError(resp) + } + return ProductGroupDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ProductGroupClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, groupID string, options *ProductGroupDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups/{groupId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if groupID == "" { + return nil, errors.New("parameter groupID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{groupId}", url.PathEscape(groupID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ProductGroupClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByProduct - Lists the collection of developer groups associated with the specified product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductGroupClient) ListByProduct(resourceGroupName string, serviceName string, productID string, options *ProductGroupListByProductOptions) ProductGroupListByProductPager { + return &productGroupListByProductPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, productID, options) + }, + advancer: func(ctx context.Context, resp ProductGroupListByProductResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.GroupCollection.NextLink) + }, + } +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *ProductGroupClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductGroupListByProductOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/groups" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *ProductGroupClient) listByProductHandleResponse(resp *azcore.Response) (ProductGroupListByProductResponse, error) { + result := ProductGroupListByProductResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.GroupCollection); err != nil { + return ProductGroupListByProductResponse{}, err + } + return result, nil +} + +// listByProductHandleError handles the ListByProduct error response. +func (client *ProductGroupClient) listByProductHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_productpolicy_client.go b/sdk/apimanagement/armapimanagement/zz_generated_productpolicy_client.go new file mode 100644 index 000000000000..b34fac20e304 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_productpolicy_client.go @@ -0,0 +1,388 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// ProductPolicyClient contains the methods for the ProductPolicy group. +// Don't use this type directly, use NewProductPolicyClient() instead. +type ProductPolicyClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewProductPolicyClient creates a new instance of ProductPolicyClient with the specified values. +func NewProductPolicyClient(con *armcore.Connection, subscriptionID string) *ProductPolicyClient { + return &ProductPolicyClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or updates policy configuration for the Product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductPolicyClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, productID string, policyID PolicyIDName, parameters PolicyContract, options *ProductPolicyCreateOrUpdateOptions) (ProductPolicyCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, productID, policyID, parameters, options) + if err != nil { + return ProductPolicyCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductPolicyCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return ProductPolicyCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *ProductPolicyClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, policyID PolicyIDName, parameters PolicyContract, options *ProductPolicyCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *ProductPolicyClient) createOrUpdateHandleResponse(resp *azcore.Response) (ProductPolicyCreateOrUpdateResponse, error) { + result := ProductPolicyCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.PolicyContract); err != nil { + return ProductPolicyCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *ProductPolicyClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the policy configuration at the Product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductPolicyClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, productID string, policyID PolicyIDName, ifMatch string, options *ProductPolicyDeleteOptions) (ProductPolicyDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, productID, policyID, ifMatch, options) + if err != nil { + return ProductPolicyDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductPolicyDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return ProductPolicyDeleteResponse{}, client.deleteHandleError(resp) + } + return ProductPolicyDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *ProductPolicyClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, policyID PolicyIDName, ifMatch string, options *ProductPolicyDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *ProductPolicyClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Get the policy configuration at the Product level. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductPolicyClient) Get(ctx context.Context, resourceGroupName string, serviceName string, productID string, policyID PolicyIDName, options *ProductPolicyGetOptions) (ProductPolicyGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, productID, policyID, options) + if err != nil { + return ProductPolicyGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductPolicyGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ProductPolicyGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *ProductPolicyClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, policyID PolicyIDName, options *ProductPolicyGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Format != nil { + reqQP.Set("format", string(*options.Format)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *ProductPolicyClient) getHandleResponse(resp *azcore.Response) (ProductPolicyGetResponse, error) { + result := ProductPolicyGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.PolicyContract); err != nil { + return ProductPolicyGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *ProductPolicyClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Get the ETag of the policy configuration at the Product level. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductPolicyClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, productID string, policyID PolicyIDName, options *ProductPolicyGetEntityTagOptions) (ProductPolicyGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, productID, policyID, options) + if err != nil { + return ProductPolicyGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductPolicyGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *ProductPolicyClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, policyID PolicyIDName, options *ProductPolicyGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies/{policyId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if policyID == "" { + return nil, errors.New("parameter policyID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{policyId}", url.PathEscape(string(policyID))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *ProductPolicyClient) getEntityTagHandleResponse(resp *azcore.Response) (ProductPolicyGetEntityTagResponse, error) { + result := ProductPolicyGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByProduct - Get the policy configuration at the Product level. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductPolicyClient) ListByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductPolicyListByProductOptions) (ProductPolicyListByProductResponse, error) { + req, err := client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, productID, options) + if err != nil { + return ProductPolicyListByProductResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ProductPolicyListByProductResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ProductPolicyListByProductResponse{}, client.listByProductHandleError(resp) + } + return client.listByProductHandleResponse(resp) +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *ProductPolicyClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductPolicyListByProductOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/policies" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *ProductPolicyClient) listByProductHandleResponse(resp *azcore.Response) (ProductPolicyListByProductResponse, error) { + result := ProductPolicyListByProductResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.PolicyCollection); err != nil { + return ProductPolicyListByProductResponse{}, err + } + return result, nil +} + +// listByProductHandleError handles the ListByProduct error response. +func (client *ProductPolicyClient) listByProductHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_productsubscriptions_client.go b/sdk/apimanagement/armapimanagement/zz_generated_productsubscriptions_client.go new file mode 100644 index 000000000000..61229789de3d --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_productsubscriptions_client.go @@ -0,0 +1,108 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// ProductSubscriptionsClient contains the methods for the ProductSubscriptions group. +// Don't use this type directly, use NewProductSubscriptionsClient() instead. +type ProductSubscriptionsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewProductSubscriptionsClient creates a new instance of ProductSubscriptionsClient with the specified values. +func NewProductSubscriptionsClient(con *armcore.Connection, subscriptionID string) *ProductSubscriptionsClient { + return &ProductSubscriptionsClient{con: con, subscriptionID: subscriptionID} +} + +// List - Lists the collection of subscriptions to the specified product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ProductSubscriptionsClient) List(resourceGroupName string, serviceName string, productID string, options *ProductSubscriptionsListOptions) ProductSubscriptionsListPager { + return &productSubscriptionsListPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, serviceName, productID, options) + }, + advancer: func(ctx context.Context, resp ProductSubscriptionsListResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.SubscriptionCollection.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *ProductSubscriptionsClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *ProductSubscriptionsListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/subscriptions" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *ProductSubscriptionsClient) listHandleResponse(resp *azcore.Response) (ProductSubscriptionsListResponse, error) { + result := ProductSubscriptionsListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.SubscriptionCollection); err != nil { + return ProductSubscriptionsListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *ProductSubscriptionsClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_quotabycounterkeys_client.go b/sdk/apimanagement/armapimanagement/zz_generated_quotabycounterkeys_client.go new file mode 100644 index 000000000000..07b0c54e2a4b --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_quotabycounterkeys_client.go @@ -0,0 +1,173 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// QuotaByCounterKeysClient contains the methods for the QuotaByCounterKeys group. +// Don't use this type directly, use NewQuotaByCounterKeysClient() instead. +type QuotaByCounterKeysClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewQuotaByCounterKeysClient creates a new instance of QuotaByCounterKeysClient with the specified values. +func NewQuotaByCounterKeysClient(con *armcore.Connection, subscriptionID string) *QuotaByCounterKeysClient { + return &QuotaByCounterKeysClient{con: con, subscriptionID: subscriptionID} +} + +// ListByService - Lists a collection of current quota counter periods associated with the counter-key configured in the policy on the specified service +// instance. The api does not support paging yet. +// If the operation fails it returns the *ErrorResponse error type. +func (client *QuotaByCounterKeysClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, options *QuotaByCounterKeysListByServiceOptions) (QuotaByCounterKeysListByServiceResponse, error) { + req, err := client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, quotaCounterKey, options) + if err != nil { + return QuotaByCounterKeysListByServiceResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return QuotaByCounterKeysListByServiceResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return QuotaByCounterKeysListByServiceResponse{}, client.listByServiceHandleError(resp) + } + return client.listByServiceHandleResponse(resp) +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *QuotaByCounterKeysClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, options *QuotaByCounterKeysListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if quotaCounterKey == "" { + return nil, errors.New("parameter quotaCounterKey cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{quotaCounterKey}", url.PathEscape(quotaCounterKey)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *QuotaByCounterKeysClient) listByServiceHandleResponse(resp *azcore.Response) (QuotaByCounterKeysListByServiceResponse, error) { + result := QuotaByCounterKeysListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.QuotaCounterCollection); err != nil { + return QuotaByCounterKeysListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *QuotaByCounterKeysClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates all the quota counter values specified with the existing quota counter key to a value in the specified service instance. This should +// be used for reset of the quota counter values. +// If the operation fails it returns the *ErrorResponse error type. +func (client *QuotaByCounterKeysClient) Update(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, parameters QuotaCounterValueUpdateContract, options *QuotaByCounterKeysUpdateOptions) (QuotaByCounterKeysUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, quotaCounterKey, parameters, options) + if err != nil { + return QuotaByCounterKeysUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return QuotaByCounterKeysUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return QuotaByCounterKeysUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *QuotaByCounterKeysClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, parameters QuotaCounterValueUpdateContract, options *QuotaByCounterKeysUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if quotaCounterKey == "" { + return nil, errors.New("parameter quotaCounterKey cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{quotaCounterKey}", url.PathEscape(quotaCounterKey)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *QuotaByCounterKeysClient) updateHandleResponse(resp *azcore.Response) (QuotaByCounterKeysUpdateResponse, error) { + result := QuotaByCounterKeysUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.QuotaCounterCollection); err != nil { + return QuotaByCounterKeysUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *QuotaByCounterKeysClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_quotabyperiodkeys_client.go b/sdk/apimanagement/armapimanagement/zz_generated_quotabyperiodkeys_client.go new file mode 100644 index 000000000000..ac24794f0409 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_quotabyperiodkeys_client.go @@ -0,0 +1,179 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// QuotaByPeriodKeysClient contains the methods for the QuotaByPeriodKeys group. +// Don't use this type directly, use NewQuotaByPeriodKeysClient() instead. +type QuotaByPeriodKeysClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewQuotaByPeriodKeysClient creates a new instance of QuotaByPeriodKeysClient with the specified values. +func NewQuotaByPeriodKeysClient(con *armcore.Connection, subscriptionID string) *QuotaByPeriodKeysClient { + return &QuotaByPeriodKeysClient{con: con, subscriptionID: subscriptionID} +} + +// Get - Gets the value of the quota counter associated with the counter-key in the policy for the specific period in service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *QuotaByPeriodKeysClient) Get(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, quotaPeriodKey string, options *QuotaByPeriodKeysGetOptions) (QuotaByPeriodKeysGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, quotaCounterKey, quotaPeriodKey, options) + if err != nil { + return QuotaByPeriodKeysGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return QuotaByPeriodKeysGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return QuotaByPeriodKeysGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *QuotaByPeriodKeysClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, quotaPeriodKey string, options *QuotaByPeriodKeysGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if quotaCounterKey == "" { + return nil, errors.New("parameter quotaCounterKey cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{quotaCounterKey}", url.PathEscape(quotaCounterKey)) + if quotaPeriodKey == "" { + return nil, errors.New("parameter quotaPeriodKey cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{quotaPeriodKey}", url.PathEscape(quotaPeriodKey)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *QuotaByPeriodKeysClient) getHandleResponse(resp *azcore.Response) (QuotaByPeriodKeysGetResponse, error) { + result := QuotaByPeriodKeysGetResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.QuotaCounterContract); err != nil { + return QuotaByPeriodKeysGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *QuotaByPeriodKeysClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates an existing quota counter value in the specified service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *QuotaByPeriodKeysClient) Update(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, quotaPeriodKey string, parameters QuotaCounterValueUpdateContract, options *QuotaByPeriodKeysUpdateOptions) (QuotaByPeriodKeysUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, quotaCounterKey, quotaPeriodKey, parameters, options) + if err != nil { + return QuotaByPeriodKeysUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return QuotaByPeriodKeysUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return QuotaByPeriodKeysUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *QuotaByPeriodKeysClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, quotaCounterKey string, quotaPeriodKey string, parameters QuotaCounterValueUpdateContract, options *QuotaByPeriodKeysUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/quotas/{quotaCounterKey}/periods/{quotaPeriodKey}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if quotaCounterKey == "" { + return nil, errors.New("parameter quotaCounterKey cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{quotaCounterKey}", url.PathEscape(quotaCounterKey)) + if quotaPeriodKey == "" { + return nil, errors.New("parameter quotaPeriodKey cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{quotaPeriodKey}", url.PathEscape(quotaPeriodKey)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *QuotaByPeriodKeysClient) updateHandleResponse(resp *azcore.Response) (QuotaByPeriodKeysUpdateResponse, error) { + result := QuotaByPeriodKeysUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.QuotaCounterContract); err != nil { + return QuotaByPeriodKeysUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *QuotaByPeriodKeysClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_region_client.go b/sdk/apimanagement/armapimanagement/zz_generated_region_client.go new file mode 100644 index 000000000000..3eea5f785860 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_region_client.go @@ -0,0 +1,94 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// RegionClient contains the methods for the Region group. +// Don't use this type directly, use NewRegionClient() instead. +type RegionClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewRegionClient creates a new instance of RegionClient with the specified values. +func NewRegionClient(con *armcore.Connection, subscriptionID string) *RegionClient { + return &RegionClient{con: con, subscriptionID: subscriptionID} +} + +// ListByService - Lists all azure regions in which the service exists. +// If the operation fails it returns the *ErrorResponse error type. +func (client *RegionClient) ListByService(resourceGroupName string, serviceName string, options *RegionListByServiceOptions) RegionListByServicePager { + return ®ionListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp RegionListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.RegionListResult.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *RegionClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *RegionListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/regions" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *RegionClient) listByServiceHandleResponse(resp *azcore.Response) (RegionListByServiceResponse, error) { + result := RegionListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RegionListResult); err != nil { + return RegionListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *RegionClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_reports_client.go b/sdk/apimanagement/armapimanagement/zz_generated_reports_client.go new file mode 100644 index 000000000000..4897c3b8b69c --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_reports_client.go @@ -0,0 +1,614 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// ReportsClient contains the methods for the Reports group. +// Don't use this type directly, use NewReportsClient() instead. +type ReportsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewReportsClient creates a new instance of ReportsClient with the specified values. +func NewReportsClient(con *armcore.Connection, subscriptionID string) *ReportsClient { + return &ReportsClient{con: con, subscriptionID: subscriptionID} +} + +// ListByAPI - Lists report records by API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ReportsClient) ListByAPI(resourceGroupName string, serviceName string, filter string, options *ReportsListByAPIOptions) ReportsListByAPIPager { + return &reportsListByAPIPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByAPICreateRequest(ctx, resourceGroupName, serviceName, filter, options) + }, + advancer: func(ctx context.Context, resp ReportsListByAPIResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ReportCollection.NextLink) + }, + } +} + +// listByAPICreateRequest creates the ListByAPI request. +func (client *ReportsClient) listByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, filter string, options *ReportsListByAPIOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byApi" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("$filter", filter) + 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.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByAPIHandleResponse handles the ListByAPI response. +func (client *ReportsClient) listByAPIHandleResponse(resp *azcore.Response) (ReportsListByAPIResponse, error) { + result := ReportsListByAPIResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ReportCollection); err != nil { + return ReportsListByAPIResponse{}, err + } + return result, nil +} + +// listByAPIHandleError handles the ListByAPI error response. +func (client *ReportsClient) listByAPIHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByGeo - Lists report records by geography. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ReportsClient) ListByGeo(resourceGroupName string, serviceName string, filter string, options *ReportsListByGeoOptions) ReportsListByGeoPager { + return &reportsListByGeoPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByGeoCreateRequest(ctx, resourceGroupName, serviceName, filter, options) + }, + advancer: func(ctx context.Context, resp ReportsListByGeoResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ReportCollection.NextLink) + }, + } +} + +// listByGeoCreateRequest creates the ListByGeo request. +func (client *ReportsClient) listByGeoCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, filter string, options *ReportsListByGeoOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byGeo" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("$filter", filter) + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByGeoHandleResponse handles the ListByGeo response. +func (client *ReportsClient) listByGeoHandleResponse(resp *azcore.Response) (ReportsListByGeoResponse, error) { + result := ReportsListByGeoResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ReportCollection); err != nil { + return ReportsListByGeoResponse{}, err + } + return result, nil +} + +// listByGeoHandleError handles the ListByGeo error response. +func (client *ReportsClient) listByGeoHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByOperation - Lists report records by API Operations. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ReportsClient) ListByOperation(resourceGroupName string, serviceName string, filter string, options *ReportsListByOperationOptions) ReportsListByOperationPager { + return &reportsListByOperationPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByOperationCreateRequest(ctx, resourceGroupName, serviceName, filter, options) + }, + advancer: func(ctx context.Context, resp ReportsListByOperationResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ReportCollection.NextLink) + }, + } +} + +// listByOperationCreateRequest creates the ListByOperation request. +func (client *ReportsClient) listByOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, filter string, options *ReportsListByOperationOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byOperation" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("$filter", filter) + 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.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByOperationHandleResponse handles the ListByOperation response. +func (client *ReportsClient) listByOperationHandleResponse(resp *azcore.Response) (ReportsListByOperationResponse, error) { + result := ReportsListByOperationResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ReportCollection); err != nil { + return ReportsListByOperationResponse{}, err + } + return result, nil +} + +// listByOperationHandleError handles the ListByOperation error response. +func (client *ReportsClient) listByOperationHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByProduct - Lists report records by Product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ReportsClient) ListByProduct(resourceGroupName string, serviceName string, filter string, options *ReportsListByProductOptions) ReportsListByProductPager { + return &reportsListByProductPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, filter, options) + }, + advancer: func(ctx context.Context, resp ReportsListByProductResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ReportCollection.NextLink) + }, + } +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *ReportsClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, filter string, options *ReportsListByProductOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byProduct" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("$filter", filter) + 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.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *ReportsClient) listByProductHandleResponse(resp *azcore.Response) (ReportsListByProductResponse, error) { + result := ReportsListByProductResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ReportCollection); err != nil { + return ReportsListByProductResponse{}, err + } + return result, nil +} + +// listByProductHandleError handles the ListByProduct error response. +func (client *ReportsClient) listByProductHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByRequest - Lists report records by Request. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ReportsClient) ListByRequest(ctx context.Context, resourceGroupName string, serviceName string, filter string, options *ReportsListByRequestOptions) (ReportsListByRequestResponse, error) { + req, err := client.listByRequestCreateRequest(ctx, resourceGroupName, serviceName, filter, options) + if err != nil { + return ReportsListByRequestResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return ReportsListByRequestResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return ReportsListByRequestResponse{}, client.listByRequestHandleError(resp) + } + return client.listByRequestHandleResponse(resp) +} + +// listByRequestCreateRequest creates the ListByRequest request. +func (client *ReportsClient) listByRequestCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, filter string, options *ReportsListByRequestOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byRequest" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("$filter", filter) + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByRequestHandleResponse handles the ListByRequest response. +func (client *ReportsClient) listByRequestHandleResponse(resp *azcore.Response) (ReportsListByRequestResponse, error) { + result := ReportsListByRequestResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.RequestReportCollection); err != nil { + return ReportsListByRequestResponse{}, err + } + return result, nil +} + +// listByRequestHandleError handles the ListByRequest error response. +func (client *ReportsClient) listByRequestHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListBySubscription - Lists report records by subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ReportsClient) ListBySubscription(resourceGroupName string, serviceName string, filter string, options *ReportsListBySubscriptionOptions) ReportsListBySubscriptionPager { + return &reportsListBySubscriptionPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, resourceGroupName, serviceName, filter, options) + }, + advancer: func(ctx context.Context, resp ReportsListBySubscriptionResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ReportCollection.NextLink) + }, + } +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *ReportsClient) listBySubscriptionCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, filter string, options *ReportsListBySubscriptionOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/bySubscription" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("$filter", filter) + 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.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *ReportsClient) listBySubscriptionHandleResponse(resp *azcore.Response) (ReportsListBySubscriptionResponse, error) { + result := ReportsListBySubscriptionResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ReportCollection); err != nil { + return ReportsListBySubscriptionResponse{}, err + } + return result, nil +} + +// listBySubscriptionHandleError handles the ListBySubscription error response. +func (client *ReportsClient) listBySubscriptionHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByTime - Lists report records by Time. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ReportsClient) ListByTime(resourceGroupName string, serviceName string, filter string, interval string, options *ReportsListByTimeOptions) ReportsListByTimePager { + return &reportsListByTimePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByTimeCreateRequest(ctx, resourceGroupName, serviceName, filter, interval, options) + }, + advancer: func(ctx context.Context, resp ReportsListByTimeResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ReportCollection.NextLink) + }, + } +} + +// listByTimeCreateRequest creates the ListByTime request. +func (client *ReportsClient) listByTimeCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, filter string, interval string, options *ReportsListByTimeOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byTime" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("$filter", filter) + 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.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) + } + reqQP.Set("interval", interval) + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByTimeHandleResponse handles the ListByTime response. +func (client *ReportsClient) listByTimeHandleResponse(resp *azcore.Response) (ReportsListByTimeResponse, error) { + result := ReportsListByTimeResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ReportCollection); err != nil { + return ReportsListByTimeResponse{}, err + } + return result, nil +} + +// listByTimeHandleError handles the ListByTime error response. +func (client *ReportsClient) listByTimeHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByUser - Lists report records by User. +// If the operation fails it returns the *ErrorResponse error type. +func (client *ReportsClient) ListByUser(resourceGroupName string, serviceName string, filter string, options *ReportsListByUserOptions) ReportsListByUserPager { + return &reportsListByUserPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByUserCreateRequest(ctx, resourceGroupName, serviceName, filter, options) + }, + advancer: func(ctx context.Context, resp ReportsListByUserResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.ReportCollection.NextLink) + }, + } +} + +// listByUserCreateRequest creates the ListByUser request. +func (client *ReportsClient) listByUserCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, filter string, options *ReportsListByUserOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/reports/byUser" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("$filter", filter) + 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.Orderby != nil { + reqQP.Set("$orderby", *options.Orderby) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByUserHandleResponse handles the ListByUser response. +func (client *ReportsClient) listByUserHandleResponse(resp *azcore.Response) (ReportsListByUserResponse, error) { + result := ReportsListByUserResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.ReportCollection); err != nil { + return ReportsListByUserResponse{}, err + } + return result, nil +} + +// listByUserHandleError handles the ListByUser error response. +func (client *ReportsClient) listByUserHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_response_types.go b/sdk/apimanagement/armapimanagement/zz_generated_response_types.go new file mode 100644 index 000000000000..596392de3068 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_response_types.go @@ -0,0 +1,4246 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "net/http" + "time" +) + +// APICreateOrUpdatePollerResponse contains the response from method API.CreateOrUpdate. +type APICreateOrUpdatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (APICreateOrUpdateResponse, error) + + // Poller contains an initialized poller. + Poller APICreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APICreateOrUpdateResponse contains the response from method API.CreateOrUpdate. +type APICreateOrUpdateResponse struct { + APICreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APICreateOrUpdateResult contains the result from method API.CreateOrUpdate. +type APICreateOrUpdateResult struct { + APIContract +} + +// APIDeleteResponse contains the response from method API.Delete. +type APIDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIDiagnosticCreateOrUpdateResponse contains the response from method APIDiagnostic.CreateOrUpdate. +type APIDiagnosticCreateOrUpdateResponse struct { + APIDiagnosticCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIDiagnosticCreateOrUpdateResult contains the result from method APIDiagnostic.CreateOrUpdate. +type APIDiagnosticCreateOrUpdateResult struct { + DiagnosticContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIDiagnosticDeleteResponse contains the response from method APIDiagnostic.Delete. +type APIDiagnosticDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIDiagnosticGetEntityTagResponse contains the response from method APIDiagnostic.GetEntityTag. +type APIDiagnosticGetEntityTagResponse struct { + APIDiagnosticGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIDiagnosticGetEntityTagResult contains the result from method APIDiagnostic.GetEntityTag. +type APIDiagnosticGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// APIDiagnosticGetResponse contains the response from method APIDiagnostic.Get. +type APIDiagnosticGetResponse struct { + APIDiagnosticGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIDiagnosticGetResult contains the result from method APIDiagnostic.Get. +type APIDiagnosticGetResult struct { + DiagnosticContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIDiagnosticListByServiceResponse contains the response from method APIDiagnostic.ListByService. +type APIDiagnosticListByServiceResponse struct { + APIDiagnosticListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIDiagnosticListByServiceResult contains the result from method APIDiagnostic.ListByService. +type APIDiagnosticListByServiceResult struct { + DiagnosticCollection +} + +// APIDiagnosticUpdateResponse contains the response from method APIDiagnostic.Update. +type APIDiagnosticUpdateResponse struct { + APIDiagnosticUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIDiagnosticUpdateResult contains the result from method APIDiagnostic.Update. +type APIDiagnosticUpdateResult struct { + DiagnosticContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIExportGetResponse contains the response from method APIExport.Get. +type APIExportGetResponse struct { + APIExportGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIExportGetResult contains the result from method APIExport.Get. +type APIExportGetResult struct { + APIExportResult +} + +// APIGetEntityTagResponse contains the response from method API.GetEntityTag. +type APIGetEntityTagResponse struct { + APIGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIGetEntityTagResult contains the result from method API.GetEntityTag. +type APIGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// APIGetResponse contains the response from method API.Get. +type APIGetResponse struct { + APIGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIGetResult contains the result from method API.Get. +type APIGetResult struct { + APIContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIIssueAttachmentCreateOrUpdateResponse contains the response from method APIIssueAttachment.CreateOrUpdate. +type APIIssueAttachmentCreateOrUpdateResponse struct { + APIIssueAttachmentCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueAttachmentCreateOrUpdateResult contains the result from method APIIssueAttachment.CreateOrUpdate. +type APIIssueAttachmentCreateOrUpdateResult struct { + IssueAttachmentContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIIssueAttachmentDeleteResponse contains the response from method APIIssueAttachment.Delete. +type APIIssueAttachmentDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueAttachmentGetEntityTagResponse contains the response from method APIIssueAttachment.GetEntityTag. +type APIIssueAttachmentGetEntityTagResponse struct { + APIIssueAttachmentGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueAttachmentGetEntityTagResult contains the result from method APIIssueAttachment.GetEntityTag. +type APIIssueAttachmentGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// APIIssueAttachmentGetResponse contains the response from method APIIssueAttachment.Get. +type APIIssueAttachmentGetResponse struct { + APIIssueAttachmentGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueAttachmentGetResult contains the result from method APIIssueAttachment.Get. +type APIIssueAttachmentGetResult struct { + IssueAttachmentContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIIssueAttachmentListByServiceResponse contains the response from method APIIssueAttachment.ListByService. +type APIIssueAttachmentListByServiceResponse struct { + APIIssueAttachmentListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueAttachmentListByServiceResult contains the result from method APIIssueAttachment.ListByService. +type APIIssueAttachmentListByServiceResult struct { + IssueAttachmentCollection +} + +// APIIssueCommentCreateOrUpdateResponse contains the response from method APIIssueComment.CreateOrUpdate. +type APIIssueCommentCreateOrUpdateResponse struct { + APIIssueCommentCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueCommentCreateOrUpdateResult contains the result from method APIIssueComment.CreateOrUpdate. +type APIIssueCommentCreateOrUpdateResult struct { + IssueCommentContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIIssueCommentDeleteResponse contains the response from method APIIssueComment.Delete. +type APIIssueCommentDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueCommentGetEntityTagResponse contains the response from method APIIssueComment.GetEntityTag. +type APIIssueCommentGetEntityTagResponse struct { + APIIssueCommentGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueCommentGetEntityTagResult contains the result from method APIIssueComment.GetEntityTag. +type APIIssueCommentGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// APIIssueCommentGetResponse contains the response from method APIIssueComment.Get. +type APIIssueCommentGetResponse struct { + APIIssueCommentGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueCommentGetResult contains the result from method APIIssueComment.Get. +type APIIssueCommentGetResult struct { + IssueCommentContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIIssueCommentListByServiceResponse contains the response from method APIIssueComment.ListByService. +type APIIssueCommentListByServiceResponse struct { + APIIssueCommentListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueCommentListByServiceResult contains the result from method APIIssueComment.ListByService. +type APIIssueCommentListByServiceResult struct { + IssueCommentCollection +} + +// APIIssueCreateOrUpdateResponse contains the response from method APIIssue.CreateOrUpdate. +type APIIssueCreateOrUpdateResponse struct { + APIIssueCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueCreateOrUpdateResult contains the result from method APIIssue.CreateOrUpdate. +type APIIssueCreateOrUpdateResult struct { + IssueContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIIssueDeleteResponse contains the response from method APIIssue.Delete. +type APIIssueDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueGetEntityTagResponse contains the response from method APIIssue.GetEntityTag. +type APIIssueGetEntityTagResponse struct { + APIIssueGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueGetEntityTagResult contains the result from method APIIssue.GetEntityTag. +type APIIssueGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// APIIssueGetResponse contains the response from method APIIssue.Get. +type APIIssueGetResponse struct { + APIIssueGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueGetResult contains the result from method APIIssue.Get. +type APIIssueGetResult struct { + IssueContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIIssueListByServiceResponse contains the response from method APIIssue.ListByService. +type APIIssueListByServiceResponse struct { + APIIssueListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueListByServiceResult contains the result from method APIIssue.ListByService. +type APIIssueListByServiceResult struct { + IssueCollection +} + +// APIIssueUpdateResponse contains the response from method APIIssue.Update. +type APIIssueUpdateResponse struct { + APIIssueUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIIssueUpdateResult contains the result from method APIIssue.Update. +type APIIssueUpdateResult struct { + IssueContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIListByServiceResponse contains the response from method API.ListByService. +type APIListByServiceResponse struct { + APIListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIListByServiceResult contains the result from method API.ListByService. +type APIListByServiceResult struct { + APICollection +} + +// APIListByTagsResponse contains the response from method API.ListByTags. +type APIListByTagsResponse struct { + APIListByTagsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIListByTagsResult contains the result from method API.ListByTags. +type APIListByTagsResult struct { + TagResourceCollection +} + +// APIManagementOperationsListResponse contains the response from method APIManagementOperations.List. +type APIManagementOperationsListResponse struct { + APIManagementOperationsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementOperationsListResult contains the result from method APIManagementOperations.List. +type APIManagementOperationsListResult struct { + OperationListResult +} + +// APIManagementSKUsListResponse contains the response from method APIManagementSKUs.List. +type APIManagementSKUsListResponse struct { + APIManagementSKUsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementSKUsListResult contains the result from method APIManagementSKUs.List. +type APIManagementSKUsListResult struct { + APIManagementSKUsResult +} + +// APIManagementServiceApplyNetworkConfigurationUpdatesPollerResponse contains the response from method APIManagementService.ApplyNetworkConfigurationUpdates. +type APIManagementServiceApplyNetworkConfigurationUpdatesPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (APIManagementServiceApplyNetworkConfigurationUpdatesResponse, error) + + // Poller contains an initialized poller. + Poller APIManagementServiceApplyNetworkConfigurationUpdatesPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceApplyNetworkConfigurationUpdatesResponse contains the response from method APIManagementService.ApplyNetworkConfigurationUpdates. +type APIManagementServiceApplyNetworkConfigurationUpdatesResponse struct { + APIManagementServiceApplyNetworkConfigurationUpdatesResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceApplyNetworkConfigurationUpdatesResult contains the result from method APIManagementService.ApplyNetworkConfigurationUpdates. +type APIManagementServiceApplyNetworkConfigurationUpdatesResult struct { + APIManagementServiceResource +} + +// APIManagementServiceBackupPollerResponse contains the response from method APIManagementService.Backup. +type APIManagementServiceBackupPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (APIManagementServiceBackupResponse, error) + + // Poller contains an initialized poller. + Poller APIManagementServiceBackupPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceBackupResponse contains the response from method APIManagementService.Backup. +type APIManagementServiceBackupResponse struct { + APIManagementServiceBackupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceBackupResult contains the result from method APIManagementService.Backup. +type APIManagementServiceBackupResult struct { + APIManagementServiceResource +} + +// APIManagementServiceCheckNameAvailabilityResponse contains the response from method APIManagementService.CheckNameAvailability. +type APIManagementServiceCheckNameAvailabilityResponse struct { + APIManagementServiceCheckNameAvailabilityResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceCheckNameAvailabilityResult contains the result from method APIManagementService.CheckNameAvailability. +type APIManagementServiceCheckNameAvailabilityResult struct { + APIManagementServiceNameAvailabilityResult +} + +// APIManagementServiceCreateOrUpdatePollerResponse contains the response from method APIManagementService.CreateOrUpdate. +type APIManagementServiceCreateOrUpdatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (APIManagementServiceCreateOrUpdateResponse, error) + + // Poller contains an initialized poller. + Poller APIManagementServiceCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceCreateOrUpdateResponse contains the response from method APIManagementService.CreateOrUpdate. +type APIManagementServiceCreateOrUpdateResponse struct { + APIManagementServiceCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceCreateOrUpdateResult contains the result from method APIManagementService.CreateOrUpdate. +type APIManagementServiceCreateOrUpdateResult struct { + APIManagementServiceResource +} + +// APIManagementServiceDeletePollerResponse contains the response from method APIManagementService.Delete. +type APIManagementServiceDeletePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (APIManagementServiceDeleteResponse, error) + + // Poller contains an initialized poller. + Poller APIManagementServiceDeletePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceDeleteResponse contains the response from method APIManagementService.Delete. +type APIManagementServiceDeleteResponse struct { + APIManagementServiceDeleteResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceDeleteResult contains the result from method APIManagementService.Delete. +type APIManagementServiceDeleteResult struct { + APIManagementServiceResource +} + +// APIManagementServiceGetDomainOwnershipIdentifierResponse contains the response from method APIManagementService.GetDomainOwnershipIdentifier. +type APIManagementServiceGetDomainOwnershipIdentifierResponse struct { + APIManagementServiceGetDomainOwnershipIdentifierResultEnvelope + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceGetDomainOwnershipIdentifierResultEnvelope contains the result from method APIManagementService.GetDomainOwnershipIdentifier. +type APIManagementServiceGetDomainOwnershipIdentifierResultEnvelope struct { + APIManagementServiceGetDomainOwnershipIdentifierResult +} + +// APIManagementServiceGetResponse contains the response from method APIManagementService.Get. +type APIManagementServiceGetResponse struct { + APIManagementServiceGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceGetResult contains the result from method APIManagementService.Get. +type APIManagementServiceGetResult struct { + APIManagementServiceResource +} + +// APIManagementServiceGetSsoTokenResponse contains the response from method APIManagementService.GetSsoToken. +type APIManagementServiceGetSsoTokenResponse struct { + APIManagementServiceGetSsoTokenResultEnvelope + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceGetSsoTokenResultEnvelope contains the result from method APIManagementService.GetSsoToken. +type APIManagementServiceGetSsoTokenResultEnvelope struct { + APIManagementServiceGetSsoTokenResult +} + +// APIManagementServiceListByResourceGroupResponse contains the response from method APIManagementService.ListByResourceGroup. +type APIManagementServiceListByResourceGroupResponse struct { + APIManagementServiceListByResourceGroupResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceListByResourceGroupResult contains the result from method APIManagementService.ListByResourceGroup. +type APIManagementServiceListByResourceGroupResult struct { + APIManagementServiceListResult +} + +// APIManagementServiceListResponse contains the response from method APIManagementService.List. +type APIManagementServiceListResponse struct { + APIManagementServiceListResultEnvelope + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceListResultEnvelope contains the result from method APIManagementService.List. +type APIManagementServiceListResultEnvelope struct { + APIManagementServiceListResult +} + +// APIManagementServiceRestorePollerResponse contains the response from method APIManagementService.Restore. +type APIManagementServiceRestorePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (APIManagementServiceRestoreResponse, error) + + // Poller contains an initialized poller. + Poller APIManagementServiceRestorePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceRestoreResponse contains the response from method APIManagementService.Restore. +type APIManagementServiceRestoreResponse struct { + APIManagementServiceRestoreResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceRestoreResult contains the result from method APIManagementService.Restore. +type APIManagementServiceRestoreResult struct { + APIManagementServiceResource +} + +// APIManagementServiceSKUsListAvailableServiceSKUsResponse contains the response from method APIManagementServiceSKUs.ListAvailableServiceSKUs. +type APIManagementServiceSKUsListAvailableServiceSKUsResponse struct { + APIManagementServiceSKUsListAvailableServiceSKUsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceSKUsListAvailableServiceSKUsResult contains the result from method APIManagementServiceSKUs.ListAvailableServiceSKUs. +type APIManagementServiceSKUsListAvailableServiceSKUsResult struct { + ResourceSKUResults +} + +// APIManagementServiceUpdatePollerResponse contains the response from method APIManagementService.Update. +type APIManagementServiceUpdatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (APIManagementServiceUpdateResponse, error) + + // Poller contains an initialized poller. + Poller APIManagementServiceUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceUpdateResponse contains the response from method APIManagementService.Update. +type APIManagementServiceUpdateResponse struct { + APIManagementServiceUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIManagementServiceUpdateResult contains the result from method APIManagementService.Update. +type APIManagementServiceUpdateResult struct { + APIManagementServiceResource +} + +// APIOperationCreateOrUpdateResponse contains the response from method APIOperation.CreateOrUpdate. +type APIOperationCreateOrUpdateResponse struct { + APIOperationCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIOperationCreateOrUpdateResult contains the result from method APIOperation.CreateOrUpdate. +type APIOperationCreateOrUpdateResult struct { + OperationContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIOperationDeleteResponse contains the response from method APIOperation.Delete. +type APIOperationDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIOperationGetEntityTagResponse contains the response from method APIOperation.GetEntityTag. +type APIOperationGetEntityTagResponse struct { + APIOperationGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIOperationGetEntityTagResult contains the result from method APIOperation.GetEntityTag. +type APIOperationGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// APIOperationGetResponse contains the response from method APIOperation.Get. +type APIOperationGetResponse struct { + APIOperationGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIOperationGetResult contains the result from method APIOperation.Get. +type APIOperationGetResult struct { + OperationContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIOperationListByAPIResponse contains the response from method APIOperation.ListByAPI. +type APIOperationListByAPIResponse struct { + APIOperationListByAPIResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIOperationListByAPIResult contains the result from method APIOperation.ListByAPI. +type APIOperationListByAPIResult struct { + OperationCollection +} + +// APIOperationPolicyCreateOrUpdateResponse contains the response from method APIOperationPolicy.CreateOrUpdate. +type APIOperationPolicyCreateOrUpdateResponse struct { + APIOperationPolicyCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIOperationPolicyCreateOrUpdateResult contains the result from method APIOperationPolicy.CreateOrUpdate. +type APIOperationPolicyCreateOrUpdateResult struct { + PolicyContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIOperationPolicyDeleteResponse contains the response from method APIOperationPolicy.Delete. +type APIOperationPolicyDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIOperationPolicyGetEntityTagResponse contains the response from method APIOperationPolicy.GetEntityTag. +type APIOperationPolicyGetEntityTagResponse struct { + APIOperationPolicyGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIOperationPolicyGetEntityTagResult contains the result from method APIOperationPolicy.GetEntityTag. +type APIOperationPolicyGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// APIOperationPolicyGetResponse contains the response from method APIOperationPolicy.Get. +type APIOperationPolicyGetResponse struct { + APIOperationPolicyGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIOperationPolicyGetResult contains the result from method APIOperationPolicy.Get. +type APIOperationPolicyGetResult struct { + PolicyContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIOperationPolicyListByOperationResponse contains the response from method APIOperationPolicy.ListByOperation. +type APIOperationPolicyListByOperationResponse struct { + APIOperationPolicyListByOperationResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIOperationPolicyListByOperationResult contains the result from method APIOperationPolicy.ListByOperation. +type APIOperationPolicyListByOperationResult struct { + PolicyCollection +} + +// APIOperationUpdateResponse contains the response from method APIOperation.Update. +type APIOperationUpdateResponse struct { + APIOperationUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIOperationUpdateResult contains the result from method APIOperation.Update. +type APIOperationUpdateResult struct { + OperationContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIPolicyCreateOrUpdateResponse contains the response from method APIPolicy.CreateOrUpdate. +type APIPolicyCreateOrUpdateResponse struct { + APIPolicyCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIPolicyCreateOrUpdateResult contains the result from method APIPolicy.CreateOrUpdate. +type APIPolicyCreateOrUpdateResult struct { + PolicyContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIPolicyDeleteResponse contains the response from method APIPolicy.Delete. +type APIPolicyDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIPolicyGetEntityTagResponse contains the response from method APIPolicy.GetEntityTag. +type APIPolicyGetEntityTagResponse struct { + APIPolicyGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIPolicyGetEntityTagResult contains the result from method APIPolicy.GetEntityTag. +type APIPolicyGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// APIPolicyGetResponse contains the response from method APIPolicy.Get. +type APIPolicyGetResponse struct { + APIPolicyGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIPolicyGetResult contains the result from method APIPolicy.Get. +type APIPolicyGetResult struct { + PolicyContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIPolicyListByAPIResponse contains the response from method APIPolicy.ListByAPI. +type APIPolicyListByAPIResponse struct { + APIPolicyListByAPIResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIPolicyListByAPIResult contains the result from method APIPolicy.ListByAPI. +type APIPolicyListByAPIResult struct { + PolicyCollection +} + +// APIProductListByApisResponse contains the response from method APIProduct.ListByApis. +type APIProductListByApisResponse struct { + APIProductListByApisResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIProductListByApisResult contains the result from method APIProduct.ListByApis. +type APIProductListByApisResult struct { + ProductCollection +} + +// APIReleaseCreateOrUpdateResponse contains the response from method APIRelease.CreateOrUpdate. +type APIReleaseCreateOrUpdateResponse struct { + APIReleaseCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIReleaseCreateOrUpdateResult contains the result from method APIRelease.CreateOrUpdate. +type APIReleaseCreateOrUpdateResult struct { + APIReleaseContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIReleaseDeleteResponse contains the response from method APIRelease.Delete. +type APIReleaseDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIReleaseGetEntityTagResponse contains the response from method APIRelease.GetEntityTag. +type APIReleaseGetEntityTagResponse struct { + APIReleaseGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIReleaseGetEntityTagResult contains the result from method APIRelease.GetEntityTag. +type APIReleaseGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// APIReleaseGetResponse contains the response from method APIRelease.Get. +type APIReleaseGetResponse struct { + APIReleaseGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIReleaseGetResult contains the result from method APIRelease.Get. +type APIReleaseGetResult struct { + APIReleaseContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIReleaseListByServiceResponse contains the response from method APIRelease.ListByService. +type APIReleaseListByServiceResponse struct { + APIReleaseListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIReleaseListByServiceResult contains the result from method APIRelease.ListByService. +type APIReleaseListByServiceResult struct { + APIReleaseCollection +} + +// APIReleaseUpdateResponse contains the response from method APIRelease.Update. +type APIReleaseUpdateResponse struct { + APIReleaseUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIReleaseUpdateResult contains the result from method APIRelease.Update. +type APIReleaseUpdateResult struct { + APIReleaseContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIRevisionListByServiceResponse contains the response from method APIRevision.ListByService. +type APIRevisionListByServiceResponse struct { + APIRevisionListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIRevisionListByServiceResult contains the result from method APIRevision.ListByService. +type APIRevisionListByServiceResult struct { + APIRevisionCollection +} + +// APISchemaCreateOrUpdatePollerResponse contains the response from method APISchema.CreateOrUpdate. +type APISchemaCreateOrUpdatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (APISchemaCreateOrUpdateResponse, error) + + // Poller contains an initialized poller. + Poller APISchemaCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APISchemaCreateOrUpdateResponse contains the response from method APISchema.CreateOrUpdate. +type APISchemaCreateOrUpdateResponse struct { + APISchemaCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APISchemaCreateOrUpdateResult contains the result from method APISchema.CreateOrUpdate. +type APISchemaCreateOrUpdateResult struct { + SchemaContract +} + +// APISchemaDeleteResponse contains the response from method APISchema.Delete. +type APISchemaDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APISchemaGetEntityTagResponse contains the response from method APISchema.GetEntityTag. +type APISchemaGetEntityTagResponse struct { + APISchemaGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APISchemaGetEntityTagResult contains the result from method APISchema.GetEntityTag. +type APISchemaGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// APISchemaGetResponse contains the response from method APISchema.Get. +type APISchemaGetResponse struct { + APISchemaGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APISchemaGetResult contains the result from method APISchema.Get. +type APISchemaGetResult struct { + SchemaContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APISchemaListByAPIResponse contains the response from method APISchema.ListByAPI. +type APISchemaListByAPIResponse struct { + APISchemaListByAPIResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APISchemaListByAPIResult contains the result from method APISchema.ListByAPI. +type APISchemaListByAPIResult struct { + SchemaCollection +} + +// APITagDescriptionCreateOrUpdateResponse contains the response from method APITagDescription.CreateOrUpdate. +type APITagDescriptionCreateOrUpdateResponse struct { + APITagDescriptionCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APITagDescriptionCreateOrUpdateResult contains the result from method APITagDescription.CreateOrUpdate. +type APITagDescriptionCreateOrUpdateResult struct { + TagDescriptionContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APITagDescriptionDeleteResponse contains the response from method APITagDescription.Delete. +type APITagDescriptionDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APITagDescriptionGetEntityTagResponse contains the response from method APITagDescription.GetEntityTag. +type APITagDescriptionGetEntityTagResponse struct { + APITagDescriptionGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APITagDescriptionGetEntityTagResult contains the result from method APITagDescription.GetEntityTag. +type APITagDescriptionGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// APITagDescriptionGetResponse contains the response from method APITagDescription.Get. +type APITagDescriptionGetResponse struct { + APITagDescriptionGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APITagDescriptionGetResult contains the result from method APITagDescription.Get. +type APITagDescriptionGetResult struct { + TagDescriptionContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APITagDescriptionListByServiceResponse contains the response from method APITagDescription.ListByService. +type APITagDescriptionListByServiceResponse struct { + APITagDescriptionListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APITagDescriptionListByServiceResult contains the result from method APITagDescription.ListByService. +type APITagDescriptionListByServiceResult struct { + TagDescriptionCollection +} + +// APIUpdateResponse contains the response from method API.Update. +type APIUpdateResponse struct { + APIUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIUpdateResult contains the result from method API.Update. +type APIUpdateResult struct { + APIContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIVersionSetCreateOrUpdateResponse contains the response from method APIVersionSet.CreateOrUpdate. +type APIVersionSetCreateOrUpdateResponse struct { + APIVersionSetCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIVersionSetCreateOrUpdateResult contains the result from method APIVersionSet.CreateOrUpdate. +type APIVersionSetCreateOrUpdateResult struct { + APIVersionSetContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIVersionSetDeleteResponse contains the response from method APIVersionSet.Delete. +type APIVersionSetDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIVersionSetGetEntityTagResponse contains the response from method APIVersionSet.GetEntityTag. +type APIVersionSetGetEntityTagResponse struct { + APIVersionSetGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIVersionSetGetEntityTagResult contains the result from method APIVersionSet.GetEntityTag. +type APIVersionSetGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// APIVersionSetGetResponse contains the response from method APIVersionSet.Get. +type APIVersionSetGetResponse struct { + APIVersionSetGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIVersionSetGetResult contains the result from method APIVersionSet.Get. +type APIVersionSetGetResult struct { + APIVersionSetContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// APIVersionSetListByServiceResponse contains the response from method APIVersionSet.ListByService. +type APIVersionSetListByServiceResponse struct { + APIVersionSetListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIVersionSetListByServiceResult contains the result from method APIVersionSet.ListByService. +type APIVersionSetListByServiceResult struct { + APIVersionSetCollection +} + +// APIVersionSetUpdateResponse contains the response from method APIVersionSet.Update. +type APIVersionSetUpdateResponse struct { + APIVersionSetUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// APIVersionSetUpdateResult contains the result from method APIVersionSet.Update. +type APIVersionSetUpdateResult struct { + APIVersionSetContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// AuthorizationServerCreateOrUpdateResponse contains the response from method AuthorizationServer.CreateOrUpdate. +type AuthorizationServerCreateOrUpdateResponse struct { + AuthorizationServerCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AuthorizationServerCreateOrUpdateResult contains the result from method AuthorizationServer.CreateOrUpdate. +type AuthorizationServerCreateOrUpdateResult struct { + AuthorizationServerContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// AuthorizationServerDeleteResponse contains the response from method AuthorizationServer.Delete. +type AuthorizationServerDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AuthorizationServerGetEntityTagResponse contains the response from method AuthorizationServer.GetEntityTag. +type AuthorizationServerGetEntityTagResponse struct { + AuthorizationServerGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AuthorizationServerGetEntityTagResult contains the result from method AuthorizationServer.GetEntityTag. +type AuthorizationServerGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// AuthorizationServerGetResponse contains the response from method AuthorizationServer.Get. +type AuthorizationServerGetResponse struct { + AuthorizationServerGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AuthorizationServerGetResult contains the result from method AuthorizationServer.Get. +type AuthorizationServerGetResult struct { + AuthorizationServerContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// AuthorizationServerListByServiceResponse contains the response from method AuthorizationServer.ListByService. +type AuthorizationServerListByServiceResponse struct { + AuthorizationServerListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AuthorizationServerListByServiceResult contains the result from method AuthorizationServer.ListByService. +type AuthorizationServerListByServiceResult struct { + AuthorizationServerCollection +} + +// AuthorizationServerListSecretsResponse contains the response from method AuthorizationServer.ListSecrets. +type AuthorizationServerListSecretsResponse struct { + AuthorizationServerListSecretsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AuthorizationServerListSecretsResult contains the result from method AuthorizationServer.ListSecrets. +type AuthorizationServerListSecretsResult struct { + AuthorizationServerSecretsContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// AuthorizationServerUpdateResponse contains the response from method AuthorizationServer.Update. +type AuthorizationServerUpdateResponse struct { + AuthorizationServerUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// AuthorizationServerUpdateResult contains the result from method AuthorizationServer.Update. +type AuthorizationServerUpdateResult struct { + AuthorizationServerContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// BackendCreateOrUpdateResponse contains the response from method Backend.CreateOrUpdate. +type BackendCreateOrUpdateResponse struct { + BackendCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// BackendCreateOrUpdateResult contains the result from method Backend.CreateOrUpdate. +type BackendCreateOrUpdateResult struct { + BackendContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// BackendDeleteResponse contains the response from method Backend.Delete. +type BackendDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// BackendGetEntityTagResponse contains the response from method Backend.GetEntityTag. +type BackendGetEntityTagResponse struct { + BackendGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// BackendGetEntityTagResult contains the result from method Backend.GetEntityTag. +type BackendGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// BackendGetResponse contains the response from method Backend.Get. +type BackendGetResponse struct { + BackendGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// BackendGetResult contains the result from method Backend.Get. +type BackendGetResult struct { + BackendContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// BackendListByServiceResponse contains the response from method Backend.ListByService. +type BackendListByServiceResponse struct { + BackendListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// BackendListByServiceResult contains the result from method Backend.ListByService. +type BackendListByServiceResult struct { + BackendCollection +} + +// BackendReconnectResponse contains the response from method Backend.Reconnect. +type BackendReconnectResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// BackendUpdateResponse contains the response from method Backend.Update. +type BackendUpdateResponse struct { + BackendUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// BackendUpdateResult contains the result from method Backend.Update. +type BackendUpdateResult struct { + BackendContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// CacheCreateOrUpdateResponse contains the response from method Cache.CreateOrUpdate. +type CacheCreateOrUpdateResponse struct { + CacheCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CacheCreateOrUpdateResult contains the result from method Cache.CreateOrUpdate. +type CacheCreateOrUpdateResult struct { + CacheContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// CacheDeleteResponse contains the response from method Cache.Delete. +type CacheDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CacheGetEntityTagResponse contains the response from method Cache.GetEntityTag. +type CacheGetEntityTagResponse struct { + CacheGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CacheGetEntityTagResult contains the result from method Cache.GetEntityTag. +type CacheGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// CacheGetResponse contains the response from method Cache.Get. +type CacheGetResponse struct { + CacheGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CacheGetResult contains the result from method Cache.Get. +type CacheGetResult struct { + CacheContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// CacheListByServiceResponse contains the response from method Cache.ListByService. +type CacheListByServiceResponse struct { + CacheListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CacheListByServiceResult contains the result from method Cache.ListByService. +type CacheListByServiceResult struct { + CacheCollection +} + +// CacheUpdateResponse contains the response from method Cache.Update. +type CacheUpdateResponse struct { + CacheUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CacheUpdateResult contains the result from method Cache.Update. +type CacheUpdateResult struct { + CacheContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// CertificateCreateOrUpdateResponse contains the response from method Certificate.CreateOrUpdate. +type CertificateCreateOrUpdateResponse struct { + CertificateCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CertificateCreateOrUpdateResult contains the result from method Certificate.CreateOrUpdate. +type CertificateCreateOrUpdateResult struct { + CertificateContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// CertificateDeleteResponse contains the response from method Certificate.Delete. +type CertificateDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CertificateGetEntityTagResponse contains the response from method Certificate.GetEntityTag. +type CertificateGetEntityTagResponse struct { + CertificateGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CertificateGetEntityTagResult contains the result from method Certificate.GetEntityTag. +type CertificateGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// CertificateGetResponse contains the response from method Certificate.Get. +type CertificateGetResponse struct { + CertificateGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CertificateGetResult contains the result from method Certificate.Get. +type CertificateGetResult struct { + CertificateContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// CertificateListByServiceResponse contains the response from method Certificate.ListByService. +type CertificateListByServiceResponse struct { + CertificateListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CertificateListByServiceResult contains the result from method Certificate.ListByService. +type CertificateListByServiceResult struct { + CertificateCollection +} + +// CertificateRefreshSecretResponse contains the response from method Certificate.RefreshSecret. +type CertificateRefreshSecretResponse struct { + CertificateRefreshSecretResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// CertificateRefreshSecretResult contains the result from method Certificate.RefreshSecret. +type CertificateRefreshSecretResult struct { + CertificateContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// ContentItemCreateOrUpdateResponse contains the response from method ContentItem.CreateOrUpdate. +type ContentItemCreateOrUpdateResponse struct { + ContentItemCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContentItemCreateOrUpdateResult contains the result from method ContentItem.CreateOrUpdate. +type ContentItemCreateOrUpdateResult struct { + ContentItemContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// ContentItemDeleteResponse contains the response from method ContentItem.Delete. +type ContentItemDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContentItemGetEntityTagResponse contains the response from method ContentItem.GetEntityTag. +type ContentItemGetEntityTagResponse struct { + ContentItemGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContentItemGetEntityTagResult contains the result from method ContentItem.GetEntityTag. +type ContentItemGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// ContentItemGetResponse contains the response from method ContentItem.Get. +type ContentItemGetResponse struct { + ContentItemGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContentItemGetResult contains the result from method ContentItem.Get. +type ContentItemGetResult struct { + ContentItemContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// ContentItemListByServiceResponse contains the response from method ContentItem.ListByService. +type ContentItemListByServiceResponse struct { + ContentItemListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContentItemListByServiceResult contains the result from method ContentItem.ListByService. +type ContentItemListByServiceResult struct { + ContentItemCollection +} + +// ContentTypeCreateOrUpdateResponse contains the response from method ContentType.CreateOrUpdate. +type ContentTypeCreateOrUpdateResponse struct { + ContentTypeCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContentTypeCreateOrUpdateResult contains the result from method ContentType.CreateOrUpdate. +type ContentTypeCreateOrUpdateResult struct { + ContentTypeContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// ContentTypeDeleteResponse contains the response from method ContentType.Delete. +type ContentTypeDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContentTypeGetResponse contains the response from method ContentType.Get. +type ContentTypeGetResponse struct { + ContentTypeGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContentTypeGetResult contains the result from method ContentType.Get. +type ContentTypeGetResult struct { + ContentTypeContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// ContentTypeListByServiceResponse contains the response from method ContentType.ListByService. +type ContentTypeListByServiceResponse struct { + ContentTypeListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ContentTypeListByServiceResult contains the result from method ContentType.ListByService. +type ContentTypeListByServiceResult struct { + ContentTypeCollection +} + +// DelegationSettingsCreateOrUpdateResponse contains the response from method DelegationSettings.CreateOrUpdate. +type DelegationSettingsCreateOrUpdateResponse struct { + DelegationSettingsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DelegationSettingsCreateOrUpdateResult contains the result from method DelegationSettings.CreateOrUpdate. +type DelegationSettingsCreateOrUpdateResult struct { + PortalDelegationSettings +} + +// DelegationSettingsGetEntityTagResponse contains the response from method DelegationSettings.GetEntityTag. +type DelegationSettingsGetEntityTagResponse struct { + DelegationSettingsGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DelegationSettingsGetEntityTagResult contains the result from method DelegationSettings.GetEntityTag. +type DelegationSettingsGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// DelegationSettingsGetResponse contains the response from method DelegationSettings.Get. +type DelegationSettingsGetResponse struct { + DelegationSettingsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DelegationSettingsGetResult contains the result from method DelegationSettings.Get. +type DelegationSettingsGetResult struct { + PortalDelegationSettings + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// DelegationSettingsListSecretsResponse contains the response from method DelegationSettings.ListSecrets. +type DelegationSettingsListSecretsResponse struct { + DelegationSettingsListSecretsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DelegationSettingsListSecretsResult contains the result from method DelegationSettings.ListSecrets. +type DelegationSettingsListSecretsResult struct { + PortalSettingValidationKeyContract +} + +// DelegationSettingsUpdateResponse contains the response from method DelegationSettings.Update. +type DelegationSettingsUpdateResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DeletedServicesGetByNameResponse contains the response from method DeletedServices.GetByName. +type DeletedServicesGetByNameResponse struct { + DeletedServicesGetByNameResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DeletedServicesGetByNameResult contains the result from method DeletedServices.GetByName. +type DeletedServicesGetByNameResult struct { + DeletedServiceContract +} + +// DeletedServicesListBySubscriptionResponse contains the response from method DeletedServices.ListBySubscription. +type DeletedServicesListBySubscriptionResponse struct { + DeletedServicesListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DeletedServicesListBySubscriptionResult contains the result from method DeletedServices.ListBySubscription. +type DeletedServicesListBySubscriptionResult struct { + DeletedServicesCollection +} + +// DeletedServicesPurgePollerResponse contains the response from method DeletedServices.Purge. +type DeletedServicesPurgePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (DeletedServicesPurgeResponse, error) + + // Poller contains an initialized poller. + Poller DeletedServicesPurgePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DeletedServicesPurgeResponse contains the response from method DeletedServices.Purge. +type DeletedServicesPurgeResponse struct { + DeletedServicesPurgeResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DeletedServicesPurgeResult contains the result from method DeletedServices.Purge. +type DeletedServicesPurgeResult struct { + DeletedServiceContract +} + +// DiagnosticCreateOrUpdateResponse contains the response from method Diagnostic.CreateOrUpdate. +type DiagnosticCreateOrUpdateResponse struct { + DiagnosticCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DiagnosticCreateOrUpdateResult contains the result from method Diagnostic.CreateOrUpdate. +type DiagnosticCreateOrUpdateResult struct { + DiagnosticContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// DiagnosticDeleteResponse contains the response from method Diagnostic.Delete. +type DiagnosticDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DiagnosticGetEntityTagResponse contains the response from method Diagnostic.GetEntityTag. +type DiagnosticGetEntityTagResponse struct { + DiagnosticGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DiagnosticGetEntityTagResult contains the result from method Diagnostic.GetEntityTag. +type DiagnosticGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// DiagnosticGetResponse contains the response from method Diagnostic.Get. +type DiagnosticGetResponse struct { + DiagnosticGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DiagnosticGetResult contains the result from method Diagnostic.Get. +type DiagnosticGetResult struct { + DiagnosticContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// DiagnosticListByServiceResponse contains the response from method Diagnostic.ListByService. +type DiagnosticListByServiceResponse struct { + DiagnosticListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DiagnosticListByServiceResult contains the result from method Diagnostic.ListByService. +type DiagnosticListByServiceResult struct { + DiagnosticCollection +} + +// DiagnosticUpdateResponse contains the response from method Diagnostic.Update. +type DiagnosticUpdateResponse struct { + DiagnosticUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// DiagnosticUpdateResult contains the result from method Diagnostic.Update. +type DiagnosticUpdateResult struct { + DiagnosticContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// EmailTemplateCreateOrUpdateResponse contains the response from method EmailTemplate.CreateOrUpdate. +type EmailTemplateCreateOrUpdateResponse struct { + EmailTemplateCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EmailTemplateCreateOrUpdateResult contains the result from method EmailTemplate.CreateOrUpdate. +type EmailTemplateCreateOrUpdateResult struct { + EmailTemplateContract +} + +// EmailTemplateDeleteResponse contains the response from method EmailTemplate.Delete. +type EmailTemplateDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EmailTemplateGetEntityTagResponse contains the response from method EmailTemplate.GetEntityTag. +type EmailTemplateGetEntityTagResponse struct { + EmailTemplateGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EmailTemplateGetEntityTagResult contains the result from method EmailTemplate.GetEntityTag. +type EmailTemplateGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// EmailTemplateGetResponse contains the response from method EmailTemplate.Get. +type EmailTemplateGetResponse struct { + EmailTemplateGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EmailTemplateGetResult contains the result from method EmailTemplate.Get. +type EmailTemplateGetResult struct { + EmailTemplateContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// EmailTemplateListByServiceResponse contains the response from method EmailTemplate.ListByService. +type EmailTemplateListByServiceResponse struct { + EmailTemplateListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EmailTemplateListByServiceResult contains the result from method EmailTemplate.ListByService. +type EmailTemplateListByServiceResult struct { + EmailTemplateCollection +} + +// EmailTemplateUpdateResponse contains the response from method EmailTemplate.Update. +type EmailTemplateUpdateResponse struct { + EmailTemplateUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// EmailTemplateUpdateResult contains the result from method EmailTemplate.Update. +type EmailTemplateUpdateResult struct { + EmailTemplateContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// GatewayAPICreateOrUpdateResponse contains the response from method GatewayAPI.CreateOrUpdate. +type GatewayAPICreateOrUpdateResponse struct { + GatewayAPICreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayAPICreateOrUpdateResult contains the result from method GatewayAPI.CreateOrUpdate. +type GatewayAPICreateOrUpdateResult struct { + APIContract +} + +// GatewayAPIDeleteResponse contains the response from method GatewayAPI.Delete. +type GatewayAPIDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayAPIGetEntityTagResponse contains the response from method GatewayAPI.GetEntityTag. +type GatewayAPIGetEntityTagResponse struct { + GatewayAPIGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayAPIGetEntityTagResult contains the result from method GatewayAPI.GetEntityTag. +type GatewayAPIGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// GatewayAPIListByServiceResponse contains the response from method GatewayAPI.ListByService. +type GatewayAPIListByServiceResponse struct { + GatewayAPIListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayAPIListByServiceResult contains the result from method GatewayAPI.ListByService. +type GatewayAPIListByServiceResult struct { + APICollection +} + +// GatewayCertificateAuthorityCreateOrUpdateResponse contains the response from method GatewayCertificateAuthority.CreateOrUpdate. +type GatewayCertificateAuthorityCreateOrUpdateResponse struct { + GatewayCertificateAuthorityCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayCertificateAuthorityCreateOrUpdateResult contains the result from method GatewayCertificateAuthority.CreateOrUpdate. +type GatewayCertificateAuthorityCreateOrUpdateResult struct { + GatewayCertificateAuthorityContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// GatewayCertificateAuthorityDeleteResponse contains the response from method GatewayCertificateAuthority.Delete. +type GatewayCertificateAuthorityDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayCertificateAuthorityGetEntityTagResponse contains the response from method GatewayCertificateAuthority.GetEntityTag. +type GatewayCertificateAuthorityGetEntityTagResponse struct { + GatewayCertificateAuthorityGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayCertificateAuthorityGetEntityTagResult contains the result from method GatewayCertificateAuthority.GetEntityTag. +type GatewayCertificateAuthorityGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// GatewayCertificateAuthorityGetResponse contains the response from method GatewayCertificateAuthority.Get. +type GatewayCertificateAuthorityGetResponse struct { + GatewayCertificateAuthorityGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayCertificateAuthorityGetResult contains the result from method GatewayCertificateAuthority.Get. +type GatewayCertificateAuthorityGetResult struct { + GatewayCertificateAuthorityContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// GatewayCertificateAuthorityListByServiceResponse contains the response from method GatewayCertificateAuthority.ListByService. +type GatewayCertificateAuthorityListByServiceResponse struct { + GatewayCertificateAuthorityListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayCertificateAuthorityListByServiceResult contains the result from method GatewayCertificateAuthority.ListByService. +type GatewayCertificateAuthorityListByServiceResult struct { + GatewayCertificateAuthorityCollection +} + +// GatewayCreateOrUpdateResponse contains the response from method Gateway.CreateOrUpdate. +type GatewayCreateOrUpdateResponse struct { + GatewayCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayCreateOrUpdateResult contains the result from method Gateway.CreateOrUpdate. +type GatewayCreateOrUpdateResult struct { + GatewayContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// GatewayDeleteResponse contains the response from method Gateway.Delete. +type GatewayDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayGenerateTokenResponse contains the response from method Gateway.GenerateToken. +type GatewayGenerateTokenResponse struct { + GatewayGenerateTokenResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayGenerateTokenResult contains the result from method Gateway.GenerateToken. +type GatewayGenerateTokenResult struct { + GatewayTokenContract +} + +// GatewayGetEntityTagResponse contains the response from method Gateway.GetEntityTag. +type GatewayGetEntityTagResponse struct { + GatewayGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayGetEntityTagResult contains the result from method Gateway.GetEntityTag. +type GatewayGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// GatewayGetResponse contains the response from method Gateway.Get. +type GatewayGetResponse struct { + GatewayGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayGetResult contains the result from method Gateway.Get. +type GatewayGetResult struct { + GatewayContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// GatewayHostnameConfigurationCreateOrUpdateResponse contains the response from method GatewayHostnameConfiguration.CreateOrUpdate. +type GatewayHostnameConfigurationCreateOrUpdateResponse struct { + GatewayHostnameConfigurationCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayHostnameConfigurationCreateOrUpdateResult contains the result from method GatewayHostnameConfiguration.CreateOrUpdate. +type GatewayHostnameConfigurationCreateOrUpdateResult struct { + GatewayHostnameConfigurationContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// GatewayHostnameConfigurationDeleteResponse contains the response from method GatewayHostnameConfiguration.Delete. +type GatewayHostnameConfigurationDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayHostnameConfigurationGetEntityTagResponse contains the response from method GatewayHostnameConfiguration.GetEntityTag. +type GatewayHostnameConfigurationGetEntityTagResponse struct { + GatewayHostnameConfigurationGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayHostnameConfigurationGetEntityTagResult contains the result from method GatewayHostnameConfiguration.GetEntityTag. +type GatewayHostnameConfigurationGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// GatewayHostnameConfigurationGetResponse contains the response from method GatewayHostnameConfiguration.Get. +type GatewayHostnameConfigurationGetResponse struct { + GatewayHostnameConfigurationGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayHostnameConfigurationGetResult contains the result from method GatewayHostnameConfiguration.Get. +type GatewayHostnameConfigurationGetResult struct { + GatewayHostnameConfigurationContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// GatewayHostnameConfigurationListByServiceResponse contains the response from method GatewayHostnameConfiguration.ListByService. +type GatewayHostnameConfigurationListByServiceResponse struct { + GatewayHostnameConfigurationListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayHostnameConfigurationListByServiceResult contains the result from method GatewayHostnameConfiguration.ListByService. +type GatewayHostnameConfigurationListByServiceResult struct { + GatewayHostnameConfigurationCollection +} + +// GatewayListByServiceResponse contains the response from method Gateway.ListByService. +type GatewayListByServiceResponse struct { + GatewayListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayListByServiceResult contains the result from method Gateway.ListByService. +type GatewayListByServiceResult struct { + GatewayCollection +} + +// GatewayListKeysResponse contains the response from method Gateway.ListKeys. +type GatewayListKeysResponse struct { + GatewayListKeysResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayListKeysResult contains the result from method Gateway.ListKeys. +type GatewayListKeysResult struct { + GatewayKeysContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// GatewayRegenerateKeyResponse contains the response from method Gateway.RegenerateKey. +type GatewayRegenerateKeyResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayUpdateResponse contains the response from method Gateway.Update. +type GatewayUpdateResponse struct { + GatewayUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GatewayUpdateResult contains the result from method Gateway.Update. +type GatewayUpdateResult struct { + GatewayContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// GroupCreateOrUpdateResponse contains the response from method Group.CreateOrUpdate. +type GroupCreateOrUpdateResponse struct { + GroupCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GroupCreateOrUpdateResult contains the result from method Group.CreateOrUpdate. +type GroupCreateOrUpdateResult struct { + GroupContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// GroupDeleteResponse contains the response from method Group.Delete. +type GroupDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GroupGetEntityTagResponse contains the response from method Group.GetEntityTag. +type GroupGetEntityTagResponse struct { + GroupGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GroupGetEntityTagResult contains the result from method Group.GetEntityTag. +type GroupGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// GroupGetResponse contains the response from method Group.Get. +type GroupGetResponse struct { + GroupGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GroupGetResult contains the result from method Group.Get. +type GroupGetResult struct { + GroupContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// GroupListByServiceResponse contains the response from method Group.ListByService. +type GroupListByServiceResponse struct { + GroupListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GroupListByServiceResult contains the result from method Group.ListByService. +type GroupListByServiceResult struct { + GroupCollection +} + +// GroupUpdateResponse contains the response from method Group.Update. +type GroupUpdateResponse struct { + GroupUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GroupUpdateResult contains the result from method Group.Update. +type GroupUpdateResult struct { + GroupContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// GroupUserCheckEntityExistsResponse contains the response from method GroupUser.CheckEntityExists. +type GroupUserCheckEntityExistsResponse struct { + GroupUserCheckEntityExistsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GroupUserCheckEntityExistsResult contains the result from method GroupUser.CheckEntityExists. +type GroupUserCheckEntityExistsResult struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// GroupUserCreateResponse contains the response from method GroupUser.Create. +type GroupUserCreateResponse struct { + GroupUserCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GroupUserCreateResult contains the result from method GroupUser.Create. +type GroupUserCreateResult struct { + UserContract +} + +// GroupUserDeleteResponse contains the response from method GroupUser.Delete. +type GroupUserDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GroupUserListResponse contains the response from method GroupUser.List. +type GroupUserListResponse struct { + GroupUserListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// GroupUserListResult contains the result from method GroupUser.List. +type GroupUserListResult struct { + UserCollection +} + +// IdentityProviderCreateOrUpdateResponse contains the response from method IdentityProvider.CreateOrUpdate. +type IdentityProviderCreateOrUpdateResponse struct { + IdentityProviderCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// IdentityProviderCreateOrUpdateResult contains the result from method IdentityProvider.CreateOrUpdate. +type IdentityProviderCreateOrUpdateResult struct { + IdentityProviderContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// IdentityProviderDeleteResponse contains the response from method IdentityProvider.Delete. +type IdentityProviderDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// IdentityProviderGetEntityTagResponse contains the response from method IdentityProvider.GetEntityTag. +type IdentityProviderGetEntityTagResponse struct { + IdentityProviderGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// IdentityProviderGetEntityTagResult contains the result from method IdentityProvider.GetEntityTag. +type IdentityProviderGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// IdentityProviderGetResponse contains the response from method IdentityProvider.Get. +type IdentityProviderGetResponse struct { + IdentityProviderGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// IdentityProviderGetResult contains the result from method IdentityProvider.Get. +type IdentityProviderGetResult struct { + IdentityProviderContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// IdentityProviderListByServiceResponse contains the response from method IdentityProvider.ListByService. +type IdentityProviderListByServiceResponse struct { + IdentityProviderListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// IdentityProviderListByServiceResult contains the result from method IdentityProvider.ListByService. +type IdentityProviderListByServiceResult struct { + IdentityProviderList +} + +// IdentityProviderListSecretsResponse contains the response from method IdentityProvider.ListSecrets. +type IdentityProviderListSecretsResponse struct { + IdentityProviderListSecretsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// IdentityProviderListSecretsResult contains the result from method IdentityProvider.ListSecrets. +type IdentityProviderListSecretsResult struct { + ClientSecretContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// IdentityProviderUpdateResponse contains the response from method IdentityProvider.Update. +type IdentityProviderUpdateResponse struct { + IdentityProviderUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// IdentityProviderUpdateResult contains the result from method IdentityProvider.Update. +type IdentityProviderUpdateResult struct { + IdentityProviderContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// IssueGetResponse contains the response from method Issue.Get. +type IssueGetResponse struct { + IssueGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// IssueGetResult contains the result from method Issue.Get. +type IssueGetResult struct { + IssueContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// IssueListByServiceResponse contains the response from method Issue.ListByService. +type IssueListByServiceResponse struct { + IssueListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// IssueListByServiceResult contains the result from method Issue.ListByService. +type IssueListByServiceResult struct { + IssueCollection +} + +// LoggerCreateOrUpdateResponse contains the response from method Logger.CreateOrUpdate. +type LoggerCreateOrUpdateResponse struct { + LoggerCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LoggerCreateOrUpdateResult contains the result from method Logger.CreateOrUpdate. +type LoggerCreateOrUpdateResult struct { + LoggerContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// LoggerDeleteResponse contains the response from method Logger.Delete. +type LoggerDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LoggerGetEntityTagResponse contains the response from method Logger.GetEntityTag. +type LoggerGetEntityTagResponse struct { + LoggerGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LoggerGetEntityTagResult contains the result from method Logger.GetEntityTag. +type LoggerGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// LoggerGetResponse contains the response from method Logger.Get. +type LoggerGetResponse struct { + LoggerGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LoggerGetResult contains the result from method Logger.Get. +type LoggerGetResult struct { + LoggerContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// LoggerListByServiceResponse contains the response from method Logger.ListByService. +type LoggerListByServiceResponse struct { + LoggerListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LoggerListByServiceResult contains the result from method Logger.ListByService. +type LoggerListByServiceResult struct { + LoggerCollection +} + +// LoggerUpdateResponse contains the response from method Logger.Update. +type LoggerUpdateResponse struct { + LoggerUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// LoggerUpdateResult contains the result from method Logger.Update. +type LoggerUpdateResult struct { + LoggerContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// NamedValueCreateOrUpdatePollerResponse contains the response from method NamedValue.CreateOrUpdate. +type NamedValueCreateOrUpdatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (NamedValueCreateOrUpdateResponse, error) + + // Poller contains an initialized poller. + Poller NamedValueCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamedValueCreateOrUpdateResponse contains the response from method NamedValue.CreateOrUpdate. +type NamedValueCreateOrUpdateResponse struct { + NamedValueCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamedValueCreateOrUpdateResult contains the result from method NamedValue.CreateOrUpdate. +type NamedValueCreateOrUpdateResult struct { + NamedValueContract +} + +// NamedValueDeleteResponse contains the response from method NamedValue.Delete. +type NamedValueDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamedValueGetEntityTagResponse contains the response from method NamedValue.GetEntityTag. +type NamedValueGetEntityTagResponse struct { + NamedValueGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamedValueGetEntityTagResult contains the result from method NamedValue.GetEntityTag. +type NamedValueGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// NamedValueGetResponse contains the response from method NamedValue.Get. +type NamedValueGetResponse struct { + NamedValueGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamedValueGetResult contains the result from method NamedValue.Get. +type NamedValueGetResult struct { + NamedValueContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// NamedValueListByServiceResponse contains the response from method NamedValue.ListByService. +type NamedValueListByServiceResponse struct { + NamedValueListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamedValueListByServiceResult contains the result from method NamedValue.ListByService. +type NamedValueListByServiceResult struct { + NamedValueCollection +} + +// NamedValueListValueResponse contains the response from method NamedValue.ListValue. +type NamedValueListValueResponse struct { + NamedValueListValueResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamedValueListValueResult contains the result from method NamedValue.ListValue. +type NamedValueListValueResult struct { + NamedValueSecretContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// NamedValueRefreshSecretPollerResponse contains the response from method NamedValue.RefreshSecret. +type NamedValueRefreshSecretPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (NamedValueRefreshSecretResponse, error) + + // Poller contains an initialized poller. + Poller NamedValueRefreshSecretPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamedValueRefreshSecretResponse contains the response from method NamedValue.RefreshSecret. +type NamedValueRefreshSecretResponse struct { + NamedValueRefreshSecretResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamedValueRefreshSecretResult contains the result from method NamedValue.RefreshSecret. +type NamedValueRefreshSecretResult struct { + NamedValueContract +} + +// NamedValueUpdatePollerResponse contains the response from method NamedValue.Update. +type NamedValueUpdatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (NamedValueUpdateResponse, error) + + // Poller contains an initialized poller. + Poller NamedValueUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamedValueUpdateResponse contains the response from method NamedValue.Update. +type NamedValueUpdateResponse struct { + NamedValueUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NamedValueUpdateResult contains the result from method NamedValue.Update. +type NamedValueUpdateResult struct { + NamedValueContract +} + +// NetworkStatusListByLocationResponse contains the response from method NetworkStatus.ListByLocation. +type NetworkStatusListByLocationResponse struct { + NetworkStatusListByLocationResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NetworkStatusListByLocationResult contains the result from method NetworkStatus.ListByLocation. +type NetworkStatusListByLocationResult struct { + NetworkStatusContract +} + +// NetworkStatusListByServiceResponse contains the response from method NetworkStatus.ListByService. +type NetworkStatusListByServiceResponse struct { + NetworkStatusListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NetworkStatusListByServiceResult contains the result from method NetworkStatus.ListByService. +type NetworkStatusListByServiceResult struct { + // List of Network Status values. + NetworkStatusContractByLocationArray []*NetworkStatusContractByLocation +} + +// NotificationCreateOrUpdateResponse contains the response from method Notification.CreateOrUpdate. +type NotificationCreateOrUpdateResponse struct { + NotificationCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationCreateOrUpdateResult contains the result from method Notification.CreateOrUpdate. +type NotificationCreateOrUpdateResult struct { + NotificationContract +} + +// NotificationGetResponse contains the response from method Notification.Get. +type NotificationGetResponse struct { + NotificationGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationGetResult contains the result from method Notification.Get. +type NotificationGetResult struct { + NotificationContract +} + +// NotificationListByServiceResponse contains the response from method Notification.ListByService. +type NotificationListByServiceResponse struct { + NotificationListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationListByServiceResult contains the result from method Notification.ListByService. +type NotificationListByServiceResult struct { + NotificationCollection +} + +// NotificationRecipientEmailCheckEntityExistsResponse contains the response from method NotificationRecipientEmail.CheckEntityExists. +type NotificationRecipientEmailCheckEntityExistsResponse struct { + NotificationRecipientEmailCheckEntityExistsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationRecipientEmailCheckEntityExistsResult contains the result from method NotificationRecipientEmail.CheckEntityExists. +type NotificationRecipientEmailCheckEntityExistsResult struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// NotificationRecipientEmailCreateOrUpdateResponse contains the response from method NotificationRecipientEmail.CreateOrUpdate. +type NotificationRecipientEmailCreateOrUpdateResponse struct { + NotificationRecipientEmailCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationRecipientEmailCreateOrUpdateResult contains the result from method NotificationRecipientEmail.CreateOrUpdate. +type NotificationRecipientEmailCreateOrUpdateResult struct { + RecipientEmailContract +} + +// NotificationRecipientEmailDeleteResponse contains the response from method NotificationRecipientEmail.Delete. +type NotificationRecipientEmailDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationRecipientEmailListByNotificationResponse contains the response from method NotificationRecipientEmail.ListByNotification. +type NotificationRecipientEmailListByNotificationResponse struct { + NotificationRecipientEmailListByNotificationResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationRecipientEmailListByNotificationResult contains the result from method NotificationRecipientEmail.ListByNotification. +type NotificationRecipientEmailListByNotificationResult struct { + RecipientEmailCollection +} + +// NotificationRecipientUserCheckEntityExistsResponse contains the response from method NotificationRecipientUser.CheckEntityExists. +type NotificationRecipientUserCheckEntityExistsResponse struct { + NotificationRecipientUserCheckEntityExistsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationRecipientUserCheckEntityExistsResult contains the result from method NotificationRecipientUser.CheckEntityExists. +type NotificationRecipientUserCheckEntityExistsResult struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// NotificationRecipientUserCreateOrUpdateResponse contains the response from method NotificationRecipientUser.CreateOrUpdate. +type NotificationRecipientUserCreateOrUpdateResponse struct { + NotificationRecipientUserCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationRecipientUserCreateOrUpdateResult contains the result from method NotificationRecipientUser.CreateOrUpdate. +type NotificationRecipientUserCreateOrUpdateResult struct { + RecipientUserContract +} + +// NotificationRecipientUserDeleteResponse contains the response from method NotificationRecipientUser.Delete. +type NotificationRecipientUserDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationRecipientUserListByNotificationResponse contains the response from method NotificationRecipientUser.ListByNotification. +type NotificationRecipientUserListByNotificationResponse struct { + NotificationRecipientUserListByNotificationResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// NotificationRecipientUserListByNotificationResult contains the result from method NotificationRecipientUser.ListByNotification. +type NotificationRecipientUserListByNotificationResult struct { + RecipientUserCollection +} + +// OpenIDConnectProviderCreateOrUpdateResponse contains the response from method OpenIDConnectProvider.CreateOrUpdate. +type OpenIDConnectProviderCreateOrUpdateResponse struct { + OpenIDConnectProviderCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OpenIDConnectProviderCreateOrUpdateResult contains the result from method OpenIDConnectProvider.CreateOrUpdate. +type OpenIDConnectProviderCreateOrUpdateResult struct { + OpenidConnectProviderContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// OpenIDConnectProviderDeleteResponse contains the response from method OpenIDConnectProvider.Delete. +type OpenIDConnectProviderDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OpenIDConnectProviderGetEntityTagResponse contains the response from method OpenIDConnectProvider.GetEntityTag. +type OpenIDConnectProviderGetEntityTagResponse struct { + OpenIDConnectProviderGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OpenIDConnectProviderGetEntityTagResult contains the result from method OpenIDConnectProvider.GetEntityTag. +type OpenIDConnectProviderGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// OpenIDConnectProviderGetResponse contains the response from method OpenIDConnectProvider.Get. +type OpenIDConnectProviderGetResponse struct { + OpenIDConnectProviderGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OpenIDConnectProviderGetResult contains the result from method OpenIDConnectProvider.Get. +type OpenIDConnectProviderGetResult struct { + OpenidConnectProviderContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// OpenIDConnectProviderListByServiceResponse contains the response from method OpenIDConnectProvider.ListByService. +type OpenIDConnectProviderListByServiceResponse struct { + OpenIDConnectProviderListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OpenIDConnectProviderListByServiceResult contains the result from method OpenIDConnectProvider.ListByService. +type OpenIDConnectProviderListByServiceResult struct { + OpenIDConnectProviderCollection +} + +// OpenIDConnectProviderListSecretsResponse contains the response from method OpenIDConnectProvider.ListSecrets. +type OpenIDConnectProviderListSecretsResponse struct { + OpenIDConnectProviderListSecretsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OpenIDConnectProviderListSecretsResult contains the result from method OpenIDConnectProvider.ListSecrets. +type OpenIDConnectProviderListSecretsResult struct { + ClientSecretContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// OpenIDConnectProviderUpdateResponse contains the response from method OpenIDConnectProvider.Update. +type OpenIDConnectProviderUpdateResponse struct { + OpenIDConnectProviderUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OpenIDConnectProviderUpdateResult contains the result from method OpenIDConnectProvider.Update. +type OpenIDConnectProviderUpdateResult struct { + OpenidConnectProviderContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// OperationListByTagsResponse contains the response from method Operation.ListByTags. +type OperationListByTagsResponse struct { + OperationListByTagsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// OperationListByTagsResult contains the result from method Operation.ListByTags. +type OperationListByTagsResult struct { + TagResourceCollection +} + +// PolicyCreateOrUpdateResponse contains the response from method Policy.CreateOrUpdate. +type PolicyCreateOrUpdateResponse struct { + PolicyCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PolicyCreateOrUpdateResult contains the result from method Policy.CreateOrUpdate. +type PolicyCreateOrUpdateResult struct { + PolicyContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// PolicyDeleteResponse contains the response from method Policy.Delete. +type PolicyDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PolicyDescriptionListByServiceResponse contains the response from method PolicyDescription.ListByService. +type PolicyDescriptionListByServiceResponse struct { + PolicyDescriptionListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PolicyDescriptionListByServiceResult contains the result from method PolicyDescription.ListByService. +type PolicyDescriptionListByServiceResult struct { + PolicyDescriptionCollection +} + +// PolicyGetEntityTagResponse contains the response from method Policy.GetEntityTag. +type PolicyGetEntityTagResponse struct { + PolicyGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PolicyGetEntityTagResult contains the result from method Policy.GetEntityTag. +type PolicyGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// PolicyGetResponse contains the response from method Policy.Get. +type PolicyGetResponse struct { + PolicyGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PolicyGetResult contains the result from method Policy.Get. +type PolicyGetResult struct { + PolicyContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// PolicyListByServiceResponse contains the response from method Policy.ListByService. +type PolicyListByServiceResponse struct { + PolicyListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PolicyListByServiceResult contains the result from method Policy.ListByService. +type PolicyListByServiceResult struct { + PolicyCollection +} + +// PortalRevisionCreateOrUpdatePollerResponse contains the response from method PortalRevision.CreateOrUpdate. +type PortalRevisionCreateOrUpdatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (PortalRevisionCreateOrUpdateResponse, error) + + // Poller contains an initialized poller. + Poller PortalRevisionCreateOrUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PortalRevisionCreateOrUpdateResponse contains the response from method PortalRevision.CreateOrUpdate. +type PortalRevisionCreateOrUpdateResponse struct { + PortalRevisionCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PortalRevisionCreateOrUpdateResult contains the result from method PortalRevision.CreateOrUpdate. +type PortalRevisionCreateOrUpdateResult struct { + PortalRevisionContract +} + +// PortalRevisionGetEntityTagResponse contains the response from method PortalRevision.GetEntityTag. +type PortalRevisionGetEntityTagResponse struct { + PortalRevisionGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PortalRevisionGetEntityTagResult contains the result from method PortalRevision.GetEntityTag. +type PortalRevisionGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// PortalRevisionGetResponse contains the response from method PortalRevision.Get. +type PortalRevisionGetResponse struct { + PortalRevisionGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PortalRevisionGetResult contains the result from method PortalRevision.Get. +type PortalRevisionGetResult struct { + PortalRevisionContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// PortalRevisionListByServiceResponse contains the response from method PortalRevision.ListByService. +type PortalRevisionListByServiceResponse struct { + PortalRevisionListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PortalRevisionListByServiceResult contains the result from method PortalRevision.ListByService. +type PortalRevisionListByServiceResult struct { + PortalRevisionCollection +} + +// PortalRevisionUpdatePollerResponse contains the response from method PortalRevision.Update. +type PortalRevisionUpdatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (PortalRevisionUpdateResponse, error) + + // Poller contains an initialized poller. + Poller PortalRevisionUpdatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PortalRevisionUpdateResponse contains the response from method PortalRevision.Update. +type PortalRevisionUpdateResponse struct { + PortalRevisionUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PortalRevisionUpdateResult contains the result from method PortalRevision.Update. +type PortalRevisionUpdateResult struct { + PortalRevisionContract +} + +// PortalSettingsListByServiceResponse contains the response from method PortalSettings.ListByService. +type PortalSettingsListByServiceResponse struct { + PortalSettingsListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// PortalSettingsListByServiceResult contains the result from method PortalSettings.ListByService. +type PortalSettingsListByServiceResult struct { + PortalSettingsCollection +} + +// ProductAPICheckEntityExistsResponse contains the response from method ProductAPI.CheckEntityExists. +type ProductAPICheckEntityExistsResponse struct { + ProductAPICheckEntityExistsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductAPICheckEntityExistsResult contains the result from method ProductAPI.CheckEntityExists. +type ProductAPICheckEntityExistsResult struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// ProductAPICreateOrUpdateResponse contains the response from method ProductAPI.CreateOrUpdate. +type ProductAPICreateOrUpdateResponse struct { + ProductAPICreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductAPICreateOrUpdateResult contains the result from method ProductAPI.CreateOrUpdate. +type ProductAPICreateOrUpdateResult struct { + APIContract +} + +// ProductAPIDeleteResponse contains the response from method ProductAPI.Delete. +type ProductAPIDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductAPIListByProductResponse contains the response from method ProductAPI.ListByProduct. +type ProductAPIListByProductResponse struct { + ProductAPIListByProductResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductAPIListByProductResult contains the result from method ProductAPI.ListByProduct. +type ProductAPIListByProductResult struct { + APICollection +} + +// ProductCreateOrUpdateResponse contains the response from method Product.CreateOrUpdate. +type ProductCreateOrUpdateResponse struct { + ProductCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductCreateOrUpdateResult contains the result from method Product.CreateOrUpdate. +type ProductCreateOrUpdateResult struct { + ProductContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// ProductDeleteResponse contains the response from method Product.Delete. +type ProductDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductGetEntityTagResponse contains the response from method Product.GetEntityTag. +type ProductGetEntityTagResponse struct { + ProductGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductGetEntityTagResult contains the result from method Product.GetEntityTag. +type ProductGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// ProductGetResponse contains the response from method Product.Get. +type ProductGetResponse struct { + ProductGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductGetResult contains the result from method Product.Get. +type ProductGetResult struct { + ProductContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// ProductGroupCheckEntityExistsResponse contains the response from method ProductGroup.CheckEntityExists. +type ProductGroupCheckEntityExistsResponse struct { + ProductGroupCheckEntityExistsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductGroupCheckEntityExistsResult contains the result from method ProductGroup.CheckEntityExists. +type ProductGroupCheckEntityExistsResult struct { + // Success indicates if the operation succeeded or failed. + Success bool +} + +// ProductGroupCreateOrUpdateResponse contains the response from method ProductGroup.CreateOrUpdate. +type ProductGroupCreateOrUpdateResponse struct { + ProductGroupCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductGroupCreateOrUpdateResult contains the result from method ProductGroup.CreateOrUpdate. +type ProductGroupCreateOrUpdateResult struct { + GroupContract +} + +// ProductGroupDeleteResponse contains the response from method ProductGroup.Delete. +type ProductGroupDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductGroupListByProductResponse contains the response from method ProductGroup.ListByProduct. +type ProductGroupListByProductResponse struct { + ProductGroupListByProductResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductGroupListByProductResult contains the result from method ProductGroup.ListByProduct. +type ProductGroupListByProductResult struct { + GroupCollection +} + +// ProductListByServiceResponse contains the response from method Product.ListByService. +type ProductListByServiceResponse struct { + ProductListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductListByServiceResult contains the result from method Product.ListByService. +type ProductListByServiceResult struct { + ProductCollection +} + +// ProductListByTagsResponse contains the response from method Product.ListByTags. +type ProductListByTagsResponse struct { + ProductListByTagsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductListByTagsResult contains the result from method Product.ListByTags. +type ProductListByTagsResult struct { + TagResourceCollection +} + +// ProductPolicyCreateOrUpdateResponse contains the response from method ProductPolicy.CreateOrUpdate. +type ProductPolicyCreateOrUpdateResponse struct { + ProductPolicyCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductPolicyCreateOrUpdateResult contains the result from method ProductPolicy.CreateOrUpdate. +type ProductPolicyCreateOrUpdateResult struct { + PolicyContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// ProductPolicyDeleteResponse contains the response from method ProductPolicy.Delete. +type ProductPolicyDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductPolicyGetEntityTagResponse contains the response from method ProductPolicy.GetEntityTag. +type ProductPolicyGetEntityTagResponse struct { + ProductPolicyGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductPolicyGetEntityTagResult contains the result from method ProductPolicy.GetEntityTag. +type ProductPolicyGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// ProductPolicyGetResponse contains the response from method ProductPolicy.Get. +type ProductPolicyGetResponse struct { + ProductPolicyGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductPolicyGetResult contains the result from method ProductPolicy.Get. +type ProductPolicyGetResult struct { + PolicyContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// ProductPolicyListByProductResponse contains the response from method ProductPolicy.ListByProduct. +type ProductPolicyListByProductResponse struct { + ProductPolicyListByProductResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductPolicyListByProductResult contains the result from method ProductPolicy.ListByProduct. +type ProductPolicyListByProductResult struct { + PolicyCollection +} + +// ProductSubscriptionsListResponse contains the response from method ProductSubscriptions.List. +type ProductSubscriptionsListResponse struct { + ProductSubscriptionsListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductSubscriptionsListResult contains the result from method ProductSubscriptions.List. +type ProductSubscriptionsListResult struct { + SubscriptionCollection +} + +// ProductUpdateResponse contains the response from method Product.Update. +type ProductUpdateResponse struct { + ProductUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ProductUpdateResult contains the result from method Product.Update. +type ProductUpdateResult struct { + ProductContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// QuotaByCounterKeysListByServiceResponse contains the response from method QuotaByCounterKeys.ListByService. +type QuotaByCounterKeysListByServiceResponse struct { + QuotaByCounterKeysListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// QuotaByCounterKeysListByServiceResult contains the result from method QuotaByCounterKeys.ListByService. +type QuotaByCounterKeysListByServiceResult struct { + QuotaCounterCollection +} + +// QuotaByCounterKeysUpdateResponse contains the response from method QuotaByCounterKeys.Update. +type QuotaByCounterKeysUpdateResponse struct { + QuotaByCounterKeysUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// QuotaByCounterKeysUpdateResult contains the result from method QuotaByCounterKeys.Update. +type QuotaByCounterKeysUpdateResult struct { + QuotaCounterCollection +} + +// QuotaByPeriodKeysGetResponse contains the response from method QuotaByPeriodKeys.Get. +type QuotaByPeriodKeysGetResponse struct { + QuotaByPeriodKeysGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// QuotaByPeriodKeysGetResult contains the result from method QuotaByPeriodKeys.Get. +type QuotaByPeriodKeysGetResult struct { + QuotaCounterContract +} + +// QuotaByPeriodKeysUpdateResponse contains the response from method QuotaByPeriodKeys.Update. +type QuotaByPeriodKeysUpdateResponse struct { + QuotaByPeriodKeysUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// QuotaByPeriodKeysUpdateResult contains the result from method QuotaByPeriodKeys.Update. +type QuotaByPeriodKeysUpdateResult struct { + QuotaCounterContract +} + +// RegionListByServiceResponse contains the response from method Region.ListByService. +type RegionListByServiceResponse struct { + RegionListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// RegionListByServiceResult contains the result from method Region.ListByService. +type RegionListByServiceResult struct { + RegionListResult +} + +// ReportsListByAPIResponse contains the response from method Reports.ListByAPI. +type ReportsListByAPIResponse struct { + ReportsListByAPIResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReportsListByAPIResult contains the result from method Reports.ListByAPI. +type ReportsListByAPIResult struct { + ReportCollection +} + +// ReportsListByGeoResponse contains the response from method Reports.ListByGeo. +type ReportsListByGeoResponse struct { + ReportsListByGeoResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReportsListByGeoResult contains the result from method Reports.ListByGeo. +type ReportsListByGeoResult struct { + ReportCollection +} + +// ReportsListByOperationResponse contains the response from method Reports.ListByOperation. +type ReportsListByOperationResponse struct { + ReportsListByOperationResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReportsListByOperationResult contains the result from method Reports.ListByOperation. +type ReportsListByOperationResult struct { + ReportCollection +} + +// ReportsListByProductResponse contains the response from method Reports.ListByProduct. +type ReportsListByProductResponse struct { + ReportsListByProductResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReportsListByProductResult contains the result from method Reports.ListByProduct. +type ReportsListByProductResult struct { + ReportCollection +} + +// ReportsListByRequestResponse contains the response from method Reports.ListByRequest. +type ReportsListByRequestResponse struct { + ReportsListByRequestResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReportsListByRequestResult contains the result from method Reports.ListByRequest. +type ReportsListByRequestResult struct { + RequestReportCollection +} + +// ReportsListBySubscriptionResponse contains the response from method Reports.ListBySubscription. +type ReportsListBySubscriptionResponse struct { + ReportsListBySubscriptionResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReportsListBySubscriptionResult contains the result from method Reports.ListBySubscription. +type ReportsListBySubscriptionResult struct { + ReportCollection +} + +// ReportsListByTimeResponse contains the response from method Reports.ListByTime. +type ReportsListByTimeResponse struct { + ReportsListByTimeResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReportsListByTimeResult contains the result from method Reports.ListByTime. +type ReportsListByTimeResult struct { + ReportCollection +} + +// ReportsListByUserResponse contains the response from method Reports.ListByUser. +type ReportsListByUserResponse struct { + ReportsListByUserResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// ReportsListByUserResult contains the result from method Reports.ListByUser. +type ReportsListByUserResult struct { + ReportCollection +} + +// SignInSettingsCreateOrUpdateResponse contains the response from method SignInSettings.CreateOrUpdate. +type SignInSettingsCreateOrUpdateResponse struct { + SignInSettingsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SignInSettingsCreateOrUpdateResult contains the result from method SignInSettings.CreateOrUpdate. +type SignInSettingsCreateOrUpdateResult struct { + PortalSigninSettings +} + +// SignInSettingsGetEntityTagResponse contains the response from method SignInSettings.GetEntityTag. +type SignInSettingsGetEntityTagResponse struct { + SignInSettingsGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SignInSettingsGetEntityTagResult contains the result from method SignInSettings.GetEntityTag. +type SignInSettingsGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// SignInSettingsGetResponse contains the response from method SignInSettings.Get. +type SignInSettingsGetResponse struct { + SignInSettingsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SignInSettingsGetResult contains the result from method SignInSettings.Get. +type SignInSettingsGetResult struct { + PortalSigninSettings + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// SignInSettingsUpdateResponse contains the response from method SignInSettings.Update. +type SignInSettingsUpdateResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SignUpSettingsCreateOrUpdateResponse contains the response from method SignUpSettings.CreateOrUpdate. +type SignUpSettingsCreateOrUpdateResponse struct { + SignUpSettingsCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SignUpSettingsCreateOrUpdateResult contains the result from method SignUpSettings.CreateOrUpdate. +type SignUpSettingsCreateOrUpdateResult struct { + PortalSignupSettings +} + +// SignUpSettingsGetEntityTagResponse contains the response from method SignUpSettings.GetEntityTag. +type SignUpSettingsGetEntityTagResponse struct { + SignUpSettingsGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SignUpSettingsGetEntityTagResult contains the result from method SignUpSettings.GetEntityTag. +type SignUpSettingsGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// SignUpSettingsGetResponse contains the response from method SignUpSettings.Get. +type SignUpSettingsGetResponse struct { + SignUpSettingsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SignUpSettingsGetResult contains the result from method SignUpSettings.Get. +type SignUpSettingsGetResult struct { + PortalSignupSettings + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// SignUpSettingsUpdateResponse contains the response from method SignUpSettings.Update. +type SignUpSettingsUpdateResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SubscriptionCreateOrUpdateResponse contains the response from method Subscription.CreateOrUpdate. +type SubscriptionCreateOrUpdateResponse struct { + SubscriptionCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SubscriptionCreateOrUpdateResult contains the result from method Subscription.CreateOrUpdate. +type SubscriptionCreateOrUpdateResult struct { + SubscriptionContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// SubscriptionDeleteResponse contains the response from method Subscription.Delete. +type SubscriptionDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SubscriptionGetEntityTagResponse contains the response from method Subscription.GetEntityTag. +type SubscriptionGetEntityTagResponse struct { + SubscriptionGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SubscriptionGetEntityTagResult contains the result from method Subscription.GetEntityTag. +type SubscriptionGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// SubscriptionGetResponse contains the response from method Subscription.Get. +type SubscriptionGetResponse struct { + SubscriptionGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SubscriptionGetResult contains the result from method Subscription.Get. +type SubscriptionGetResult struct { + SubscriptionContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// SubscriptionListResponse contains the response from method Subscription.List. +type SubscriptionListResponse struct { + SubscriptionListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SubscriptionListResult contains the result from method Subscription.List. +type SubscriptionListResult struct { + SubscriptionCollection +} + +// SubscriptionListSecretsResponse contains the response from method Subscription.ListSecrets. +type SubscriptionListSecretsResponse struct { + SubscriptionListSecretsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SubscriptionListSecretsResult contains the result from method Subscription.ListSecrets. +type SubscriptionListSecretsResult struct { + SubscriptionKeysContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// SubscriptionRegeneratePrimaryKeyResponse contains the response from method Subscription.RegeneratePrimaryKey. +type SubscriptionRegeneratePrimaryKeyResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SubscriptionRegenerateSecondaryKeyResponse contains the response from method Subscription.RegenerateSecondaryKey. +type SubscriptionRegenerateSecondaryKeyResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SubscriptionUpdateResponse contains the response from method Subscription.Update. +type SubscriptionUpdateResponse struct { + SubscriptionUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// SubscriptionUpdateResult contains the result from method Subscription.Update. +type SubscriptionUpdateResult struct { + SubscriptionContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TagAssignToAPIResponse contains the response from method Tag.AssignToAPI. +type TagAssignToAPIResponse struct { + TagAssignToAPIResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagAssignToAPIResult contains the result from method Tag.AssignToAPI. +type TagAssignToAPIResult struct { + TagContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TagAssignToOperationResponse contains the response from method Tag.AssignToOperation. +type TagAssignToOperationResponse struct { + TagAssignToOperationResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagAssignToOperationResult contains the result from method Tag.AssignToOperation. +type TagAssignToOperationResult struct { + TagContract +} + +// TagAssignToProductResponse contains the response from method Tag.AssignToProduct. +type TagAssignToProductResponse struct { + TagAssignToProductResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagAssignToProductResult contains the result from method Tag.AssignToProduct. +type TagAssignToProductResult struct { + TagContract +} + +// TagCreateOrUpdateResponse contains the response from method Tag.CreateOrUpdate. +type TagCreateOrUpdateResponse struct { + TagCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagCreateOrUpdateResult contains the result from method Tag.CreateOrUpdate. +type TagCreateOrUpdateResult struct { + TagContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TagDeleteResponse contains the response from method Tag.Delete. +type TagDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagDetachFromAPIResponse contains the response from method Tag.DetachFromAPI. +type TagDetachFromAPIResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagDetachFromOperationResponse contains the response from method Tag.DetachFromOperation. +type TagDetachFromOperationResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagDetachFromProductResponse contains the response from method Tag.DetachFromProduct. +type TagDetachFromProductResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagGetByAPIResponse contains the response from method Tag.GetByAPI. +type TagGetByAPIResponse struct { + TagGetByAPIResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagGetByAPIResult contains the result from method Tag.GetByAPI. +type TagGetByAPIResult struct { + TagContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TagGetByOperationResponse contains the response from method Tag.GetByOperation. +type TagGetByOperationResponse struct { + TagGetByOperationResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagGetByOperationResult contains the result from method Tag.GetByOperation. +type TagGetByOperationResult struct { + TagContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TagGetByProductResponse contains the response from method Tag.GetByProduct. +type TagGetByProductResponse struct { + TagGetByProductResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagGetByProductResult contains the result from method Tag.GetByProduct. +type TagGetByProductResult struct { + TagContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TagGetEntityStateByAPIResponse contains the response from method Tag.GetEntityStateByAPI. +type TagGetEntityStateByAPIResponse struct { + TagGetEntityStateByAPIResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagGetEntityStateByAPIResult contains the result from method Tag.GetEntityStateByAPI. +type TagGetEntityStateByAPIResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// TagGetEntityStateByOperationResponse contains the response from method Tag.GetEntityStateByOperation. +type TagGetEntityStateByOperationResponse struct { + TagGetEntityStateByOperationResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagGetEntityStateByOperationResult contains the result from method Tag.GetEntityStateByOperation. +type TagGetEntityStateByOperationResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// TagGetEntityStateByProductResponse contains the response from method Tag.GetEntityStateByProduct. +type TagGetEntityStateByProductResponse struct { + TagGetEntityStateByProductResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagGetEntityStateByProductResult contains the result from method Tag.GetEntityStateByProduct. +type TagGetEntityStateByProductResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// TagGetEntityStateResponse contains the response from method Tag.GetEntityState. +type TagGetEntityStateResponse struct { + TagGetEntityStateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagGetEntityStateResult contains the result from method Tag.GetEntityState. +type TagGetEntityStateResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// TagGetResponse contains the response from method Tag.Get. +type TagGetResponse struct { + TagGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagGetResult contains the result from method Tag.Get. +type TagGetResult struct { + TagContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TagListByAPIResponse contains the response from method Tag.ListByAPI. +type TagListByAPIResponse struct { + TagListByAPIResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagListByAPIResult contains the result from method Tag.ListByAPI. +type TagListByAPIResult struct { + TagCollection +} + +// TagListByOperationResponse contains the response from method Tag.ListByOperation. +type TagListByOperationResponse struct { + TagListByOperationResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagListByOperationResult contains the result from method Tag.ListByOperation. +type TagListByOperationResult struct { + TagCollection +} + +// TagListByProductResponse contains the response from method Tag.ListByProduct. +type TagListByProductResponse struct { + TagListByProductResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagListByProductResult contains the result from method Tag.ListByProduct. +type TagListByProductResult struct { + TagCollection +} + +// TagListByServiceResponse contains the response from method Tag.ListByService. +type TagListByServiceResponse struct { + TagListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagListByServiceResult contains the result from method Tag.ListByService. +type TagListByServiceResult struct { + TagCollection +} + +// TagResourceListByServiceResponse contains the response from method TagResource.ListByService. +type TagResourceListByServiceResponse struct { + TagResourceListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagResourceListByServiceResult contains the result from method TagResource.ListByService. +type TagResourceListByServiceResult struct { + TagResourceCollection +} + +// TagUpdateResponse contains the response from method Tag.Update. +type TagUpdateResponse struct { + TagUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TagUpdateResult contains the result from method Tag.Update. +type TagUpdateResult struct { + TagContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TenantAccessCreateResponse contains the response from method TenantAccess.Create. +type TenantAccessCreateResponse struct { + TenantAccessCreateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantAccessCreateResult contains the result from method TenantAccess.Create. +type TenantAccessCreateResult struct { + AccessInformationContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TenantAccessGetEntityTagResponse contains the response from method TenantAccess.GetEntityTag. +type TenantAccessGetEntityTagResponse struct { + TenantAccessGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantAccessGetEntityTagResult contains the result from method TenantAccess.GetEntityTag. +type TenantAccessGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// TenantAccessGetResponse contains the response from method TenantAccess.Get. +type TenantAccessGetResponse struct { + TenantAccessGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantAccessGetResult contains the result from method TenantAccess.Get. +type TenantAccessGetResult struct { + AccessInformationContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TenantAccessGitRegeneratePrimaryKeyResponse contains the response from method TenantAccessGit.RegeneratePrimaryKey. +type TenantAccessGitRegeneratePrimaryKeyResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantAccessGitRegenerateSecondaryKeyResponse contains the response from method TenantAccessGit.RegenerateSecondaryKey. +type TenantAccessGitRegenerateSecondaryKeyResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantAccessListByServiceResponse contains the response from method TenantAccess.ListByService. +type TenantAccessListByServiceResponse struct { + TenantAccessListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantAccessListByServiceResult contains the result from method TenantAccess.ListByService. +type TenantAccessListByServiceResult struct { + AccessInformationCollection +} + +// TenantAccessListSecretsResponse contains the response from method TenantAccess.ListSecrets. +type TenantAccessListSecretsResponse struct { + TenantAccessListSecretsResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantAccessListSecretsResult contains the result from method TenantAccess.ListSecrets. +type TenantAccessListSecretsResult struct { + AccessInformationSecretsContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TenantAccessRegeneratePrimaryKeyResponse contains the response from method TenantAccess.RegeneratePrimaryKey. +type TenantAccessRegeneratePrimaryKeyResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantAccessRegenerateSecondaryKeyResponse contains the response from method TenantAccess.RegenerateSecondaryKey. +type TenantAccessRegenerateSecondaryKeyResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantAccessUpdateResponse contains the response from method TenantAccess.Update. +type TenantAccessUpdateResponse struct { + TenantAccessUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantAccessUpdateResult contains the result from method TenantAccess.Update. +type TenantAccessUpdateResult struct { + AccessInformationContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TenantConfigurationDeployPollerResponse contains the response from method TenantConfiguration.Deploy. +type TenantConfigurationDeployPollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (TenantConfigurationDeployResponse, error) + + // Poller contains an initialized poller. + Poller TenantConfigurationDeployPoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantConfigurationDeployResponse contains the response from method TenantConfiguration.Deploy. +type TenantConfigurationDeployResponse struct { + TenantConfigurationDeployResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantConfigurationDeployResult contains the result from method TenantConfiguration.Deploy. +type TenantConfigurationDeployResult struct { + OperationResultContract +} + +// TenantConfigurationGetSyncStateResponse contains the response from method TenantConfiguration.GetSyncState. +type TenantConfigurationGetSyncStateResponse struct { + TenantConfigurationGetSyncStateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantConfigurationGetSyncStateResult contains the result from method TenantConfiguration.GetSyncState. +type TenantConfigurationGetSyncStateResult struct { + TenantConfigurationSyncStateContract +} + +// TenantConfigurationSavePollerResponse contains the response from method TenantConfiguration.Save. +type TenantConfigurationSavePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (TenantConfigurationSaveResponse, error) + + // Poller contains an initialized poller. + Poller TenantConfigurationSavePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantConfigurationSaveResponse contains the response from method TenantConfiguration.Save. +type TenantConfigurationSaveResponse struct { + TenantConfigurationSaveResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantConfigurationSaveResult contains the result from method TenantConfiguration.Save. +type TenantConfigurationSaveResult struct { + OperationResultContract +} + +// TenantConfigurationValidatePollerResponse contains the response from method TenantConfiguration.Validate. +type TenantConfigurationValidatePollerResponse struct { + // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received + PollUntilDone func(ctx context.Context, frequency time.Duration) (TenantConfigurationValidateResponse, error) + + // Poller contains an initialized poller. + Poller TenantConfigurationValidatePoller + + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantConfigurationValidateResponse contains the response from method TenantConfiguration.Validate. +type TenantConfigurationValidateResponse struct { + TenantConfigurationValidateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantConfigurationValidateResult contains the result from method TenantConfiguration.Validate. +type TenantConfigurationValidateResult struct { + OperationResultContract +} + +// TenantSettingsGetResponse contains the response from method TenantSettings.Get. +type TenantSettingsGetResponse struct { + TenantSettingsGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantSettingsGetResult contains the result from method TenantSettings.Get. +type TenantSettingsGetResult struct { + TenantSettingsContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// TenantSettingsListByServiceResponse contains the response from method TenantSettings.ListByService. +type TenantSettingsListByServiceResponse struct { + TenantSettingsListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// TenantSettingsListByServiceResult contains the result from method TenantSettings.ListByService. +type TenantSettingsListByServiceResult struct { + TenantSettingsCollection +} + +// UserConfirmationPasswordSendResponse contains the response from method UserConfirmationPassword.Send. +type UserConfirmationPasswordSendResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UserCreateOrUpdateResponse contains the response from method User.CreateOrUpdate. +type UserCreateOrUpdateResponse struct { + UserCreateOrUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UserCreateOrUpdateResult contains the result from method User.CreateOrUpdate. +type UserCreateOrUpdateResult struct { + UserContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// UserDeleteResponse contains the response from method User.Delete. +type UserDeleteResponse struct { + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UserGenerateSsoURLResponse contains the response from method User.GenerateSsoURL. +type UserGenerateSsoURLResponse struct { + UserGenerateSsoURLResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UserGenerateSsoURLResult contains the result from method User.GenerateSsoURL. +type UserGenerateSsoURLResult struct { + GenerateSsoURLResult +} + +// UserGetEntityTagResponse contains the response from method User.GetEntityTag. +type UserGetEntityTagResponse struct { + UserGetEntityTagResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UserGetEntityTagResult contains the result from method User.GetEntityTag. +type UserGetEntityTagResult struct { + // ETag contains the information returned from the ETag header response. + ETag *string + + // Success indicates if the operation succeeded or failed. + Success bool +} + +// UserGetResponse contains the response from method User.Get. +type UserGetResponse struct { + UserGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UserGetResult contains the result from method User.Get. +type UserGetResult struct { + UserContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// UserGetSharedAccessTokenResponse contains the response from method User.GetSharedAccessToken. +type UserGetSharedAccessTokenResponse struct { + UserGetSharedAccessTokenResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UserGetSharedAccessTokenResult contains the result from method User.GetSharedAccessToken. +type UserGetSharedAccessTokenResult struct { + UserTokenResult +} + +// UserGroupListResponse contains the response from method UserGroup.List. +type UserGroupListResponse struct { + UserGroupListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UserGroupListResult contains the result from method UserGroup.List. +type UserGroupListResult struct { + GroupCollection +} + +// UserIdentitiesListResponse contains the response from method UserIdentities.List. +type UserIdentitiesListResponse struct { + UserIdentitiesListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UserIdentitiesListResult contains the result from method UserIdentities.List. +type UserIdentitiesListResult struct { + UserIdentityCollection +} + +// UserListByServiceResponse contains the response from method User.ListByService. +type UserListByServiceResponse struct { + UserListByServiceResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UserListByServiceResult contains the result from method User.ListByService. +type UserListByServiceResult struct { + UserCollection +} + +// UserSubscriptionGetResponse contains the response from method UserSubscription.Get. +type UserSubscriptionGetResponse struct { + UserSubscriptionGetResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UserSubscriptionGetResult contains the result from method UserSubscription.Get. +type UserSubscriptionGetResult struct { + SubscriptionContract + // ETag contains the information returned from the ETag header response. + ETag *string +} + +// UserSubscriptionListResponse contains the response from method UserSubscription.List. +type UserSubscriptionListResponse struct { + UserSubscriptionListResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UserSubscriptionListResult contains the result from method UserSubscription.List. +type UserSubscriptionListResult struct { + SubscriptionCollection +} + +// UserUpdateResponse contains the response from method User.Update. +type UserUpdateResponse struct { + UserUpdateResult + // RawResponse contains the underlying HTTP response. + RawResponse *http.Response +} + +// UserUpdateResult contains the result from method User.Update. +type UserUpdateResult struct { + UserContract + // ETag contains the information returned from the ETag header response. + ETag *string +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_signinsettings_client.go b/sdk/apimanagement/armapimanagement/zz_generated_signinsettings_client.go new file mode 100644 index 000000000000..fc3b77be1f17 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_signinsettings_client.go @@ -0,0 +1,280 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// SignInSettingsClient contains the methods for the SignInSettings group. +// Don't use this type directly, use NewSignInSettingsClient() instead. +type SignInSettingsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewSignInSettingsClient creates a new instance of SignInSettingsClient with the specified values. +func NewSignInSettingsClient(con *armcore.Connection, subscriptionID string) *SignInSettingsClient { + return &SignInSettingsClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Create or Update Sign-In settings. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SignInSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalSigninSettings, options *SignInSettingsCreateOrUpdateOptions) (SignInSettingsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, parameters, options) + if err != nil { + return SignInSettingsCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SignInSettingsCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return SignInSettingsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *SignInSettingsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalSigninSettings, options *SignInSettingsCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *SignInSettingsClient) createOrUpdateHandleResponse(resp *azcore.Response) (SignInSettingsCreateOrUpdateResponse, error) { + result := SignInSettingsCreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.PortalSigninSettings); err != nil { + return SignInSettingsCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *SignInSettingsClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Get Sign In Settings for the Portal +// If the operation fails it returns the *ErrorResponse error type. +func (client *SignInSettingsClient) Get(ctx context.Context, resourceGroupName string, serviceName string, options *SignInSettingsGetOptions) (SignInSettingsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return SignInSettingsGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SignInSettingsGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return SignInSettingsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *SignInSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *SignInSettingsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SignInSettingsClient) getHandleResponse(resp *azcore.Response) (SignInSettingsGetResponse, error) { + result := SignInSettingsGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.PortalSigninSettings); err != nil { + return SignInSettingsGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *SignInSettingsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the SignInSettings. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SignInSettingsClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, options *SignInSettingsGetEntityTagOptions) (SignInSettingsGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return SignInSettingsGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SignInSettingsGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *SignInSettingsClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *SignInSettingsGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *SignInSettingsClient) getEntityTagHandleResponse(resp *azcore.Response) (SignInSettingsGetEntityTagResponse, error) { + result := SignInSettingsGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// Update - Update Sign-In settings. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SignInSettingsClient) Update(ctx context.Context, resourceGroupName string, serviceName string, ifMatch string, parameters PortalSigninSettings, options *SignInSettingsUpdateOptions) (SignInSettingsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, ifMatch, parameters, options) + if err != nil { + return SignInSettingsUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SignInSettingsUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusNoContent) { + return SignInSettingsUpdateResponse{}, client.updateHandleError(resp) + } + return SignInSettingsUpdateResponse{RawResponse: resp.Response}, nil +} + +// updateCreateRequest creates the Update request. +func (client *SignInSettingsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, ifMatch string, parameters PortalSigninSettings, options *SignInSettingsUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signin" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleError handles the Update error response. +func (client *SignInSettingsClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_signupsettings_client.go b/sdk/apimanagement/armapimanagement/zz_generated_signupsettings_client.go new file mode 100644 index 000000000000..8b4927479acb --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_signupsettings_client.go @@ -0,0 +1,280 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// SignUpSettingsClient contains the methods for the SignUpSettings group. +// Don't use this type directly, use NewSignUpSettingsClient() instead. +type SignUpSettingsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewSignUpSettingsClient creates a new instance of SignUpSettingsClient with the specified values. +func NewSignUpSettingsClient(con *armcore.Connection, subscriptionID string) *SignUpSettingsClient { + return &SignUpSettingsClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Create or Update Sign-Up settings. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SignUpSettingsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalSignupSettings, options *SignUpSettingsCreateOrUpdateOptions) (SignUpSettingsCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, parameters, options) + if err != nil { + return SignUpSettingsCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SignUpSettingsCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return SignUpSettingsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *SignUpSettingsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, parameters PortalSignupSettings, options *SignUpSettingsCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *SignUpSettingsClient) createOrUpdateHandleResponse(resp *azcore.Response) (SignUpSettingsCreateOrUpdateResponse, error) { + result := SignUpSettingsCreateOrUpdateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.PortalSignupSettings); err != nil { + return SignUpSettingsCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *SignUpSettingsClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Get Sign Up Settings for the Portal +// If the operation fails it returns the *ErrorResponse error type. +func (client *SignUpSettingsClient) Get(ctx context.Context, resourceGroupName string, serviceName string, options *SignUpSettingsGetOptions) (SignUpSettingsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return SignUpSettingsGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SignUpSettingsGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return SignUpSettingsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *SignUpSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *SignUpSettingsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SignUpSettingsClient) getHandleResponse(resp *azcore.Response) (SignUpSettingsGetResponse, error) { + result := SignUpSettingsGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.PortalSignupSettings); err != nil { + return SignUpSettingsGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *SignUpSettingsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the SignUpSettings. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SignUpSettingsClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, options *SignUpSettingsGetEntityTagOptions) (SignUpSettingsGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, options) + if err != nil { + return SignUpSettingsGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SignUpSettingsGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *SignUpSettingsClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *SignUpSettingsGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *SignUpSettingsClient) getEntityTagHandleResponse(resp *azcore.Response) (SignUpSettingsGetEntityTagResponse, error) { + result := SignUpSettingsGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// Update - Update Sign-Up settings. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SignUpSettingsClient) Update(ctx context.Context, resourceGroupName string, serviceName string, ifMatch string, parameters PortalSignupSettings, options *SignUpSettingsUpdateOptions) (SignUpSettingsUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, ifMatch, parameters, options) + if err != nil { + return SignUpSettingsUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SignUpSettingsUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusNoContent) { + return SignUpSettingsUpdateResponse{}, client.updateHandleError(resp) + } + return SignUpSettingsUpdateResponse{RawResponse: resp.Response}, nil +} + +// updateCreateRequest creates the Update request. +func (client *SignUpSettingsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, ifMatch string, parameters PortalSignupSettings, options *SignUpSettingsUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/portalsettings/signup" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleError handles the Update error response. +func (client *SignUpSettingsClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_subscription_client.go b/sdk/apimanagement/armapimanagement/zz_generated_subscription_client.go new file mode 100644 index 000000000000..261a0d5c71fb --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_subscription_client.go @@ -0,0 +1,653 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// SubscriptionClient contains the methods for the Subscription group. +// Don't use this type directly, use NewSubscriptionClient() instead. +type SubscriptionClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewSubscriptionClient creates a new instance of SubscriptionClient with the specified values. +func NewSubscriptionClient(con *armcore.Connection, subscriptionID string) *SubscriptionClient { + return &SubscriptionClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or updates the subscription of specified user to the specified product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SubscriptionClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, sid string, parameters SubscriptionCreateParameters, options *SubscriptionCreateOrUpdateOptions) (SubscriptionCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, sid, parameters, options) + if err != nil { + return SubscriptionCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SubscriptionCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return SubscriptionCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *SubscriptionClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, parameters SubscriptionCreateParameters, options *SubscriptionCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Notify != nil { + reqQP.Set("notify", strconv.FormatBool(*options.Notify)) + } + reqQP.Set("api-version", "2020-12-01") + if options != nil && options.AppType != nil { + reqQP.Set("appType", string(*options.AppType)) + } + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *SubscriptionClient) createOrUpdateHandleResponse(resp *azcore.Response) (SubscriptionCreateOrUpdateResponse, error) { + result := SubscriptionCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.SubscriptionContract); err != nil { + return SubscriptionCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *SubscriptionClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes the specified subscription. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SubscriptionClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, sid string, ifMatch string, options *SubscriptionDeleteOptions) (SubscriptionDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, sid, ifMatch, options) + if err != nil { + return SubscriptionDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SubscriptionDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return SubscriptionDeleteResponse{}, client.deleteHandleError(resp) + } + return SubscriptionDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *SubscriptionClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, ifMatch string, options *SubscriptionDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *SubscriptionClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the specified Subscription entity. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SubscriptionClient) Get(ctx context.Context, resourceGroupName string, serviceName string, sid string, options *SubscriptionGetOptions) (SubscriptionGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, sid, options) + if err != nil { + return SubscriptionGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SubscriptionGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return SubscriptionGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *SubscriptionClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, options *SubscriptionGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *SubscriptionClient) getHandleResponse(resp *azcore.Response) (SubscriptionGetResponse, error) { + result := SubscriptionGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.SubscriptionContract); err != nil { + return SubscriptionGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *SubscriptionClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the apimanagement subscription specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SubscriptionClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, sid string, options *SubscriptionGetEntityTagOptions) (SubscriptionGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, sid, options) + if err != nil { + return SubscriptionGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SubscriptionGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *SubscriptionClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, options *SubscriptionGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *SubscriptionClient) getEntityTagHandleResponse(resp *azcore.Response) (SubscriptionGetEntityTagResponse, error) { + result := SubscriptionGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// List - Lists all subscriptions of the API Management service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SubscriptionClient) List(resourceGroupName string, serviceName string, options *SubscriptionListOptions) SubscriptionListPager { + return &subscriptionListPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp SubscriptionListResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.SubscriptionCollection.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *SubscriptionClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *SubscriptionListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *SubscriptionClient) listHandleResponse(resp *azcore.Response) (SubscriptionListResponse, error) { + result := SubscriptionListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.SubscriptionCollection); err != nil { + return SubscriptionListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *SubscriptionClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListSecrets - Gets the specified Subscription keys. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SubscriptionClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, sid string, options *SubscriptionListSecretsOptions) (SubscriptionListSecretsResponse, error) { + req, err := client.listSecretsCreateRequest(ctx, resourceGroupName, serviceName, sid, options) + if err != nil { + return SubscriptionListSecretsResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SubscriptionListSecretsResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return SubscriptionListSecretsResponse{}, client.listSecretsHandleError(resp) + } + return client.listSecretsHandleResponse(resp) +} + +// listSecretsCreateRequest creates the ListSecrets request. +func (client *SubscriptionClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, options *SubscriptionListSecretsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/listSecrets" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listSecretsHandleResponse handles the ListSecrets response. +func (client *SubscriptionClient) listSecretsHandleResponse(resp *azcore.Response) (SubscriptionListSecretsResponse, error) { + result := SubscriptionListSecretsResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.SubscriptionKeysContract); err != nil { + return SubscriptionListSecretsResponse{}, err + } + return result, nil +} + +// listSecretsHandleError handles the ListSecrets error response. +func (client *SubscriptionClient) listSecretsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// RegeneratePrimaryKey - Regenerates primary key of existing subscription of the API Management service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SubscriptionClient) RegeneratePrimaryKey(ctx context.Context, resourceGroupName string, serviceName string, sid string, options *SubscriptionRegeneratePrimaryKeyOptions) (SubscriptionRegeneratePrimaryKeyResponse, error) { + req, err := client.regeneratePrimaryKeyCreateRequest(ctx, resourceGroupName, serviceName, sid, options) + if err != nil { + return SubscriptionRegeneratePrimaryKeyResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SubscriptionRegeneratePrimaryKeyResponse{}, err + } + if !resp.HasStatusCode(http.StatusNoContent) { + return SubscriptionRegeneratePrimaryKeyResponse{}, client.regeneratePrimaryKeyHandleError(resp) + } + return SubscriptionRegeneratePrimaryKeyResponse{RawResponse: resp.Response}, nil +} + +// regeneratePrimaryKeyCreateRequest creates the RegeneratePrimaryKey request. +func (client *SubscriptionClient) regeneratePrimaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, options *SubscriptionRegeneratePrimaryKeyOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regeneratePrimaryKey" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// regeneratePrimaryKeyHandleError handles the RegeneratePrimaryKey error response. +func (client *SubscriptionClient) regeneratePrimaryKeyHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// RegenerateSecondaryKey - Regenerates secondary key of existing subscription of the API Management service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SubscriptionClient) RegenerateSecondaryKey(ctx context.Context, resourceGroupName string, serviceName string, sid string, options *SubscriptionRegenerateSecondaryKeyOptions) (SubscriptionRegenerateSecondaryKeyResponse, error) { + req, err := client.regenerateSecondaryKeyCreateRequest(ctx, resourceGroupName, serviceName, sid, options) + if err != nil { + return SubscriptionRegenerateSecondaryKeyResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SubscriptionRegenerateSecondaryKeyResponse{}, err + } + if !resp.HasStatusCode(http.StatusNoContent) { + return SubscriptionRegenerateSecondaryKeyResponse{}, client.regenerateSecondaryKeyHandleError(resp) + } + return SubscriptionRegenerateSecondaryKeyResponse{RawResponse: resp.Response}, nil +} + +// regenerateSecondaryKeyCreateRequest creates the RegenerateSecondaryKey request. +func (client *SubscriptionClient) regenerateSecondaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, options *SubscriptionRegenerateSecondaryKeyOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}/regenerateSecondaryKey" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// regenerateSecondaryKeyHandleError handles the RegenerateSecondaryKey error response. +func (client *SubscriptionClient) regenerateSecondaryKeyHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates the details of a subscription specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *SubscriptionClient) Update(ctx context.Context, resourceGroupName string, serviceName string, sid string, ifMatch string, parameters SubscriptionUpdateParameters, options *SubscriptionUpdateOptions) (SubscriptionUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, sid, ifMatch, parameters, options) + if err != nil { + return SubscriptionUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return SubscriptionUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return SubscriptionUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *SubscriptionClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, sid string, ifMatch string, parameters SubscriptionUpdateParameters, options *SubscriptionUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Notify != nil { + reqQP.Set("notify", strconv.FormatBool(*options.Notify)) + } + reqQP.Set("api-version", "2020-12-01") + if options != nil && options.AppType != nil { + reqQP.Set("appType", string(*options.AppType)) + } + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *SubscriptionClient) updateHandleResponse(resp *azcore.Response) (SubscriptionUpdateResponse, error) { + result := SubscriptionUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.SubscriptionContract); err != nil { + return SubscriptionUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *SubscriptionClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_tag_client.go b/sdk/apimanagement/armapimanagement/zz_generated_tag_client.go new file mode 100644 index 000000000000..0da9d9739654 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_tag_client.go @@ -0,0 +1,1531 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// TagClient contains the methods for the Tag group. +// Don't use this type directly, use NewTagClient() instead. +type TagClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewTagClient creates a new instance of TagClient with the specified values. +func NewTagClient(con *armcore.Connection, subscriptionID string) *TagClient { + return &TagClient{con: con, subscriptionID: subscriptionID} +} + +// AssignToAPI - Assign tag to the Api. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) AssignToAPI(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, options *TagAssignToAPIOptions) (TagAssignToAPIResponse, error) { + req, err := client.assignToAPICreateRequest(ctx, resourceGroupName, serviceName, apiID, tagID, options) + if err != nil { + return TagAssignToAPIResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagAssignToAPIResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return TagAssignToAPIResponse{}, client.assignToAPIHandleError(resp) + } + return client.assignToAPIHandleResponse(resp) +} + +// assignToAPICreateRequest creates the AssignToAPI request. +func (client *TagClient) assignToAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, options *TagAssignToAPIOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// assignToAPIHandleResponse handles the AssignToAPI response. +func (client *TagClient) assignToAPIHandleResponse(resp *azcore.Response) (TagAssignToAPIResponse, error) { + result := TagAssignToAPIResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.TagContract); err != nil { + return TagAssignToAPIResponse{}, err + } + return result, nil +} + +// assignToAPIHandleError handles the AssignToAPI error response. +func (client *TagClient) assignToAPIHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// AssignToOperation - Assign tag to the Operation. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) AssignToOperation(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, options *TagAssignToOperationOptions) (TagAssignToOperationResponse, error) { + req, err := client.assignToOperationCreateRequest(ctx, resourceGroupName, serviceName, apiID, operationID, tagID, options) + if err != nil { + return TagAssignToOperationResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagAssignToOperationResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return TagAssignToOperationResponse{}, client.assignToOperationHandleError(resp) + } + return client.assignToOperationHandleResponse(resp) +} + +// assignToOperationCreateRequest creates the AssignToOperation request. +func (client *TagClient) assignToOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, options *TagAssignToOperationOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// assignToOperationHandleResponse handles the AssignToOperation response. +func (client *TagClient) assignToOperationHandleResponse(resp *azcore.Response) (TagAssignToOperationResponse, error) { + result := TagAssignToOperationResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.TagContract); err != nil { + return TagAssignToOperationResponse{}, err + } + return result, nil +} + +// assignToOperationHandleError handles the AssignToOperation error response. +func (client *TagClient) assignToOperationHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// AssignToProduct - Assign tag to the Product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) AssignToProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, options *TagAssignToProductOptions) (TagAssignToProductResponse, error) { + req, err := client.assignToProductCreateRequest(ctx, resourceGroupName, serviceName, productID, tagID, options) + if err != nil { + return TagAssignToProductResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagAssignToProductResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return TagAssignToProductResponse{}, client.assignToProductHandleError(resp) + } + return client.assignToProductHandleResponse(resp) +} + +// assignToProductCreateRequest creates the AssignToProduct request. +func (client *TagClient) assignToProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, options *TagAssignToProductOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// assignToProductHandleResponse handles the AssignToProduct response. +func (client *TagClient) assignToProductHandleResponse(resp *azcore.Response) (TagAssignToProductResponse, error) { + result := TagAssignToProductResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.TagContract); err != nil { + return TagAssignToProductResponse{}, err + } + return result, nil +} + +// assignToProductHandleError handles the AssignToProduct error response. +func (client *TagClient) assignToProductHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// CreateOrUpdate - Creates a tag. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, tagID string, parameters TagCreateUpdateParameters, options *TagCreateOrUpdateOptions) (TagCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, tagID, parameters, options) + if err != nil { + return TagCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return TagCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *TagClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, parameters TagCreateUpdateParameters, options *TagCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *TagClient) createOrUpdateHandleResponse(resp *azcore.Response) (TagCreateOrUpdateResponse, error) { + result := TagCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.TagContract); err != nil { + return TagCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *TagClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes specific tag of the API Management service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, tagID string, ifMatch string, options *TagDeleteOptions) (TagDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, tagID, ifMatch, options) + if err != nil { + return TagDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return TagDeleteResponse{}, client.deleteHandleError(resp) + } + return TagDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *TagClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, ifMatch string, options *TagDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *TagClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// DetachFromAPI - Detach the tag from the Api. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) DetachFromAPI(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, options *TagDetachFromAPIOptions) (TagDetachFromAPIResponse, error) { + req, err := client.detachFromAPICreateRequest(ctx, resourceGroupName, serviceName, apiID, tagID, options) + if err != nil { + return TagDetachFromAPIResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagDetachFromAPIResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return TagDetachFromAPIResponse{}, client.detachFromAPIHandleError(resp) + } + return TagDetachFromAPIResponse{RawResponse: resp.Response}, nil +} + +// detachFromAPICreateRequest creates the DetachFromAPI request. +func (client *TagClient) detachFromAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, options *TagDetachFromAPIOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// detachFromAPIHandleError handles the DetachFromAPI error response. +func (client *TagClient) detachFromAPIHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// DetachFromOperation - Detach the tag from the Operation. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) DetachFromOperation(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, options *TagDetachFromOperationOptions) (TagDetachFromOperationResponse, error) { + req, err := client.detachFromOperationCreateRequest(ctx, resourceGroupName, serviceName, apiID, operationID, tagID, options) + if err != nil { + return TagDetachFromOperationResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagDetachFromOperationResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return TagDetachFromOperationResponse{}, client.detachFromOperationHandleError(resp) + } + return TagDetachFromOperationResponse{RawResponse: resp.Response}, nil +} + +// detachFromOperationCreateRequest creates the DetachFromOperation request. +func (client *TagClient) detachFromOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, options *TagDetachFromOperationOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// detachFromOperationHandleError handles the DetachFromOperation error response. +func (client *TagClient) detachFromOperationHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// DetachFromProduct - Detach the tag from the Product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) DetachFromProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, options *TagDetachFromProductOptions) (TagDetachFromProductResponse, error) { + req, err := client.detachFromProductCreateRequest(ctx, resourceGroupName, serviceName, productID, tagID, options) + if err != nil { + return TagDetachFromProductResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagDetachFromProductResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return TagDetachFromProductResponse{}, client.detachFromProductHandleError(resp) + } + return TagDetachFromProductResponse{RawResponse: resp.Response}, nil +} + +// detachFromProductCreateRequest creates the DetachFromProduct request. +func (client *TagClient) detachFromProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, options *TagDetachFromProductOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// detachFromProductHandleError handles the DetachFromProduct error response. +func (client *TagClient) detachFromProductHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the tag specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) Get(ctx context.Context, resourceGroupName string, serviceName string, tagID string, options *TagGetOptions) (TagGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, tagID, options) + if err != nil { + return TagGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TagGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *TagClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, options *TagGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TagClient) getHandleResponse(resp *azcore.Response) (TagGetResponse, error) { + result := TagGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.TagContract); err != nil { + return TagGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *TagClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetByAPI - Get tag associated with the API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) GetByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, options *TagGetByAPIOptions) (TagGetByAPIResponse, error) { + req, err := client.getByAPICreateRequest(ctx, resourceGroupName, serviceName, apiID, tagID, options) + if err != nil { + return TagGetByAPIResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagGetByAPIResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TagGetByAPIResponse{}, client.getByAPIHandleError(resp) + } + return client.getByAPIHandleResponse(resp) +} + +// getByAPICreateRequest creates the GetByAPI request. +func (client *TagClient) getByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, options *TagGetByAPIOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getByAPIHandleResponse handles the GetByAPI response. +func (client *TagClient) getByAPIHandleResponse(resp *azcore.Response) (TagGetByAPIResponse, error) { + result := TagGetByAPIResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.TagContract); err != nil { + return TagGetByAPIResponse{}, err + } + return result, nil +} + +// getByAPIHandleError handles the GetByAPI error response. +func (client *TagClient) getByAPIHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetByOperation - Get tag associated with the Operation. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) GetByOperation(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, options *TagGetByOperationOptions) (TagGetByOperationResponse, error) { + req, err := client.getByOperationCreateRequest(ctx, resourceGroupName, serviceName, apiID, operationID, tagID, options) + if err != nil { + return TagGetByOperationResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagGetByOperationResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TagGetByOperationResponse{}, client.getByOperationHandleError(resp) + } + return client.getByOperationHandleResponse(resp) +} + +// getByOperationCreateRequest creates the GetByOperation request. +func (client *TagClient) getByOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, options *TagGetByOperationOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getByOperationHandleResponse handles the GetByOperation response. +func (client *TagClient) getByOperationHandleResponse(resp *azcore.Response) (TagGetByOperationResponse, error) { + result := TagGetByOperationResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.TagContract); err != nil { + return TagGetByOperationResponse{}, err + } + return result, nil +} + +// getByOperationHandleError handles the GetByOperation error response. +func (client *TagClient) getByOperationHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetByProduct - Get tag associated with the Product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) GetByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, options *TagGetByProductOptions) (TagGetByProductResponse, error) { + req, err := client.getByProductCreateRequest(ctx, resourceGroupName, serviceName, productID, tagID, options) + if err != nil { + return TagGetByProductResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagGetByProductResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TagGetByProductResponse{}, client.getByProductHandleError(resp) + } + return client.getByProductHandleResponse(resp) +} + +// getByProductCreateRequest creates the GetByProduct request. +func (client *TagClient) getByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, options *TagGetByProductOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getByProductHandleResponse handles the GetByProduct response. +func (client *TagClient) getByProductHandleResponse(resp *azcore.Response) (TagGetByProductResponse, error) { + result := TagGetByProductResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.TagContract); err != nil { + return TagGetByProductResponse{}, err + } + return result, nil +} + +// getByProductHandleError handles the GetByProduct error response. +func (client *TagClient) getByProductHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityState - Gets the entity state version of the tag specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) GetEntityState(ctx context.Context, resourceGroupName string, serviceName string, tagID string, options *TagGetEntityStateOptions) (TagGetEntityStateResponse, error) { + req, err := client.getEntityStateCreateRequest(ctx, resourceGroupName, serviceName, tagID, options) + if err != nil { + return TagGetEntityStateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagGetEntityStateResponse{}, err + } + return client.getEntityStateHandleResponse(resp) +} + +// getEntityStateCreateRequest creates the GetEntityState request. +func (client *TagClient) getEntityStateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, options *TagGetEntityStateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityStateHandleResponse handles the GetEntityState response. +func (client *TagClient) getEntityStateHandleResponse(resp *azcore.Response) (TagGetEntityStateResponse, error) { + result := TagGetEntityStateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// GetEntityStateByAPI - Gets the entity state version of the tag specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) GetEntityStateByAPI(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, options *TagGetEntityStateByAPIOptions) (TagGetEntityStateByAPIResponse, error) { + req, err := client.getEntityStateByAPICreateRequest(ctx, resourceGroupName, serviceName, apiID, tagID, options) + if err != nil { + return TagGetEntityStateByAPIResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagGetEntityStateByAPIResponse{}, err + } + return client.getEntityStateByAPIHandleResponse(resp) +} + +// getEntityStateByAPICreateRequest creates the GetEntityStateByAPI request. +func (client *TagClient) getEntityStateByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, tagID string, options *TagGetEntityStateByAPIOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityStateByAPIHandleResponse handles the GetEntityStateByAPI response. +func (client *TagClient) getEntityStateByAPIHandleResponse(resp *azcore.Response) (TagGetEntityStateByAPIResponse, error) { + result := TagGetEntityStateByAPIResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// GetEntityStateByOperation - Gets the entity state version of the tag specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) GetEntityStateByOperation(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, options *TagGetEntityStateByOperationOptions) (TagGetEntityStateByOperationResponse, error) { + req, err := client.getEntityStateByOperationCreateRequest(ctx, resourceGroupName, serviceName, apiID, operationID, tagID, options) + if err != nil { + return TagGetEntityStateByOperationResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagGetEntityStateByOperationResponse{}, err + } + return client.getEntityStateByOperationHandleResponse(resp) +} + +// getEntityStateByOperationCreateRequest creates the GetEntityStateByOperation request. +func (client *TagClient) getEntityStateByOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, tagID string, options *TagGetEntityStateByOperationOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityStateByOperationHandleResponse handles the GetEntityStateByOperation response. +func (client *TagClient) getEntityStateByOperationHandleResponse(resp *azcore.Response) (TagGetEntityStateByOperationResponse, error) { + result := TagGetEntityStateByOperationResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// GetEntityStateByProduct - Gets the entity state version of the tag specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) GetEntityStateByProduct(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, options *TagGetEntityStateByProductOptions) (TagGetEntityStateByProductResponse, error) { + req, err := client.getEntityStateByProductCreateRequest(ctx, resourceGroupName, serviceName, productID, tagID, options) + if err != nil { + return TagGetEntityStateByProductResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagGetEntityStateByProductResponse{}, err + } + return client.getEntityStateByProductHandleResponse(resp) +} + +// getEntityStateByProductCreateRequest creates the GetEntityStateByProduct request. +func (client *TagClient) getEntityStateByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, tagID string, options *TagGetEntityStateByProductOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityStateByProductHandleResponse handles the GetEntityStateByProduct response. +func (client *TagClient) getEntityStateByProductHandleResponse(resp *azcore.Response) (TagGetEntityStateByProductResponse, error) { + result := TagGetEntityStateByProductResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByAPI - Lists all Tags associated with the API. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) ListByAPI(resourceGroupName string, serviceName string, apiID string, options *TagListByAPIOptions) TagListByAPIPager { + return &tagListByAPIPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByAPICreateRequest(ctx, resourceGroupName, serviceName, apiID, options) + }, + advancer: func(ctx context.Context, resp TagListByAPIResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.TagCollection.NextLink) + }, + } +} + +// listByAPICreateRequest creates the ListByAPI request. +func (client *TagClient) listByAPICreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, options *TagListByAPIOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/tags" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByAPIHandleResponse handles the ListByAPI response. +func (client *TagClient) listByAPIHandleResponse(resp *azcore.Response) (TagListByAPIResponse, error) { + result := TagListByAPIResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.TagCollection); err != nil { + return TagListByAPIResponse{}, err + } + return result, nil +} + +// listByAPIHandleError handles the ListByAPI error response. +func (client *TagClient) listByAPIHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByOperation - Lists all Tags associated with the Operation. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) ListByOperation(resourceGroupName string, serviceName string, apiID string, operationID string, options *TagListByOperationOptions) TagListByOperationPager { + return &tagListByOperationPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByOperationCreateRequest(ctx, resourceGroupName, serviceName, apiID, operationID, options) + }, + advancer: func(ctx context.Context, resp TagListByOperationResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.TagCollection.NextLink) + }, + } +} + +// listByOperationCreateRequest creates the ListByOperation request. +func (client *TagClient) listByOperationCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, apiID string, operationID string, options *TagListByOperationOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}/tags" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if apiID == "" { + return nil, errors.New("parameter apiID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{apiId}", url.PathEscape(apiID)) + if operationID == "" { + return nil, errors.New("parameter operationID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{operationId}", url.PathEscape(operationID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByOperationHandleResponse handles the ListByOperation response. +func (client *TagClient) listByOperationHandleResponse(resp *azcore.Response) (TagListByOperationResponse, error) { + result := TagListByOperationResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.TagCollection); err != nil { + return TagListByOperationResponse{}, err + } + return result, nil +} + +// listByOperationHandleError handles the ListByOperation error response. +func (client *TagClient) listByOperationHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByProduct - Lists all Tags associated with the Product. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) ListByProduct(resourceGroupName string, serviceName string, productID string, options *TagListByProductOptions) TagListByProductPager { + return &tagListByProductPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByProductCreateRequest(ctx, resourceGroupName, serviceName, productID, options) + }, + advancer: func(ctx context.Context, resp TagListByProductResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.TagCollection.NextLink) + }, + } +} + +// listByProductCreateRequest creates the ListByProduct request. +func (client *TagClient) listByProductCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, productID string, options *TagListByProductOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/products/{productId}/tags" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if productID == "" { + return nil, errors.New("parameter productID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{productId}", url.PathEscape(productID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByProductHandleResponse handles the ListByProduct response. +func (client *TagClient) listByProductHandleResponse(resp *azcore.Response) (TagListByProductResponse, error) { + result := TagListByProductResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.TagCollection); err != nil { + return TagListByProductResponse{}, err + } + return result, nil +} + +// listByProductHandleError handles the ListByProduct error response. +func (client *TagClient) listByProductHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByService - Lists a collection of tags defined within a service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) ListByService(resourceGroupName string, serviceName string, options *TagListByServiceOptions) TagListByServicePager { + return &tagListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp TagListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.TagCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *TagClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *TagListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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.Scope != nil { + reqQP.Set("scope", *options.Scope) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *TagClient) listByServiceHandleResponse(resp *azcore.Response) (TagListByServiceResponse, error) { + result := TagListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.TagCollection); err != nil { + return TagListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *TagClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates the details of the tag specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagClient) Update(ctx context.Context, resourceGroupName string, serviceName string, tagID string, ifMatch string, parameters TagCreateUpdateParameters, options *TagUpdateOptions) (TagUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, tagID, ifMatch, parameters, options) + if err != nil { + return TagUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TagUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TagUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *TagClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, tagID string, ifMatch string, parameters TagCreateUpdateParameters, options *TagUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tags/{tagId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if tagID == "" { + return nil, errors.New("parameter tagID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{tagId}", url.PathEscape(tagID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *TagClient) updateHandleResponse(resp *azcore.Response) (TagUpdateResponse, error) { + result := TagUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.TagContract); err != nil { + return TagUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *TagClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_tagresource_client.go b/sdk/apimanagement/armapimanagement/zz_generated_tagresource_client.go new file mode 100644 index 000000000000..91ef20059951 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_tagresource_client.go @@ -0,0 +1,104 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// TagResourceClient contains the methods for the TagResource group. +// Don't use this type directly, use NewTagResourceClient() instead. +type TagResourceClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewTagResourceClient creates a new instance of TagResourceClient with the specified values. +func NewTagResourceClient(con *armcore.Connection, subscriptionID string) *TagResourceClient { + return &TagResourceClient{con: con, subscriptionID: subscriptionID} +} + +// ListByService - Lists a collection of resources associated with tags. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TagResourceClient) ListByService(resourceGroupName string, serviceName string, options *TagResourceListByServiceOptions) TagResourceListByServicePager { + return &tagResourceListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp TagResourceListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.TagResourceCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *TagResourceClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *TagResourceListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tagResources" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *TagResourceClient) listByServiceHandleResponse(resp *azcore.Response) (TagResourceListByServiceResponse, error) { + result := TagResourceListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.TagResourceCollection); err != nil { + return TagResourceListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *TagResourceClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_tenantaccess_client.go b/sdk/apimanagement/armapimanagement/zz_generated_tenantaccess_client.go new file mode 100644 index 000000000000..78ae3d950539 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_tenantaccess_client.go @@ -0,0 +1,570 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// TenantAccessClient contains the methods for the TenantAccess group. +// Don't use this type directly, use NewTenantAccessClient() instead. +type TenantAccessClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewTenantAccessClient creates a new instance of TenantAccessClient with the specified values. +func NewTenantAccessClient(con *armcore.Connection, subscriptionID string) *TenantAccessClient { + return &TenantAccessClient{con: con, subscriptionID: subscriptionID} +} + +// Create - Update tenant access information details. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantAccessClient) Create(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, ifMatch string, parameters AccessInformationCreateParameters, options *TenantAccessCreateOptions) (TenantAccessCreateResponse, error) { + req, err := client.createCreateRequest(ctx, resourceGroupName, serviceName, accessName, ifMatch, parameters, options) + if err != nil { + return TenantAccessCreateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TenantAccessCreateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TenantAccessCreateResponse{}, client.createHandleError(resp) + } + return client.createHandleResponse(resp) +} + +// createCreateRequest creates the Create request. +func (client *TenantAccessClient) createCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, ifMatch string, parameters AccessInformationCreateParameters, options *TenantAccessCreateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if accessName == "" { + return nil, errors.New("parameter accessName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accessName}", url.PathEscape(string(accessName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createHandleResponse handles the Create response. +func (client *TenantAccessClient) createHandleResponse(resp *azcore.Response) (TenantAccessCreateResponse, error) { + result := TenantAccessCreateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.AccessInformationContract); err != nil { + return TenantAccessCreateResponse{}, err + } + return result, nil +} + +// createHandleError handles the Create error response. +func (client *TenantAccessClient) createHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Get tenant access information details without secrets. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantAccessClient) Get(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessGetOptions) (TenantAccessGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, accessName, options) + if err != nil { + return TenantAccessGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TenantAccessGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TenantAccessGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *TenantAccessClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if accessName == "" { + return nil, errors.New("parameter accessName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accessName}", url.PathEscape(string(accessName))) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TenantAccessClient) getHandleResponse(resp *azcore.Response) (TenantAccessGetResponse, error) { + result := TenantAccessGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.AccessInformationContract); err != nil { + return TenantAccessGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *TenantAccessClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Tenant access metadata +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantAccessClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessGetEntityTagOptions) (TenantAccessGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, accessName, options) + if err != nil { + return TenantAccessGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TenantAccessGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *TenantAccessClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if accessName == "" { + return nil, errors.New("parameter accessName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accessName}", url.PathEscape(string(accessName))) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *TenantAccessClient) getEntityTagHandleResponse(resp *azcore.Response) (TenantAccessGetEntityTagResponse, error) { + result := TenantAccessGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// ListByService - Returns list of access infos - for Git and Management endpoints. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantAccessClient) ListByService(resourceGroupName string, serviceName string, options *TenantAccessListByServiceOptions) TenantAccessListByServicePager { + return &tenantAccessListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp TenantAccessListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.AccessInformationCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *TenantAccessClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *TenantAccessListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *TenantAccessClient) listByServiceHandleResponse(resp *azcore.Response) (TenantAccessListByServiceResponse, error) { + result := TenantAccessListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.AccessInformationCollection); err != nil { + return TenantAccessListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *TenantAccessClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListSecrets - Get tenant access information details. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantAccessClient) ListSecrets(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessListSecretsOptions) (TenantAccessListSecretsResponse, error) { + req, err := client.listSecretsCreateRequest(ctx, resourceGroupName, serviceName, accessName, options) + if err != nil { + return TenantAccessListSecretsResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TenantAccessListSecretsResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TenantAccessListSecretsResponse{}, client.listSecretsHandleError(resp) + } + return client.listSecretsHandleResponse(resp) +} + +// listSecretsCreateRequest creates the ListSecrets request. +func (client *TenantAccessClient) listSecretsCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessListSecretsOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/listSecrets" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if accessName == "" { + return nil, errors.New("parameter accessName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accessName}", url.PathEscape(string(accessName))) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listSecretsHandleResponse handles the ListSecrets response. +func (client *TenantAccessClient) listSecretsHandleResponse(resp *azcore.Response) (TenantAccessListSecretsResponse, error) { + result := TenantAccessListSecretsResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.AccessInformationSecretsContract); err != nil { + return TenantAccessListSecretsResponse{}, err + } + return result, nil +} + +// listSecretsHandleError handles the ListSecrets error response. +func (client *TenantAccessClient) listSecretsHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// RegeneratePrimaryKey - Regenerate primary access key +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantAccessClient) RegeneratePrimaryKey(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessRegeneratePrimaryKeyOptions) (TenantAccessRegeneratePrimaryKeyResponse, error) { + req, err := client.regeneratePrimaryKeyCreateRequest(ctx, resourceGroupName, serviceName, accessName, options) + if err != nil { + return TenantAccessRegeneratePrimaryKeyResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TenantAccessRegeneratePrimaryKeyResponse{}, err + } + if !resp.HasStatusCode(http.StatusNoContent) { + return TenantAccessRegeneratePrimaryKeyResponse{}, client.regeneratePrimaryKeyHandleError(resp) + } + return TenantAccessRegeneratePrimaryKeyResponse{RawResponse: resp.Response}, nil +} + +// regeneratePrimaryKeyCreateRequest creates the RegeneratePrimaryKey request. +func (client *TenantAccessClient) regeneratePrimaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessRegeneratePrimaryKeyOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regeneratePrimaryKey" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if accessName == "" { + return nil, errors.New("parameter accessName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accessName}", url.PathEscape(string(accessName))) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// regeneratePrimaryKeyHandleError handles the RegeneratePrimaryKey error response. +func (client *TenantAccessClient) regeneratePrimaryKeyHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// RegenerateSecondaryKey - Regenerate secondary access key +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantAccessClient) RegenerateSecondaryKey(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessRegenerateSecondaryKeyOptions) (TenantAccessRegenerateSecondaryKeyResponse, error) { + req, err := client.regenerateSecondaryKeyCreateRequest(ctx, resourceGroupName, serviceName, accessName, options) + if err != nil { + return TenantAccessRegenerateSecondaryKeyResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TenantAccessRegenerateSecondaryKeyResponse{}, err + } + if !resp.HasStatusCode(http.StatusNoContent) { + return TenantAccessRegenerateSecondaryKeyResponse{}, client.regenerateSecondaryKeyHandleError(resp) + } + return TenantAccessRegenerateSecondaryKeyResponse{RawResponse: resp.Response}, nil +} + +// regenerateSecondaryKeyCreateRequest creates the RegenerateSecondaryKey request. +func (client *TenantAccessClient) regenerateSecondaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessRegenerateSecondaryKeyOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/regenerateSecondaryKey" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if accessName == "" { + return nil, errors.New("parameter accessName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accessName}", url.PathEscape(string(accessName))) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// regenerateSecondaryKeyHandleError handles the RegenerateSecondaryKey error response. +func (client *TenantAccessClient) regenerateSecondaryKeyHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Update tenant access information details. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantAccessClient) Update(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, ifMatch string, parameters AccessInformationUpdateParameters, options *TenantAccessUpdateOptions) (TenantAccessUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, accessName, ifMatch, parameters, options) + if err != nil { + return TenantAccessUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TenantAccessUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TenantAccessUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *TenantAccessClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, ifMatch string, parameters AccessInformationUpdateParameters, options *TenantAccessUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if accessName == "" { + return nil, errors.New("parameter accessName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accessName}", url.PathEscape(string(accessName))) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *TenantAccessClient) updateHandleResponse(resp *azcore.Response) (TenantAccessUpdateResponse, error) { + result := TenantAccessUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.AccessInformationContract); err != nil { + return TenantAccessUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *TenantAccessClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_tenantaccessgit_client.go b/sdk/apimanagement/armapimanagement/zz_generated_tenantaccessgit_client.go new file mode 100644 index 000000000000..013057f0c54b --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_tenantaccessgit_client.go @@ -0,0 +1,153 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// TenantAccessGitClient contains the methods for the TenantAccessGit group. +// Don't use this type directly, use NewTenantAccessGitClient() instead. +type TenantAccessGitClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewTenantAccessGitClient creates a new instance of TenantAccessGitClient with the specified values. +func NewTenantAccessGitClient(con *armcore.Connection, subscriptionID string) *TenantAccessGitClient { + return &TenantAccessGitClient{con: con, subscriptionID: subscriptionID} +} + +// RegeneratePrimaryKey - Regenerate primary access key for GIT. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantAccessGitClient) RegeneratePrimaryKey(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessGitRegeneratePrimaryKeyOptions) (TenantAccessGitRegeneratePrimaryKeyResponse, error) { + req, err := client.regeneratePrimaryKeyCreateRequest(ctx, resourceGroupName, serviceName, accessName, options) + if err != nil { + return TenantAccessGitRegeneratePrimaryKeyResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TenantAccessGitRegeneratePrimaryKeyResponse{}, err + } + if !resp.HasStatusCode(http.StatusNoContent) { + return TenantAccessGitRegeneratePrimaryKeyResponse{}, client.regeneratePrimaryKeyHandleError(resp) + } + return TenantAccessGitRegeneratePrimaryKeyResponse{RawResponse: resp.Response}, nil +} + +// regeneratePrimaryKeyCreateRequest creates the RegeneratePrimaryKey request. +func (client *TenantAccessGitClient) regeneratePrimaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessGitRegeneratePrimaryKeyOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regeneratePrimaryKey" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if accessName == "" { + return nil, errors.New("parameter accessName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accessName}", url.PathEscape(string(accessName))) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// regeneratePrimaryKeyHandleError handles the RegeneratePrimaryKey error response. +func (client *TenantAccessGitClient) regeneratePrimaryKeyHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// RegenerateSecondaryKey - Regenerate secondary access key for GIT. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantAccessGitClient) RegenerateSecondaryKey(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessGitRegenerateSecondaryKeyOptions) (TenantAccessGitRegenerateSecondaryKeyResponse, error) { + req, err := client.regenerateSecondaryKeyCreateRequest(ctx, resourceGroupName, serviceName, accessName, options) + if err != nil { + return TenantAccessGitRegenerateSecondaryKeyResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TenantAccessGitRegenerateSecondaryKeyResponse{}, err + } + if !resp.HasStatusCode(http.StatusNoContent) { + return TenantAccessGitRegenerateSecondaryKeyResponse{}, client.regenerateSecondaryKeyHandleError(resp) + } + return TenantAccessGitRegenerateSecondaryKeyResponse{RawResponse: resp.Response}, nil +} + +// regenerateSecondaryKeyCreateRequest creates the RegenerateSecondaryKey request. +func (client *TenantAccessGitClient) regenerateSecondaryKeyCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, accessName AccessIDName, options *TenantAccessGitRegenerateSecondaryKeyOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{accessName}/git/regenerateSecondaryKey" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if accessName == "" { + return nil, errors.New("parameter accessName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{accessName}", url.PathEscape(string(accessName))) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// regenerateSecondaryKeyHandleError handles the RegenerateSecondaryKey error response. +func (client *TenantAccessGitClient) regenerateSecondaryKeyHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_tenantconfiguration_client.go b/sdk/apimanagement/armapimanagement/zz_generated_tenantconfiguration_client.go new file mode 100644 index 000000000000..0e8c72a445c5 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_tenantconfiguration_client.go @@ -0,0 +1,434 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" + "time" +) + +// TenantConfigurationClient contains the methods for the TenantConfiguration group. +// Don't use this type directly, use NewTenantConfigurationClient() instead. +type TenantConfigurationClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewTenantConfigurationClient creates a new instance of TenantConfigurationClient with the specified values. +func NewTenantConfigurationClient(con *armcore.Connection, subscriptionID string) *TenantConfigurationClient { + return &TenantConfigurationClient{con: con, subscriptionID: subscriptionID} +} + +// BeginDeploy - This operation applies changes from the specified Git branch to the configuration database. This is a long running operation and could +// take several minutes to complete. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantConfigurationClient) BeginDeploy(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters DeployConfigurationParameters, options *TenantConfigurationBeginDeployOptions) (TenantConfigurationDeployPollerResponse, error) { + resp, err := client.deploy(ctx, resourceGroupName, serviceName, configurationName, parameters, options) + if err != nil { + return TenantConfigurationDeployPollerResponse{}, err + } + result := TenantConfigurationDeployPollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("TenantConfigurationClient.Deploy", "location", resp, client.con.Pipeline(), client.deployHandleError) + if err != nil { + return TenantConfigurationDeployPollerResponse{}, err + } + poller := &tenantConfigurationDeployPoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TenantConfigurationDeployResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeDeploy creates a new TenantConfigurationDeployPoller from the specified resume token. +// token - The value must come from a previous call to TenantConfigurationDeployPoller.ResumeToken(). +func (client *TenantConfigurationClient) ResumeDeploy(ctx context.Context, token string) (TenantConfigurationDeployPollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("TenantConfigurationClient.Deploy", token, client.con.Pipeline(), client.deployHandleError) + if err != nil { + return TenantConfigurationDeployPollerResponse{}, err + } + poller := &tenantConfigurationDeployPoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return TenantConfigurationDeployPollerResponse{}, err + } + result := TenantConfigurationDeployPollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TenantConfigurationDeployResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Deploy - This operation applies changes from the specified Git branch to the configuration database. This is a long running operation and could take +// several minutes to complete. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantConfigurationClient) deploy(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters DeployConfigurationParameters, options *TenantConfigurationBeginDeployOptions) (*azcore.Response, error) { + req, err := client.deployCreateRequest(ctx, resourceGroupName, serviceName, configurationName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.deployHandleError(resp) + } + return resp, nil +} + +// deployCreateRequest creates the Deploy request. +func (client *TenantConfigurationClient) deployCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters DeployConfigurationParameters, options *TenantConfigurationBeginDeployOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/deploy" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if configurationName == "" { + return nil, errors.New("parameter configurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(string(configurationName))) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// deployHandleError handles the Deploy error response. +func (client *TenantConfigurationClient) deployHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetSyncState - Gets the status of the most recent synchronization between the configuration database and the Git repository. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantConfigurationClient) GetSyncState(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, options *TenantConfigurationGetSyncStateOptions) (TenantConfigurationGetSyncStateResponse, error) { + req, err := client.getSyncStateCreateRequest(ctx, resourceGroupName, serviceName, configurationName, options) + if err != nil { + return TenantConfigurationGetSyncStateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TenantConfigurationGetSyncStateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TenantConfigurationGetSyncStateResponse{}, client.getSyncStateHandleError(resp) + } + return client.getSyncStateHandleResponse(resp) +} + +// getSyncStateCreateRequest creates the GetSyncState request. +func (client *TenantConfigurationClient) getSyncStateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, options *TenantConfigurationGetSyncStateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/syncState" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if configurationName == "" { + return nil, errors.New("parameter configurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(string(configurationName))) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getSyncStateHandleResponse handles the GetSyncState response. +func (client *TenantConfigurationClient) getSyncStateHandleResponse(resp *azcore.Response) (TenantConfigurationGetSyncStateResponse, error) { + result := TenantConfigurationGetSyncStateResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.TenantConfigurationSyncStateContract); err != nil { + return TenantConfigurationGetSyncStateResponse{}, err + } + return result, nil +} + +// getSyncStateHandleError handles the GetSyncState error response. +func (client *TenantConfigurationClient) getSyncStateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginSave - This operation creates a commit with the current configuration snapshot to the specified branch in the repository. This is a long running +// operation and could take several minutes to complete. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantConfigurationClient) BeginSave(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters SaveConfigurationParameter, options *TenantConfigurationBeginSaveOptions) (TenantConfigurationSavePollerResponse, error) { + resp, err := client.save(ctx, resourceGroupName, serviceName, configurationName, parameters, options) + if err != nil { + return TenantConfigurationSavePollerResponse{}, err + } + result := TenantConfigurationSavePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("TenantConfigurationClient.Save", "location", resp, client.con.Pipeline(), client.saveHandleError) + if err != nil { + return TenantConfigurationSavePollerResponse{}, err + } + poller := &tenantConfigurationSavePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TenantConfigurationSaveResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeSave creates a new TenantConfigurationSavePoller from the specified resume token. +// token - The value must come from a previous call to TenantConfigurationSavePoller.ResumeToken(). +func (client *TenantConfigurationClient) ResumeSave(ctx context.Context, token string) (TenantConfigurationSavePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("TenantConfigurationClient.Save", token, client.con.Pipeline(), client.saveHandleError) + if err != nil { + return TenantConfigurationSavePollerResponse{}, err + } + poller := &tenantConfigurationSavePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return TenantConfigurationSavePollerResponse{}, err + } + result := TenantConfigurationSavePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TenantConfigurationSaveResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Save - This operation creates a commit with the current configuration snapshot to the specified branch in the repository. This is a long running operation +// and could take several minutes to complete. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantConfigurationClient) save(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters SaveConfigurationParameter, options *TenantConfigurationBeginSaveOptions) (*azcore.Response, error) { + req, err := client.saveCreateRequest(ctx, resourceGroupName, serviceName, configurationName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.saveHandleError(resp) + } + return resp, nil +} + +// saveCreateRequest creates the Save request. +func (client *TenantConfigurationClient) saveCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters SaveConfigurationParameter, options *TenantConfigurationBeginSaveOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/save" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if configurationName == "" { + return nil, errors.New("parameter configurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(string(configurationName))) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// saveHandleError handles the Save error response. +func (client *TenantConfigurationClient) saveHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// BeginValidate - This operation validates the changes in the specified Git branch. This is a long running operation and could take several minutes to +// complete. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantConfigurationClient) BeginValidate(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters DeployConfigurationParameters, options *TenantConfigurationBeginValidateOptions) (TenantConfigurationValidatePollerResponse, error) { + resp, err := client.validate(ctx, resourceGroupName, serviceName, configurationName, parameters, options) + if err != nil { + return TenantConfigurationValidatePollerResponse{}, err + } + result := TenantConfigurationValidatePollerResponse{ + RawResponse: resp.Response, + } + pt, err := armcore.NewLROPoller("TenantConfigurationClient.Validate", "location", resp, client.con.Pipeline(), client.validateHandleError) + if err != nil { + return TenantConfigurationValidatePollerResponse{}, err + } + poller := &tenantConfigurationValidatePoller{ + pt: pt, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TenantConfigurationValidateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// ResumeValidate creates a new TenantConfigurationValidatePoller from the specified resume token. +// token - The value must come from a previous call to TenantConfigurationValidatePoller.ResumeToken(). +func (client *TenantConfigurationClient) ResumeValidate(ctx context.Context, token string) (TenantConfigurationValidatePollerResponse, error) { + pt, err := armcore.NewLROPollerFromResumeToken("TenantConfigurationClient.Validate", token, client.con.Pipeline(), client.validateHandleError) + if err != nil { + return TenantConfigurationValidatePollerResponse{}, err + } + poller := &tenantConfigurationValidatePoller{ + pt: pt, + } + resp, err := poller.Poll(ctx) + if err != nil { + return TenantConfigurationValidatePollerResponse{}, err + } + result := TenantConfigurationValidatePollerResponse{ + RawResponse: resp, + } + result.Poller = poller + result.PollUntilDone = func(ctx context.Context, frequency time.Duration) (TenantConfigurationValidateResponse, error) { + return poller.pollUntilDone(ctx, frequency) + } + return result, nil +} + +// Validate - This operation validates the changes in the specified Git branch. This is a long running operation and could take several minutes to complete. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantConfigurationClient) validate(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters DeployConfigurationParameters, options *TenantConfigurationBeginValidateOptions) (*azcore.Response, error) { + req, err := client.validateCreateRequest(ctx, resourceGroupName, serviceName, configurationName, parameters, options) + if err != nil { + return nil, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusAccepted) { + return nil, client.validateHandleError(resp) + } + return resp, nil +} + +// validateCreateRequest creates the Validate request. +func (client *TenantConfigurationClient) validateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, configurationName ConfigurationIDName, parameters DeployConfigurationParameters, options *TenantConfigurationBeginValidateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/{configurationName}/validate" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if configurationName == "" { + return nil, errors.New("parameter configurationName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{configurationName}", url.PathEscape(string(configurationName))) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// validateHandleError handles the Validate error response. +func (client *TenantConfigurationClient) validateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_tenantsettings_client.go b/sdk/apimanagement/armapimanagement/zz_generated_tenantsettings_client.go new file mode 100644 index 000000000000..39229277e3c1 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_tenantsettings_client.go @@ -0,0 +1,170 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// TenantSettingsClient contains the methods for the TenantSettings group. +// Don't use this type directly, use NewTenantSettingsClient() instead. +type TenantSettingsClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewTenantSettingsClient creates a new instance of TenantSettingsClient with the specified values. +func NewTenantSettingsClient(con *armcore.Connection, subscriptionID string) *TenantSettingsClient { + return &TenantSettingsClient{con: con, subscriptionID: subscriptionID} +} + +// Get - Get tenant settings. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantSettingsClient) Get(ctx context.Context, resourceGroupName string, serviceName string, settingsType SettingsTypeName, options *TenantSettingsGetOptions) (TenantSettingsGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, settingsType, options) + if err != nil { + return TenantSettingsGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return TenantSettingsGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return TenantSettingsGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *TenantSettingsClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, settingsType SettingsTypeName, options *TenantSettingsGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings/{settingsType}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if settingsType == "" { + return nil, errors.New("parameter settingsType cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{settingsType}", url.PathEscape(string(settingsType))) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *TenantSettingsClient) getHandleResponse(resp *azcore.Response) (TenantSettingsGetResponse, error) { + result := TenantSettingsGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.TenantSettingsContract); err != nil { + return TenantSettingsGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *TenantSettingsClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByService - Public settings. +// If the operation fails it returns the *ErrorResponse error type. +func (client *TenantSettingsClient) ListByService(resourceGroupName string, serviceName string, options *TenantSettingsListByServiceOptions) TenantSettingsListByServicePager { + return &tenantSettingsListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp TenantSettingsListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.TenantSettingsCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *TenantSettingsClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *TenantSettingsListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/settings" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *TenantSettingsClient) listByServiceHandleResponse(resp *azcore.Response) (TenantSettingsListByServiceResponse, error) { + result := TenantSettingsListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.TenantSettingsCollection); err != nil { + return TenantSettingsListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *TenantSettingsClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_time_rfc3339.go b/sdk/apimanagement/armapimanagement/zz_generated_time_rfc3339.go new file mode 100644 index 000000000000..dd6bb596facd --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_time_rfc3339.go @@ -0,0 +1,57 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "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 +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_user_client.go b/sdk/apimanagement/armapimanagement/zz_generated_user_client.go new file mode 100644 index 000000000000..aa7acc47fac7 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_user_client.go @@ -0,0 +1,601 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// UserClient contains the methods for the User group. +// Don't use this type directly, use NewUserClient() instead. +type UserClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewUserClient creates a new instance of UserClient with the specified values. +func NewUserClient(con *armcore.Connection, subscriptionID string) *UserClient { + return &UserClient{con: con, subscriptionID: subscriptionID} +} + +// CreateOrUpdate - Creates or Updates a user. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UserClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters UserCreateParameters, options *UserCreateOrUpdateOptions) (UserCreateOrUpdateResponse, error) { + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, serviceName, userID, parameters, options) + if err != nil { + return UserCreateOrUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return UserCreateOrUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusCreated) { + return UserCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + } + return client.createOrUpdateHandleResponse(resp) +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *UserClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters UserCreateParameters, options *UserCreateOrUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPut, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Notify != nil { + reqQP.Set("notify", strconv.FormatBool(*options.Notify)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + if options != nil && options.IfMatch != nil { + req.Header.Set("If-Match", *options.IfMatch) + } + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// createOrUpdateHandleResponse handles the CreateOrUpdate response. +func (client *UserClient) createOrUpdateHandleResponse(resp *azcore.Response) (UserCreateOrUpdateResponse, error) { + result := UserCreateOrUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.UserContract); err != nil { + return UserCreateOrUpdateResponse{}, err + } + return result, nil +} + +// createOrUpdateHandleError handles the CreateOrUpdate error response. +func (client *UserClient) createOrUpdateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Delete - Deletes specific user. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UserClient) Delete(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, options *UserDeleteOptions) (UserDeleteResponse, error) { + req, err := client.deleteCreateRequest(ctx, resourceGroupName, serviceName, userID, ifMatch, options) + if err != nil { + return UserDeleteResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return UserDeleteResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK, http.StatusNoContent) { + return UserDeleteResponse{}, client.deleteHandleError(resp) + } + return UserDeleteResponse{RawResponse: resp.Response}, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *UserClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, options *UserDeleteOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodDelete, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.DeleteSubscriptions != nil { + reqQP.Set("deleteSubscriptions", strconv.FormatBool(*options.DeleteSubscriptions)) + } + if options != nil && options.Notify != nil { + reqQP.Set("notify", strconv.FormatBool(*options.Notify)) + } + reqQP.Set("api-version", "2020-12-01") + if options != nil && options.AppType != nil { + reqQP.Set("appType", string(*options.AppType)) + } + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, nil +} + +// deleteHandleError handles the Delete error response. +func (client *UserClient) deleteHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GenerateSsoURL - Retrieves a redirection URL containing an authentication token for signing a given user into the developer portal. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UserClient) GenerateSsoURL(ctx context.Context, resourceGroupName string, serviceName string, userID string, options *UserGenerateSsoURLOptions) (UserGenerateSsoURLResponse, error) { + req, err := client.generateSsoURLCreateRequest(ctx, resourceGroupName, serviceName, userID, options) + if err != nil { + return UserGenerateSsoURLResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return UserGenerateSsoURLResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return UserGenerateSsoURLResponse{}, client.generateSsoURLHandleError(resp) + } + return client.generateSsoURLHandleResponse(resp) +} + +// generateSsoURLCreateRequest creates the GenerateSsoURL request. +func (client *UserClient) generateSsoURLCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, options *UserGenerateSsoURLOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/generateSsoUrl" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// generateSsoURLHandleResponse handles the GenerateSsoURL response. +func (client *UserClient) generateSsoURLHandleResponse(resp *azcore.Response) (UserGenerateSsoURLResponse, error) { + result := UserGenerateSsoURLResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.GenerateSsoURLResult); err != nil { + return UserGenerateSsoURLResponse{}, err + } + return result, nil +} + +// generateSsoURLHandleError handles the GenerateSsoURL error response. +func (client *UserClient) generateSsoURLHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Get - Gets the details of the user specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UserClient) Get(ctx context.Context, resourceGroupName string, serviceName string, userID string, options *UserGetOptions) (UserGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, userID, options) + if err != nil { + return UserGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return UserGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return UserGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *UserClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, options *UserGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *UserClient) getHandleResponse(resp *azcore.Response) (UserGetResponse, error) { + result := UserGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.UserContract); err != nil { + return UserGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *UserClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// GetEntityTag - Gets the entity state (Etag) version of the user specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UserClient) GetEntityTag(ctx context.Context, resourceGroupName string, serviceName string, userID string, options *UserGetEntityTagOptions) (UserGetEntityTagResponse, error) { + req, err := client.getEntityTagCreateRequest(ctx, resourceGroupName, serviceName, userID, options) + if err != nil { + return UserGetEntityTagResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return UserGetEntityTagResponse{}, err + } + return client.getEntityTagHandleResponse(resp) +} + +// getEntityTagCreateRequest creates the GetEntityTag request. +func (client *UserClient) getEntityTagCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, options *UserGetEntityTagOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodHead, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getEntityTagHandleResponse handles the GetEntityTag response. +func (client *UserClient) getEntityTagHandleResponse(resp *azcore.Response) (UserGetEntityTagResponse, error) { + result := UserGetEntityTagResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if resp.StatusCode >= 200 && resp.StatusCode < 300 { + result.Success = true + } + return result, nil +} + +// GetSharedAccessToken - Gets the Shared Access Authorization Token for the User. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UserClient) GetSharedAccessToken(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters UserTokenParameters, options *UserGetSharedAccessTokenOptions) (UserGetSharedAccessTokenResponse, error) { + req, err := client.getSharedAccessTokenCreateRequest(ctx, resourceGroupName, serviceName, userID, parameters, options) + if err != nil { + return UserGetSharedAccessTokenResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return UserGetSharedAccessTokenResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return UserGetSharedAccessTokenResponse{}, client.getSharedAccessTokenHandleError(resp) + } + return client.getSharedAccessTokenHandleResponse(resp) +} + +// getSharedAccessTokenCreateRequest creates the GetSharedAccessToken request. +func (client *UserClient) getSharedAccessTokenCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, parameters UserTokenParameters, options *UserGetSharedAccessTokenOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/token" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// getSharedAccessTokenHandleResponse handles the GetSharedAccessToken response. +func (client *UserClient) getSharedAccessTokenHandleResponse(resp *azcore.Response) (UserGetSharedAccessTokenResponse, error) { + result := UserGetSharedAccessTokenResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.UserTokenResult); err != nil { + return UserGetSharedAccessTokenResponse{}, err + } + return result, nil +} + +// getSharedAccessTokenHandleError handles the GetSharedAccessToken error response. +func (client *UserClient) getSharedAccessTokenHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// ListByService - Lists a collection of registered users in the specified service instance. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UserClient) ListByService(resourceGroupName string, serviceName string, options *UserListByServiceOptions) UserListByServicePager { + return &userListByServicePager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listByServiceCreateRequest(ctx, resourceGroupName, serviceName, options) + }, + advancer: func(ctx context.Context, resp UserListByServiceResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.UserCollection.NextLink) + }, + } +} + +// listByServiceCreateRequest creates the ListByService request. +func (client *UserClient) listByServiceCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, options *UserListByServiceOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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.ExpandGroups != nil { + reqQP.Set("expandGroups", strconv.FormatBool(*options.ExpandGroups)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listByServiceHandleResponse handles the ListByService response. +func (client *UserClient) listByServiceHandleResponse(resp *azcore.Response) (UserListByServiceResponse, error) { + result := UserListByServiceResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.UserCollection); err != nil { + return UserListByServiceResponse{}, err + } + return result, nil +} + +// listByServiceHandleError handles the ListByService error response. +func (client *UserClient) listByServiceHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// Update - Updates the details of the user specified by its identifier. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UserClient) Update(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, parameters UserUpdateParameters, options *UserUpdateOptions) (UserUpdateResponse, error) { + req, err := client.updateCreateRequest(ctx, resourceGroupName, serviceName, userID, ifMatch, parameters, options) + if err != nil { + return UserUpdateResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return UserUpdateResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return UserUpdateResponse{}, client.updateHandleError(resp) + } + return client.updateHandleResponse(resp) +} + +// updateCreateRequest creates the Update request. +func (client *UserClient) updateCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, ifMatch string, parameters UserUpdateParameters, options *UserUpdateOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPatch, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("If-Match", ifMatch) + req.Header.Set("Accept", "application/json") + return req, req.MarshalAsJSON(parameters) +} + +// updateHandleResponse handles the Update response. +func (client *UserClient) updateHandleResponse(resp *azcore.Response) (UserUpdateResponse, error) { + result := UserUpdateResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.UserContract); err != nil { + return UserUpdateResponse{}, err + } + return result, nil +} + +// updateHandleError handles the Update error response. +func (client *UserClient) updateHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_userconfirmationpassword_client.go b/sdk/apimanagement/armapimanagement/zz_generated_userconfirmationpassword_client.go new file mode 100644 index 000000000000..b88bac7491bb --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_userconfirmationpassword_client.go @@ -0,0 +1,95 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// UserConfirmationPasswordClient contains the methods for the UserConfirmationPassword group. +// Don't use this type directly, use NewUserConfirmationPasswordClient() instead. +type UserConfirmationPasswordClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewUserConfirmationPasswordClient creates a new instance of UserConfirmationPasswordClient with the specified values. +func NewUserConfirmationPasswordClient(con *armcore.Connection, subscriptionID string) *UserConfirmationPasswordClient { + return &UserConfirmationPasswordClient{con: con, subscriptionID: subscriptionID} +} + +// Send - Sends confirmation +// If the operation fails it returns the *ErrorResponse error type. +func (client *UserConfirmationPasswordClient) Send(ctx context.Context, resourceGroupName string, serviceName string, userID string, options *UserConfirmationPasswordSendOptions) (UserConfirmationPasswordSendResponse, error) { + req, err := client.sendCreateRequest(ctx, resourceGroupName, serviceName, userID, options) + if err != nil { + return UserConfirmationPasswordSendResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return UserConfirmationPasswordSendResponse{}, err + } + if !resp.HasStatusCode(http.StatusNoContent) { + return UserConfirmationPasswordSendResponse{}, client.sendHandleError(resp) + } + return UserConfirmationPasswordSendResponse{RawResponse: resp.Response}, nil +} + +// sendCreateRequest creates the Send request. +func (client *UserConfirmationPasswordClient) sendCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, options *UserConfirmationPasswordSendOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/confirmations/password/send" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodPost, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + if options != nil && options.AppType != nil { + reqQP.Set("appType", string(*options.AppType)) + } + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// sendHandleError handles the Send error response. +func (client *UserConfirmationPasswordClient) sendHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_usergroup_client.go b/sdk/apimanagement/armapimanagement/zz_generated_usergroup_client.go new file mode 100644 index 000000000000..2ba6f131b4bb --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_usergroup_client.go @@ -0,0 +1,108 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// UserGroupClient contains the methods for the UserGroup group. +// Don't use this type directly, use NewUserGroupClient() instead. +type UserGroupClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewUserGroupClient creates a new instance of UserGroupClient with the specified values. +func NewUserGroupClient(con *armcore.Connection, subscriptionID string) *UserGroupClient { + return &UserGroupClient{con: con, subscriptionID: subscriptionID} +} + +// List - Lists all user groups. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UserGroupClient) List(resourceGroupName string, serviceName string, userID string, options *UserGroupListOptions) UserGroupListPager { + return &userGroupListPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, serviceName, userID, options) + }, + advancer: func(ctx context.Context, resp UserGroupListResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.GroupCollection.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *UserGroupClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, options *UserGroupListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/groups" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *UserGroupClient) listHandleResponse(resp *azcore.Response) (UserGroupListResponse, error) { + result := UserGroupListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.GroupCollection); err != nil { + return UserGroupListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *UserGroupClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_useridentities_client.go b/sdk/apimanagement/armapimanagement/zz_generated_useridentities_client.go new file mode 100644 index 000000000000..7a3fc29e7ae2 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_useridentities_client.go @@ -0,0 +1,98 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strings" +) + +// UserIdentitiesClient contains the methods for the UserIdentities group. +// Don't use this type directly, use NewUserIdentitiesClient() instead. +type UserIdentitiesClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewUserIdentitiesClient creates a new instance of UserIdentitiesClient with the specified values. +func NewUserIdentitiesClient(con *armcore.Connection, subscriptionID string) *UserIdentitiesClient { + return &UserIdentitiesClient{con: con, subscriptionID: subscriptionID} +} + +// List - List of all user identities. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UserIdentitiesClient) List(resourceGroupName string, serviceName string, userID string, options *UserIdentitiesListOptions) UserIdentitiesListPager { + return &userIdentitiesListPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, serviceName, userID, options) + }, + advancer: func(ctx context.Context, resp UserIdentitiesListResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.UserIdentityCollection.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *UserIdentitiesClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, options *UserIdentitiesListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/identities" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *UserIdentitiesClient) listHandleResponse(resp *azcore.Response) (UserIdentitiesListResponse, error) { + result := UserIdentitiesListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.UserIdentityCollection); err != nil { + return UserIdentitiesListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *UserIdentitiesClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} diff --git a/sdk/apimanagement/armapimanagement/zz_generated_usersubscription_client.go b/sdk/apimanagement/armapimanagement/zz_generated_usersubscription_client.go new file mode 100644 index 000000000000..5dd530cf25f0 --- /dev/null +++ b/sdk/apimanagement/armapimanagement/zz_generated_usersubscription_client.go @@ -0,0 +1,185 @@ +// +build go1.13 + +// 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 armapimanagement + +import ( + "context" + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/armcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "net/http" + "net/url" + "strconv" + "strings" +) + +// UserSubscriptionClient contains the methods for the UserSubscription group. +// Don't use this type directly, use NewUserSubscriptionClient() instead. +type UserSubscriptionClient struct { + con *armcore.Connection + subscriptionID string +} + +// NewUserSubscriptionClient creates a new instance of UserSubscriptionClient with the specified values. +func NewUserSubscriptionClient(con *armcore.Connection, subscriptionID string) *UserSubscriptionClient { + return &UserSubscriptionClient{con: con, subscriptionID: subscriptionID} +} + +// Get - Gets the specified Subscription entity associated with a particular user. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UserSubscriptionClient) Get(ctx context.Context, resourceGroupName string, serviceName string, userID string, sid string, options *UserSubscriptionGetOptions) (UserSubscriptionGetResponse, error) { + req, err := client.getCreateRequest(ctx, resourceGroupName, serviceName, userID, sid, options) + if err != nil { + return UserSubscriptionGetResponse{}, err + } + resp, err := client.con.Pipeline().Do(req) + if err != nil { + return UserSubscriptionGetResponse{}, err + } + if !resp.HasStatusCode(http.StatusOK) { + return UserSubscriptionGetResponse{}, client.getHandleError(resp) + } + return client.getHandleResponse(resp) +} + +// getCreateRequest creates the Get request. +func (client *UserSubscriptionClient) getCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, sid string, options *UserSubscriptionGetOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions/{sid}" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if sid == "" { + return nil, errors.New("parameter sid cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{sid}", url.PathEscape(sid)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *UserSubscriptionClient) getHandleResponse(resp *azcore.Response) (UserSubscriptionGetResponse, error) { + result := UserSubscriptionGetResponse{RawResponse: resp.Response} + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = &val + } + if err := resp.UnmarshalAsJSON(&result.SubscriptionContract); err != nil { + return UserSubscriptionGetResponse{}, err + } + return result, nil +} + +// getHandleError handles the Get error response. +func (client *UserSubscriptionClient) getHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +} + +// List - Lists the collection of subscriptions of the specified user. +// If the operation fails it returns the *ErrorResponse error type. +func (client *UserSubscriptionClient) List(resourceGroupName string, serviceName string, userID string, options *UserSubscriptionListOptions) UserSubscriptionListPager { + return &userSubscriptionListPager{ + client: client, + requester: func(ctx context.Context) (*azcore.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, serviceName, userID, options) + }, + advancer: func(ctx context.Context, resp UserSubscriptionListResponse) (*azcore.Request, error) { + return azcore.NewRequest(ctx, http.MethodGet, *resp.SubscriptionCollection.NextLink) + }, + } +} + +// listCreateRequest creates the List request. +func (client *UserSubscriptionClient) listCreateRequest(ctx context.Context, resourceGroupName string, serviceName string, userID string, options *UserSubscriptionListOptions) (*azcore.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/users/{userId}/subscriptions" + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if serviceName == "" { + return nil, errors.New("parameter serviceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{serviceName}", url.PathEscape(serviceName)) + if userID == "" { + return nil, errors.New("parameter userID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{userId}", url.PathEscape(userID)) + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := azcore.NewRequest(ctx, http.MethodGet, azcore.JoinPaths(client.con.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + req.Telemetry(telemetryInfo) + reqQP := req.URL.Query() + if options != nil && options.Filter != nil { + reqQP.Set("$filter", *options.Filter) + } + 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)) + } + reqQP.Set("api-version", "2020-12-01") + req.URL.RawQuery = reqQP.Encode() + req.Header.Set("Accept", "application/json") + return req, nil +} + +// listHandleResponse handles the List response. +func (client *UserSubscriptionClient) listHandleResponse(resp *azcore.Response) (UserSubscriptionListResponse, error) { + result := UserSubscriptionListResponse{RawResponse: resp.Response} + if err := resp.UnmarshalAsJSON(&result.SubscriptionCollection); err != nil { + return UserSubscriptionListResponse{}, err + } + return result, nil +} + +// listHandleError handles the List error response. +func (client *UserSubscriptionClient) listHandleError(resp *azcore.Response) error { + body, err := resp.Payload() + if err != nil { + return azcore.NewResponseError(err, resp.Response) + } + errType := ErrorResponse{raw: string(body)} + if err := resp.UnmarshalAsJSON(&errType.InnerError); err != nil { + return azcore.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp.Response) + } + return azcore.NewResponseError(&errType, resp.Response) +}