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