1package visualstudio 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 "net/http" 25) 26 27// ExtensionsClient is the use these APIs to manage Visual Studio Team Services resources through the Azure Resource 28// Manager. All task operations conform to the HTTP/1.1 protocol specification and each operation returns an 29// x-ms-request-id header that can be used to obtain information about the request. You must make sure that requests 30// made to these resources are secure. For more information, see https://docs.microsoft.com/en-us/rest/api/index. 31type ExtensionsClient struct { 32 BaseClient 33} 34 35// NewExtensionsClient creates an instance of the ExtensionsClient client. 36func NewExtensionsClient(subscriptionID string) ExtensionsClient { 37 return NewExtensionsClientWithBaseURI(DefaultBaseURI, subscriptionID) 38} 39 40// NewExtensionsClientWithBaseURI creates an instance of the ExtensionsClient client. 41func NewExtensionsClientWithBaseURI(baseURI string, subscriptionID string) ExtensionsClient { 42 return ExtensionsClient{NewWithBaseURI(baseURI, subscriptionID)} 43} 44 45// Create registers the extension with a Visual Studio Team Services account. 46// Parameters: 47// resourceGroupName - name of the resource group within the Azure subscription. 48// body - an object containing additional information related to the extension request. 49// accountResourceName - the name of the Visual Studio Team Services account resource. 50// extensionResourceName - the name of the extension. 51func (client ExtensionsClient) Create(ctx context.Context, resourceGroupName string, body ExtensionResourceRequest, accountResourceName string, extensionResourceName string) (result ExtensionResource, err error) { 52 req, err := client.CreatePreparer(ctx, resourceGroupName, body, accountResourceName, extensionResourceName) 53 if err != nil { 54 err = autorest.NewErrorWithError(err, "visualstudio.ExtensionsClient", "Create", nil, "Failure preparing request") 55 return 56 } 57 58 resp, err := client.CreateSender(req) 59 if err != nil { 60 result.Response = autorest.Response{Response: resp} 61 err = autorest.NewErrorWithError(err, "visualstudio.ExtensionsClient", "Create", resp, "Failure sending request") 62 return 63 } 64 65 result, err = client.CreateResponder(resp) 66 if err != nil { 67 err = autorest.NewErrorWithError(err, "visualstudio.ExtensionsClient", "Create", resp, "Failure responding to request") 68 } 69 70 return 71} 72 73// CreatePreparer prepares the Create request. 74func (client ExtensionsClient) CreatePreparer(ctx context.Context, resourceGroupName string, body ExtensionResourceRequest, accountResourceName string, extensionResourceName string) (*http.Request, error) { 75 pathParameters := map[string]interface{}{ 76 "accountResourceName": autorest.Encode("path", accountResourceName), 77 "extensionResourceName": autorest.Encode("path", extensionResourceName), 78 "resourceGroupName": autorest.Encode("path", resourceGroupName), 79 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 80 } 81 82 const APIVersion = "2014-04-01-preview" 83 queryParameters := map[string]interface{}{ 84 "api-version": APIVersion, 85 } 86 87 preparer := autorest.CreatePreparer( 88 autorest.AsContentType("application/json; charset=utf-8"), 89 autorest.AsPut(), 90 autorest.WithBaseURL(client.BaseURI), 91 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.visualstudio/account/{accountResourceName}/extension/{extensionResourceName}", pathParameters), 92 autorest.WithJSON(body), 93 autorest.WithQueryParameters(queryParameters)) 94 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 95} 96 97// CreateSender sends the Create request. The method will close the 98// http.Response Body if it receives an error. 99func (client ExtensionsClient) CreateSender(req *http.Request) (*http.Response, error) { 100 return autorest.SendWithSender(client, req, 101 azure.DoRetryWithRegistration(client.Client)) 102} 103 104// CreateResponder handles the response to the Create request. The method always 105// closes the http.Response Body. 106func (client ExtensionsClient) CreateResponder(resp *http.Response) (result ExtensionResource, err error) { 107 err = autorest.Respond( 108 resp, 109 client.ByInspecting(), 110 azure.WithErrorUnlessStatusCode(http.StatusOK), 111 autorest.ByUnmarshallingJSON(&result), 112 autorest.ByClosing()) 113 result.Response = autorest.Response{Response: resp} 114 return 115} 116 117// Delete removes an extension resource registration for a Visual Studio Team Services account. 118// Parameters: 119// resourceGroupName - name of the resource group within the Azure subscription. 120// accountResourceName - the name of the Visual Studio Team Services account resource. 121// extensionResourceName - the name of the extension. 122func (client ExtensionsClient) Delete(ctx context.Context, resourceGroupName string, accountResourceName string, extensionResourceName string) (result autorest.Response, err error) { 123 req, err := client.DeletePreparer(ctx, resourceGroupName, accountResourceName, extensionResourceName) 124 if err != nil { 125 err = autorest.NewErrorWithError(err, "visualstudio.ExtensionsClient", "Delete", nil, "Failure preparing request") 126 return 127 } 128 129 resp, err := client.DeleteSender(req) 130 if err != nil { 131 result.Response = resp 132 err = autorest.NewErrorWithError(err, "visualstudio.ExtensionsClient", "Delete", resp, "Failure sending request") 133 return 134 } 135 136 result, err = client.DeleteResponder(resp) 137 if err != nil { 138 err = autorest.NewErrorWithError(err, "visualstudio.ExtensionsClient", "Delete", resp, "Failure responding to request") 139 } 140 141 return 142} 143 144// DeletePreparer prepares the Delete request. 145func (client ExtensionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, accountResourceName string, extensionResourceName string) (*http.Request, error) { 146 pathParameters := map[string]interface{}{ 147 "accountResourceName": autorest.Encode("path", accountResourceName), 148 "extensionResourceName": autorest.Encode("path", extensionResourceName), 149 "resourceGroupName": autorest.Encode("path", resourceGroupName), 150 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 151 } 152 153 const APIVersion = "2014-04-01-preview" 154 queryParameters := map[string]interface{}{ 155 "api-version": APIVersion, 156 } 157 158 preparer := autorest.CreatePreparer( 159 autorest.AsDelete(), 160 autorest.WithBaseURL(client.BaseURI), 161 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.visualstudio/account/{accountResourceName}/extension/{extensionResourceName}", pathParameters), 162 autorest.WithQueryParameters(queryParameters)) 163 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 164} 165 166// DeleteSender sends the Delete request. The method will close the 167// http.Response Body if it receives an error. 168func (client ExtensionsClient) DeleteSender(req *http.Request) (*http.Response, error) { 169 return autorest.SendWithSender(client, req, 170 azure.DoRetryWithRegistration(client.Client)) 171} 172 173// DeleteResponder handles the response to the Delete request. The method always 174// closes the http.Response Body. 175func (client ExtensionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 176 err = autorest.Respond( 177 resp, 178 client.ByInspecting(), 179 azure.WithErrorUnlessStatusCode(http.StatusOK), 180 autorest.ByClosing()) 181 result.Response = resp 182 return 183} 184 185// Get gets the details of an extension associated with a Visual Studio Team Services account resource. 186// Parameters: 187// resourceGroupName - name of the resource group within the Azure subscription. 188// accountResourceName - the name of the Visual Studio Team Services account resource. 189// extensionResourceName - the name of the extension. 190func (client ExtensionsClient) Get(ctx context.Context, resourceGroupName string, accountResourceName string, extensionResourceName string) (result ExtensionResource, err error) { 191 req, err := client.GetPreparer(ctx, resourceGroupName, accountResourceName, extensionResourceName) 192 if err != nil { 193 err = autorest.NewErrorWithError(err, "visualstudio.ExtensionsClient", "Get", nil, "Failure preparing request") 194 return 195 } 196 197 resp, err := client.GetSender(req) 198 if err != nil { 199 result.Response = autorest.Response{Response: resp} 200 err = autorest.NewErrorWithError(err, "visualstudio.ExtensionsClient", "Get", resp, "Failure sending request") 201 return 202 } 203 204 result, err = client.GetResponder(resp) 205 if err != nil { 206 err = autorest.NewErrorWithError(err, "visualstudio.ExtensionsClient", "Get", resp, "Failure responding to request") 207 } 208 209 return 210} 211 212// GetPreparer prepares the Get request. 213func (client ExtensionsClient) GetPreparer(ctx context.Context, resourceGroupName string, accountResourceName string, extensionResourceName string) (*http.Request, error) { 214 pathParameters := map[string]interface{}{ 215 "accountResourceName": autorest.Encode("path", accountResourceName), 216 "extensionResourceName": autorest.Encode("path", extensionResourceName), 217 "resourceGroupName": autorest.Encode("path", resourceGroupName), 218 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 219 } 220 221 const APIVersion = "2014-04-01-preview" 222 queryParameters := map[string]interface{}{ 223 "api-version": APIVersion, 224 } 225 226 preparer := autorest.CreatePreparer( 227 autorest.AsGet(), 228 autorest.WithBaseURL(client.BaseURI), 229 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.visualstudio/account/{accountResourceName}/extension/{extensionResourceName}", pathParameters), 230 autorest.WithQueryParameters(queryParameters)) 231 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 232} 233 234// GetSender sends the Get request. The method will close the 235// http.Response Body if it receives an error. 236func (client ExtensionsClient) GetSender(req *http.Request) (*http.Response, error) { 237 return autorest.SendWithSender(client, req, 238 azure.DoRetryWithRegistration(client.Client)) 239} 240 241// GetResponder handles the response to the Get request. The method always 242// closes the http.Response Body. 243func (client ExtensionsClient) GetResponder(resp *http.Response) (result ExtensionResource, err error) { 244 err = autorest.Respond( 245 resp, 246 client.ByInspecting(), 247 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNotFound), 248 autorest.ByUnmarshallingJSON(&result), 249 autorest.ByClosing()) 250 result.Response = autorest.Response{Response: resp} 251 return 252} 253 254// ListByAccount gets the details of the extension resources created within the resource group. 255// Parameters: 256// resourceGroupName - name of the resource group within the Azure subscription. 257// accountResourceName - the name of the Visual Studio Team Services account resource. 258func (client ExtensionsClient) ListByAccount(ctx context.Context, resourceGroupName string, accountResourceName string) (result ExtensionResourceListResult, err error) { 259 req, err := client.ListByAccountPreparer(ctx, resourceGroupName, accountResourceName) 260 if err != nil { 261 err = autorest.NewErrorWithError(err, "visualstudio.ExtensionsClient", "ListByAccount", nil, "Failure preparing request") 262 return 263 } 264 265 resp, err := client.ListByAccountSender(req) 266 if err != nil { 267 result.Response = autorest.Response{Response: resp} 268 err = autorest.NewErrorWithError(err, "visualstudio.ExtensionsClient", "ListByAccount", resp, "Failure sending request") 269 return 270 } 271 272 result, err = client.ListByAccountResponder(resp) 273 if err != nil { 274 err = autorest.NewErrorWithError(err, "visualstudio.ExtensionsClient", "ListByAccount", resp, "Failure responding to request") 275 } 276 277 return 278} 279 280// ListByAccountPreparer prepares the ListByAccount request. 281func (client ExtensionsClient) ListByAccountPreparer(ctx context.Context, resourceGroupName string, accountResourceName string) (*http.Request, error) { 282 pathParameters := map[string]interface{}{ 283 "accountResourceName": autorest.Encode("path", accountResourceName), 284 "resourceGroupName": autorest.Encode("path", resourceGroupName), 285 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 286 } 287 288 const APIVersion = "2014-04-01-preview" 289 queryParameters := map[string]interface{}{ 290 "api-version": APIVersion, 291 } 292 293 preparer := autorest.CreatePreparer( 294 autorest.AsGet(), 295 autorest.WithBaseURL(client.BaseURI), 296 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.visualstudio/account/{accountResourceName}/extension", pathParameters), 297 autorest.WithQueryParameters(queryParameters)) 298 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 299} 300 301// ListByAccountSender sends the ListByAccount request. The method will close the 302// http.Response Body if it receives an error. 303func (client ExtensionsClient) ListByAccountSender(req *http.Request) (*http.Response, error) { 304 return autorest.SendWithSender(client, req, 305 azure.DoRetryWithRegistration(client.Client)) 306} 307 308// ListByAccountResponder handles the response to the ListByAccount request. The method always 309// closes the http.Response Body. 310func (client ExtensionsClient) ListByAccountResponder(resp *http.Response) (result ExtensionResourceListResult, err error) { 311 err = autorest.Respond( 312 resp, 313 client.ByInspecting(), 314 azure.WithErrorUnlessStatusCode(http.StatusOK), 315 autorest.ByUnmarshallingJSON(&result), 316 autorest.ByClosing()) 317 result.Response = autorest.Response{Response: resp} 318 return 319} 320 321// Update updates an existing extension registration for the Visual Studio Team Services account. 322// Parameters: 323// resourceGroupName - name of the resource group within the Azure subscription. 324// body - an object containing additional information related to the extension request. 325// accountResourceName - the name of the Visual Studio Team Services account resource. 326// extensionResourceName - the name of the extension. 327func (client ExtensionsClient) Update(ctx context.Context, resourceGroupName string, body ExtensionResourceRequest, accountResourceName string, extensionResourceName string) (result ExtensionResource, err error) { 328 req, err := client.UpdatePreparer(ctx, resourceGroupName, body, accountResourceName, extensionResourceName) 329 if err != nil { 330 err = autorest.NewErrorWithError(err, "visualstudio.ExtensionsClient", "Update", nil, "Failure preparing request") 331 return 332 } 333 334 resp, err := client.UpdateSender(req) 335 if err != nil { 336 result.Response = autorest.Response{Response: resp} 337 err = autorest.NewErrorWithError(err, "visualstudio.ExtensionsClient", "Update", resp, "Failure sending request") 338 return 339 } 340 341 result, err = client.UpdateResponder(resp) 342 if err != nil { 343 err = autorest.NewErrorWithError(err, "visualstudio.ExtensionsClient", "Update", resp, "Failure responding to request") 344 } 345 346 return 347} 348 349// UpdatePreparer prepares the Update request. 350func (client ExtensionsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, body ExtensionResourceRequest, accountResourceName string, extensionResourceName string) (*http.Request, error) { 351 pathParameters := map[string]interface{}{ 352 "accountResourceName": autorest.Encode("path", accountResourceName), 353 "extensionResourceName": autorest.Encode("path", extensionResourceName), 354 "resourceGroupName": autorest.Encode("path", resourceGroupName), 355 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 356 } 357 358 const APIVersion = "2014-04-01-preview" 359 queryParameters := map[string]interface{}{ 360 "api-version": APIVersion, 361 } 362 363 preparer := autorest.CreatePreparer( 364 autorest.AsContentType("application/json; charset=utf-8"), 365 autorest.AsPatch(), 366 autorest.WithBaseURL(client.BaseURI), 367 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.visualstudio/account/{accountResourceName}/extension/{extensionResourceName}", pathParameters), 368 autorest.WithJSON(body), 369 autorest.WithQueryParameters(queryParameters)) 370 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 371} 372 373// UpdateSender sends the Update request. The method will close the 374// http.Response Body if it receives an error. 375func (client ExtensionsClient) UpdateSender(req *http.Request) (*http.Response, error) { 376 return autorest.SendWithSender(client, req, 377 azure.DoRetryWithRegistration(client.Client)) 378} 379 380// UpdateResponder handles the response to the Update request. The method always 381// closes the http.Response Body. 382func (client ExtensionsClient) UpdateResponder(resp *http.Response) (result ExtensionResource, err error) { 383 err = autorest.Respond( 384 resp, 385 client.ByInspecting(), 386 azure.WithErrorUnlessStatusCode(http.StatusOK), 387 autorest.ByUnmarshallingJSON(&result), 388 autorest.ByClosing()) 389 result.Response = autorest.Response{Response: resp} 390 return 391} 392