1package hybridkubernetes 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/hybridkubernetes/mgmt/2021-03-01/hybridkubernetes" 22 23// AzureEntityResource the resource model definition for an Azure Resource Manager resource with an etag. 24type AzureEntityResource struct { 25 // Etag - READ-ONLY; Resource Etag. 26 Etag *string `json:"etag,omitempty"` 27 // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} 28 ID *string `json:"id,omitempty"` 29 // Name - READ-ONLY; The name of the resource 30 Name *string `json:"name,omitempty"` 31 // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" 32 Type *string `json:"type,omitempty"` 33} 34 35// MarshalJSON is the custom marshaler for AzureEntityResource. 36func (aer AzureEntityResource) MarshalJSON() ([]byte, error) { 37 objectMap := make(map[string]interface{}) 38 return json.Marshal(objectMap) 39} 40 41// ConnectedCluster represents a connected cluster. 42type ConnectedCluster struct { 43 autorest.Response `json:"-"` 44 // Identity - The identity of the connected cluster. 45 Identity *ConnectedClusterIdentity `json:"identity,omitempty"` 46 // ConnectedClusterProperties - Describes the connected cluster resource properties. 47 *ConnectedClusterProperties `json:"properties,omitempty"` 48 // SystemData - READ-ONLY; Metadata pertaining to creation and last modification of the resource 49 SystemData *SystemData `json:"systemData,omitempty"` 50 // Tags - Resource tags. 51 Tags map[string]*string `json:"tags"` 52 // Location - The geo-location where the resource lives 53 Location *string `json:"location,omitempty"` 54 // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} 55 ID *string `json:"id,omitempty"` 56 // Name - READ-ONLY; The name of the resource 57 Name *string `json:"name,omitempty"` 58 // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" 59 Type *string `json:"type,omitempty"` 60} 61 62// MarshalJSON is the custom marshaler for ConnectedCluster. 63func (cc ConnectedCluster) MarshalJSON() ([]byte, error) { 64 objectMap := make(map[string]interface{}) 65 if cc.Identity != nil { 66 objectMap["identity"] = cc.Identity 67 } 68 if cc.ConnectedClusterProperties != nil { 69 objectMap["properties"] = cc.ConnectedClusterProperties 70 } 71 if cc.Tags != nil { 72 objectMap["tags"] = cc.Tags 73 } 74 if cc.Location != nil { 75 objectMap["location"] = cc.Location 76 } 77 return json.Marshal(objectMap) 78} 79 80// UnmarshalJSON is the custom unmarshaler for ConnectedCluster struct. 81func (cc *ConnectedCluster) UnmarshalJSON(body []byte) error { 82 var m map[string]*json.RawMessage 83 err := json.Unmarshal(body, &m) 84 if err != nil { 85 return err 86 } 87 for k, v := range m { 88 switch k { 89 case "identity": 90 if v != nil { 91 var identity ConnectedClusterIdentity 92 err = json.Unmarshal(*v, &identity) 93 if err != nil { 94 return err 95 } 96 cc.Identity = &identity 97 } 98 case "properties": 99 if v != nil { 100 var connectedClusterProperties ConnectedClusterProperties 101 err = json.Unmarshal(*v, &connectedClusterProperties) 102 if err != nil { 103 return err 104 } 105 cc.ConnectedClusterProperties = &connectedClusterProperties 106 } 107 case "systemData": 108 if v != nil { 109 var systemData SystemData 110 err = json.Unmarshal(*v, &systemData) 111 if err != nil { 112 return err 113 } 114 cc.SystemData = &systemData 115 } 116 case "tags": 117 if v != nil { 118 var tags map[string]*string 119 err = json.Unmarshal(*v, &tags) 120 if err != nil { 121 return err 122 } 123 cc.Tags = tags 124 } 125 case "location": 126 if v != nil { 127 var location string 128 err = json.Unmarshal(*v, &location) 129 if err != nil { 130 return err 131 } 132 cc.Location = &location 133 } 134 case "id": 135 if v != nil { 136 var ID string 137 err = json.Unmarshal(*v, &ID) 138 if err != nil { 139 return err 140 } 141 cc.ID = &ID 142 } 143 case "name": 144 if v != nil { 145 var name string 146 err = json.Unmarshal(*v, &name) 147 if err != nil { 148 return err 149 } 150 cc.Name = &name 151 } 152 case "type": 153 if v != nil { 154 var typeVar string 155 err = json.Unmarshal(*v, &typeVar) 156 if err != nil { 157 return err 158 } 159 cc.Type = &typeVar 160 } 161 } 162 } 163 164 return nil 165} 166 167// ConnectedClusterCreateFuture an abstraction for monitoring and retrieving the results of a long-running 168// operation. 169type ConnectedClusterCreateFuture struct { 170 azure.FutureAPI 171 // Result returns the result of the asynchronous operation. 172 // If the operation has not completed it will return an error. 173 Result func(ConnectedClusterClient) (ConnectedCluster, error) 174} 175 176// UnmarshalJSON is the custom unmarshaller for CreateFuture. 177func (future *ConnectedClusterCreateFuture) UnmarshalJSON(body []byte) error { 178 var azFuture azure.Future 179 if err := json.Unmarshal(body, &azFuture); err != nil { 180 return err 181 } 182 future.FutureAPI = &azFuture 183 future.Result = future.result 184 return nil 185} 186 187// result is the default implementation for ConnectedClusterCreateFuture.Result. 188func (future *ConnectedClusterCreateFuture) result(client ConnectedClusterClient) (cc ConnectedCluster, err error) { 189 var done bool 190 done, err = future.DoneWithContext(context.Background(), client) 191 if err != nil { 192 err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterCreateFuture", "Result", future.Response(), "Polling failure") 193 return 194 } 195 if !done { 196 cc.Response.Response = future.Response() 197 err = azure.NewAsyncOpIncompleteError("hybridkubernetes.ConnectedClusterCreateFuture") 198 return 199 } 200 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 201 if cc.Response.Response, err = future.GetResult(sender); err == nil && cc.Response.Response.StatusCode != http.StatusNoContent { 202 cc, err = client.CreateResponder(cc.Response.Response) 203 if err != nil { 204 err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterCreateFuture", "Result", cc.Response.Response, "Failure responding to request") 205 } 206 } 207 return 208} 209 210// ConnectedClusterDeleteFuture an abstraction for monitoring and retrieving the results of a long-running 211// operation. 212type ConnectedClusterDeleteFuture struct { 213 azure.FutureAPI 214 // Result returns the result of the asynchronous operation. 215 // If the operation has not completed it will return an error. 216 Result func(ConnectedClusterClient) (autorest.Response, error) 217} 218 219// UnmarshalJSON is the custom unmarshaller for CreateFuture. 220func (future *ConnectedClusterDeleteFuture) UnmarshalJSON(body []byte) error { 221 var azFuture azure.Future 222 if err := json.Unmarshal(body, &azFuture); err != nil { 223 return err 224 } 225 future.FutureAPI = &azFuture 226 future.Result = future.result 227 return nil 228} 229 230// result is the default implementation for ConnectedClusterDeleteFuture.Result. 231func (future *ConnectedClusterDeleteFuture) result(client ConnectedClusterClient) (ar autorest.Response, err error) { 232 var done bool 233 done, err = future.DoneWithContext(context.Background(), client) 234 if err != nil { 235 err = autorest.NewErrorWithError(err, "hybridkubernetes.ConnectedClusterDeleteFuture", "Result", future.Response(), "Polling failure") 236 return 237 } 238 if !done { 239 ar.Response = future.Response() 240 err = azure.NewAsyncOpIncompleteError("hybridkubernetes.ConnectedClusterDeleteFuture") 241 return 242 } 243 ar.Response = future.Response() 244 return 245} 246 247// ConnectedClusterIdentity identity for the connected cluster. 248type ConnectedClusterIdentity struct { 249 // PrincipalID - READ-ONLY; The principal id of connected cluster identity. This property will only be provided for a system assigned identity. 250 PrincipalID *string `json:"principalId,omitempty"` 251 // TenantID - READ-ONLY; The tenant id associated with the connected cluster. This property will only be provided for a system assigned identity. 252 TenantID *string `json:"tenantId,omitempty"` 253 // Type - The type of identity used for the connected cluster. The type 'SystemAssigned, includes a system created identity. The type 'None' means no identity is assigned to the connected cluster. Possible values include: 'None', 'SystemAssigned' 254 Type ResourceIdentityType `json:"type,omitempty"` 255} 256 257// MarshalJSON is the custom marshaler for ConnectedClusterIdentity. 258func (cci ConnectedClusterIdentity) MarshalJSON() ([]byte, error) { 259 objectMap := make(map[string]interface{}) 260 if cci.Type != "" { 261 objectMap["type"] = cci.Type 262 } 263 return json.Marshal(objectMap) 264} 265 266// ConnectedClusterList the paginated list of connected Clusters 267type ConnectedClusterList struct { 268 autorest.Response `json:"-"` 269 // Value - The list of connected clusters 270 Value *[]ConnectedCluster `json:"value,omitempty"` 271 // NextLink - The link to fetch the next page of connected cluster 272 NextLink *string `json:"nextLink,omitempty"` 273} 274 275// ConnectedClusterListIterator provides access to a complete listing of ConnectedCluster values. 276type ConnectedClusterListIterator struct { 277 i int 278 page ConnectedClusterListPage 279} 280 281// NextWithContext advances to the next value. If there was an error making 282// the request the iterator does not advance and the error is returned. 283func (iter *ConnectedClusterListIterator) NextWithContext(ctx context.Context) (err error) { 284 if tracing.IsEnabled() { 285 ctx = tracing.StartSpan(ctx, fqdn+"/ConnectedClusterListIterator.NextWithContext") 286 defer func() { 287 sc := -1 288 if iter.Response().Response.Response != nil { 289 sc = iter.Response().Response.Response.StatusCode 290 } 291 tracing.EndSpan(ctx, sc, err) 292 }() 293 } 294 iter.i++ 295 if iter.i < len(iter.page.Values()) { 296 return nil 297 } 298 err = iter.page.NextWithContext(ctx) 299 if err != nil { 300 iter.i-- 301 return err 302 } 303 iter.i = 0 304 return nil 305} 306 307// Next advances to the next value. If there was an error making 308// the request the iterator does not advance and the error is returned. 309// Deprecated: Use NextWithContext() instead. 310func (iter *ConnectedClusterListIterator) Next() error { 311 return iter.NextWithContext(context.Background()) 312} 313 314// NotDone returns true if the enumeration should be started or is not yet complete. 315func (iter ConnectedClusterListIterator) NotDone() bool { 316 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 317} 318 319// Response returns the raw server response from the last page request. 320func (iter ConnectedClusterListIterator) Response() ConnectedClusterList { 321 return iter.page.Response() 322} 323 324// Value returns the current value or a zero-initialized value if the 325// iterator has advanced beyond the end of the collection. 326func (iter ConnectedClusterListIterator) Value() ConnectedCluster { 327 if !iter.page.NotDone() { 328 return ConnectedCluster{} 329 } 330 return iter.page.Values()[iter.i] 331} 332 333// Creates a new instance of the ConnectedClusterListIterator type. 334func NewConnectedClusterListIterator(page ConnectedClusterListPage) ConnectedClusterListIterator { 335 return ConnectedClusterListIterator{page: page} 336} 337 338// IsEmpty returns true if the ListResult contains no values. 339func (ccl ConnectedClusterList) IsEmpty() bool { 340 return ccl.Value == nil || len(*ccl.Value) == 0 341} 342 343// hasNextLink returns true if the NextLink is not empty. 344func (ccl ConnectedClusterList) hasNextLink() bool { 345 return ccl.NextLink != nil && len(*ccl.NextLink) != 0 346} 347 348// connectedClusterListPreparer prepares a request to retrieve the next set of results. 349// It returns nil if no more results exist. 350func (ccl ConnectedClusterList) connectedClusterListPreparer(ctx context.Context) (*http.Request, error) { 351 if !ccl.hasNextLink() { 352 return nil, nil 353 } 354 return autorest.Prepare((&http.Request{}).WithContext(ctx), 355 autorest.AsJSON(), 356 autorest.AsGet(), 357 autorest.WithBaseURL(to.String(ccl.NextLink))) 358} 359 360// ConnectedClusterListPage contains a page of ConnectedCluster values. 361type ConnectedClusterListPage struct { 362 fn func(context.Context, ConnectedClusterList) (ConnectedClusterList, error) 363 ccl ConnectedClusterList 364} 365 366// NextWithContext advances to the next page of values. If there was an error making 367// the request the page does not advance and the error is returned. 368func (page *ConnectedClusterListPage) NextWithContext(ctx context.Context) (err error) { 369 if tracing.IsEnabled() { 370 ctx = tracing.StartSpan(ctx, fqdn+"/ConnectedClusterListPage.NextWithContext") 371 defer func() { 372 sc := -1 373 if page.Response().Response.Response != nil { 374 sc = page.Response().Response.Response.StatusCode 375 } 376 tracing.EndSpan(ctx, sc, err) 377 }() 378 } 379 for { 380 next, err := page.fn(ctx, page.ccl) 381 if err != nil { 382 return err 383 } 384 page.ccl = next 385 if !next.hasNextLink() || !next.IsEmpty() { 386 break 387 } 388 } 389 return nil 390} 391 392// Next advances to the next page of values. If there was an error making 393// the request the page does not advance and the error is returned. 394// Deprecated: Use NextWithContext() instead. 395func (page *ConnectedClusterListPage) Next() error { 396 return page.NextWithContext(context.Background()) 397} 398 399// NotDone returns true if the page enumeration should be started or is not yet complete. 400func (page ConnectedClusterListPage) NotDone() bool { 401 return !page.ccl.IsEmpty() 402} 403 404// Response returns the raw server response from the last page request. 405func (page ConnectedClusterListPage) Response() ConnectedClusterList { 406 return page.ccl 407} 408 409// Values returns the slice of values for the current page or nil if there are no values. 410func (page ConnectedClusterListPage) Values() []ConnectedCluster { 411 if page.ccl.IsEmpty() { 412 return nil 413 } 414 return *page.ccl.Value 415} 416 417// Creates a new instance of the ConnectedClusterListPage type. 418func NewConnectedClusterListPage(cur ConnectedClusterList, getNextPage func(context.Context, ConnectedClusterList) (ConnectedClusterList, error)) ConnectedClusterListPage { 419 return ConnectedClusterListPage{ 420 fn: getNextPage, 421 ccl: cur, 422 } 423} 424 425// ConnectedClusterPatch object containing updates for patch operations. 426type ConnectedClusterPatch struct { 427 // Tags - Resource tags. 428 Tags map[string]*string `json:"tags"` 429 // Properties - Describes the connected cluster resource properties that can be updated during PATCH operation. 430 Properties interface{} `json:"properties,omitempty"` 431} 432 433// MarshalJSON is the custom marshaler for ConnectedClusterPatch. 434func (ccp ConnectedClusterPatch) MarshalJSON() ([]byte, error) { 435 objectMap := make(map[string]interface{}) 436 if ccp.Tags != nil { 437 objectMap["tags"] = ccp.Tags 438 } 439 if ccp.Properties != nil { 440 objectMap["properties"] = ccp.Properties 441 } 442 return json.Marshal(objectMap) 443} 444 445// ConnectedClusterProperties properties of the connected cluster. 446type ConnectedClusterProperties struct { 447 // AgentPublicKeyCertificate - Base64 encoded public certificate used by the agent to do the initial handshake to the backend services in Azure. 448 AgentPublicKeyCertificate *string `json:"agentPublicKeyCertificate,omitempty"` 449 // KubernetesVersion - READ-ONLY; The Kubernetes version of the connected cluster resource 450 KubernetesVersion *string `json:"kubernetesVersion,omitempty"` 451 // TotalNodeCount - READ-ONLY; Number of nodes present in the connected cluster resource 452 TotalNodeCount *int32 `json:"totalNodeCount,omitempty"` 453 // TotalCoreCount - READ-ONLY; Number of CPU cores present in the connected cluster resource 454 TotalCoreCount *int32 `json:"totalCoreCount,omitempty"` 455 // AgentVersion - READ-ONLY; Version of the agent running on the connected cluster resource 456 AgentVersion *string `json:"agentVersion,omitempty"` 457 // ProvisioningState - Provisioning state of the connected cluster resource. Possible values include: 'Succeeded', 'Failed', 'Canceled', 'Provisioning', 'Updating', 'Deleting', 'Accepted' 458 ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` 459 // Distribution - The Kubernetes distribution running on this connected cluster. 460 Distribution *string `json:"distribution,omitempty"` 461 // Infrastructure - The infrastructure on which the Kubernetes cluster represented by this connected cluster is running on. 462 Infrastructure *string `json:"infrastructure,omitempty"` 463 // Offering - READ-ONLY; Connected cluster offering 464 Offering *string `json:"offering,omitempty"` 465 // ManagedIdentityCertificateExpirationTime - READ-ONLY; Expiration time of the managed identity certificate 466 ManagedIdentityCertificateExpirationTime *date.Time `json:"managedIdentityCertificateExpirationTime,omitempty"` 467 // LastConnectivityTime - READ-ONLY; Time representing the last instance when heart beat was received from the cluster 468 LastConnectivityTime *date.Time `json:"lastConnectivityTime,omitempty"` 469 // ConnectivityStatus - READ-ONLY; Represents the connectivity status of the connected cluster. Possible values include: 'Connecting', 'Connected', 'Offline', 'Expired' 470 ConnectivityStatus ConnectivityStatus `json:"connectivityStatus,omitempty"` 471} 472 473// MarshalJSON is the custom marshaler for ConnectedClusterProperties. 474func (ccp ConnectedClusterProperties) MarshalJSON() ([]byte, error) { 475 objectMap := make(map[string]interface{}) 476 if ccp.AgentPublicKeyCertificate != nil { 477 objectMap["agentPublicKeyCertificate"] = ccp.AgentPublicKeyCertificate 478 } 479 if ccp.ProvisioningState != "" { 480 objectMap["provisioningState"] = ccp.ProvisioningState 481 } 482 if ccp.Distribution != nil { 483 objectMap["distribution"] = ccp.Distribution 484 } 485 if ccp.Infrastructure != nil { 486 objectMap["infrastructure"] = ccp.Infrastructure 487 } 488 return json.Marshal(objectMap) 489} 490 491// ErrorAdditionalInfo the resource management error additional info. 492type ErrorAdditionalInfo struct { 493 // Type - READ-ONLY; The additional info type. 494 Type *string `json:"type,omitempty"` 495 // Info - READ-ONLY; The additional info. 496 Info interface{} `json:"info,omitempty"` 497} 498 499// MarshalJSON is the custom marshaler for ErrorAdditionalInfo. 500func (eai ErrorAdditionalInfo) MarshalJSON() ([]byte, error) { 501 objectMap := make(map[string]interface{}) 502 return json.Marshal(objectMap) 503} 504 505// ErrorDetail the error detail. 506type ErrorDetail struct { 507 // Code - READ-ONLY; The error code. 508 Code *string `json:"code,omitempty"` 509 // Message - READ-ONLY; The error message. 510 Message *string `json:"message,omitempty"` 511 // Target - READ-ONLY; The error target. 512 Target *string `json:"target,omitempty"` 513 // Details - READ-ONLY; The error details. 514 Details *[]ErrorDetail `json:"details,omitempty"` 515 // AdditionalInfo - READ-ONLY; The error additional info. 516 AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` 517} 518 519// MarshalJSON is the custom marshaler for ErrorDetail. 520func (ed ErrorDetail) MarshalJSON() ([]byte, error) { 521 objectMap := make(map[string]interface{}) 522 return json.Marshal(objectMap) 523} 524 525// ErrorResponse common error response for all Azure Resource Manager APIs to return error details for 526// failed operations. (This also follows the OData error response format.). 527type ErrorResponse struct { 528 // Error - The error object. 529 Error *ErrorDetail `json:"error,omitempty"` 530} 531 532// Operation the Connected cluster API operation 533type Operation struct { 534 // Name - READ-ONLY; Operation name: {Microsoft.Kubernetes}/{resource}/{operation} 535 Name *string `json:"name,omitempty"` 536 // Display - READ-ONLY; The object that represents the operation. 537 Display *OperationDisplay `json:"display,omitempty"` 538} 539 540// MarshalJSON is the custom marshaler for Operation. 541func (o Operation) MarshalJSON() ([]byte, error) { 542 objectMap := make(map[string]interface{}) 543 return json.Marshal(objectMap) 544} 545 546// OperationDisplay the object that represents the operation. 547type OperationDisplay struct { 548 // Provider - Service provider: Microsoft.connectedClusters 549 Provider *string `json:"provider,omitempty"` 550 // Resource - Connected Cluster Resource on which the operation is performed 551 Resource *string `json:"resource,omitempty"` 552 // Operation - Operation type: Read, write, delete, etc. 553 Operation *string `json:"operation,omitempty"` 554 // Description - Description of the operation. 555 Description *string `json:"description,omitempty"` 556} 557 558// OperationList the paginated list of connected cluster API operations. 559type OperationList struct { 560 autorest.Response `json:"-"` 561 // Value - READ-ONLY; The list of connected cluster API operations. 562 Value *[]Operation `json:"value,omitempty"` 563 // NextLink - The link to fetch the next page of connected cluster API operations. 564 NextLink *string `json:"nextLink,omitempty"` 565} 566 567// MarshalJSON is the custom marshaler for OperationList. 568func (ol OperationList) MarshalJSON() ([]byte, error) { 569 objectMap := make(map[string]interface{}) 570 if ol.NextLink != nil { 571 objectMap["nextLink"] = ol.NextLink 572 } 573 return json.Marshal(objectMap) 574} 575 576// OperationListIterator provides access to a complete listing of Operation values. 577type OperationListIterator struct { 578 i int 579 page OperationListPage 580} 581 582// NextWithContext advances to the next value. If there was an error making 583// the request the iterator does not advance and the error is returned. 584func (iter *OperationListIterator) NextWithContext(ctx context.Context) (err error) { 585 if tracing.IsEnabled() { 586 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListIterator.NextWithContext") 587 defer func() { 588 sc := -1 589 if iter.Response().Response.Response != nil { 590 sc = iter.Response().Response.Response.StatusCode 591 } 592 tracing.EndSpan(ctx, sc, err) 593 }() 594 } 595 iter.i++ 596 if iter.i < len(iter.page.Values()) { 597 return nil 598 } 599 err = iter.page.NextWithContext(ctx) 600 if err != nil { 601 iter.i-- 602 return err 603 } 604 iter.i = 0 605 return nil 606} 607 608// Next advances to the next value. If there was an error making 609// the request the iterator does not advance and the error is returned. 610// Deprecated: Use NextWithContext() instead. 611func (iter *OperationListIterator) Next() error { 612 return iter.NextWithContext(context.Background()) 613} 614 615// NotDone returns true if the enumeration should be started or is not yet complete. 616func (iter OperationListIterator) NotDone() bool { 617 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 618} 619 620// Response returns the raw server response from the last page request. 621func (iter OperationListIterator) Response() OperationList { 622 return iter.page.Response() 623} 624 625// Value returns the current value or a zero-initialized value if the 626// iterator has advanced beyond the end of the collection. 627func (iter OperationListIterator) Value() Operation { 628 if !iter.page.NotDone() { 629 return Operation{} 630 } 631 return iter.page.Values()[iter.i] 632} 633 634// Creates a new instance of the OperationListIterator type. 635func NewOperationListIterator(page OperationListPage) OperationListIterator { 636 return OperationListIterator{page: page} 637} 638 639// IsEmpty returns true if the ListResult contains no values. 640func (ol OperationList) IsEmpty() bool { 641 return ol.Value == nil || len(*ol.Value) == 0 642} 643 644// hasNextLink returns true if the NextLink is not empty. 645func (ol OperationList) hasNextLink() bool { 646 return ol.NextLink != nil && len(*ol.NextLink) != 0 647} 648 649// operationListPreparer prepares a request to retrieve the next set of results. 650// It returns nil if no more results exist. 651func (ol OperationList) operationListPreparer(ctx context.Context) (*http.Request, error) { 652 if !ol.hasNextLink() { 653 return nil, nil 654 } 655 return autorest.Prepare((&http.Request{}).WithContext(ctx), 656 autorest.AsJSON(), 657 autorest.AsGet(), 658 autorest.WithBaseURL(to.String(ol.NextLink))) 659} 660 661// OperationListPage contains a page of Operation values. 662type OperationListPage struct { 663 fn func(context.Context, OperationList) (OperationList, error) 664 ol OperationList 665} 666 667// NextWithContext advances to the next page of values. If there was an error making 668// the request the page does not advance and the error is returned. 669func (page *OperationListPage) NextWithContext(ctx context.Context) (err error) { 670 if tracing.IsEnabled() { 671 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListPage.NextWithContext") 672 defer func() { 673 sc := -1 674 if page.Response().Response.Response != nil { 675 sc = page.Response().Response.Response.StatusCode 676 } 677 tracing.EndSpan(ctx, sc, err) 678 }() 679 } 680 for { 681 next, err := page.fn(ctx, page.ol) 682 if err != nil { 683 return err 684 } 685 page.ol = next 686 if !next.hasNextLink() || !next.IsEmpty() { 687 break 688 } 689 } 690 return nil 691} 692 693// Next advances to the next page of values. If there was an error making 694// the request the page does not advance and the error is returned. 695// Deprecated: Use NextWithContext() instead. 696func (page *OperationListPage) Next() error { 697 return page.NextWithContext(context.Background()) 698} 699 700// NotDone returns true if the page enumeration should be started or is not yet complete. 701func (page OperationListPage) NotDone() bool { 702 return !page.ol.IsEmpty() 703} 704 705// Response returns the raw server response from the last page request. 706func (page OperationListPage) Response() OperationList { 707 return page.ol 708} 709 710// Values returns the slice of values for the current page or nil if there are no values. 711func (page OperationListPage) Values() []Operation { 712 if page.ol.IsEmpty() { 713 return nil 714 } 715 return *page.ol.Value 716} 717 718// Creates a new instance of the OperationListPage type. 719func NewOperationListPage(cur OperationList, getNextPage func(context.Context, OperationList) (OperationList, error)) OperationListPage { 720 return OperationListPage{ 721 fn: getNextPage, 722 ol: cur, 723 } 724} 725 726// ProxyResource the resource model definition for a Azure Resource Manager proxy resource. It will not 727// have tags and a location 728type ProxyResource struct { 729 // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} 730 ID *string `json:"id,omitempty"` 731 // Name - READ-ONLY; The name of the resource 732 Name *string `json:"name,omitempty"` 733 // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" 734 Type *string `json:"type,omitempty"` 735} 736 737// MarshalJSON is the custom marshaler for ProxyResource. 738func (pr ProxyResource) MarshalJSON() ([]byte, error) { 739 objectMap := make(map[string]interface{}) 740 return json.Marshal(objectMap) 741} 742 743// Resource common fields that are returned in the response for all Azure Resource Manager resources 744type Resource struct { 745 // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} 746 ID *string `json:"id,omitempty"` 747 // Name - READ-ONLY; The name of the resource 748 Name *string `json:"name,omitempty"` 749 // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" 750 Type *string `json:"type,omitempty"` 751} 752 753// MarshalJSON is the custom marshaler for Resource. 754func (r Resource) MarshalJSON() ([]byte, error) { 755 objectMap := make(map[string]interface{}) 756 return json.Marshal(objectMap) 757} 758 759// SystemData metadata pertaining to creation and last modification of the resource. 760type SystemData struct { 761 // CreatedBy - The identity that created the resource. 762 CreatedBy *string `json:"createdBy,omitempty"` 763 // CreatedByType - The type of identity that created the resource. Possible values include: 'User', 'Application', 'ManagedIdentity', 'Key' 764 CreatedByType CreatedByType `json:"createdByType,omitempty"` 765 // CreatedAt - The timestamp of resource creation (UTC). 766 CreatedAt *date.Time `json:"createdAt,omitempty"` 767 // LastModifiedBy - The identity that last modified the resource. 768 LastModifiedBy *string `json:"lastModifiedBy,omitempty"` 769 // LastModifiedByType - The type of identity that last modified the resource. Possible values include: 'LastModifiedByTypeUser', 'LastModifiedByTypeApplication', 'LastModifiedByTypeManagedIdentity', 'LastModifiedByTypeKey' 770 LastModifiedByType LastModifiedByType `json:"lastModifiedByType,omitempty"` 771 // LastModifiedAt - The timestamp of resource modification (UTC). 772 LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"` 773} 774 775// TrackedResource the resource model definition for an Azure Resource Manager tracked top level resource 776// which has 'tags' and a 'location' 777type TrackedResource struct { 778 // Tags - Resource tags. 779 Tags map[string]*string `json:"tags"` 780 // Location - The geo-location where the resource lives 781 Location *string `json:"location,omitempty"` 782 // ID - READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} 783 ID *string `json:"id,omitempty"` 784 // Name - READ-ONLY; The name of the resource 785 Name *string `json:"name,omitempty"` 786 // Type - READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" 787 Type *string `json:"type,omitempty"` 788} 789 790// MarshalJSON is the custom marshaler for TrackedResource. 791func (tr TrackedResource) MarshalJSON() ([]byte, error) { 792 objectMap := make(map[string]interface{}) 793 if tr.Tags != nil { 794 objectMap["tags"] = tr.Tags 795 } 796 if tr.Location != nil { 797 objectMap["location"] = tr.Location 798 } 799 return json.Marshal(objectMap) 800} 801