1package logic 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// MapsClient is the REST API for Azure Logic Apps. 19type MapsClient struct { 20 BaseClient 21} 22 23// NewMapsClient creates an instance of the MapsClient client. 24func NewMapsClient(subscriptionID string) MapsClient { 25 return NewMapsClientWithBaseURI(DefaultBaseURI, subscriptionID) 26} 27 28// NewMapsClientWithBaseURI creates an instance of the MapsClient client using a custom endpoint. Use this when 29// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). 30func NewMapsClientWithBaseURI(baseURI string, subscriptionID string) MapsClient { 31 return MapsClient{NewWithBaseURI(baseURI, subscriptionID)} 32} 33 34// CreateOrUpdate creates or updates an integration account map. 35// Parameters: 36// resourceGroupName - the resource group name. 37// integrationAccountName - the integration account name. 38// mapName - the integration account map name. 39// mapParameter - the integration account map. 40func (client MapsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string, mapParameter IntegrationAccountMap) (result IntegrationAccountMap, err error) { 41 if tracing.IsEnabled() { 42 ctx = tracing.StartSpan(ctx, fqdn+"/MapsClient.CreateOrUpdate") 43 defer func() { 44 sc := -1 45 if result.Response.Response != nil { 46 sc = result.Response.Response.StatusCode 47 } 48 tracing.EndSpan(ctx, sc, err) 49 }() 50 } 51 if err := validation.Validate([]validation.Validation{ 52 {TargetValue: mapParameter, 53 Constraints: []validation.Constraint{{Target: "mapParameter.IntegrationAccountMapProperties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { 54 return result, validation.NewError("logic.MapsClient", "CreateOrUpdate", err.Error()) 55 } 56 57 req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, integrationAccountName, mapName, mapParameter) 58 if err != nil { 59 err = autorest.NewErrorWithError(err, "logic.MapsClient", "CreateOrUpdate", nil, "Failure preparing request") 60 return 61 } 62 63 resp, err := client.CreateOrUpdateSender(req) 64 if err != nil { 65 result.Response = autorest.Response{Response: resp} 66 err = autorest.NewErrorWithError(err, "logic.MapsClient", "CreateOrUpdate", resp, "Failure sending request") 67 return 68 } 69 70 result, err = client.CreateOrUpdateResponder(resp) 71 if err != nil { 72 err = autorest.NewErrorWithError(err, "logic.MapsClient", "CreateOrUpdate", resp, "Failure responding to request") 73 return 74 } 75 76 return 77} 78 79// CreateOrUpdatePreparer prepares the CreateOrUpdate request. 80func (client MapsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string, mapParameter IntegrationAccountMap) (*http.Request, error) { 81 pathParameters := map[string]interface{}{ 82 "integrationAccountName": autorest.Encode("path", integrationAccountName), 83 "mapName": autorest.Encode("path", mapName), 84 "resourceGroupName": autorest.Encode("path", resourceGroupName), 85 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 86 } 87 88 const APIVersion = "2016-06-01" 89 queryParameters := map[string]interface{}{ 90 "api-version": APIVersion, 91 } 92 93 preparer := autorest.CreatePreparer( 94 autorest.AsContentType("application/json; charset=utf-8"), 95 autorest.AsPut(), 96 autorest.WithBaseURL(client.BaseURI), 97 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/integrationAccounts/{integrationAccountName}/maps/{mapName}", pathParameters), 98 autorest.WithJSON(mapParameter), 99 autorest.WithQueryParameters(queryParameters)) 100 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 101} 102 103// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the 104// http.Response Body if it receives an error. 105func (client MapsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { 106 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 107} 108 109// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always 110// closes the http.Response Body. 111func (client MapsClient) CreateOrUpdateResponder(resp *http.Response) (result IntegrationAccountMap, err error) { 112 err = autorest.Respond( 113 resp, 114 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), 115 autorest.ByUnmarshallingJSON(&result), 116 autorest.ByClosing()) 117 result.Response = autorest.Response{Response: resp} 118 return 119} 120 121// Delete deletes an integration account map. 122// Parameters: 123// resourceGroupName - the resource group name. 124// integrationAccountName - the integration account name. 125// mapName - the integration account map name. 126func (client MapsClient) Delete(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string) (result autorest.Response, err error) { 127 if tracing.IsEnabled() { 128 ctx = tracing.StartSpan(ctx, fqdn+"/MapsClient.Delete") 129 defer func() { 130 sc := -1 131 if result.Response != nil { 132 sc = result.Response.StatusCode 133 } 134 tracing.EndSpan(ctx, sc, err) 135 }() 136 } 137 req, err := client.DeletePreparer(ctx, resourceGroupName, integrationAccountName, mapName) 138 if err != nil { 139 err = autorest.NewErrorWithError(err, "logic.MapsClient", "Delete", nil, "Failure preparing request") 140 return 141 } 142 143 resp, err := client.DeleteSender(req) 144 if err != nil { 145 result.Response = resp 146 err = autorest.NewErrorWithError(err, "logic.MapsClient", "Delete", resp, "Failure sending request") 147 return 148 } 149 150 result, err = client.DeleteResponder(resp) 151 if err != nil { 152 err = autorest.NewErrorWithError(err, "logic.MapsClient", "Delete", resp, "Failure responding to request") 153 return 154 } 155 156 return 157} 158 159// DeletePreparer prepares the Delete request. 160func (client MapsClient) DeletePreparer(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string) (*http.Request, error) { 161 pathParameters := map[string]interface{}{ 162 "integrationAccountName": autorest.Encode("path", integrationAccountName), 163 "mapName": autorest.Encode("path", mapName), 164 "resourceGroupName": autorest.Encode("path", resourceGroupName), 165 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 166 } 167 168 const APIVersion = "2016-06-01" 169 queryParameters := map[string]interface{}{ 170 "api-version": APIVersion, 171 } 172 173 preparer := autorest.CreatePreparer( 174 autorest.AsDelete(), 175 autorest.WithBaseURL(client.BaseURI), 176 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/integrationAccounts/{integrationAccountName}/maps/{mapName}", pathParameters), 177 autorest.WithQueryParameters(queryParameters)) 178 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 179} 180 181// DeleteSender sends the Delete request. The method will close the 182// http.Response Body if it receives an error. 183func (client MapsClient) DeleteSender(req *http.Request) (*http.Response, error) { 184 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 185} 186 187// DeleteResponder handles the response to the Delete request. The method always 188// closes the http.Response Body. 189func (client MapsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { 190 err = autorest.Respond( 191 resp, 192 azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), 193 autorest.ByClosing()) 194 result.Response = resp 195 return 196} 197 198// Get gets an integration account map. 199// Parameters: 200// resourceGroupName - the resource group name. 201// integrationAccountName - the integration account name. 202// mapName - the integration account map name. 203func (client MapsClient) Get(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string) (result IntegrationAccountMap, err error) { 204 if tracing.IsEnabled() { 205 ctx = tracing.StartSpan(ctx, fqdn+"/MapsClient.Get") 206 defer func() { 207 sc := -1 208 if result.Response.Response != nil { 209 sc = result.Response.Response.StatusCode 210 } 211 tracing.EndSpan(ctx, sc, err) 212 }() 213 } 214 req, err := client.GetPreparer(ctx, resourceGroupName, integrationAccountName, mapName) 215 if err != nil { 216 err = autorest.NewErrorWithError(err, "logic.MapsClient", "Get", nil, "Failure preparing request") 217 return 218 } 219 220 resp, err := client.GetSender(req) 221 if err != nil { 222 result.Response = autorest.Response{Response: resp} 223 err = autorest.NewErrorWithError(err, "logic.MapsClient", "Get", resp, "Failure sending request") 224 return 225 } 226 227 result, err = client.GetResponder(resp) 228 if err != nil { 229 err = autorest.NewErrorWithError(err, "logic.MapsClient", "Get", resp, "Failure responding to request") 230 return 231 } 232 233 return 234} 235 236// GetPreparer prepares the Get request. 237func (client MapsClient) GetPreparer(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string) (*http.Request, error) { 238 pathParameters := map[string]interface{}{ 239 "integrationAccountName": autorest.Encode("path", integrationAccountName), 240 "mapName": autorest.Encode("path", mapName), 241 "resourceGroupName": autorest.Encode("path", resourceGroupName), 242 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 243 } 244 245 const APIVersion = "2016-06-01" 246 queryParameters := map[string]interface{}{ 247 "api-version": APIVersion, 248 } 249 250 preparer := autorest.CreatePreparer( 251 autorest.AsGet(), 252 autorest.WithBaseURL(client.BaseURI), 253 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/integrationAccounts/{integrationAccountName}/maps/{mapName}", pathParameters), 254 autorest.WithQueryParameters(queryParameters)) 255 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 256} 257 258// GetSender sends the Get request. The method will close the 259// http.Response Body if it receives an error. 260func (client MapsClient) GetSender(req *http.Request) (*http.Response, error) { 261 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 262} 263 264// GetResponder handles the response to the Get request. The method always 265// closes the http.Response Body. 266func (client MapsClient) GetResponder(resp *http.Response) (result IntegrationAccountMap, err error) { 267 err = autorest.Respond( 268 resp, 269 azure.WithErrorUnlessStatusCode(http.StatusOK), 270 autorest.ByUnmarshallingJSON(&result), 271 autorest.ByClosing()) 272 result.Response = autorest.Response{Response: resp} 273 return 274} 275 276// ListByIntegrationAccounts gets a list of integration account maps. 277// Parameters: 278// resourceGroupName - the resource group name. 279// integrationAccountName - the integration account name. 280// top - the number of items to be included in the result. 281// filter - the filter to apply on the operation. Options for filters include: MapType. 282func (client MapsClient) ListByIntegrationAccounts(ctx context.Context, resourceGroupName string, integrationAccountName string, top *int32, filter string) (result IntegrationAccountMapListResultPage, err error) { 283 if tracing.IsEnabled() { 284 ctx = tracing.StartSpan(ctx, fqdn+"/MapsClient.ListByIntegrationAccounts") 285 defer func() { 286 sc := -1 287 if result.iamlr.Response.Response != nil { 288 sc = result.iamlr.Response.Response.StatusCode 289 } 290 tracing.EndSpan(ctx, sc, err) 291 }() 292 } 293 result.fn = client.listByIntegrationAccountsNextResults 294 req, err := client.ListByIntegrationAccountsPreparer(ctx, resourceGroupName, integrationAccountName, top, filter) 295 if err != nil { 296 err = autorest.NewErrorWithError(err, "logic.MapsClient", "ListByIntegrationAccounts", nil, "Failure preparing request") 297 return 298 } 299 300 resp, err := client.ListByIntegrationAccountsSender(req) 301 if err != nil { 302 result.iamlr.Response = autorest.Response{Response: resp} 303 err = autorest.NewErrorWithError(err, "logic.MapsClient", "ListByIntegrationAccounts", resp, "Failure sending request") 304 return 305 } 306 307 result.iamlr, err = client.ListByIntegrationAccountsResponder(resp) 308 if err != nil { 309 err = autorest.NewErrorWithError(err, "logic.MapsClient", "ListByIntegrationAccounts", resp, "Failure responding to request") 310 return 311 } 312 if result.iamlr.hasNextLink() && result.iamlr.IsEmpty() { 313 err = result.NextWithContext(ctx) 314 return 315 } 316 317 return 318} 319 320// ListByIntegrationAccountsPreparer prepares the ListByIntegrationAccounts request. 321func (client MapsClient) ListByIntegrationAccountsPreparer(ctx context.Context, resourceGroupName string, integrationAccountName string, top *int32, filter string) (*http.Request, error) { 322 pathParameters := map[string]interface{}{ 323 "integrationAccountName": autorest.Encode("path", integrationAccountName), 324 "resourceGroupName": autorest.Encode("path", resourceGroupName), 325 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 326 } 327 328 const APIVersion = "2016-06-01" 329 queryParameters := map[string]interface{}{ 330 "api-version": APIVersion, 331 } 332 if top != nil { 333 queryParameters["$top"] = autorest.Encode("query", *top) 334 } 335 if len(filter) > 0 { 336 queryParameters["$filter"] = autorest.Encode("query", filter) 337 } 338 339 preparer := autorest.CreatePreparer( 340 autorest.AsGet(), 341 autorest.WithBaseURL(client.BaseURI), 342 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/integrationAccounts/{integrationAccountName}/maps", pathParameters), 343 autorest.WithQueryParameters(queryParameters)) 344 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 345} 346 347// ListByIntegrationAccountsSender sends the ListByIntegrationAccounts request. The method will close the 348// http.Response Body if it receives an error. 349func (client MapsClient) ListByIntegrationAccountsSender(req *http.Request) (*http.Response, error) { 350 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 351} 352 353// ListByIntegrationAccountsResponder handles the response to the ListByIntegrationAccounts request. The method always 354// closes the http.Response Body. 355func (client MapsClient) ListByIntegrationAccountsResponder(resp *http.Response) (result IntegrationAccountMapListResult, err error) { 356 err = autorest.Respond( 357 resp, 358 azure.WithErrorUnlessStatusCode(http.StatusOK), 359 autorest.ByUnmarshallingJSON(&result), 360 autorest.ByClosing()) 361 result.Response = autorest.Response{Response: resp} 362 return 363} 364 365// listByIntegrationAccountsNextResults retrieves the next set of results, if any. 366func (client MapsClient) listByIntegrationAccountsNextResults(ctx context.Context, lastResults IntegrationAccountMapListResult) (result IntegrationAccountMapListResult, err error) { 367 req, err := lastResults.integrationAccountMapListResultPreparer(ctx) 368 if err != nil { 369 return result, autorest.NewErrorWithError(err, "logic.MapsClient", "listByIntegrationAccountsNextResults", nil, "Failure preparing next results request") 370 } 371 if req == nil { 372 return 373 } 374 resp, err := client.ListByIntegrationAccountsSender(req) 375 if err != nil { 376 result.Response = autorest.Response{Response: resp} 377 return result, autorest.NewErrorWithError(err, "logic.MapsClient", "listByIntegrationAccountsNextResults", resp, "Failure sending next results request") 378 } 379 result, err = client.ListByIntegrationAccountsResponder(resp) 380 if err != nil { 381 err = autorest.NewErrorWithError(err, "logic.MapsClient", "listByIntegrationAccountsNextResults", resp, "Failure responding to next results request") 382 } 383 return 384} 385 386// ListByIntegrationAccountsComplete enumerates all values, automatically crossing page boundaries as required. 387func (client MapsClient) ListByIntegrationAccountsComplete(ctx context.Context, resourceGroupName string, integrationAccountName string, top *int32, filter string) (result IntegrationAccountMapListResultIterator, err error) { 388 if tracing.IsEnabled() { 389 ctx = tracing.StartSpan(ctx, fqdn+"/MapsClient.ListByIntegrationAccounts") 390 defer func() { 391 sc := -1 392 if result.Response().Response.Response != nil { 393 sc = result.page.Response().Response.Response.StatusCode 394 } 395 tracing.EndSpan(ctx, sc, err) 396 }() 397 } 398 result.page, err = client.ListByIntegrationAccounts(ctx, resourceGroupName, integrationAccountName, top, filter) 399 return 400} 401 402// ListContentCallbackURL get the content callback url. 403// Parameters: 404// resourceGroupName - the resource group name. 405// integrationAccountName - the integration account name. 406// mapName - the integration account map name. 407func (client MapsClient) ListContentCallbackURL(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string, listContentCallbackURL GetCallbackURLParameters) (result WorkflowTriggerCallbackURL, err error) { 408 if tracing.IsEnabled() { 409 ctx = tracing.StartSpan(ctx, fqdn+"/MapsClient.ListContentCallbackURL") 410 defer func() { 411 sc := -1 412 if result.Response.Response != nil { 413 sc = result.Response.Response.StatusCode 414 } 415 tracing.EndSpan(ctx, sc, err) 416 }() 417 } 418 req, err := client.ListContentCallbackURLPreparer(ctx, resourceGroupName, integrationAccountName, mapName, listContentCallbackURL) 419 if err != nil { 420 err = autorest.NewErrorWithError(err, "logic.MapsClient", "ListContentCallbackURL", nil, "Failure preparing request") 421 return 422 } 423 424 resp, err := client.ListContentCallbackURLSender(req) 425 if err != nil { 426 result.Response = autorest.Response{Response: resp} 427 err = autorest.NewErrorWithError(err, "logic.MapsClient", "ListContentCallbackURL", resp, "Failure sending request") 428 return 429 } 430 431 result, err = client.ListContentCallbackURLResponder(resp) 432 if err != nil { 433 err = autorest.NewErrorWithError(err, "logic.MapsClient", "ListContentCallbackURL", resp, "Failure responding to request") 434 return 435 } 436 437 return 438} 439 440// ListContentCallbackURLPreparer prepares the ListContentCallbackURL request. 441func (client MapsClient) ListContentCallbackURLPreparer(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string, listContentCallbackURL GetCallbackURLParameters) (*http.Request, error) { 442 pathParameters := map[string]interface{}{ 443 "integrationAccountName": autorest.Encode("path", integrationAccountName), 444 "mapName": autorest.Encode("path", mapName), 445 "resourceGroupName": autorest.Encode("path", resourceGroupName), 446 "subscriptionId": autorest.Encode("path", client.SubscriptionID), 447 } 448 449 const APIVersion = "2016-06-01" 450 queryParameters := map[string]interface{}{ 451 "api-version": APIVersion, 452 } 453 454 preparer := autorest.CreatePreparer( 455 autorest.AsContentType("application/json; charset=utf-8"), 456 autorest.AsPost(), 457 autorest.WithBaseURL(client.BaseURI), 458 autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Logic/integrationAccounts/{integrationAccountName}/maps/{mapName}/listContentCallbackUrl", pathParameters), 459 autorest.WithJSON(listContentCallbackURL), 460 autorest.WithQueryParameters(queryParameters)) 461 return preparer.Prepare((&http.Request{}).WithContext(ctx)) 462} 463 464// ListContentCallbackURLSender sends the ListContentCallbackURL request. The method will close the 465// http.Response Body if it receives an error. 466func (client MapsClient) ListContentCallbackURLSender(req *http.Request) (*http.Response, error) { 467 return client.Send(req, azure.DoRetryWithRegistration(client.Client)) 468} 469 470// ListContentCallbackURLResponder handles the response to the ListContentCallbackURL request. The method always 471// closes the http.Response Body. 472func (client MapsClient) ListContentCallbackURLResponder(resp *http.Response) (result WorkflowTriggerCallbackURL, err error) { 473 err = autorest.Respond( 474 resp, 475 azure.WithErrorUnlessStatusCode(http.StatusOK), 476 autorest.ByUnmarshallingJSON(&result), 477 autorest.ByClosing()) 478 result.Response = autorest.Response{Response: resp} 479 return 480} 481