1package apimanagement 2 3// Copyright (c) Microsoft and contributors. All rights reserved. 4// 5// Licensed under the Apache License, Version 2.0 (the "License"); 6// you may not use this file except in compliance with the License. 7// You may obtain a copy of the License at 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// 14// See the License for the specific language governing permissions and 15// limitations under the License. 16// 17// Code generated by Microsoft (R) AutoRest Code Generator. 18// Changes may cause incorrect behavior and will be lost if the code is regenerated. 19 20import ( 21 "context" 22 "github.com/Azure/go-autorest/autorest" 23 "github.com/Azure/go-autorest/autorest/azure" 24 "github.com/Azure/go-autorest/autorest/validation" 25 "net/http" 26) 27 28// APIExportClient is the apiManagement Client 29type APIExportClient struct { 30 BaseClient 31} 32 33// NewAPIExportClient creates an instance of the APIExportClient client. 34func NewAPIExportClient(subscriptionID string) APIExportClient { 35 return NewAPIExportClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewAPIExportClientWithBaseURI creates an instance of the APIExportClient client. 39func NewAPIExportClientWithBaseURI(baseURI string, subscriptionID string) APIExportClient { 40 return APIExportClient{NewWithBaseURI(baseURI, subscriptionID)} 41} 42 43// Get gets the details of the API specified by its identifier in the format specified to the Storage Blob with SAS Key 44// valid for 5 minutes. 45// Parameters: 46// resourceGroupName - the name of the resource group. 47// serviceName - the name of the API Management service. 48// apiid - API identifier. Must be unique in the current API Management service instance. 49func (client APIExportClient) Get(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (result APIExportResult, err error) { 50 if err := validation.Validate([]validation.Validation{ 51 {TargetValue: serviceName, 52 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 53 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 54 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 55 {TargetValue: apiid, 56 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 57 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 58 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 59 return result, validation.NewError("apimanagement.APIExportClient", "Get", err.Error()) 60 } 61 62 req, err := client.GetPreparer(ctx, resourceGroupName, serviceName, apiid) 63 if err != nil { 64 err = autorest.NewErrorWithError(err, "apimanagement.APIExportClient", "Get", nil, "Failure preparing request") 65 return 66 } 67 68 resp, err := client.GetSender(req) 69 if err != nil { 70 result.Response = autorest.Response{Response: resp} 71 err = autorest.NewErrorWithError(err, "apimanagement.APIExportClient", "Get", resp, "Failure sending request") 72 return 73 } 74 75 result, err = client.GetResponder(resp) 76 if err != nil { 77 err = autorest.NewErrorWithError(err, "apimanagement.APIExportClient", "Get", resp, "Failure responding to request") 78 } 79 80 return 81} 82 83// GetPreparer prepares the Get request. 84func (client APIExportClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string) (*http.Request, error) { 85 pathParameters := map[string]interface{}{ 86 "apiId": autorest.Encode("path", apiid), 87 "resourceGroupName": autorest.Encode("path", resourceGroupName), 88 "serviceName": autorest.Encode("path", serviceName), 89 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 90 } 91 92 const APIVersion = "2017-03-01" 93 queryParameters := map[string]interface{}{ 94 "api-version": APIVersion, 95 "export": autorest.Encode("query", "true"), 96 } 97 98 preparer := autorest.CreatePreparer( 99 autorest.AsGet(), 100 autorest.WithBaseURL(client.BaseURI), 101 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}", pathParameters), 102 autorest.WithQueryParameters(queryParameters)) 103 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 104} 105 106// GetSender sends the Get request. The method will close the 107// http.Response Body if it receives an error. 108func (client APIExportClient) GetSender(req *http.Request) (*http.Response, error) { 109 return autorest.SendWithSender(client, req, 110 azure.DoRetryWithRegistration(client.Client)) 111} 112 113// GetResponder handles the response to the Get request. The method always 114// closes the http.Response Body. 115func (client APIExportClient) GetResponder(resp *http.Response) (result APIExportResult, err error) { 116 err = autorest.Respond( 117 resp, 118 client.ByInspecting(), 119 azure.WithErrorUnlessStatusCode(http.StatusOK), 120 autorest.ByUnmarshallingJSON(&result), 121 autorest.ByClosing()) 122 result.Response = autorest.Response{Response: resp} 123 return 124} 125