1package apimanagement 2 3// Copyright (c) Microsoft Corporation. All rights reserved. 4// Licensed under the MIT License. See License.txt in the project root for license information. 5// 6// Code generated by Microsoft (R) AutoRest Code Generator. 7// Changes may cause incorrect behavior and will be lost if the code is regenerated. 8 9import ( 10 "context" 11 "github.com/Azure/go-autorest/autorest" 12 "github.com/Azure/go-autorest/autorest/azure" 13 "github.com/Azure/go-autorest/autorest/validation" 14 "github.com/Azure/go-autorest/tracing" 15 "net/http" 16) 17 18// APIIssuCommentClient is the apiManagement Client 19type APIIssuCommentClient struct { 20 BaseClient 21} 22 23// NewAPIIssuCommentClient creates an instance of the APIIssuCommentClient client. 24func NewAPIIssuCommentClient(subscriptionID string) APIIssuCommentClient { 25 return NewAPIIssuCommentClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewAPIIssuCommentClientWithBaseURI creates an instance of the APIIssuCommentClient client using a custom endpoint. 29// Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewAPIIssuCommentClientWithBaseURI(baseURI string, subscriptionID string) APIIssuCommentClient { 31 return APIIssuCommentClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// Head gets the entity state (Etag) version of the issue Comment for an API specified by its identifier. 35// Parameters: 36// resourceGroupName - the name of the resource group. 37// serviceName - the name of the API Management service. 38// apiid - API identifier. Must be unique in the current API Management service instance. 39// issueID - issue identifier. Must be unique in the current API Management service instance. 40// commentID - comment identifier within an Issue. Must be unique in the current Issue. 41func (client APIIssuCommentClient) Head(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string) (result autorest.Response, err error) { 42 if tracing.IsEnabled() { 43 ctx = tracing.StartSpan(ctx, fqdn+"/APIIssuCommentClient.Head") 44 defer func() { 45 sc := -1 46 if result.Response != nil { 47 sc = result.Response.StatusCode 48 } 49 tracing.EndSpan(ctx, sc, err) 50 }() 51 } 52 if err := validation.Validate([]validation.Validation{ 53 {TargetValue: serviceName, 54 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 55 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 56 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 57 {TargetValue: apiid, 58 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 59 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 60 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 61 {TargetValue: issueID, 62 Constraints: []validation.Constraint{{Target: "issueID", Name: validation.MaxLength, Rule: 256, Chain: nil}, 63 {Target: "issueID", Name: validation.MinLength, Rule: 1, Chain: nil}, 64 {Target: "issueID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 65 {TargetValue: commentID, 66 Constraints: []validation.Constraint{{Target: "commentID", Name: validation.MaxLength, Rule: 256, Chain: nil}, 67 {Target: "commentID", Name: validation.MinLength, Rule: 1, Chain: nil}, 68 {Target: "commentID", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}}); err != nil { 69 return result, validation.NewError("apimanagement.APIIssuCommentClient", "Head", err.Error()) 70 } 71 72 req, err := client.HeadPreparer(ctx, resourceGroupName, serviceName, apiid, issueID, commentID) 73 if err != nil { 74 err = autorest.NewErrorWithError(err, "apimanagement.APIIssuCommentClient", "Head", nil, "Failure preparing request") 75 return 76 } 77 78 resp, err := client.HeadSender(req) 79 if err != nil { 80 result.Response = resp 81 err = autorest.NewErrorWithError(err, "apimanagement.APIIssuCommentClient", "Head", resp, "Failure sending request") 82 return 83 } 84 85 result, err = client.HeadResponder(resp) 86 if err != nil { 87 err = autorest.NewErrorWithError(err, "apimanagement.APIIssuCommentClient", "Head", resp, "Failure responding to request") 88 return 89 } 90 91 return 92} 93 94// HeadPreparer prepares the Head request. 95func (client APIIssuCommentClient) HeadPreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, issueID string, commentID string) (*http.Request, error) { 96 pathParameters := map[string]interface{}{ 97 "apiId": autorest.Encode("path", apiid), 98 "commentId": autorest.Encode("path", commentID), 99 "issueId": autorest.Encode("path", issueID), 100 "resourceGroupName": autorest.Encode("path", resourceGroupName), 101 "serviceName": autorest.Encode("path", serviceName), 102 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 103 } 104 105 const APIVersion = "2017-03-01" 106 queryParameters := map[string]interface{}{ 107 "api-version": APIVersion, 108 } 109 110 preparer := autorest.CreatePreparer( 111 autorest.AsHead(), 112 autorest.WithBaseURL(client.BaseURI), 113 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues/{issueId}/comments/{commentId}", pathParameters), 114 autorest.WithQueryParameters(queryParameters)) 115 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 116} 117 118// HeadSender sends the Head request. The method will close the 119// http.Response Body if it receives an error. 120func (client APIIssuCommentClient) HeadSender(req *http.Request) (*http.Response, error) { 121 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 122} 123 124// HeadResponder handles the response to the Head request. The method always 125// closes the http.Response Body. 126func (client APIIssuCommentClient) HeadResponder(resp *http.Response) (result autorest.Response, err error) { 127 err = autorest.Respond( 128 resp, 129 azure.WithErrorUnlessStatusCode(http.StatusOK), 130 autorest.ByClosing()) 131 result.Response = resp 132 return 133} 134