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// APIIssuesClient is the apiManagement Client 29type APIIssuesClient struct { 30 BaseClient 31} 32 33// NewAPIIssuesClient creates an instance of the APIIssuesClient client. 34func NewAPIIssuesClient(subscriptionID string) APIIssuesClient { 35 return NewAPIIssuesClientWithBaseURI(DefaultBaseURI, subscriptionID) 36} 37 38// NewAPIIssuesClientWithBaseURI creates an instance of the APIIssuesClient client. 39func NewAPIIssuesClientWithBaseURI(baseURI string, subscriptionID string) APIIssuesClient { 40 return APIIssuesClient{NewWithBaseURI(baseURI, subscriptionID)} 41} 42 43// ListByService lists all issues assosiated with the specified API. 44// Parameters: 45// resourceGroupName - the name of the resource group. 46// serviceName - the name of the API Management service. 47// apiid - API identifier. Must be unique in the current API Management service instance. 48// filter - | Field | Supported operators | Supported functions | 49// |-------------|------------------------|-----------------------------------| 50// | id | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | 51// | state | eq | | 52// | userId | ge, le, eq, ne, gt, lt | substringof, startswith, endswith | 53// top - number of records to return. 54// skip - number of records to skip. 55func (client APIIssuesClient) ListByService(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result IssueCollectionPage, err error) { 56 if err := validation.Validate([]validation.Validation{ 57 {TargetValue: serviceName, 58 Constraints: []validation.Constraint{{Target: "serviceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, 59 {Target: "serviceName", Name: validation.MinLength, Rule: 1, Chain: nil}, 60 {Target: "serviceName", Name: validation.Pattern, Rule: `^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$`, Chain: nil}}}, 61 {TargetValue: apiid, 62 Constraints: []validation.Constraint{{Target: "apiid", Name: validation.MaxLength, Rule: 256, Chain: nil}, 63 {Target: "apiid", Name: validation.MinLength, Rule: 1, Chain: nil}, 64 {Target: "apiid", Name: validation.Pattern, Rule: `^[^*#&+:<>?]+$`, Chain: nil}}}, 65 {TargetValue: top, 66 Constraints: []validation.Constraint{{Target: "top", Name: validation.Null, Rule: false, 67 Chain: []validation.Constraint{{Target: "top", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}}}}}, 68 {TargetValue: skip, 69 Constraints: []validation.Constraint{{Target: "skip", Name: validation.Null, Rule: false, 70 Chain: []validation.Constraint{{Target: "skip", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil}}}}}}); err != nil { 71 return result, validation.NewError("apimanagement.APIIssuesClient", "ListByService", err.Error()) 72 } 73 74 result.fn = client.listByServiceNextResults 75 req, err := client.ListByServicePreparer(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) 76 if err != nil { 77 err = autorest.NewErrorWithError(err, "apimanagement.APIIssuesClient", "ListByService", nil, "Failure preparing request") 78 return 79 } 80 81 resp, err := client.ListByServiceSender(req) 82 if err != nil { 83 result.ic.Response = autorest.Response{Response: resp} 84 err = autorest.NewErrorWithError(err, "apimanagement.APIIssuesClient", "ListByService", resp, "Failure sending request") 85 return 86 } 87 88 result.ic, err = client.ListByServiceResponder(resp) 89 if err != nil { 90 err = autorest.NewErrorWithError(err, "apimanagement.APIIssuesClient", "ListByService", resp, "Failure responding to request") 91 } 92 93 return 94} 95 96// ListByServicePreparer prepares the ListByService request. 97func (client APIIssuesClient) ListByServicePreparer(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (*http.Request, error) { 98 pathParameters := map[string]interface{}{ 99 "apiId": autorest.Encode("path", apiid), 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 if len(filter) > 0 { 110 queryParameters["$filter"] = autorest.Encode("query", filter) 111 } 112 if top != nil { 113 queryParameters["$top"] = autorest.Encode("query", *top) 114 } 115 if skip != nil { 116 queryParameters["$skip"] = autorest.Encode("query", *skip) 117 } 118 119 preparer := autorest.CreatePreparer( 120 autorest.AsGet(), 121 autorest.WithBaseURL(client.BaseURI), 122 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiId}/issues", pathParameters), 123 autorest.WithQueryParameters(queryParameters)) 124 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 125} 126 127// ListByServiceSender sends the ListByService request. The method will close the 128// http.Response Body if it receives an error. 129func (client APIIssuesClient) ListByServiceSender(req *http.Request) (*http.Response, error) { 130 return autorest.SendWithSender(client, req, 131 azure.DoRetryWithRegistration(client.Client)) 132} 133 134// ListByServiceResponder handles the response to the ListByService request. The method always 135// closes the http.Response Body. 136func (client APIIssuesClient) ListByServiceResponder(resp *http.Response) (result IssueCollection, err error) { 137 err = autorest.Respond( 138 resp, 139 client.ByInspecting(), 140 azure.WithErrorUnlessStatusCode(http.StatusOK), 141 autorest.ByUnmarshallingJSON(&result), 142 autorest.ByClosing()) 143 result.Response = autorest.Response{Response: resp} 144 return 145} 146 147// listByServiceNextResults retrieves the next set of results, if any. 148func (client APIIssuesClient) listByServiceNextResults(lastResults IssueCollection) (result IssueCollection, err error) { 149 req, err := lastResults.issueCollectionPreparer() 150 if err != nil { 151 return result, autorest.NewErrorWithError(err, "apimanagement.APIIssuesClient", "listByServiceNextResults", nil, "Failure preparing next results request") 152 } 153 if req == nil { 154 return 155 } 156 resp, err := client.ListByServiceSender(req) 157 if err != nil { 158 result.Response = autorest.Response{Response: resp} 159 return result, autorest.NewErrorWithError(err, "apimanagement.APIIssuesClient", "listByServiceNextResults", resp, "Failure sending next results request") 160 } 161 result, err = client.ListByServiceResponder(resp) 162 if err != nil { 163 err = autorest.NewErrorWithError(err, "apimanagement.APIIssuesClient", "listByServiceNextResults", resp, "Failure responding to next results request") 164 } 165 return 166} 167 168// ListByServiceComplete enumerates all values, automatically crossing page boundaries as required. 169func (client APIIssuesClient) ListByServiceComplete(ctx context.Context, resourceGroupName string, serviceName string, apiid string, filter string, top *int32, skip *int32) (result IssueCollectionIterator, err error) { 170 result.page, err = client.ListByService(ctx, resourceGroupName, serviceName, apiid, filter, top, skip) 171 return 172} 173