1package storage 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 "encoding/json" 12 "github.com/Azure/go-autorest/autorest" 13 "github.com/Azure/go-autorest/autorest/azure" 14 "github.com/Azure/go-autorest/autorest/date" 15 "github.com/Azure/go-autorest/autorest/to" 16 "github.com/Azure/go-autorest/tracing" 17 "net/http" 18) 19 20// The package's fully qualified name. 21const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/storage/mgmt/2015-05-01-preview/storage" 22 23// Account the storage account. 24type Account struct { 25 autorest.Response `json:"-"` 26 *AccountProperties `json:"properties,omitempty"` 27 // ID - READ-ONLY; Resource Id 28 ID *string `json:"id,omitempty"` 29 // Name - READ-ONLY; Resource name 30 Name *string `json:"name,omitempty"` 31 // Type - READ-ONLY; Resource type 32 Type *string `json:"type,omitempty"` 33 // Location - Resource location 34 Location *string `json:"location,omitempty"` 35 // Tags - Resource tags 36 Tags map[string]*string `json:"tags"` 37} 38 39// MarshalJSON is the custom marshaler for Account. 40func (a Account) MarshalJSON() ([]byte, error) { 41 objectMap := make(map[string]interface{}) 42 if a.AccountProperties != nil { 43 objectMap["properties"] = a.AccountProperties 44 } 45 if a.Location != nil { 46 objectMap["location"] = a.Location 47 } 48 if a.Tags != nil { 49 objectMap["tags"] = a.Tags 50 } 51 return json.Marshal(objectMap) 52} 53 54// UnmarshalJSON is the custom unmarshaler for Account struct. 55func (a *Account) UnmarshalJSON(body []byte) error { 56 var m map[string]*json.RawMessage 57 err := json.Unmarshal(body, &m) 58 if err != nil { 59 return err 60 } 61 for k, v := range m { 62 switch k { 63 case "properties": 64 if v != nil { 65 var accountProperties AccountProperties 66 err = json.Unmarshal(*v, &accountProperties) 67 if err != nil { 68 return err 69 } 70 a.AccountProperties = &accountProperties 71 } 72 case "id": 73 if v != nil { 74 var ID string 75 err = json.Unmarshal(*v, &ID) 76 if err != nil { 77 return err 78 } 79 a.ID = &ID 80 } 81 case "name": 82 if v != nil { 83 var name string 84 err = json.Unmarshal(*v, &name) 85 if err != nil { 86 return err 87 } 88 a.Name = &name 89 } 90 case "type": 91 if v != nil { 92 var typeVar string 93 err = json.Unmarshal(*v, &typeVar) 94 if err != nil { 95 return err 96 } 97 a.Type = &typeVar 98 } 99 case "location": 100 if v != nil { 101 var location string 102 err = json.Unmarshal(*v, &location) 103 if err != nil { 104 return err 105 } 106 a.Location = &location 107 } 108 case "tags": 109 if v != nil { 110 var tags map[string]*string 111 err = json.Unmarshal(*v, &tags) 112 if err != nil { 113 return err 114 } 115 a.Tags = tags 116 } 117 } 118 } 119 120 return nil 121} 122 123// AccountCheckNameAvailabilityParameters ... 124type AccountCheckNameAvailabilityParameters struct { 125 Name *string `json:"name,omitempty"` 126 Type *string `json:"type,omitempty"` 127} 128 129// AccountCreateParameters the parameters to provide for the account. 130type AccountCreateParameters struct { 131 *AccountPropertiesCreateParameters `json:"properties,omitempty"` 132 // ID - READ-ONLY; Resource Id 133 ID *string `json:"id,omitempty"` 134 // Name - READ-ONLY; Resource name 135 Name *string `json:"name,omitempty"` 136 // Type - READ-ONLY; Resource type 137 Type *string `json:"type,omitempty"` 138 // Location - Resource location 139 Location *string `json:"location,omitempty"` 140 // Tags - Resource tags 141 Tags map[string]*string `json:"tags"` 142} 143 144// MarshalJSON is the custom marshaler for AccountCreateParameters. 145func (acp AccountCreateParameters) MarshalJSON() ([]byte, error) { 146 objectMap := make(map[string]interface{}) 147 if acp.AccountPropertiesCreateParameters != nil { 148 objectMap["properties"] = acp.AccountPropertiesCreateParameters 149 } 150 if acp.Location != nil { 151 objectMap["location"] = acp.Location 152 } 153 if acp.Tags != nil { 154 objectMap["tags"] = acp.Tags 155 } 156 return json.Marshal(objectMap) 157} 158 159// UnmarshalJSON is the custom unmarshaler for AccountCreateParameters struct. 160func (acp *AccountCreateParameters) UnmarshalJSON(body []byte) error { 161 var m map[string]*json.RawMessage 162 err := json.Unmarshal(body, &m) 163 if err != nil { 164 return err 165 } 166 for k, v := range m { 167 switch k { 168 case "properties": 169 if v != nil { 170 var accountPropertiesCreateParameters AccountPropertiesCreateParameters 171 err = json.Unmarshal(*v, &accountPropertiesCreateParameters) 172 if err != nil { 173 return err 174 } 175 acp.AccountPropertiesCreateParameters = &accountPropertiesCreateParameters 176 } 177 case "id": 178 if v != nil { 179 var ID string 180 err = json.Unmarshal(*v, &ID) 181 if err != nil { 182 return err 183 } 184 acp.ID = &ID 185 } 186 case "name": 187 if v != nil { 188 var name string 189 err = json.Unmarshal(*v, &name) 190 if err != nil { 191 return err 192 } 193 acp.Name = &name 194 } 195 case "type": 196 if v != nil { 197 var typeVar string 198 err = json.Unmarshal(*v, &typeVar) 199 if err != nil { 200 return err 201 } 202 acp.Type = &typeVar 203 } 204 case "location": 205 if v != nil { 206 var location string 207 err = json.Unmarshal(*v, &location) 208 if err != nil { 209 return err 210 } 211 acp.Location = &location 212 } 213 case "tags": 214 if v != nil { 215 var tags map[string]*string 216 err = json.Unmarshal(*v, &tags) 217 if err != nil { 218 return err 219 } 220 acp.Tags = tags 221 } 222 } 223 } 224 225 return nil 226} 227 228// AccountKeys the access keys for the storage account. 229type AccountKeys struct { 230 autorest.Response `json:"-"` 231 // Key1 - Gets the value of key 1. 232 Key1 *string `json:"key1,omitempty"` 233 // Key2 - Gets the value of key 2. 234 Key2 *string `json:"key2,omitempty"` 235} 236 237// AccountListResult the list storage accounts operation response. 238type AccountListResult struct { 239 autorest.Response `json:"-"` 240 // Value - Gets the list of storage accounts and their properties. 241 Value *[]Account `json:"value,omitempty"` 242 // NextLink - Gets the link to the next set of results. Currently this will always be empty as the API does not support pagination. 243 NextLink *string `json:"nextLink,omitempty"` 244} 245 246// AccountListResultIterator provides access to a complete listing of Account values. 247type AccountListResultIterator struct { 248 i int 249 page AccountListResultPage 250} 251 252// NextWithContext advances to the next value. If there was an error making 253// the request the iterator does not advance and the error is returned. 254func (iter *AccountListResultIterator) NextWithContext(ctx context.Context) (err error) { 255 if tracing.IsEnabled() { 256 ctx = tracing.StartSpan(ctx, fqdn+"/AccountListResultIterator.NextWithContext") 257 defer func() { 258 sc := -1 259 if iter.Response().Response.Response != nil { 260 sc = iter.Response().Response.Response.StatusCode 261 } 262 tracing.EndSpan(ctx, sc, err) 263 }() 264 } 265 iter.i++ 266 if iter.i < len(iter.page.Values()) { 267 return nil 268 } 269 err = iter.page.NextWithContext(ctx) 270 if err != nil { 271 iter.i-- 272 return err 273 } 274 iter.i = 0 275 return nil 276} 277 278// Next advances to the next value. If there was an error making 279// the request the iterator does not advance and the error is returned. 280// Deprecated: Use NextWithContext() instead. 281func (iter *AccountListResultIterator) Next() error { 282 return iter.NextWithContext(context.Background()) 283} 284 285// NotDone returns true if the enumeration should be started or is not yet complete. 286func (iter AccountListResultIterator) NotDone() bool { 287 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 288} 289 290// Response returns the raw server response from the last page request. 291func (iter AccountListResultIterator) Response() AccountListResult { 292 return iter.page.Response() 293} 294 295// Value returns the current value or a zero-initialized value if the 296// iterator has advanced beyond the end of the collection. 297func (iter AccountListResultIterator) Value() Account { 298 if !iter.page.NotDone() { 299 return Account{} 300 } 301 return iter.page.Values()[iter.i] 302} 303 304// Creates a new instance of the AccountListResultIterator type. 305func NewAccountListResultIterator(page AccountListResultPage) AccountListResultIterator { 306 return AccountListResultIterator{page: page} 307} 308 309// IsEmpty returns true if the ListResult contains no values. 310func (alr AccountListResult) IsEmpty() bool { 311 return alr.Value == nil || len(*alr.Value) == 0 312} 313 314// hasNextLink returns true if the NextLink is not empty. 315func (alr AccountListResult) hasNextLink() bool { 316 return alr.NextLink != nil && len(*alr.NextLink) != 0 317} 318 319// accountListResultPreparer prepares a request to retrieve the next set of results. 320// It returns nil if no more results exist. 321func (alr AccountListResult) accountListResultPreparer(ctx context.Context) (*http.Request, error) { 322 if !alr.hasNextLink() { 323 return nil, nil 324 } 325 return autorest.Prepare((&http.Request{}).WithContext(ctx), 326 autorest.AsJSON(), 327 autorest.AsGet(), 328 autorest.WithBaseURL(to.String(alr.NextLink))) 329} 330 331// AccountListResultPage contains a page of Account values. 332type AccountListResultPage struct { 333 fn func(context.Context, AccountListResult) (AccountListResult, error) 334 alr AccountListResult 335} 336 337// NextWithContext advances to the next page of values. If there was an error making 338// the request the page does not advance and the error is returned. 339func (page *AccountListResultPage) NextWithContext(ctx context.Context) (err error) { 340 if tracing.IsEnabled() { 341 ctx = tracing.StartSpan(ctx, fqdn+"/AccountListResultPage.NextWithContext") 342 defer func() { 343 sc := -1 344 if page.Response().Response.Response != nil { 345 sc = page.Response().Response.Response.StatusCode 346 } 347 tracing.EndSpan(ctx, sc, err) 348 }() 349 } 350 for { 351 next, err := page.fn(ctx, page.alr) 352 if err != nil { 353 return err 354 } 355 page.alr = next 356 if !next.hasNextLink() || !next.IsEmpty() { 357 break 358 } 359 } 360 return nil 361} 362 363// Next advances to the next page of values. If there was an error making 364// the request the page does not advance and the error is returned. 365// Deprecated: Use NextWithContext() instead. 366func (page *AccountListResultPage) Next() error { 367 return page.NextWithContext(context.Background()) 368} 369 370// NotDone returns true if the page enumeration should be started or is not yet complete. 371func (page AccountListResultPage) NotDone() bool { 372 return !page.alr.IsEmpty() 373} 374 375// Response returns the raw server response from the last page request. 376func (page AccountListResultPage) Response() AccountListResult { 377 return page.alr 378} 379 380// Values returns the slice of values for the current page or nil if there are no values. 381func (page AccountListResultPage) Values() []Account { 382 if page.alr.IsEmpty() { 383 return nil 384 } 385 return *page.alr.Value 386} 387 388// Creates a new instance of the AccountListResultPage type. 389func NewAccountListResultPage(cur AccountListResult, getNextPage func(context.Context, AccountListResult) (AccountListResult, error)) AccountListResultPage { 390 return AccountListResultPage{ 391 fn: getNextPage, 392 alr: cur, 393 } 394} 395 396// AccountProperties ... 397type AccountProperties struct { 398 // ProvisioningState - Gets the status of the storage account at the time the operation was called. Possible values include: 'Creating', 'ResolvingDNS', 'Succeeded' 399 ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` 400 // AccountType - Gets the type of the storage account. Possible values include: 'StandardLRS', 'StandardZRS', 'StandardGRS', 'StandardRAGRS', 'PremiumLRS' 401 AccountType AccountType `json:"accountType,omitempty"` 402 // PrimaryEndpoints - Gets the URLs that are used to perform a retrieval of a public blob, queue or table object.Note that StandardZRS and PremiumLRS accounts only return the blob endpoint. 403 PrimaryEndpoints *Endpoints `json:"primaryEndpoints,omitempty"` 404 // PrimaryLocation - Gets the location of the primary for the storage account. 405 PrimaryLocation *string `json:"primaryLocation,omitempty"` 406 // StatusOfPrimary - Gets the status indicating whether the primary location of the storage account is available or unavailable. Possible values include: 'Available', 'Unavailable' 407 StatusOfPrimary AccountStatus `json:"statusOfPrimary,omitempty"` 408 // LastGeoFailoverTime - Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not returned if there has never been a failover instance. Only available if the accountType is StandardGRS or StandardRAGRS. 409 LastGeoFailoverTime *date.Time `json:"lastGeoFailoverTime,omitempty"` 410 // SecondaryLocation - Gets the location of the geo replicated secondary for the storage account. Only available if the accountType is StandardGRS or StandardRAGRS. 411 SecondaryLocation *string `json:"secondaryLocation,omitempty"` 412 // StatusOfSecondary - Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the accountType is StandardGRS or StandardRAGRS. Possible values include: 'Available', 'Unavailable' 413 StatusOfSecondary AccountStatus `json:"statusOfSecondary,omitempty"` 414 // CreationTime - Gets the creation date and time of the storage account in UTC. 415 CreationTime *date.Time `json:"creationTime,omitempty"` 416 // CustomDomain - Gets the user assigned custom domain assigned to this storage account. 417 CustomDomain *CustomDomain `json:"customDomain,omitempty"` 418 // SecondaryEndpoints - Gets the URLs that are used to perform a retrieval of a public blob, queue or table object from the secondary location of the storage account. Only available if the accountType is StandardRAGRS. 419 SecondaryEndpoints *Endpoints `json:"secondaryEndpoints,omitempty"` 420} 421 422// AccountPropertiesCreateParameters ... 423type AccountPropertiesCreateParameters struct { 424 // AccountType - Gets or sets the account type. Possible values include: 'StandardLRS', 'StandardZRS', 'StandardGRS', 'StandardRAGRS', 'PremiumLRS' 425 AccountType AccountType `json:"accountType,omitempty"` 426} 427 428// AccountPropertiesUpdateParameters ... 429type AccountPropertiesUpdateParameters struct { 430 // AccountType - Gets or sets the account type. Note that StandardZRS and PremiumLRS accounts cannot be changed to other account types, and other account types cannot be changed to StandardZRS or PremiumLRS. Possible values include: 'StandardLRS', 'StandardZRS', 'StandardGRS', 'StandardRAGRS', 'PremiumLRS' 431 AccountType AccountType `json:"accountType,omitempty"` 432 // CustomDomain - User domain assigned to the storage account. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear the existing custom domain, use an empty string for the custom domain name property. 433 CustomDomain *CustomDomain `json:"customDomain,omitempty"` 434} 435 436// AccountRegenerateKeyParameters ... 437type AccountRegenerateKeyParameters struct { 438 // KeyName - Possible values include: 'Key1', 'Key2' 439 KeyName KeyName `json:"keyName,omitempty"` 440} 441 442// AccountsCreateFuture an abstraction for monitoring and retrieving the results of a long-running 443// operation. 444type AccountsCreateFuture struct { 445 azure.FutureAPI 446 // Result returns the result of the asynchronous operation. 447 // If the operation has not completed it will return an error. 448 Result func(AccountsClient) (Account, error) 449} 450 451// UnmarshalJSON is the custom unmarshaller for CreateFuture. 452func (future *AccountsCreateFuture) UnmarshalJSON(body []byte) error { 453 var azFuture azure.Future 454 if err := json.Unmarshal(body, &azFuture); err != nil { 455 return err 456 } 457 future.FutureAPI = &azFuture 458 future.Result = future.result 459 return nil 460} 461 462// result is the default implementation for AccountsCreateFuture.Result. 463func (future *AccountsCreateFuture) result(client AccountsClient) (a Account, err error) { 464 var done bool 465 done, err = future.DoneWithContext(context.Background(), client) 466 if err != nil { 467 err = autorest.NewErrorWithError(err, "storage.AccountsCreateFuture", "Result", future.Response(), "Polling failure") 468 return 469 } 470 if !done { 471 a.Response.Response = future.Response() 472 err = azure.NewAsyncOpIncompleteError("storage.AccountsCreateFuture") 473 return 474 } 475 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 476 if a.Response.Response, err = future.GetResult(sender); err == nil && a.Response.Response.StatusCode != http.StatusNoContent { 477 a, err = client.CreateResponder(a.Response.Response) 478 if err != nil { 479 err = autorest.NewErrorWithError(err, "storage.AccountsCreateFuture", "Result", a.Response.Response, "Failure responding to request") 480 } 481 } 482 return 483} 484 485// AccountUpdateParameters the parameters to update on the account. 486type AccountUpdateParameters struct { 487 *AccountPropertiesUpdateParameters `json:"properties,omitempty"` 488 // ID - READ-ONLY; Resource Id 489 ID *string `json:"id,omitempty"` 490 // Name - READ-ONLY; Resource name 491 Name *string `json:"name,omitempty"` 492 // Type - READ-ONLY; Resource type 493 Type *string `json:"type,omitempty"` 494 // Location - Resource location 495 Location *string `json:"location,omitempty"` 496 // Tags - Resource tags 497 Tags map[string]*string `json:"tags"` 498} 499 500// MarshalJSON is the custom marshaler for AccountUpdateParameters. 501func (aup AccountUpdateParameters) MarshalJSON() ([]byte, error) { 502 objectMap := make(map[string]interface{}) 503 if aup.AccountPropertiesUpdateParameters != nil { 504 objectMap["properties"] = aup.AccountPropertiesUpdateParameters 505 } 506 if aup.Location != nil { 507 objectMap["location"] = aup.Location 508 } 509 if aup.Tags != nil { 510 objectMap["tags"] = aup.Tags 511 } 512 return json.Marshal(objectMap) 513} 514 515// UnmarshalJSON is the custom unmarshaler for AccountUpdateParameters struct. 516func (aup *AccountUpdateParameters) UnmarshalJSON(body []byte) error { 517 var m map[string]*json.RawMessage 518 err := json.Unmarshal(body, &m) 519 if err != nil { 520 return err 521 } 522 for k, v := range m { 523 switch k { 524 case "properties": 525 if v != nil { 526 var accountPropertiesUpdateParameters AccountPropertiesUpdateParameters 527 err = json.Unmarshal(*v, &accountPropertiesUpdateParameters) 528 if err != nil { 529 return err 530 } 531 aup.AccountPropertiesUpdateParameters = &accountPropertiesUpdateParameters 532 } 533 case "id": 534 if v != nil { 535 var ID string 536 err = json.Unmarshal(*v, &ID) 537 if err != nil { 538 return err 539 } 540 aup.ID = &ID 541 } 542 case "name": 543 if v != nil { 544 var name string 545 err = json.Unmarshal(*v, &name) 546 if err != nil { 547 return err 548 } 549 aup.Name = &name 550 } 551 case "type": 552 if v != nil { 553 var typeVar string 554 err = json.Unmarshal(*v, &typeVar) 555 if err != nil { 556 return err 557 } 558 aup.Type = &typeVar 559 } 560 case "location": 561 if v != nil { 562 var location string 563 err = json.Unmarshal(*v, &location) 564 if err != nil { 565 return err 566 } 567 aup.Location = &location 568 } 569 case "tags": 570 if v != nil { 571 var tags map[string]*string 572 err = json.Unmarshal(*v, &tags) 573 if err != nil { 574 return err 575 } 576 aup.Tags = tags 577 } 578 } 579 } 580 581 return nil 582} 583 584// CheckNameAvailabilityResult the CheckNameAvailability operation response. 585type CheckNameAvailabilityResult struct { 586 autorest.Response `json:"-"` 587 // NameAvailable - Gets a boolean value that indicates whether the name is available for you to use. If true, the name is available. If false, the name has already been taken or invalid and cannot be used. 588 NameAvailable *bool `json:"nameAvailable,omitempty"` 589 // Reason - Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. Possible values include: 'AccountNameInvalid', 'AlreadyExists' 590 Reason Reason `json:"reason,omitempty"` 591 // Message - Gets an error message explaining the Reason value in more detail. 592 Message *string `json:"message,omitempty"` 593} 594 595// CustomDomain the custom domain assigned to this storage account. This can be set via Update. 596type CustomDomain struct { 597 // Name - Gets or sets the custom domain name. Name is the CNAME source. 598 Name *string `json:"name,omitempty"` 599 // UseSubDomainName - Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates 600 UseSubDomainName *bool `json:"useSubDomainName,omitempty"` 601} 602 603// Endpoints the URIs that are used to perform a retrieval of a public blob, queue or table object. 604type Endpoints struct { 605 // Blob - Gets the blob endpoint. 606 Blob *string `json:"blob,omitempty"` 607 // Queue - Gets the queue endpoint. 608 Queue *string `json:"queue,omitempty"` 609 // Table - Gets the table endpoint. 610 Table *string `json:"table,omitempty"` 611} 612 613// Resource ... 614type Resource struct { 615 // ID - READ-ONLY; Resource Id 616 ID *string `json:"id,omitempty"` 617 // Name - READ-ONLY; Resource name 618 Name *string `json:"name,omitempty"` 619 // Type - READ-ONLY; Resource type 620 Type *string `json:"type,omitempty"` 621 // Location - Resource location 622 Location *string `json:"location,omitempty"` 623 // Tags - Resource tags 624 Tags map[string]*string `json:"tags"` 625} 626 627// MarshalJSON is the custom marshaler for Resource. 628func (r Resource) MarshalJSON() ([]byte, error) { 629 objectMap := make(map[string]interface{}) 630 if r.Location != nil { 631 objectMap["location"] = r.Location 632 } 633 if r.Tags != nil { 634 objectMap["tags"] = r.Tags 635 } 636 return json.Marshal(objectMap) 637} 638 639// SubResource ... 640type SubResource struct { 641 // ID - Resource Id 642 ID *string `json:"id,omitempty"` 643} 644 645// Usage describes Storage Resource Usage. 646type Usage struct { 647 // Unit - Gets the unit of measurement. Possible values include: 'Count', 'Bytes', 'Seconds', 'Percent', 'CountsPerSecond', 'BytesPerSecond' 648 Unit UsageUnit `json:"unit,omitempty"` 649 // CurrentValue - Gets the current count of the allocated resources in the subscription. 650 CurrentValue *int32 `json:"currentValue,omitempty"` 651 // Limit - Gets the maximum count of the resources that can be allocated in the subscription. 652 Limit *int32 `json:"limit,omitempty"` 653 // Name - Gets the name of the type of usage. 654 Name *UsageName `json:"name,omitempty"` 655} 656 657// UsageListResult the List Usages operation response. 658type UsageListResult struct { 659 autorest.Response `json:"-"` 660 // Value - Gets or sets the list Storage Resource Usages. 661 Value *[]Usage `json:"value,omitempty"` 662} 663 664// UsageName the Usage Names. 665type UsageName struct { 666 // Value - Gets a string describing the resource name. 667 Value *string `json:"value,omitempty"` 668 // LocalizedValue - Gets a localized string describing the resource name. 669 LocalizedValue *string `json:"localizedValue,omitempty"` 670} 671