1package network 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/tracing" 25 "net/http" 26) 27 28// ServiceTagsClient is the network Client 29type ServiceTagsClient struct { 30 BaseClient 31} 32 33// NewServiceTagsClient creates an instance of the ServiceTagsClient client. 34func NewServiceTagsClient(subscriptionID string) ServiceTagsClient { 35 return NewServiceTagsClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewServiceTagsClientWithBaseURI creates an instance of the ServiceTagsClient client using a custom endpoint. Use 39// this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 40func NewServiceTagsClientWithBaseURI(baseURI string, subscriptionID string) ServiceTagsClient { 41 return ServiceTagsClient{NewWithBaseURI(baseURI, subscriptionID)} 42} 43 44// List gets a list of service tag information resources. 45// Parameters: 46// location - the location that will be used as a reference for version (not as a filter based on location, you 47// will get the list of service tags with prefix details across all regions but limited to the cloud that your 48// subscription belongs to). 49func (client ServiceTagsClient) List(ctx context.Context, location string) (result ServiceTagsListResult, err error) { 50 if tracing.IsEnabled() { 51 ctx = tracing.StartSpan(ctx, fqdn+"/ServiceTagsClient.List") 52 defer func() { 53 sc := -1 54 if result.Response.Response != nil { 55 sc = result.Response.Response.StatusCode 56 } 57 tracing.EndSpan(ctx, sc, err) 58 }() 59 } 60 req, err := client.ListPreparer(ctx, location) 61 if err != nil { 62 err = autorest.NewErrorWithError(err, "network.ServiceTagsClient", "List", nil, "Failure preparing request") 63 return 64 } 65 66 resp, err := client.ListSender(req) 67 if err != nil { 68 result.Response = autorest.Response{Response: resp} 69 err = autorest.NewErrorWithError(err, "network.ServiceTagsClient", "List", resp, "Failure sending request") 70 return 71 } 72 73 result, err = client.ListResponder(resp) 74 if err != nil { 75 err = autorest.NewErrorWithError(err, "network.ServiceTagsClient", "List", resp, "Failure responding to request") 76 } 77 78 return 79} 80 81// ListPreparer prepares the List request. 82func (client ServiceTagsClient) ListPreparer(ctx context.Context, location string) (*http.Request, error) { 83 pathParameters := map[string]interface{}{ 84 "location": autorest.Encode("path", location), 85 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 86 } 87 88 const APIVersion = "2020-04-01" 89 queryParameters := map[string]interface{}{ 90 "api-version": APIVersion, 91 } 92 93 preparer := autorest.CreatePreparer( 94 autorest.AsGet(), 95 autorest.WithBaseURL(client.BaseURI), 96 autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/serviceTags", pathParameters), 97 autorest.WithQueryParameters(queryParameters)) 98 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 99} 100 101// ListSender sends the List request. The method will close the 102// http.Response Body if it receives an error. 103func (client ServiceTagsClient) ListSender(req *http.Request) (*http.Response, error) { 104 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 105} 106 107// ListResponder handles the response to the List request. The method always 108// closes the http.Response Body. 109func (client ServiceTagsClient) ListResponder(resp *http.Response) (result ServiceTagsListResult, err error) { 110 err = autorest.Respond( 111 resp, 112 client.ByInspecting(), 113 azure.WithErrorUnlessStatusCode(http.StatusOK), 114 autorest.ByUnmarshallingJSON(&result), 115 autorest.ByClosing()) 116 result.Response = autorest.Response{Response: resp} 117 return 118} 119