mirror of
https://github.com/rclone/rclone.git
synced 2024-12-13 02:33:58 +01:00
536 lines
25 KiB
Go
536 lines
25 KiB
Go
|
package apimanagement
|
||
|
|
||
|
// Copyright (c) Microsoft and contributors. All rights reserved.
|
||
|
//
|
||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
// you may not use this file except in compliance with the License.
|
||
|
// You may obtain a copy of the License at
|
||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||
|
//
|
||
|
// Unless required by applicable law or agreed to in writing, software
|
||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
//
|
||
|
// See the License for the specific language governing permissions and
|
||
|
// limitations under the License.
|
||
|
//
|
||
|
// Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
|
||
|
// Changes may cause incorrect behavior and will be lost if the code is
|
||
|
// regenerated.
|
||
|
|
||
|
import (
|
||
|
"github.com/Azure/go-autorest/autorest"
|
||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||
|
"github.com/Azure/go-autorest/autorest/validation"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
// APIOperationsClient is the composite Swagger for ApiManagement Client
|
||
|
type APIOperationsClient struct {
|
||
|
ManagementClient
|
||
|
}
|
||
|
|
||
|
// NewAPIOperationsClient creates an instance of the APIOperationsClient
|
||
|
// client.
|
||
|
func NewAPIOperationsClient(subscriptionID string) APIOperationsClient {
|
||
|
return NewAPIOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||
|
}
|
||
|
|
||
|
// NewAPIOperationsClientWithBaseURI creates an instance of the
|
||
|
// APIOperationsClient client.
|
||
|
func NewAPIOperationsClientWithBaseURI(baseURI string, subscriptionID string) APIOperationsClient {
|
||
|
return APIOperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||
|
}
|
||
|
|
||
|
// CreateOrUpdate creates a new API operation or updates an existing one.
|
||
|
//
|
||
|
// resourceGroupName is the name of the resource group. serviceName is the name
|
||
|
// of the API Management service. aPIID is aPI identifier. Must be unique in
|
||
|
// the current API Management service instance. operationID is operation
|
||
|
// identifier within an API. Must be unique in the current API Management
|
||
|
// service instance. parameters is create parameters.
|
||
|
func (client APIOperationsClient) CreateOrUpdate(resourceGroupName string, serviceName string, aPIID string, operationID string, parameters OperationContract) (result autorest.Response, err error) {
|
||
|
if err := validation.Validate([]validation.Validation{
|
||
|
{TargetValue: serviceName,
|
||
|
Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
|
||
|
{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
|
||
|
{TargetValue: aPIID,
|
||
|
Constraints: []validation.Constraint{{Target: "aPIID", Name: validation.MaxLength, Rule: 256, Chain: nil},
|
||
|
{Target: "aPIID", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
{Target: "aPIID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
|
||
|
{TargetValue: operationID,
|
||
|
Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 256, Chain: nil},
|
||
|
{Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
{Target: "operationID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
|
||
|
{TargetValue: parameters,
|
||
|
Constraints: []validation.Constraint{{Target: "parameters.Name", Name: validation.Null, Rule: true,
|
||
|
Chain: []validation.Constraint{{Target: "parameters.Name", Name: validation.MaxLength, Rule: 300, Chain: nil},
|
||
|
{Target: "parameters.Name", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
}},
|
||
|
{Target: "parameters.Method", Name: validation.Null, Rule: true, Chain: nil},
|
||
|
{Target: "parameters.URLTemplate", Name: validation.Null, Rule: true,
|
||
|
Chain: []validation.Constraint{{Target: "parameters.URLTemplate", Name: validation.MaxLength, Rule: 1000, Chain: nil},
|
||
|
{Target: "parameters.URLTemplate", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
}}}}}); err != nil {
|
||
|
return result, validation.NewErrorWithValidationError(err, "apimanagement.APIOperationsClient", "CreateOrUpdate")
|
||
|
}
|
||
|
|
||
|
req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, aPIID, operationID, parameters)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.CreateOrUpdateSender(req)
|
||
|
if err != nil {
|
||
|
result.Response = resp
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "CreateOrUpdate", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.CreateOrUpdateResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "CreateOrUpdate", resp, "Failure responding to request")
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||
|
func (client APIOperationsClient) CreateOrUpdatePreparer(resourceGroupName string, serviceName string, aPIID string, operationID string, parameters OperationContract) (*http.Request, error) {
|
||
|
pathParameters := map[string]interface{}{
|
||
|
"apiId": autorest.Encode("path", aPIID),
|
||
|
"operationId": autorest.Encode("path", operationID),
|
||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
|
"serviceName": autorest.Encode("path", serviceName),
|
||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
|
}
|
||
|
|
||
|
const APIVersion = "2016-10-10"
|
||
|
queryParameters := map[string]interface{}{
|
||
|
"api-version": APIVersion,
|
||
|
}
|
||
|
|
||
|
preparer := autorest.CreatePreparer(
|
||
|
autorest.AsJSON(),
|
||
|
autorest.AsPut(),
|
||
|
autorest.WithBaseURL(client.BaseURI),
|
||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}", pathParameters),
|
||
|
autorest.WithJSON(parameters),
|
||
|
autorest.WithQueryParameters(queryParameters))
|
||
|
return preparer.Prepare(&http.Request{})
|
||
|
}
|
||
|
|
||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||
|
// http.Response Body if it receives an error.
|
||
|
func (client APIOperationsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
|
||
|
return autorest.SendWithSender(client, req)
|
||
|
}
|
||
|
|
||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||
|
// closes the http.Response Body.
|
||
|
func (client APIOperationsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) {
|
||
|
err = autorest.Respond(
|
||
|
resp,
|
||
|
client.ByInspecting(),
|
||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusNoContent),
|
||
|
autorest.ByClosing())
|
||
|
result.Response = resp
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// Delete deletes the specified operation.
|
||
|
//
|
||
|
// resourceGroupName is the name of the resource group. serviceName is the name
|
||
|
// of the API Management service. aPIID is aPI identifier. Must be unique in
|
||
|
// the current API Management service instance. operationID is operation
|
||
|
// identifier within an API. Must be unique in the current API Management
|
||
|
// service instance. ifMatch is eTag of the API Operation Entity. ETag should
|
||
|
// match the current entity state from the header response of the GET request
|
||
|
// or it should be * for unconditional update.
|
||
|
func (client APIOperationsClient) Delete(resourceGroupName string, serviceName string, aPIID string, operationID string, ifMatch string) (result autorest.Response, err error) {
|
||
|
if err := validation.Validate([]validation.Validation{
|
||
|
{TargetValue: serviceName,
|
||
|
Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
|
||
|
{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
|
||
|
{TargetValue: aPIID,
|
||
|
Constraints: []validation.Constraint{{Target: "aPIID", Name: validation.MaxLength, Rule: 256, Chain: nil},
|
||
|
{Target: "aPIID", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
{Target: "aPIID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
|
||
|
{TargetValue: operationID,
|
||
|
Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 256, Chain: nil},
|
||
|
{Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
{Target: "operationID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
|
||
|
return result, validation.NewErrorWithValidationError(err, "apimanagement.APIOperationsClient", "Delete")
|
||
|
}
|
||
|
|
||
|
req, err := client.DeletePreparer(resourceGroupName, serviceName, aPIID, operationID, ifMatch)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Delete", nil, "Failure preparing request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.DeleteSender(req)
|
||
|
if err != nil {
|
||
|
result.Response = resp
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Delete", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.DeleteResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Delete", resp, "Failure responding to request")
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// DeletePreparer prepares the Delete request.
|
||
|
func (client APIOperationsClient) DeletePreparer(resourceGroupName string, serviceName string, aPIID string, operationID string, ifMatch string) (*http.Request, error) {
|
||
|
pathParameters := map[string]interface{}{
|
||
|
"apiId": autorest.Encode("path", aPIID),
|
||
|
"operationId": autorest.Encode("path", operationID),
|
||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
|
"serviceName": autorest.Encode("path", serviceName),
|
||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
|
}
|
||
|
|
||
|
const APIVersion = "2016-10-10"
|
||
|
queryParameters := map[string]interface{}{
|
||
|
"api-version": APIVersion,
|
||
|
}
|
||
|
|
||
|
preparer := autorest.CreatePreparer(
|
||
|
autorest.AsDelete(),
|
||
|
autorest.WithBaseURL(client.BaseURI),
|
||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}", pathParameters),
|
||
|
autorest.WithQueryParameters(queryParameters),
|
||
|
autorest.WithHeader("If-Match", autorest.String(ifMatch)))
|
||
|
return preparer.Prepare(&http.Request{})
|
||
|
}
|
||
|
|
||
|
// DeleteSender sends the Delete request. The method will close the
|
||
|
// http.Response Body if it receives an error.
|
||
|
func (client APIOperationsClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
||
|
return autorest.SendWithSender(client, req)
|
||
|
}
|
||
|
|
||
|
// DeleteResponder handles the response to the Delete request. The method always
|
||
|
// closes the http.Response Body.
|
||
|
func (client APIOperationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||
|
err = autorest.Respond(
|
||
|
resp,
|
||
|
client.ByInspecting(),
|
||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
|
||
|
autorest.ByClosing())
|
||
|
result.Response = resp
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// Get gets the details of the API Operation specified by its identifier.
|
||
|
//
|
||
|
// resourceGroupName is the name of the resource group. serviceName is the name
|
||
|
// of the API Management service. aPIID is aPI identifier. Must be unique in
|
||
|
// the current API Management service instance. operationID is operation
|
||
|
// identifier within an API. Must be unique in the current API Management
|
||
|
// service instance.
|
||
|
func (client APIOperationsClient) Get(resourceGroupName string, serviceName string, aPIID string, operationID string) (result OperationContract, err error) {
|
||
|
if err := validation.Validate([]validation.Validation{
|
||
|
{TargetValue: serviceName,
|
||
|
Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
|
||
|
{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
|
||
|
{TargetValue: aPIID,
|
||
|
Constraints: []validation.Constraint{{Target: "aPIID", Name: validation.MaxLength, Rule: 256, Chain: nil},
|
||
|
{Target: "aPIID", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
{Target: "aPIID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
|
||
|
{TargetValue: operationID,
|
||
|
Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 256, Chain: nil},
|
||
|
{Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
{Target: "operationID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
|
||
|
return result, validation.NewErrorWithValidationError(err, "apimanagement.APIOperationsClient", "Get")
|
||
|
}
|
||
|
|
||
|
req, err := client.GetPreparer(resourceGroupName, serviceName, aPIID, operationID)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Get", nil, "Failure preparing request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.GetSender(req)
|
||
|
if err != nil {
|
||
|
result.Response = autorest.Response{Response: resp}
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Get", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.GetResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Get", resp, "Failure responding to request")
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// GetPreparer prepares the Get request.
|
||
|
func (client APIOperationsClient) GetPreparer(resourceGroupName string, serviceName string, aPIID string, operationID string) (*http.Request, error) {
|
||
|
pathParameters := map[string]interface{}{
|
||
|
"apiId": autorest.Encode("path", aPIID),
|
||
|
"operationId": autorest.Encode("path", operationID),
|
||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
|
"serviceName": autorest.Encode("path", serviceName),
|
||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
|
}
|
||
|
|
||
|
const APIVersion = "2016-10-10"
|
||
|
queryParameters := map[string]interface{}{
|
||
|
"api-version": APIVersion,
|
||
|
}
|
||
|
|
||
|
preparer := autorest.CreatePreparer(
|
||
|
autorest.AsGet(),
|
||
|
autorest.WithBaseURL(client.BaseURI),
|
||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}", pathParameters),
|
||
|
autorest.WithQueryParameters(queryParameters))
|
||
|
return preparer.Prepare(&http.Request{})
|
||
|
}
|
||
|
|
||
|
// GetSender sends the Get request. The method will close the
|
||
|
// http.Response Body if it receives an error.
|
||
|
func (client APIOperationsClient) GetSender(req *http.Request) (*http.Response, error) {
|
||
|
return autorest.SendWithSender(client, req)
|
||
|
}
|
||
|
|
||
|
// GetResponder handles the response to the Get request. The method always
|
||
|
// closes the http.Response Body.
|
||
|
func (client APIOperationsClient) GetResponder(resp *http.Response) (result OperationContract, err error) {
|
||
|
err = autorest.Respond(
|
||
|
resp,
|
||
|
client.ByInspecting(),
|
||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||
|
autorest.ByUnmarshallingJSON(&result),
|
||
|
autorest.ByClosing())
|
||
|
result.Response = autorest.Response{Response: resp}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// ListByApis lists a collection of the operations for the specified API.
|
||
|
//
|
||
|
// resourceGroupName is the name of the resource group. serviceName is the name
|
||
|
// of the API Management service. aPIID is aPI identifier. Must be unique in
|
||
|
// the current API Management service instance. filter is | Field |
|
||
|
// Supported operators | Supported functions |
|
||
|
// |-------------|------------------------|-----------------------------------|
|
||
|
// | name | ge, le, eq, ne, gt, lt | substringof, startswith, endswith |
|
||
|
// | method | ge, le, eq, ne, gt, lt | substringof, startswith, endswith |
|
||
|
// | description | ge, le, eq, ne, gt, lt | substringof, startswith, endswith |
|
||
|
// | urlTemplate | ge, le, eq, ne, gt, lt | substringof, startswith, endswith |
|
||
|
// top is number of records to return. skip is number of records to skip.
|
||
|
func (client APIOperationsClient) ListByApis(resourceGroupName string, serviceName string, aPIID string, filter string, top *int32, skip *int32) (result OperationCollection, err error) {
|
||
|
if err := validation.Validate([]validation.Validation{
|
||
|
{TargetValue: serviceName,
|
||
|
Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
|
||
|
{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
|
||
|
{TargetValue: aPIID,
|
||
|
Constraints: []validation.Constraint{{Target: "aPIID", Name: validation.MaxLength, Rule: 256, Chain: nil},
|
||
|
{Target: "aPIID", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
{Target: "aPIID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
|
||
|
{TargetValue: top,
|
||
|
Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false,
|
||
|
Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}},
|
||
|
{TargetValue: skip,
|
||
|
Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false,
|
||
|
Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil {
|
||
|
return result, validation.NewErrorWithValidationError(err, "apimanagement.APIOperationsClient", "ListByApis")
|
||
|
}
|
||
|
|
||
|
req, err := client.ListByApisPreparer(resourceGroupName, serviceName, aPIID, filter, top, skip)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByApis", nil, "Failure preparing request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.ListByApisSender(req)
|
||
|
if err != nil {
|
||
|
result.Response = autorest.Response{Response: resp}
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByApis", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.ListByApisResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByApis", resp, "Failure responding to request")
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// ListByApisPreparer prepares the ListByApis request.
|
||
|
func (client APIOperationsClient) ListByApisPreparer(resourceGroupName string, serviceName string, aPIID string, filter string, top *int32, skip *int32) (*http.Request, error) {
|
||
|
pathParameters := map[string]interface{}{
|
||
|
"apiId": autorest.Encode("path", aPIID),
|
||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
|
"serviceName": autorest.Encode("path", serviceName),
|
||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
|
}
|
||
|
|
||
|
const APIVersion = "2016-10-10"
|
||
|
queryParameters := map[string]interface{}{
|
||
|
"api-version": APIVersion,
|
||
|
}
|
||
|
if len(filter) > 0 {
|
||
|
queryParameters["$filter"] = autorest.Encode("query", filter)
|
||
|
}
|
||
|
if top != nil {
|
||
|
queryParameters["$top"] = autorest.Encode("query", *top)
|
||
|
}
|
||
|
if skip != nil {
|
||
|
queryParameters["$skip"] = autorest.Encode("query", *skip)
|
||
|
}
|
||
|
|
||
|
preparer := autorest.CreatePreparer(
|
||
|
autorest.AsGet(),
|
||
|
autorest.WithBaseURL(client.BaseURI),
|
||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations", pathParameters),
|
||
|
autorest.WithQueryParameters(queryParameters))
|
||
|
return preparer.Prepare(&http.Request{})
|
||
|
}
|
||
|
|
||
|
// ListByApisSender sends the ListByApis request. The method will close the
|
||
|
// http.Response Body if it receives an error.
|
||
|
func (client APIOperationsClient) ListByApisSender(req *http.Request) (*http.Response, error) {
|
||
|
return autorest.SendWithSender(client, req)
|
||
|
}
|
||
|
|
||
|
// ListByApisResponder handles the response to the ListByApis request. The method always
|
||
|
// closes the http.Response Body.
|
||
|
func (client APIOperationsClient) ListByApisResponder(resp *http.Response) (result OperationCollection, err error) {
|
||
|
err = autorest.Respond(
|
||
|
resp,
|
||
|
client.ByInspecting(),
|
||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||
|
autorest.ByUnmarshallingJSON(&result),
|
||
|
autorest.ByClosing())
|
||
|
result.Response = autorest.Response{Response: resp}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// ListByApisNextResults retrieves the next set of results, if any.
|
||
|
func (client APIOperationsClient) ListByApisNextResults(lastResults OperationCollection) (result OperationCollection, err error) {
|
||
|
req, err := lastResults.OperationCollectionPreparer()
|
||
|
if err != nil {
|
||
|
return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByApis", nil, "Failure preparing next results request")
|
||
|
}
|
||
|
if req == nil {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.ListByApisSender(req)
|
||
|
if err != nil {
|
||
|
result.Response = autorest.Response{Response: resp}
|
||
|
return result, autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByApis", resp, "Failure sending next results request")
|
||
|
}
|
||
|
|
||
|
result, err = client.ListByApisResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "ListByApis", resp, "Failure responding to next results request")
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// Update updates the details of the operation specified by its identifier.
|
||
|
//
|
||
|
// resourceGroupName is the name of the resource group. serviceName is the name
|
||
|
// of the API Management service. aPIID is aPI identifier. Must be unique in
|
||
|
// the current API Management service instance. operationID is operation
|
||
|
// identifier within an API. Must be unique in the current API Management
|
||
|
// service instance. parameters is aPI Operation Update parameters. ifMatch is
|
||
|
// eTag of the API Operation Entity. ETag should match the current entity state
|
||
|
// from the header response of the GET request or it should be * for
|
||
|
// unconditional update.
|
||
|
func (client APIOperationsClient) Update(resourceGroupName string, serviceName string, aPIID string, operationID string, parameters OperationUpdateContract, ifMatch string) (result autorest.Response, err error) {
|
||
|
if err := validation.Validate([]validation.Validation{
|
||
|
{TargetValue: serviceName,
|
||
|
Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil},
|
||
|
{Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
{Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}},
|
||
|
{TargetValue: aPIID,
|
||
|
Constraints: []validation.Constraint{{Target: "aPIID", Name: validation.MaxLength, Rule: 256, Chain: nil},
|
||
|
{Target: "aPIID", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
{Target: "aPIID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
|
||
|
{TargetValue: operationID,
|
||
|
Constraints: []validation.Constraint{{Target: "operationID", Name: validation.MaxLength, Rule: 256, Chain: nil},
|
||
|
{Target: "operationID", Name: validation.MinLength, Rule: 1, Chain: nil},
|
||
|
{Target: "operationID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
|
||
|
return result, validation.NewErrorWithValidationError(err, "apimanagement.APIOperationsClient", "Update")
|
||
|
}
|
||
|
|
||
|
req, err := client.UpdatePreparer(resourceGroupName, serviceName, aPIID, operationID, parameters, ifMatch)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Update", nil, "Failure preparing request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
resp, err := client.UpdateSender(req)
|
||
|
if err != nil {
|
||
|
result.Response = resp
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Update", resp, "Failure sending request")
|
||
|
return
|
||
|
}
|
||
|
|
||
|
result, err = client.UpdateResponder(resp)
|
||
|
if err != nil {
|
||
|
err = autorest.NewErrorWithError(err, "apimanagement.APIOperationsClient", "Update", resp, "Failure responding to request")
|
||
|
}
|
||
|
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// UpdatePreparer prepares the Update request.
|
||
|
func (client APIOperationsClient) UpdatePreparer(resourceGroupName string, serviceName string, aPIID string, operationID string, parameters OperationUpdateContract, ifMatch string) (*http.Request, error) {
|
||
|
pathParameters := map[string]interface{}{
|
||
|
"apiId": autorest.Encode("path", aPIID),
|
||
|
"operationId": autorest.Encode("path", operationID),
|
||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||
|
"serviceName": autorest.Encode("path", serviceName),
|
||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||
|
}
|
||
|
|
||
|
const APIVersion = "2016-10-10"
|
||
|
queryParameters := map[string]interface{}{
|
||
|
"api-version": APIVersion,
|
||
|
}
|
||
|
|
||
|
preparer := autorest.CreatePreparer(
|
||
|
autorest.AsJSON(),
|
||
|
autorest.AsPatch(),
|
||
|
autorest.WithBaseURL(client.BaseURI),
|
||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/operations/{operationId}", pathParameters),
|
||
|
autorest.WithJSON(parameters),
|
||
|
autorest.WithQueryParameters(queryParameters),
|
||
|
autorest.WithHeader("If-Match", autorest.String(ifMatch)))
|
||
|
return preparer.Prepare(&http.Request{})
|
||
|
}
|
||
|
|
||
|
// UpdateSender sends the Update request. The method will close the
|
||
|
// http.Response Body if it receives an error.
|
||
|
func (client APIOperationsClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
||
|
return autorest.SendWithSender(client, req)
|
||
|
}
|
||
|
|
||
|
// UpdateResponder handles the response to the Update request. The method always
|
||
|
// closes the http.Response Body.
|
||
|
func (client APIOperationsClient) UpdateResponder(resp *http.Response) (result autorest.Response, err error) {
|
||
|
err = autorest.Respond(
|
||
|
resp,
|
||
|
client.ByInspecting(),
|
||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
|
||
|
autorest.ByClosing())
|
||
|
result.Response = resp
|
||
|
return
|
||
|
}
|