mirror of
https://github.com/octoleo/restic.git
synced 2024-12-02 09:58:25 +00:00
423 lines
19 KiB
Go
Executable File
423 lines
19 KiB
Go
Executable File
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"
|
|
)
|
|
|
|
// CertificatesClient is the composite Swagger for ApiManagement Client
|
|
type CertificatesClient struct {
|
|
ManagementClient
|
|
}
|
|
|
|
// NewCertificatesClient creates an instance of the CertificatesClient client.
|
|
func NewCertificatesClient(subscriptionID string) CertificatesClient {
|
|
return NewCertificatesClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
|
}
|
|
|
|
// NewCertificatesClientWithBaseURI creates an instance of the
|
|
// CertificatesClient client.
|
|
func NewCertificatesClientWithBaseURI(baseURI string, subscriptionID string) CertificatesClient {
|
|
return CertificatesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
|
}
|
|
|
|
// CreateOrUpdate creates or updates the certificate being used for
|
|
// authentication with the backend.
|
|
//
|
|
// resourceGroupName is the name of the resource group. serviceName is the name
|
|
// of the API Management service. certificateID is identifier of the
|
|
// certificate entity. Must be unique in the current API Management service
|
|
// instance. parameters is create parameters. ifMatch is the entity state
|
|
// (Etag) version of the certificate to update. A value of "*" can be used for
|
|
// If-Match to unconditionally apply the operation..
|
|
func (client CertificatesClient) CreateOrUpdate(resourceGroupName string, serviceName string, certificateID string, parameters CertificateCreateOrUpdateParameters, 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: certificateID,
|
|
Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 256, Chain: nil},
|
|
{Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil},
|
|
{Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}},
|
|
{TargetValue: parameters,
|
|
Constraints: []validation.Constraint{{Target: "parameters.Data", Name: validation.Null, Rule: true, Chain: nil},
|
|
{Target: "parameters.Password", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "apimanagement.CertificatesClient", "CreateOrUpdate")
|
|
}
|
|
|
|
req, err := client.CreateOrUpdatePreparer(resourceGroupName, serviceName, certificateID, parameters, ifMatch)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "CreateOrUpdate", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.CreateOrUpdateSender(req)
|
|
if err != nil {
|
|
result.Response = resp
|
|
err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "CreateOrUpdate", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.CreateOrUpdateResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "CreateOrUpdate", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
|
func (client CertificatesClient) CreateOrUpdatePreparer(resourceGroupName string, serviceName string, certificateID string, parameters CertificateCreateOrUpdateParameters, ifMatch string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"certificateId": autorest.Encode("path", certificateID),
|
|
"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}/certificates/{certificateId}", pathParameters),
|
|
autorest.WithJSON(parameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
if len(ifMatch) > 0 {
|
|
preparer = autorest.DecoratePreparer(preparer,
|
|
autorest.WithHeader("If-Match", autorest.String(ifMatch)))
|
|
}
|
|
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 CertificatesClient) 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 CertificatesClient) 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 specific certificate.
|
|
//
|
|
// resourceGroupName is the name of the resource group. serviceName is the name
|
|
// of the API Management service. certificateID is identifier of the
|
|
// certificate entity. Must be unique in the current API Management service
|
|
// instance. ifMatch is the entity state (Etag) version of the certificate to
|
|
// delete. A value of "*" can be used for If-Match to unconditionally apply the
|
|
// operation.
|
|
func (client CertificatesClient) Delete(resourceGroupName string, serviceName string, certificateID 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: certificateID,
|
|
Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 256, Chain: nil},
|
|
{Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil},
|
|
{Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "apimanagement.CertificatesClient", "Delete")
|
|
}
|
|
|
|
req, err := client.DeletePreparer(resourceGroupName, serviceName, certificateID, ifMatch)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "Delete", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.DeleteSender(req)
|
|
if err != nil {
|
|
result.Response = resp
|
|
err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "Delete", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.DeleteResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "Delete", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// DeletePreparer prepares the Delete request.
|
|
func (client CertificatesClient) DeletePreparer(resourceGroupName string, serviceName string, certificateID string, ifMatch string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"certificateId": autorest.Encode("path", certificateID),
|
|
"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}/certificates/{certificateId}", 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 CertificatesClient) 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 CertificatesClient) 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 certificate specified by its identifier.
|
|
//
|
|
// resourceGroupName is the name of the resource group. serviceName is the name
|
|
// of the API Management service. certificateID is identifier of the
|
|
// certificate entity. Must be unique in the current API Management service
|
|
// instance.
|
|
func (client CertificatesClient) Get(resourceGroupName string, serviceName string, certificateID string) (result CertificateContract, 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: certificateID,
|
|
Constraints: []validation.Constraint{{Target: "certificateID", Name: validation.MaxLength, Rule: 256, Chain: nil},
|
|
{Target: "certificateID", Name: validation.MinLength, Rule: 1, Chain: nil},
|
|
{Target: "certificateID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil {
|
|
return result, validation.NewErrorWithValidationError(err, "apimanagement.CertificatesClient", "Get")
|
|
}
|
|
|
|
req, err := client.GetPreparer(resourceGroupName, serviceName, certificateID)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "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.CertificatesClient", "Get", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.GetResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "Get", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// GetPreparer prepares the Get request.
|
|
func (client CertificatesClient) GetPreparer(resourceGroupName string, serviceName string, certificateID string) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"certificateId": autorest.Encode("path", certificateID),
|
|
"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}/certificates/{certificateId}", 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 CertificatesClient) 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 CertificatesClient) GetResponder(resp *http.Response) (result CertificateContract, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// ListByService lists a collection of all certificates in the specified
|
|
// service instance.
|
|
//
|
|
// resourceGroupName is the name of the resource group. serviceName is the name
|
|
// of the API Management service. filter is | Field | Supported
|
|
// operators | Supported functions |
|
|
// |----------------|------------------------|---------------------------------------------|
|
|
// | id | ge, le, eq, ne, gt, lt | substringof, contains,
|
|
// startswith, endswith |
|
|
// | subject | ge, le, eq, ne, gt, lt | substringof, contains,
|
|
// startswith, endswith |
|
|
// | thumbprint | ge, le, eq, ne, gt, lt | substringof, contains,
|
|
// startswith, endswith |
|
|
// | expirationDate | ge, le, eq, ne, gt, lt | N/A
|
|
// | top is number of records to return. skip is number of records to skip.
|
|
func (client CertificatesClient) ListByService(resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (result CertificateCollection, 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: 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.CertificatesClient", "ListByService")
|
|
}
|
|
|
|
req, err := client.ListByServicePreparer(resourceGroupName, serviceName, filter, top, skip)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "ListByService", nil, "Failure preparing request")
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListByServiceSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "ListByService", resp, "Failure sending request")
|
|
return
|
|
}
|
|
|
|
result, err = client.ListByServiceResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "ListByService", resp, "Failure responding to request")
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// ListByServicePreparer prepares the ListByService request.
|
|
func (client CertificatesClient) ListByServicePreparer(resourceGroupName string, serviceName string, filter string, top *int32, skip *int32) (*http.Request, error) {
|
|
pathParameters := map[string]interface{}{
|
|
"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}/certificates", pathParameters),
|
|
autorest.WithQueryParameters(queryParameters))
|
|
return preparer.Prepare(&http.Request{})
|
|
}
|
|
|
|
// ListByServiceSender sends the ListByService request. The method will close the
|
|
// http.Response Body if it receives an error.
|
|
func (client CertificatesClient) ListByServiceSender(req *http.Request) (*http.Response, error) {
|
|
return autorest.SendWithSender(client, req)
|
|
}
|
|
|
|
// ListByServiceResponder handles the response to the ListByService request. The method always
|
|
// closes the http.Response Body.
|
|
func (client CertificatesClient) ListByServiceResponder(resp *http.Response) (result CertificateCollection, err error) {
|
|
err = autorest.Respond(
|
|
resp,
|
|
client.ByInspecting(),
|
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
|
autorest.ByUnmarshallingJSON(&result),
|
|
autorest.ByClosing())
|
|
result.Response = autorest.Response{Response: resp}
|
|
return
|
|
}
|
|
|
|
// ListByServiceNextResults retrieves the next set of results, if any.
|
|
func (client CertificatesClient) ListByServiceNextResults(lastResults CertificateCollection) (result CertificateCollection, err error) {
|
|
req, err := lastResults.CertificateCollectionPreparer()
|
|
if err != nil {
|
|
return result, autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "ListByService", nil, "Failure preparing next results request")
|
|
}
|
|
if req == nil {
|
|
return
|
|
}
|
|
|
|
resp, err := client.ListByServiceSender(req)
|
|
if err != nil {
|
|
result.Response = autorest.Response{Response: resp}
|
|
return result, autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "ListByService", resp, "Failure sending next results request")
|
|
}
|
|
|
|
result, err = client.ListByServiceResponder(resp)
|
|
if err != nil {
|
|
err = autorest.NewErrorWithError(err, "apimanagement.CertificatesClient", "ListByService", resp, "Failure responding to next results request")
|
|
}
|
|
|
|
return
|
|
}
|