1package iotspaces 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/to" 26 "github.com/Azure/go-autorest/tracing" 27 "net/http" 28) 29 30// The package's fully qualified name. 31const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/iotspaces/mgmt/2017-10-01-preview/iotspaces" 32 33// NameUnavailabilityReason enumerates the values for name unavailability reason. 34type NameUnavailabilityReason string 35 36const ( 37 // AlreadyExists ... 38 AlreadyExists NameUnavailabilityReason = "AlreadyExists" 39 // Invalid ... 40 Invalid NameUnavailabilityReason = "Invalid" 41) 42 43// PossibleNameUnavailabilityReasonValues returns an array of possible values for the NameUnavailabilityReason const type. 44func PossibleNameUnavailabilityReasonValues() []NameUnavailabilityReason { 45 return []NameUnavailabilityReason{AlreadyExists, Invalid} 46} 47 48// ProvisioningState enumerates the values for provisioning state. 49type ProvisioningState string 50 51const ( 52 // Canceled ... 53 Canceled ProvisioningState = "Canceled" 54 // Deleting ... 55 Deleting ProvisioningState = "Deleting" 56 // Failed ... 57 Failed ProvisioningState = "Failed" 58 // Provisioning ... 59 Provisioning ProvisioningState = "Provisioning" 60 // Succeeded ... 61 Succeeded ProvisioningState = "Succeeded" 62) 63 64// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. 65func PossibleProvisioningStateValues() []ProvisioningState { 66 return []ProvisioningState{Canceled, Deleting, Failed, Provisioning, Succeeded} 67} 68 69// Sku enumerates the values for sku. 70type Sku string 71 72const ( 73 // F1 ... 74 F1 Sku = "F1" 75 // S1 ... 76 S1 Sku = "S1" 77 // S2 ... 78 S2 Sku = "S2" 79 // S3 ... 80 S3 Sku = "S3" 81) 82 83// PossibleSkuValues returns an array of possible values for the Sku const type. 84func PossibleSkuValues() []Sku { 85 return []Sku{F1, S1, S2, S3} 86} 87 88// CreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running 89// operation. 90type CreateOrUpdateFuture struct { 91 azure.Future 92} 93 94// Result returns the result of the asynchronous operation. 95// If the operation has not completed it will return an error. 96func (future *CreateOrUpdateFuture) Result(client Client) (d Description, err error) { 97 var done bool 98 done, err = future.DoneWithContext(context.Background(), client) 99 if err != nil { 100 err = autorest.NewErrorWithError(err, "iotspaces.CreateOrUpdateFuture", "Result", future.Response(), "Polling failure") 101 return 102 } 103 if !done { 104 err = azure.NewAsyncOpIncompleteError("iotspaces.CreateOrUpdateFuture") 105 return 106 } 107 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 108 if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { 109 d, err = client.CreateOrUpdateResponder(d.Response.Response) 110 if err != nil { 111 err = autorest.NewErrorWithError(err, "iotspaces.CreateOrUpdateFuture", "Result", d.Response.Response, "Failure responding to request") 112 } 113 } 114 return 115} 116 117// DeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. 118type DeleteFuture struct { 119 azure.Future 120} 121 122// Result returns the result of the asynchronous operation. 123// If the operation has not completed it will return an error. 124func (future *DeleteFuture) Result(client Client) (d Description, err error) { 125 var done bool 126 done, err = future.DoneWithContext(context.Background(), client) 127 if err != nil { 128 err = autorest.NewErrorWithError(err, "iotspaces.DeleteFuture", "Result", future.Response(), "Polling failure") 129 return 130 } 131 if !done { 132 err = azure.NewAsyncOpIncompleteError("iotspaces.DeleteFuture") 133 return 134 } 135 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 136 if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { 137 d, err = client.DeleteResponder(d.Response.Response) 138 if err != nil { 139 err = autorest.NewErrorWithError(err, "iotspaces.DeleteFuture", "Result", d.Response.Response, "Failure responding to request") 140 } 141 } 142 return 143} 144 145// Description the description of the IoTSpaces service. 146type Description struct { 147 autorest.Response `json:"-"` 148 // Properties - The common properties of a IoTSpaces service. 149 Properties *Properties `json:"properties,omitempty"` 150 // Sku - A valid instance SKU. 151 Sku *SkuInfo `json:"sku,omitempty"` 152 // ID - READ-ONLY; The resource identifier. 153 ID *string `json:"id,omitempty"` 154 // Name - READ-ONLY; The resource name. 155 Name *string `json:"name,omitempty"` 156 // Type - READ-ONLY; The resource type. 157 Type *string `json:"type,omitempty"` 158 // Location - The resource location. 159 Location *string `json:"location,omitempty"` 160 // Tags - The resource tags. 161 Tags map[string]*string `json:"tags"` 162} 163 164// MarshalJSON is the custom marshaler for Description. 165func (d Description) MarshalJSON() ([]byte, error) { 166 objectMap := make(map[string]interface{}) 167 if d.Properties != nil { 168 objectMap["properties"] = d.Properties 169 } 170 if d.Sku != nil { 171 objectMap["sku"] = d.Sku 172 } 173 if d.Location != nil { 174 objectMap["location"] = d.Location 175 } 176 if d.Tags != nil { 177 objectMap["tags"] = d.Tags 178 } 179 return json.Marshal(objectMap) 180} 181 182// DescriptionListResult a list of IoTSpaces description objects with a next link. 183type DescriptionListResult struct { 184 autorest.Response `json:"-"` 185 // NextLink - The link used to get the next page of IoTSpaces description objects. 186 NextLink *string `json:"nextLink,omitempty"` 187 // Value - A list of IoTSpaces description objects. 188 Value *[]Description `json:"value,omitempty"` 189} 190 191// DescriptionListResultIterator provides access to a complete listing of Description values. 192type DescriptionListResultIterator struct { 193 i int 194 page DescriptionListResultPage 195} 196 197// NextWithContext advances to the next value. If there was an error making 198// the request the iterator does not advance and the error is returned. 199func (iter *DescriptionListResultIterator) NextWithContext(ctx context.Context) (err error) { 200 if tracing.IsEnabled() { 201 ctx = tracing.StartSpan(ctx, fqdn+"/DescriptionListResultIterator.NextWithContext") 202 defer func() { 203 sc := -1 204 if iter.Response().Response.Response != nil { 205 sc = iter.Response().Response.Response.StatusCode 206 } 207 tracing.EndSpan(ctx, sc, err) 208 }() 209 } 210 iter.i++ 211 if iter.i < len(iter.page.Values()) { 212 return nil 213 } 214 err = iter.page.NextWithContext(ctx) 215 if err != nil { 216 iter.i-- 217 return err 218 } 219 iter.i = 0 220 return nil 221} 222 223// Next advances to the next value. If there was an error making 224// the request the iterator does not advance and the error is returned. 225// Deprecated: Use NextWithContext() instead. 226func (iter *DescriptionListResultIterator) Next() error { 227 return iter.NextWithContext(context.Background()) 228} 229 230// NotDone returns true if the enumeration should be started or is not yet complete. 231func (iter DescriptionListResultIterator) NotDone() bool { 232 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 233} 234 235// Response returns the raw server response from the last page request. 236func (iter DescriptionListResultIterator) Response() DescriptionListResult { 237 return iter.page.Response() 238} 239 240// Value returns the current value or a zero-initialized value if the 241// iterator has advanced beyond the end of the collection. 242func (iter DescriptionListResultIterator) Value() Description { 243 if !iter.page.NotDone() { 244 return Description{} 245 } 246 return iter.page.Values()[iter.i] 247} 248 249// Creates a new instance of the DescriptionListResultIterator type. 250func NewDescriptionListResultIterator(page DescriptionListResultPage) DescriptionListResultIterator { 251 return DescriptionListResultIterator{page: page} 252} 253 254// IsEmpty returns true if the ListResult contains no values. 255func (dlr DescriptionListResult) IsEmpty() bool { 256 return dlr.Value == nil || len(*dlr.Value) == 0 257} 258 259// descriptionListResultPreparer prepares a request to retrieve the next set of results. 260// It returns nil if no more results exist. 261func (dlr DescriptionListResult) descriptionListResultPreparer(ctx context.Context) (*http.Request, error) { 262 if dlr.NextLink == nil || len(to.String(dlr.NextLink)) < 1 { 263 return nil, nil 264 } 265 return autorest.Prepare((&http.Request{}).WithContext(ctx), 266 autorest.AsJSON(), 267 autorest.AsGet(), 268 autorest.WithBaseURL(to.String(dlr.NextLink))) 269} 270 271// DescriptionListResultPage contains a page of Description values. 272type DescriptionListResultPage struct { 273 fn func(context.Context, DescriptionListResult) (DescriptionListResult, error) 274 dlr DescriptionListResult 275} 276 277// NextWithContext advances to the next page of values. If there was an error making 278// the request the page does not advance and the error is returned. 279func (page *DescriptionListResultPage) NextWithContext(ctx context.Context) (err error) { 280 if tracing.IsEnabled() { 281 ctx = tracing.StartSpan(ctx, fqdn+"/DescriptionListResultPage.NextWithContext") 282 defer func() { 283 sc := -1 284 if page.Response().Response.Response != nil { 285 sc = page.Response().Response.Response.StatusCode 286 } 287 tracing.EndSpan(ctx, sc, err) 288 }() 289 } 290 next, err := page.fn(ctx, page.dlr) 291 if err != nil { 292 return err 293 } 294 page.dlr = next 295 return nil 296} 297 298// Next advances to the next page of values. If there was an error making 299// the request the page does not advance and the error is returned. 300// Deprecated: Use NextWithContext() instead. 301func (page *DescriptionListResultPage) Next() error { 302 return page.NextWithContext(context.Background()) 303} 304 305// NotDone returns true if the page enumeration should be started or is not yet complete. 306func (page DescriptionListResultPage) NotDone() bool { 307 return !page.dlr.IsEmpty() 308} 309 310// Response returns the raw server response from the last page request. 311func (page DescriptionListResultPage) Response() DescriptionListResult { 312 return page.dlr 313} 314 315// Values returns the slice of values for the current page or nil if there are no values. 316func (page DescriptionListResultPage) Values() []Description { 317 if page.dlr.IsEmpty() { 318 return nil 319 } 320 return *page.dlr.Value 321} 322 323// Creates a new instance of the DescriptionListResultPage type. 324func NewDescriptionListResultPage(getNextPage func(context.Context, DescriptionListResult) (DescriptionListResult, error)) DescriptionListResultPage { 325 return DescriptionListResultPage{fn: getNextPage} 326} 327 328// ErrorDetails error details. 329type ErrorDetails struct { 330 // Code - READ-ONLY; The error code. 331 Code *string `json:"code,omitempty"` 332 // Message - READ-ONLY; The error message. 333 Message *string `json:"message,omitempty"` 334 // Target - READ-ONLY; The target of the particular error. 335 Target *string `json:"target,omitempty"` 336} 337 338// NameAvailabilityInfo the properties indicating whether a given IoTSpaces service name is available. 339type NameAvailabilityInfo struct { 340 autorest.Response `json:"-"` 341 // NameAvailable - READ-ONLY; The value which indicates whether the provided name is available. 342 NameAvailable *bool `json:"nameAvailable,omitempty"` 343 // Reason - READ-ONLY; The reason for unavailability. Possible values include: 'Invalid', 'AlreadyExists' 344 Reason NameUnavailabilityReason `json:"reason,omitempty"` 345 // Message - The detailed reason message. 346 Message *string `json:"message,omitempty"` 347} 348 349// Operation ioTSpaces service REST API operation 350type Operation struct { 351 // Name - READ-ONLY; Operation name: {provider}/{resource}/{read | write | action | delete} 352 Name *string `json:"name,omitempty"` 353 Display *OperationDisplay `json:"display,omitempty"` 354} 355 356// OperationDisplay the object that represents the operation. 357type OperationDisplay struct { 358 // Provider - READ-ONLY; Service provider: Microsoft IoTSpaces 359 Provider *string `json:"provider,omitempty"` 360 // Resource - READ-ONLY; Resource Type: IoTSpaces 361 Resource *string `json:"resource,omitempty"` 362 // Operation - READ-ONLY; Name of the operation 363 Operation *string `json:"operation,omitempty"` 364 // Description - READ-ONLY; Friendly description for the operation, 365 Description *string `json:"description,omitempty"` 366} 367 368// OperationInputs input values. 369type OperationInputs struct { 370 // Name - The name of the IoTSpaces service instance to check. 371 Name *string `json:"name,omitempty"` 372} 373 374// OperationListResult a list of IoTSpaces service operations. It contains a list of operations and a URL 375// link to get the next set of results. 376type OperationListResult struct { 377 autorest.Response `json:"-"` 378 // NextLink - The link used to get the next page of IoTSpaces description objects. 379 NextLink *string `json:"nextLink,omitempty"` 380 // Value - READ-ONLY; A list of IoT spaces operations supported by the Microsoft.IoTSpaces resource provider. 381 Value *[]Operation `json:"value,omitempty"` 382} 383 384// OperationListResultIterator provides access to a complete listing of Operation values. 385type OperationListResultIterator struct { 386 i int 387 page OperationListResultPage 388} 389 390// NextWithContext advances to the next value. If there was an error making 391// the request the iterator does not advance and the error is returned. 392func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { 393 if tracing.IsEnabled() { 394 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") 395 defer func() { 396 sc := -1 397 if iter.Response().Response.Response != nil { 398 sc = iter.Response().Response.Response.StatusCode 399 } 400 tracing.EndSpan(ctx, sc, err) 401 }() 402 } 403 iter.i++ 404 if iter.i < len(iter.page.Values()) { 405 return nil 406 } 407 err = iter.page.NextWithContext(ctx) 408 if err != nil { 409 iter.i-- 410 return err 411 } 412 iter.i = 0 413 return nil 414} 415 416// Next advances to the next value. If there was an error making 417// the request the iterator does not advance and the error is returned. 418// Deprecated: Use NextWithContext() instead. 419func (iter *OperationListResultIterator) Next() error { 420 return iter.NextWithContext(context.Background()) 421} 422 423// NotDone returns true if the enumeration should be started or is not yet complete. 424func (iter OperationListResultIterator) NotDone() bool { 425 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 426} 427 428// Response returns the raw server response from the last page request. 429func (iter OperationListResultIterator) Response() OperationListResult { 430 return iter.page.Response() 431} 432 433// Value returns the current value or a zero-initialized value if the 434// iterator has advanced beyond the end of the collection. 435func (iter OperationListResultIterator) Value() Operation { 436 if !iter.page.NotDone() { 437 return Operation{} 438 } 439 return iter.page.Values()[iter.i] 440} 441 442// Creates a new instance of the OperationListResultIterator type. 443func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { 444 return OperationListResultIterator{page: page} 445} 446 447// IsEmpty returns true if the ListResult contains no values. 448func (olr OperationListResult) IsEmpty() bool { 449 return olr.Value == nil || len(*olr.Value) == 0 450} 451 452// operationListResultPreparer prepares a request to retrieve the next set of results. 453// It returns nil if no more results exist. 454func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { 455 if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { 456 return nil, nil 457 } 458 return autorest.Prepare((&http.Request{}).WithContext(ctx), 459 autorest.AsJSON(), 460 autorest.AsGet(), 461 autorest.WithBaseURL(to.String(olr.NextLink))) 462} 463 464// OperationListResultPage contains a page of Operation values. 465type OperationListResultPage struct { 466 fn func(context.Context, OperationListResult) (OperationListResult, error) 467 olr OperationListResult 468} 469 470// NextWithContext advances to the next page of values. If there was an error making 471// the request the page does not advance and the error is returned. 472func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { 473 if tracing.IsEnabled() { 474 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") 475 defer func() { 476 sc := -1 477 if page.Response().Response.Response != nil { 478 sc = page.Response().Response.Response.StatusCode 479 } 480 tracing.EndSpan(ctx, sc, err) 481 }() 482 } 483 next, err := page.fn(ctx, page.olr) 484 if err != nil { 485 return err 486 } 487 page.olr = next 488 return nil 489} 490 491// Next advances to the next page of values. If there was an error making 492// the request the page does not advance and the error is returned. 493// Deprecated: Use NextWithContext() instead. 494func (page *OperationListResultPage) Next() error { 495 return page.NextWithContext(context.Background()) 496} 497 498// NotDone returns true if the page enumeration should be started or is not yet complete. 499func (page OperationListResultPage) NotDone() bool { 500 return !page.olr.IsEmpty() 501} 502 503// Response returns the raw server response from the last page request. 504func (page OperationListResultPage) Response() OperationListResult { 505 return page.olr 506} 507 508// Values returns the slice of values for the current page or nil if there are no values. 509func (page OperationListResultPage) Values() []Operation { 510 if page.olr.IsEmpty() { 511 return nil 512 } 513 return *page.olr.Value 514} 515 516// Creates a new instance of the OperationListResultPage type. 517func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { 518 return OperationListResultPage{fn: getNextPage} 519} 520 521// PatchDescription the description of the IoTSpaces service. 522type PatchDescription struct { 523 // Tags - Instance tags 524 Tags map[string]*string `json:"tags"` 525 // Properties - The common properties of an IoTSpaces service. 526 Properties *Properties `json:"properties,omitempty"` 527} 528 529// MarshalJSON is the custom marshaler for PatchDescription. 530func (pd PatchDescription) MarshalJSON() ([]byte, error) { 531 objectMap := make(map[string]interface{}) 532 if pd.Tags != nil { 533 objectMap["tags"] = pd.Tags 534 } 535 if pd.Properties != nil { 536 objectMap["properties"] = pd.Properties 537 } 538 return json.Marshal(objectMap) 539} 540 541// Properties the properties of an IoTSpaces instance. 542type Properties struct { 543 // ProvisioningState - READ-ONLY; The provisioning state. Possible values include: 'Provisioning', 'Deleting', 'Succeeded', 'Failed', 'Canceled' 544 ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` 545 // ManagementAPIURL - READ-ONLY; The management Api endpoint. 546 ManagementAPIURL *string `json:"managementApiUrl,omitempty"` 547 // WebPortalURL - READ-ONLY; The management UI endpoint. 548 WebPortalURL *string `json:"webPortalUrl,omitempty"` 549 // StorageContainer - The properties of the designated storage container. 550 StorageContainer *StorageContainerProperties `json:"storageContainer,omitempty"` 551} 552 553// Resource the common properties of an IoTSpaces service. 554type Resource struct { 555 // ID - READ-ONLY; The resource identifier. 556 ID *string `json:"id,omitempty"` 557 // Name - READ-ONLY; The resource name. 558 Name *string `json:"name,omitempty"` 559 // Type - READ-ONLY; The resource type. 560 Type *string `json:"type,omitempty"` 561 // Location - The resource location. 562 Location *string `json:"location,omitempty"` 563 // Tags - The resource tags. 564 Tags map[string]*string `json:"tags"` 565} 566 567// MarshalJSON is the custom marshaler for Resource. 568func (r Resource) MarshalJSON() ([]byte, error) { 569 objectMap := make(map[string]interface{}) 570 if r.Location != nil { 571 objectMap["location"] = r.Location 572 } 573 if r.Tags != nil { 574 objectMap["tags"] = r.Tags 575 } 576 return json.Marshal(objectMap) 577} 578 579// SkuInfo information about the SKU of the IoTSpaces instance. 580type SkuInfo struct { 581 // Name - The name of the SKU. Possible values include: 'F1', 'S1', 'S2', 'S3' 582 Name Sku `json:"name,omitempty"` 583} 584 585// StorageContainerProperties the properties of the Azure Storage Container for file archive. 586type StorageContainerProperties struct { 587 // ConnectionString - The connection string of the storage account. 588 ConnectionString *string `json:"connectionString,omitempty"` 589 // SubscriptionID - The subscription identifier of the storage account. 590 SubscriptionID *string `json:"subscriptionId,omitempty"` 591 // ResourceGroup - The name of the resource group of the storage account. 592 ResourceGroup *string `json:"resourceGroup,omitempty"` 593 // ContainerName - The name of storage container in the storage account. 594 ContainerName *string `json:"containerName,omitempty"` 595} 596 597// UpdateFuture an abstraction for monitoring and retrieving the results of a long-running operation. 598type UpdateFuture struct { 599 azure.Future 600} 601 602// Result returns the result of the asynchronous operation. 603// If the operation has not completed it will return an error. 604func (future *UpdateFuture) Result(client Client) (d Description, err error) { 605 var done bool 606 done, err = future.DoneWithContext(context.Background(), client) 607 if err != nil { 608 err = autorest.NewErrorWithError(err, "iotspaces.UpdateFuture", "Result", future.Response(), "Polling failure") 609 return 610 } 611 if !done { 612 err = azure.NewAsyncOpIncompleteError("iotspaces.UpdateFuture") 613 return 614 } 615 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 616 if d.Response.Response, err = future.GetResult(sender); err == nil && d.Response.Response.StatusCode != http.StatusNoContent { 617 d, err = client.UpdateResponder(d.Response.Response) 618 if err != nil { 619 err = autorest.NewErrorWithError(err, "iotspaces.UpdateFuture", "Result", d.Response.Response, "Failure responding to request") 620 } 621 } 622 return 623} 624