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