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 "github.com/Azure/go-autorest/tracing" 26 "net/http" 27) 28 29// TenantConfigurationSyncStateClient is the apiManagement Client 30type TenantConfigurationSyncStateClient struct { 31 BaseClient 32} 33 34// NewTenantConfigurationSyncStateClient creates an instance of the TenantConfigurationSyncStateClient client. 35func NewTenantConfigurationSyncStateClient(subscriptionID string) TenantConfigurationSyncStateClient { 36 return NewTenantConfigurationSyncStateClientWithBaseURI(DefaultBaseURI, subscriptionID) 37} 38 39// NewTenantConfigurationSyncStateClientWithBaseURI creates an instance of the TenantConfigurationSyncStateClient 40// client using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI 41// (sovereign clouds, Azure stack). 42func NewTenantConfigurationSyncStateClientWithBaseURI(baseURI string, subscriptionID string) TenantConfigurationSyncStateClient { 43 return TenantConfigurationSyncStateClient{NewWithBaseURI(baseURI, subscriptionID)} 44} 45 46// Get gets the status of the most recent synchronization between the configuration database and the Git repository. 47// Parameters: 48// resourceGroupName - the name of the resource group. 49// serviceName - the name of the API Management service. 50func (client TenantConfigurationSyncStateClient) Get(ctx context.Context, resourceGroupName string, serviceName string) (result TenantConfigurationSyncStateContract, err error) { 51 if tracing.IsEnabled() { 52 ctx = tracing.StartSpan(ctx, fqdn+"/TenantConfigurationSyncStateClient.Get") 53 defer func() { 54 sc := -1 55 if result.Response.Response != nil { 56 sc = result.Response.Response.StatusCode 57 } 58 tracing.EndSpan(ctx, sc, err) 59 }() 60 } 61 if err := validation.Validate([]validation.Validation{ 62 {TargetValue: serviceName, 63 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 64 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 65 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}}); err != nil { 66 return result, validation.NewError("apimanagement.TenantConfigurationSyncStateClient", "Get", err.Error()) 67 } 68 69 req, err := client.GetPreparer(ctx, resourceGroupName, serviceName) 70 if err != nil { 71 err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationSyncStateClient", "Get", nil, "Failure preparing request") 72 return 73 } 74 75 resp, err := client.GetSender(req) 76 if err != nil { 77 result.Response = autorest.Response{Response: resp} 78 err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationSyncStateClient", "Get", resp, "Failure sending request") 79 return 80 } 81 82 result, err = client.GetResponder(resp) 83 if err != nil { 84 err = autorest.NewErrorWithError(err, "apimanagement.TenantConfigurationSyncStateClient", "Get", resp, "Failure responding to request") 85 return 86 } 87 88 return 89} 90 91// GetPreparer prepares the Get request. 92func (client TenantConfigurationSyncStateClient) GetPreparer(ctx context.Context, resourceGroupName string, serviceName string) (*http.Request, error) { 93 pathParameters := map[string]interface{}{ 94 "resourceGroupName": autorest.Encode("path", resourceGroupName), 95 "serviceName": autorest.Encode("path", serviceName), 96 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 97 } 98 99 const APIVersion = "2016-07-07" 100 queryParameters := map[string]interface{}{ 101 "api-version": APIVersion, 102 } 103 104 preparer := autorest.CreatePreparer( 105 autorest.AsGet(), 106 autorest.WithBaseURL(client.BaseURI), 107 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/tenant/configuration/syncState", pathParameters), 108 autorest.WithQueryParameters(queryParameters)) 109 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 110} 111 112// GetSender sends the Get request. The method will close the 113// http.Response Body if it receives an error. 114func (client TenantConfigurationSyncStateClient) GetSender(req *http.Request) (*http.Response, error) { 115 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 116} 117 118// GetResponder handles the response to the Get request. The method always 119// closes the http.Response Body. 120func (client TenantConfigurationSyncStateClient) GetResponder(resp *http.Response) (result TenantConfigurationSyncStateContract, err error) { 121 err = autorest.Respond( 122 resp, 123 azure.WithErrorUnlessStatusCode(http.StatusOK), 124 autorest.ByUnmarshallingJSON(&result), 125 autorest.ByClosing()) 126 result.Response = autorest.Response{Response: resp} 127 return 128} 129