1package containerregistry 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/containerregistry/mgmt/2017-10-01/containerregistry" 33 34// Action enumerates the values for action. 35type Action string 36 37const ( 38 // Allow ... 39 Allow Action = "Allow" 40) 41 42// PossibleActionValues returns an array of possible values for the Action const type. 43func PossibleActionValues() []Action { 44 return []Action{Allow} 45} 46 47// DefaultAction enumerates the values for default action. 48type DefaultAction string 49 50const ( 51 // DefaultActionAllow ... 52 DefaultActionAllow DefaultAction = "Allow" 53 // DefaultActionDeny ... 54 DefaultActionDeny DefaultAction = "Deny" 55) 56 57// PossibleDefaultActionValues returns an array of possible values for the DefaultAction const type. 58func PossibleDefaultActionValues() []DefaultAction { 59 return []DefaultAction{DefaultActionAllow, DefaultActionDeny} 60} 61 62// ImportMode enumerates the values for import mode. 63type ImportMode string 64 65const ( 66 // Force ... 67 Force ImportMode = "Force" 68 // NoForce ... 69 NoForce ImportMode = "NoForce" 70) 71 72// PossibleImportModeValues returns an array of possible values for the ImportMode const type. 73func PossibleImportModeValues() []ImportMode { 74 return []ImportMode{Force, NoForce} 75} 76 77// PasswordName enumerates the values for password name. 78type PasswordName string 79 80const ( 81 // Password ... 82 Password PasswordName = "password" 83 // Password2 ... 84 Password2 PasswordName = "password2" 85) 86 87// PossiblePasswordNameValues returns an array of possible values for the PasswordName const type. 88func PossiblePasswordNameValues() []PasswordName { 89 return []PasswordName{Password, Password2} 90} 91 92// PolicyStatus enumerates the values for policy status. 93type PolicyStatus string 94 95const ( 96 // Disabled ... 97 Disabled PolicyStatus = "disabled" 98 // Enabled ... 99 Enabled PolicyStatus = "enabled" 100) 101 102// PossiblePolicyStatusValues returns an array of possible values for the PolicyStatus const type. 103func PossiblePolicyStatusValues() []PolicyStatus { 104 return []PolicyStatus{Disabled, Enabled} 105} 106 107// ProvisioningState enumerates the values for provisioning state. 108type ProvisioningState string 109 110const ( 111 // Canceled ... 112 Canceled ProvisioningState = "Canceled" 113 // Creating ... 114 Creating ProvisioningState = "Creating" 115 // Deleting ... 116 Deleting ProvisioningState = "Deleting" 117 // Failed ... 118 Failed ProvisioningState = "Failed" 119 // Succeeded ... 120 Succeeded ProvisioningState = "Succeeded" 121 // Updating ... 122 Updating ProvisioningState = "Updating" 123) 124 125// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. 126func PossibleProvisioningStateValues() []ProvisioningState { 127 return []ProvisioningState{Canceled, Creating, Deleting, Failed, Succeeded, Updating} 128} 129 130// RegistryUsageUnit enumerates the values for registry usage unit. 131type RegistryUsageUnit string 132 133const ( 134 // Bytes ... 135 Bytes RegistryUsageUnit = "Bytes" 136 // Count ... 137 Count RegistryUsageUnit = "Count" 138) 139 140// PossibleRegistryUsageUnitValues returns an array of possible values for the RegistryUsageUnit const type. 141func PossibleRegistryUsageUnitValues() []RegistryUsageUnit { 142 return []RegistryUsageUnit{Bytes, Count} 143} 144 145// SkuName enumerates the values for sku name. 146type SkuName string 147 148const ( 149 // Basic ... 150 Basic SkuName = "Basic" 151 // Classic ... 152 Classic SkuName = "Classic" 153 // Premium ... 154 Premium SkuName = "Premium" 155 // Standard ... 156 Standard SkuName = "Standard" 157) 158 159// PossibleSkuNameValues returns an array of possible values for the SkuName const type. 160func PossibleSkuNameValues() []SkuName { 161 return []SkuName{Basic, Classic, Premium, Standard} 162} 163 164// SkuTier enumerates the values for sku tier. 165type SkuTier string 166 167const ( 168 // SkuTierBasic ... 169 SkuTierBasic SkuTier = "Basic" 170 // SkuTierClassic ... 171 SkuTierClassic SkuTier = "Classic" 172 // SkuTierPremium ... 173 SkuTierPremium SkuTier = "Premium" 174 // SkuTierStandard ... 175 SkuTierStandard SkuTier = "Standard" 176) 177 178// PossibleSkuTierValues returns an array of possible values for the SkuTier const type. 179func PossibleSkuTierValues() []SkuTier { 180 return []SkuTier{SkuTierBasic, SkuTierClassic, SkuTierPremium, SkuTierStandard} 181} 182 183// TrustPolicyType enumerates the values for trust policy type. 184type TrustPolicyType string 185 186const ( 187 // Notary ... 188 Notary TrustPolicyType = "Notary" 189) 190 191// PossibleTrustPolicyTypeValues returns an array of possible values for the TrustPolicyType const type. 192func PossibleTrustPolicyTypeValues() []TrustPolicyType { 193 return []TrustPolicyType{Notary} 194} 195 196// WebhookAction enumerates the values for webhook action. 197type WebhookAction string 198 199const ( 200 // ChartDelete ... 201 ChartDelete WebhookAction = "chart_delete" 202 // ChartPush ... 203 ChartPush WebhookAction = "chart_push" 204 // Delete ... 205 Delete WebhookAction = "delete" 206 // Push ... 207 Push WebhookAction = "push" 208 // Quarantine ... 209 Quarantine WebhookAction = "quarantine" 210) 211 212// PossibleWebhookActionValues returns an array of possible values for the WebhookAction const type. 213func PossibleWebhookActionValues() []WebhookAction { 214 return []WebhookAction{ChartDelete, ChartPush, Delete, Push, Quarantine} 215} 216 217// WebhookStatus enumerates the values for webhook status. 218type WebhookStatus string 219 220const ( 221 // WebhookStatusDisabled ... 222 WebhookStatusDisabled WebhookStatus = "disabled" 223 // WebhookStatusEnabled ... 224 WebhookStatusEnabled WebhookStatus = "enabled" 225) 226 227// PossibleWebhookStatusValues returns an array of possible values for the WebhookStatus const type. 228func PossibleWebhookStatusValues() []WebhookStatus { 229 return []WebhookStatus{WebhookStatusDisabled, WebhookStatusEnabled} 230} 231 232// Actor the agent that initiated the event. For most situations, this could be from the authorization 233// context of the request. 234type Actor struct { 235 // Name - The subject or username associated with the request context that generated the event. 236 Name *string `json:"name,omitempty"` 237} 238 239// CallbackConfig the configuration of service URI and custom headers for the webhook. 240type CallbackConfig struct { 241 autorest.Response `json:"-"` 242 // ServiceURI - The service URI for the webhook to post notifications. 243 ServiceURI *string `json:"serviceUri,omitempty"` 244 // CustomHeaders - Custom headers that will be added to the webhook notifications. 245 CustomHeaders map[string]*string `json:"customHeaders"` 246} 247 248// MarshalJSON is the custom marshaler for CallbackConfig. 249func (cc CallbackConfig) MarshalJSON() ([]byte, error) { 250 objectMap := make(map[string]interface{}) 251 if cc.ServiceURI != nil { 252 objectMap["serviceUri"] = cc.ServiceURI 253 } 254 if cc.CustomHeaders != nil { 255 objectMap["customHeaders"] = cc.CustomHeaders 256 } 257 return json.Marshal(objectMap) 258} 259 260// Event the event for a webhook. 261type Event struct { 262 // EventRequestMessage - The event request message sent to the service URI. 263 EventRequestMessage *EventRequestMessage `json:"eventRequestMessage,omitempty"` 264 // EventResponseMessage - The event response message received from the service URI. 265 EventResponseMessage *EventResponseMessage `json:"eventResponseMessage,omitempty"` 266 // ID - The event ID. 267 ID *string `json:"id,omitempty"` 268} 269 270// EventContent the content of the event request message. 271type EventContent struct { 272 // ID - The event ID. 273 ID *string `json:"id,omitempty"` 274 // Timestamp - The time at which the event occurred. 275 Timestamp *date.Time `json:"timestamp,omitempty"` 276 // Action - The action that encompasses the provided event. 277 Action *string `json:"action,omitempty"` 278 // Target - The target of the event. 279 Target *Target `json:"target,omitempty"` 280 // Request - The request that generated the event. 281 Request *Request `json:"request,omitempty"` 282 // Actor - The agent that initiated the event. For most situations, this could be from the authorization context of the request. 283 Actor *Actor `json:"actor,omitempty"` 284 // Source - The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. 285 Source *Source `json:"source,omitempty"` 286} 287 288// EventInfo the basic information of an event. 289type EventInfo struct { 290 autorest.Response `json:"-"` 291 // ID - The event ID. 292 ID *string `json:"id,omitempty"` 293} 294 295// EventListResult the result of a request to list events for a webhook. 296type EventListResult struct { 297 autorest.Response `json:"-"` 298 // Value - The list of events. Since this list may be incomplete, the nextLink field should be used to request the next list of events. 299 Value *[]Event `json:"value,omitempty"` 300 // NextLink - The URI that can be used to request the next list of events. 301 NextLink *string `json:"nextLink,omitempty"` 302} 303 304// EventListResultIterator provides access to a complete listing of Event values. 305type EventListResultIterator struct { 306 i int 307 page EventListResultPage 308} 309 310// NextWithContext advances to the next value. If there was an error making 311// the request the iterator does not advance and the error is returned. 312func (iter *EventListResultIterator) NextWithContext(ctx context.Context) (err error) { 313 if tracing.IsEnabled() { 314 ctx = tracing.StartSpan(ctx, fqdn+"/EventListResultIterator.NextWithContext") 315 defer func() { 316 sc := -1 317 if iter.Response().Response.Response != nil { 318 sc = iter.Response().Response.Response.StatusCode 319 } 320 tracing.EndSpan(ctx, sc, err) 321 }() 322 } 323 iter.i++ 324 if iter.i < len(iter.page.Values()) { 325 return nil 326 } 327 err = iter.page.NextWithContext(ctx) 328 if err != nil { 329 iter.i-- 330 return err 331 } 332 iter.i = 0 333 return nil 334} 335 336// Next advances to the next value. If there was an error making 337// the request the iterator does not advance and the error is returned. 338// Deprecated: Use NextWithContext() instead. 339func (iter *EventListResultIterator) Next() error { 340 return iter.NextWithContext(context.Background()) 341} 342 343// NotDone returns true if the enumeration should be started or is not yet complete. 344func (iter EventListResultIterator) NotDone() bool { 345 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 346} 347 348// Response returns the raw server response from the last page request. 349func (iter EventListResultIterator) Response() EventListResult { 350 return iter.page.Response() 351} 352 353// Value returns the current value or a zero-initialized value if the 354// iterator has advanced beyond the end of the collection. 355func (iter EventListResultIterator) Value() Event { 356 if !iter.page.NotDone() { 357 return Event{} 358 } 359 return iter.page.Values()[iter.i] 360} 361 362// Creates a new instance of the EventListResultIterator type. 363func NewEventListResultIterator(page EventListResultPage) EventListResultIterator { 364 return EventListResultIterator{page: page} 365} 366 367// IsEmpty returns true if the ListResult contains no values. 368func (elr EventListResult) IsEmpty() bool { 369 return elr.Value == nil || len(*elr.Value) == 0 370} 371 372// eventListResultPreparer prepares a request to retrieve the next set of results. 373// It returns nil if no more results exist. 374func (elr EventListResult) eventListResultPreparer(ctx context.Context) (*http.Request, error) { 375 if elr.NextLink == nil || len(to.String(elr.NextLink)) < 1 { 376 return nil, nil 377 } 378 return autorest.Prepare((&http.Request{}).WithContext(ctx), 379 autorest.AsJSON(), 380 autorest.AsGet(), 381 autorest.WithBaseURL(to.String(elr.NextLink))) 382} 383 384// EventListResultPage contains a page of Event values. 385type EventListResultPage struct { 386 fn func(context.Context, EventListResult) (EventListResult, error) 387 elr EventListResult 388} 389 390// NextWithContext advances to the next page of values. If there was an error making 391// the request the page does not advance and the error is returned. 392func (page *EventListResultPage) NextWithContext(ctx context.Context) (err error) { 393 if tracing.IsEnabled() { 394 ctx = tracing.StartSpan(ctx, fqdn+"/EventListResultPage.NextWithContext") 395 defer func() { 396 sc := -1 397 if page.Response().Response.Response != nil { 398 sc = page.Response().Response.Response.StatusCode 399 } 400 tracing.EndSpan(ctx, sc, err) 401 }() 402 } 403 next, err := page.fn(ctx, page.elr) 404 if err != nil { 405 return err 406 } 407 page.elr = next 408 return nil 409} 410 411// Next advances to the next page of values. If there was an error making 412// the request the page does not advance and the error is returned. 413// Deprecated: Use NextWithContext() instead. 414func (page *EventListResultPage) Next() error { 415 return page.NextWithContext(context.Background()) 416} 417 418// NotDone returns true if the page enumeration should be started or is not yet complete. 419func (page EventListResultPage) NotDone() bool { 420 return !page.elr.IsEmpty() 421} 422 423// Response returns the raw server response from the last page request. 424func (page EventListResultPage) Response() EventListResult { 425 return page.elr 426} 427 428// Values returns the slice of values for the current page or nil if there are no values. 429func (page EventListResultPage) Values() []Event { 430 if page.elr.IsEmpty() { 431 return nil 432 } 433 return *page.elr.Value 434} 435 436// Creates a new instance of the EventListResultPage type. 437func NewEventListResultPage(getNextPage func(context.Context, EventListResult) (EventListResult, error)) EventListResultPage { 438 return EventListResultPage{fn: getNextPage} 439} 440 441// EventRequestMessage the event request message sent to the service URI. 442type EventRequestMessage struct { 443 // Content - The content of the event request message. 444 Content *EventContent `json:"content,omitempty"` 445 // Headers - The headers of the event request message. 446 Headers map[string]*string `json:"headers"` 447 // Method - The HTTP method used to send the event request message. 448 Method *string `json:"method,omitempty"` 449 // RequestURI - The URI used to send the event request message. 450 RequestURI *string `json:"requestUri,omitempty"` 451 // Version - The HTTP message version. 452 Version *string `json:"version,omitempty"` 453} 454 455// MarshalJSON is the custom marshaler for EventRequestMessage. 456func (erm EventRequestMessage) MarshalJSON() ([]byte, error) { 457 objectMap := make(map[string]interface{}) 458 if erm.Content != nil { 459 objectMap["content"] = erm.Content 460 } 461 if erm.Headers != nil { 462 objectMap["headers"] = erm.Headers 463 } 464 if erm.Method != nil { 465 objectMap["method"] = erm.Method 466 } 467 if erm.RequestURI != nil { 468 objectMap["requestUri"] = erm.RequestURI 469 } 470 if erm.Version != nil { 471 objectMap["version"] = erm.Version 472 } 473 return json.Marshal(objectMap) 474} 475 476// EventResponseMessage the event response message received from the service URI. 477type EventResponseMessage struct { 478 // Content - The content of the event response message. 479 Content *string `json:"content,omitempty"` 480 // Headers - The headers of the event response message. 481 Headers map[string]*string `json:"headers"` 482 // ReasonPhrase - The reason phrase of the event response message. 483 ReasonPhrase *string `json:"reasonPhrase,omitempty"` 484 // StatusCode - The status code of the event response message. 485 StatusCode *string `json:"statusCode,omitempty"` 486 // Version - The HTTP message version. 487 Version *string `json:"version,omitempty"` 488} 489 490// MarshalJSON is the custom marshaler for EventResponseMessage. 491func (erm EventResponseMessage) MarshalJSON() ([]byte, error) { 492 objectMap := make(map[string]interface{}) 493 if erm.Content != nil { 494 objectMap["content"] = erm.Content 495 } 496 if erm.Headers != nil { 497 objectMap["headers"] = erm.Headers 498 } 499 if erm.ReasonPhrase != nil { 500 objectMap["reasonPhrase"] = erm.ReasonPhrase 501 } 502 if erm.StatusCode != nil { 503 objectMap["statusCode"] = erm.StatusCode 504 } 505 if erm.Version != nil { 506 objectMap["version"] = erm.Version 507 } 508 return json.Marshal(objectMap) 509} 510 511// ImportImageParameters ... 512type ImportImageParameters struct { 513 // Source - The source of the image. 514 Source *ImportSource `json:"source,omitempty"` 515 // TargetTags - List of strings of the form repo[:tag]. When tag is omitted the source will be used (or 'latest' if source tag is also omitted). 516 TargetTags *[]string `json:"targetTags,omitempty"` 517 // UntaggedTargetRepositories - List of strings of repository names to do a manifest only copy. No tag will be created. 518 UntaggedTargetRepositories *[]string `json:"untaggedTargetRepositories,omitempty"` 519 // Mode - When Force, any existing target tags will be overwritten. When NoForce, any existing target tags will fail the operation before any copying begins. Possible values include: 'NoForce', 'Force' 520 Mode ImportMode `json:"mode,omitempty"` 521} 522 523// ImportSource ... 524type ImportSource struct { 525 // ResourceID - The resource identifier of the source Azure Container Registry. 526 ResourceID *string `json:"resourceId,omitempty"` 527 // RegistryURI - The address of the source registry (e.g. 'mcr.microsoft.com'). 528 RegistryURI *string `json:"registryUri,omitempty"` 529 // Credentials - Credentials used when importing from a registry uri. 530 Credentials *ImportSourceCredentials `json:"credentials,omitempty"` 531 // SourceImage - Repository name of the source image. 532 // Specify an image by repository ('hello-world'). This will use the 'latest' tag. 533 // Specify an image by tag ('hello-world:latest'). 534 // Specify an image by sha256-based manifest digest ('hello-world@sha256:abc123'). 535 SourceImage *string `json:"sourceImage,omitempty"` 536} 537 538// ImportSourceCredentials ... 539type ImportSourceCredentials struct { 540 // Username - The username to authenticate with the source registry. 541 Username *string `json:"username,omitempty"` 542 // Password - The password used to authenticate with the source registry. 543 Password *string `json:"password,omitempty"` 544} 545 546// IPRule IP rule with specific IP or IP range in CIDR format. 547type IPRule struct { 548 // Action - The action of IP ACL rule. Possible values include: 'Allow' 549 Action Action `json:"action,omitempty"` 550 // IPAddressOrRange - Specifies the IP or IP range in CIDR format. Only IPV4 address is allowed. 551 IPAddressOrRange *string `json:"value,omitempty"` 552} 553 554// NetworkRuleSet the network rule set for a container registry. 555type NetworkRuleSet struct { 556 // DefaultAction - The default action of allow or deny when no other rules match. Possible values include: 'DefaultActionAllow', 'DefaultActionDeny' 557 DefaultAction DefaultAction `json:"defaultAction,omitempty"` 558 // VirtualNetworkRules - The virtual network rules. 559 VirtualNetworkRules *[]VirtualNetworkRule `json:"virtualNetworkRules,omitempty"` 560 // IPRules - The IP ACL rules. 561 IPRules *[]IPRule `json:"ipRules,omitempty"` 562} 563 564// OperationDefinition the definition of a container registry operation. 565type OperationDefinition struct { 566 // Origin - The origin information of the container registry operation. 567 Origin *string `json:"origin,omitempty"` 568 // Name - Operation name: {provider}/{resource}/{operation}. 569 Name *string `json:"name,omitempty"` 570 // Display - The display information for the container registry operation. 571 Display *OperationDisplayDefinition `json:"display,omitempty"` 572 // OperationPropertiesDefinition - The properties information for the container registry operation. 573 *OperationPropertiesDefinition `json:"properties,omitempty"` 574} 575 576// MarshalJSON is the custom marshaler for OperationDefinition. 577func (od OperationDefinition) MarshalJSON() ([]byte, error) { 578 objectMap := make(map[string]interface{}) 579 if od.Origin != nil { 580 objectMap["origin"] = od.Origin 581 } 582 if od.Name != nil { 583 objectMap["name"] = od.Name 584 } 585 if od.Display != nil { 586 objectMap["display"] = od.Display 587 } 588 if od.OperationPropertiesDefinition != nil { 589 objectMap["properties"] = od.OperationPropertiesDefinition 590 } 591 return json.Marshal(objectMap) 592} 593 594// UnmarshalJSON is the custom unmarshaler for OperationDefinition struct. 595func (od *OperationDefinition) UnmarshalJSON(body []byte) error { 596 var m map[string]*json.RawMessage 597 err := json.Unmarshal(body, &m) 598 if err != nil { 599 return err 600 } 601 for k, v := range m { 602 switch k { 603 case "origin": 604 if v != nil { 605 var origin string 606 err = json.Unmarshal(*v, &origin) 607 if err != nil { 608 return err 609 } 610 od.Origin = &origin 611 } 612 case "name": 613 if v != nil { 614 var name string 615 err = json.Unmarshal(*v, &name) 616 if err != nil { 617 return err 618 } 619 od.Name = &name 620 } 621 case "display": 622 if v != nil { 623 var display OperationDisplayDefinition 624 err = json.Unmarshal(*v, &display) 625 if err != nil { 626 return err 627 } 628 od.Display = &display 629 } 630 case "properties": 631 if v != nil { 632 var operationPropertiesDefinition OperationPropertiesDefinition 633 err = json.Unmarshal(*v, &operationPropertiesDefinition) 634 if err != nil { 635 return err 636 } 637 od.OperationPropertiesDefinition = &operationPropertiesDefinition 638 } 639 } 640 } 641 642 return nil 643} 644 645// OperationDisplayDefinition the display information for a container registry operation. 646type OperationDisplayDefinition struct { 647 // Provider - The resource provider name: Microsoft.ContainerRegistry. 648 Provider *string `json:"provider,omitempty"` 649 // Resource - The resource on which the operation is performed. 650 Resource *string `json:"resource,omitempty"` 651 // Operation - The operation that users can perform. 652 Operation *string `json:"operation,omitempty"` 653 // Description - The description for the operation. 654 Description *string `json:"description,omitempty"` 655} 656 657// OperationListResult the result of a request to list container registry operations. 658type OperationListResult struct { 659 autorest.Response `json:"-"` 660 // Value - The list of container registry operations. Since this list may be incomplete, the nextLink field should be used to request the next list of operations. 661 Value *[]OperationDefinition `json:"value,omitempty"` 662 // NextLink - The URI that can be used to request the next list of container registry operations. 663 NextLink *string `json:"nextLink,omitempty"` 664} 665 666// OperationListResultIterator provides access to a complete listing of OperationDefinition values. 667type OperationListResultIterator struct { 668 i int 669 page OperationListResultPage 670} 671 672// NextWithContext advances to the next value. If there was an error making 673// the request the iterator does not advance and the error is returned. 674func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { 675 if tracing.IsEnabled() { 676 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") 677 defer func() { 678 sc := -1 679 if iter.Response().Response.Response != nil { 680 sc = iter.Response().Response.Response.StatusCode 681 } 682 tracing.EndSpan(ctx, sc, err) 683 }() 684 } 685 iter.i++ 686 if iter.i < len(iter.page.Values()) { 687 return nil 688 } 689 err = iter.page.NextWithContext(ctx) 690 if err != nil { 691 iter.i-- 692 return err 693 } 694 iter.i = 0 695 return nil 696} 697 698// Next advances to the next value. If there was an error making 699// the request the iterator does not advance and the error is returned. 700// Deprecated: Use NextWithContext() instead. 701func (iter *OperationListResultIterator) Next() error { 702 return iter.NextWithContext(context.Background()) 703} 704 705// NotDone returns true if the enumeration should be started or is not yet complete. 706func (iter OperationListResultIterator) NotDone() bool { 707 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 708} 709 710// Response returns the raw server response from the last page request. 711func (iter OperationListResultIterator) Response() OperationListResult { 712 return iter.page.Response() 713} 714 715// Value returns the current value or a zero-initialized value if the 716// iterator has advanced beyond the end of the collection. 717func (iter OperationListResultIterator) Value() OperationDefinition { 718 if !iter.page.NotDone() { 719 return OperationDefinition{} 720 } 721 return iter.page.Values()[iter.i] 722} 723 724// Creates a new instance of the OperationListResultIterator type. 725func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { 726 return OperationListResultIterator{page: page} 727} 728 729// IsEmpty returns true if the ListResult contains no values. 730func (olr OperationListResult) IsEmpty() bool { 731 return olr.Value == nil || len(*olr.Value) == 0 732} 733 734// operationListResultPreparer prepares a request to retrieve the next set of results. 735// It returns nil if no more results exist. 736func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { 737 if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { 738 return nil, nil 739 } 740 return autorest.Prepare((&http.Request{}).WithContext(ctx), 741 autorest.AsJSON(), 742 autorest.AsGet(), 743 autorest.WithBaseURL(to.String(olr.NextLink))) 744} 745 746// OperationListResultPage contains a page of OperationDefinition values. 747type OperationListResultPage struct { 748 fn func(context.Context, OperationListResult) (OperationListResult, error) 749 olr OperationListResult 750} 751 752// NextWithContext advances to the next page of values. If there was an error making 753// the request the page does not advance and the error is returned. 754func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { 755 if tracing.IsEnabled() { 756 ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") 757 defer func() { 758 sc := -1 759 if page.Response().Response.Response != nil { 760 sc = page.Response().Response.Response.StatusCode 761 } 762 tracing.EndSpan(ctx, sc, err) 763 }() 764 } 765 next, err := page.fn(ctx, page.olr) 766 if err != nil { 767 return err 768 } 769 page.olr = next 770 return nil 771} 772 773// Next advances to the next page of values. If there was an error making 774// the request the page does not advance and the error is returned. 775// Deprecated: Use NextWithContext() instead. 776func (page *OperationListResultPage) Next() error { 777 return page.NextWithContext(context.Background()) 778} 779 780// NotDone returns true if the page enumeration should be started or is not yet complete. 781func (page OperationListResultPage) NotDone() bool { 782 return !page.olr.IsEmpty() 783} 784 785// Response returns the raw server response from the last page request. 786func (page OperationListResultPage) Response() OperationListResult { 787 return page.olr 788} 789 790// Values returns the slice of values for the current page or nil if there are no values. 791func (page OperationListResultPage) Values() []OperationDefinition { 792 if page.olr.IsEmpty() { 793 return nil 794 } 795 return *page.olr.Value 796} 797 798// Creates a new instance of the OperationListResultPage type. 799func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { 800 return OperationListResultPage{fn: getNextPage} 801} 802 803// OperationMetricSpecificationDefinition the definition of Azure Monitoring metric. 804type OperationMetricSpecificationDefinition struct { 805 // Name - Metric name. 806 Name *string `json:"name,omitempty"` 807 // DisplayName - Metric display name. 808 DisplayName *string `json:"displayName,omitempty"` 809 // DisplayDescription - Metric description. 810 DisplayDescription *string `json:"displayDescription,omitempty"` 811 // Unit - Metric unit. 812 Unit *string `json:"unit,omitempty"` 813 // AggregationType - Metric aggregation type. 814 AggregationType *string `json:"aggregationType,omitempty"` 815 // InternalMetricName - Internal metric name. 816 InternalMetricName *string `json:"internalMetricName,omitempty"` 817} 818 819// OperationPropertiesDefinition the definition of Azure Monitoring properties. 820type OperationPropertiesDefinition struct { 821 // ServiceSpecification - The definition of Azure Monitoring service. 822 ServiceSpecification *OperationServiceSpecificationDefinition `json:"serviceSpecification,omitempty"` 823} 824 825// OperationServiceSpecificationDefinition the definition of Azure Monitoring metrics list. 826type OperationServiceSpecificationDefinition struct { 827 // MetricSpecifications - A list of Azure Monitoring metrics definition. 828 MetricSpecifications *[]OperationMetricSpecificationDefinition `json:"metricSpecifications,omitempty"` 829} 830 831// QuarantinePolicy an object that represents quarantine policy for a container registry. 832type QuarantinePolicy struct { 833 // Status - The value that indicates whether the policy is enabled or not. Possible values include: 'Enabled', 'Disabled' 834 Status PolicyStatus `json:"status,omitempty"` 835} 836 837// RegenerateCredentialParameters the parameters used to regenerate the login credential. 838type RegenerateCredentialParameters struct { 839 // Name - Specifies name of the password which should be regenerated -- password or password2. Possible values include: 'Password', 'Password2' 840 Name PasswordName `json:"name,omitempty"` 841} 842 843// RegistriesCreateFuture an abstraction for monitoring and retrieving the results of a long-running 844// operation. 845type RegistriesCreateFuture struct { 846 azure.Future 847} 848 849// Result returns the result of the asynchronous operation. 850// If the operation has not completed it will return an error. 851func (future *RegistriesCreateFuture) Result(client RegistriesClient) (r Registry, err error) { 852 var done bool 853 done, err = future.DoneWithContext(context.Background(), client) 854 if err != nil { 855 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesCreateFuture", "Result", future.Response(), "Polling failure") 856 return 857 } 858 if !done { 859 err = azure.NewAsyncOpIncompleteError("containerregistry.RegistriesCreateFuture") 860 return 861 } 862 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 863 if r.Response.Response, err = future.GetResult(sender); err == nil && r.Response.Response.StatusCode != http.StatusNoContent { 864 r, err = client.CreateResponder(r.Response.Response) 865 if err != nil { 866 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesCreateFuture", "Result", r.Response.Response, "Failure responding to request") 867 } 868 } 869 return 870} 871 872// RegistriesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running 873// operation. 874type RegistriesDeleteFuture struct { 875 azure.Future 876} 877 878// Result returns the result of the asynchronous operation. 879// If the operation has not completed it will return an error. 880func (future *RegistriesDeleteFuture) Result(client RegistriesClient) (ar autorest.Response, err error) { 881 var done bool 882 done, err = future.DoneWithContext(context.Background(), client) 883 if err != nil { 884 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesDeleteFuture", "Result", future.Response(), "Polling failure") 885 return 886 } 887 if !done { 888 err = azure.NewAsyncOpIncompleteError("containerregistry.RegistriesDeleteFuture") 889 return 890 } 891 ar.Response = future.Response() 892 return 893} 894 895// RegistriesImportImageFuture an abstraction for monitoring and retrieving the results of a long-running 896// operation. 897type RegistriesImportImageFuture struct { 898 azure.Future 899} 900 901// Result returns the result of the asynchronous operation. 902// If the operation has not completed it will return an error. 903func (future *RegistriesImportImageFuture) Result(client RegistriesClient) (ar autorest.Response, err error) { 904 var done bool 905 done, err = future.DoneWithContext(context.Background(), client) 906 if err != nil { 907 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesImportImageFuture", "Result", future.Response(), "Polling failure") 908 return 909 } 910 if !done { 911 err = azure.NewAsyncOpIncompleteError("containerregistry.RegistriesImportImageFuture") 912 return 913 } 914 ar.Response = future.Response() 915 return 916} 917 918// RegistriesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running 919// operation. 920type RegistriesUpdateFuture struct { 921 azure.Future 922} 923 924// Result returns the result of the asynchronous operation. 925// If the operation has not completed it will return an error. 926func (future *RegistriesUpdateFuture) Result(client RegistriesClient) (r Registry, err error) { 927 var done bool 928 done, err = future.DoneWithContext(context.Background(), client) 929 if err != nil { 930 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesUpdateFuture", "Result", future.Response(), "Polling failure") 931 return 932 } 933 if !done { 934 err = azure.NewAsyncOpIncompleteError("containerregistry.RegistriesUpdateFuture") 935 return 936 } 937 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 938 if r.Response.Response, err = future.GetResult(sender); err == nil && r.Response.Response.StatusCode != http.StatusNoContent { 939 r, err = client.UpdateResponder(r.Response.Response) 940 if err != nil { 941 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesUpdateFuture", "Result", r.Response.Response, "Failure responding to request") 942 } 943 } 944 return 945} 946 947// RegistriesUpdatePoliciesFuture an abstraction for monitoring and retrieving the results of a 948// long-running operation. 949type RegistriesUpdatePoliciesFuture struct { 950 azure.Future 951} 952 953// Result returns the result of the asynchronous operation. 954// If the operation has not completed it will return an error. 955func (future *RegistriesUpdatePoliciesFuture) Result(client RegistriesClient) (rp RegistryPolicies, err error) { 956 var done bool 957 done, err = future.DoneWithContext(context.Background(), client) 958 if err != nil { 959 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesUpdatePoliciesFuture", "Result", future.Response(), "Polling failure") 960 return 961 } 962 if !done { 963 err = azure.NewAsyncOpIncompleteError("containerregistry.RegistriesUpdatePoliciesFuture") 964 return 965 } 966 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 967 if rp.Response.Response, err = future.GetResult(sender); err == nil && rp.Response.Response.StatusCode != http.StatusNoContent { 968 rp, err = client.UpdatePoliciesResponder(rp.Response.Response) 969 if err != nil { 970 err = autorest.NewErrorWithError(err, "containerregistry.RegistriesUpdatePoliciesFuture", "Result", rp.Response.Response, "Failure responding to request") 971 } 972 } 973 return 974} 975 976// Registry an object that represents a container registry. 977type Registry struct { 978 autorest.Response `json:"-"` 979 // Sku - The SKU of the container registry. 980 Sku *Sku `json:"sku,omitempty"` 981 // Identity - The identity of the container registry. 982 Identity *RegistryIdentity `json:"identity,omitempty"` 983 // RegistryProperties - The properties of the container registry. 984 *RegistryProperties `json:"properties,omitempty"` 985 // ID - READ-ONLY; The resource ID. 986 ID *string `json:"id,omitempty"` 987 // Name - READ-ONLY; The name of the resource. 988 Name *string `json:"name,omitempty"` 989 // Type - READ-ONLY; The type of the resource. 990 Type *string `json:"type,omitempty"` 991 // Location - The location of the resource. This cannot be changed after the resource is created. 992 Location *string `json:"location,omitempty"` 993 // Tags - The tags of the resource. 994 Tags map[string]*string `json:"tags"` 995} 996 997// MarshalJSON is the custom marshaler for Registry. 998func (r Registry) MarshalJSON() ([]byte, error) { 999 objectMap := make(map[string]interface{}) 1000 if r.Sku != nil { 1001 objectMap["sku"] = r.Sku 1002 } 1003 if r.Identity != nil { 1004 objectMap["identity"] = r.Identity 1005 } 1006 if r.RegistryProperties != nil { 1007 objectMap["properties"] = r.RegistryProperties 1008 } 1009 if r.Location != nil { 1010 objectMap["location"] = r.Location 1011 } 1012 if r.Tags != nil { 1013 objectMap["tags"] = r.Tags 1014 } 1015 return json.Marshal(objectMap) 1016} 1017 1018// UnmarshalJSON is the custom unmarshaler for Registry struct. 1019func (r *Registry) UnmarshalJSON(body []byte) error { 1020 var m map[string]*json.RawMessage 1021 err := json.Unmarshal(body, &m) 1022 if err != nil { 1023 return err 1024 } 1025 for k, v := range m { 1026 switch k { 1027 case "sku": 1028 if v != nil { 1029 var sku Sku 1030 err = json.Unmarshal(*v, &sku) 1031 if err != nil { 1032 return err 1033 } 1034 r.Sku = &sku 1035 } 1036 case "identity": 1037 if v != nil { 1038 var identity RegistryIdentity 1039 err = json.Unmarshal(*v, &identity) 1040 if err != nil { 1041 return err 1042 } 1043 r.Identity = &identity 1044 } 1045 case "properties": 1046 if v != nil { 1047 var registryProperties RegistryProperties 1048 err = json.Unmarshal(*v, ®istryProperties) 1049 if err != nil { 1050 return err 1051 } 1052 r.RegistryProperties = ®istryProperties 1053 } 1054 case "id": 1055 if v != nil { 1056 var ID string 1057 err = json.Unmarshal(*v, &ID) 1058 if err != nil { 1059 return err 1060 } 1061 r.ID = &ID 1062 } 1063 case "name": 1064 if v != nil { 1065 var name string 1066 err = json.Unmarshal(*v, &name) 1067 if err != nil { 1068 return err 1069 } 1070 r.Name = &name 1071 } 1072 case "type": 1073 if v != nil { 1074 var typeVar string 1075 err = json.Unmarshal(*v, &typeVar) 1076 if err != nil { 1077 return err 1078 } 1079 r.Type = &typeVar 1080 } 1081 case "location": 1082 if v != nil { 1083 var location string 1084 err = json.Unmarshal(*v, &location) 1085 if err != nil { 1086 return err 1087 } 1088 r.Location = &location 1089 } 1090 case "tags": 1091 if v != nil { 1092 var tags map[string]*string 1093 err = json.Unmarshal(*v, &tags) 1094 if err != nil { 1095 return err 1096 } 1097 r.Tags = tags 1098 } 1099 } 1100 } 1101 1102 return nil 1103} 1104 1105// RegistryIdentity the identity of the container registry. 1106type RegistryIdentity struct { 1107 // Type - The type of identity used for the registry. 1108 Type *string `json:"type,omitempty"` 1109 // PrincipalID - The principal ID of registry identity. 1110 PrincipalID *string `json:"principalId,omitempty"` 1111 // TenantID - The tenant ID associated with the registry. 1112 TenantID *string `json:"tenantId,omitempty"` 1113} 1114 1115// RegistryListCredentialsResult the response from the ListCredentials operation. 1116type RegistryListCredentialsResult struct { 1117 autorest.Response `json:"-"` 1118 // Username - The username for a container registry. 1119 Username *string `json:"username,omitempty"` 1120 // Passwords - The list of passwords for a container registry. 1121 Passwords *[]RegistryPassword `json:"passwords,omitempty"` 1122} 1123 1124// RegistryListResult the result of a request to list container registries. 1125type RegistryListResult struct { 1126 autorest.Response `json:"-"` 1127 // Value - The list of container registries. Since this list may be incomplete, the nextLink field should be used to request the next list of container registries. 1128 Value *[]Registry `json:"value,omitempty"` 1129 // NextLink - The URI that can be used to request the next list of container registries. 1130 NextLink *string `json:"nextLink,omitempty"` 1131} 1132 1133// RegistryListResultIterator provides access to a complete listing of Registry values. 1134type RegistryListResultIterator struct { 1135 i int 1136 page RegistryListResultPage 1137} 1138 1139// NextWithContext advances to the next value. If there was an error making 1140// the request the iterator does not advance and the error is returned. 1141func (iter *RegistryListResultIterator) NextWithContext(ctx context.Context) (err error) { 1142 if tracing.IsEnabled() { 1143 ctx = tracing.StartSpan(ctx, fqdn+"/RegistryListResultIterator.NextWithContext") 1144 defer func() { 1145 sc := -1 1146 if iter.Response().Response.Response != nil { 1147 sc = iter.Response().Response.Response.StatusCode 1148 } 1149 tracing.EndSpan(ctx, sc, err) 1150 }() 1151 } 1152 iter.i++ 1153 if iter.i < len(iter.page.Values()) { 1154 return nil 1155 } 1156 err = iter.page.NextWithContext(ctx) 1157 if err != nil { 1158 iter.i-- 1159 return err 1160 } 1161 iter.i = 0 1162 return nil 1163} 1164 1165// Next advances to the next value. If there was an error making 1166// the request the iterator does not advance and the error is returned. 1167// Deprecated: Use NextWithContext() instead. 1168func (iter *RegistryListResultIterator) Next() error { 1169 return iter.NextWithContext(context.Background()) 1170} 1171 1172// NotDone returns true if the enumeration should be started or is not yet complete. 1173func (iter RegistryListResultIterator) NotDone() bool { 1174 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1175} 1176 1177// Response returns the raw server response from the last page request. 1178func (iter RegistryListResultIterator) Response() RegistryListResult { 1179 return iter.page.Response() 1180} 1181 1182// Value returns the current value or a zero-initialized value if the 1183// iterator has advanced beyond the end of the collection. 1184func (iter RegistryListResultIterator) Value() Registry { 1185 if !iter.page.NotDone() { 1186 return Registry{} 1187 } 1188 return iter.page.Values()[iter.i] 1189} 1190 1191// Creates a new instance of the RegistryListResultIterator type. 1192func NewRegistryListResultIterator(page RegistryListResultPage) RegistryListResultIterator { 1193 return RegistryListResultIterator{page: page} 1194} 1195 1196// IsEmpty returns true if the ListResult contains no values. 1197func (rlr RegistryListResult) IsEmpty() bool { 1198 return rlr.Value == nil || len(*rlr.Value) == 0 1199} 1200 1201// registryListResultPreparer prepares a request to retrieve the next set of results. 1202// It returns nil if no more results exist. 1203func (rlr RegistryListResult) registryListResultPreparer(ctx context.Context) (*http.Request, error) { 1204 if rlr.NextLink == nil || len(to.String(rlr.NextLink)) < 1 { 1205 return nil, nil 1206 } 1207 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1208 autorest.AsJSON(), 1209 autorest.AsGet(), 1210 autorest.WithBaseURL(to.String(rlr.NextLink))) 1211} 1212 1213// RegistryListResultPage contains a page of Registry values. 1214type RegistryListResultPage struct { 1215 fn func(context.Context, RegistryListResult) (RegistryListResult, error) 1216 rlr RegistryListResult 1217} 1218 1219// NextWithContext advances to the next page of values. If there was an error making 1220// the request the page does not advance and the error is returned. 1221func (page *RegistryListResultPage) NextWithContext(ctx context.Context) (err error) { 1222 if tracing.IsEnabled() { 1223 ctx = tracing.StartSpan(ctx, fqdn+"/RegistryListResultPage.NextWithContext") 1224 defer func() { 1225 sc := -1 1226 if page.Response().Response.Response != nil { 1227 sc = page.Response().Response.Response.StatusCode 1228 } 1229 tracing.EndSpan(ctx, sc, err) 1230 }() 1231 } 1232 next, err := page.fn(ctx, page.rlr) 1233 if err != nil { 1234 return err 1235 } 1236 page.rlr = next 1237 return nil 1238} 1239 1240// Next advances to the next page of values. If there was an error making 1241// the request the page does not advance and the error is returned. 1242// Deprecated: Use NextWithContext() instead. 1243func (page *RegistryListResultPage) Next() error { 1244 return page.NextWithContext(context.Background()) 1245} 1246 1247// NotDone returns true if the page enumeration should be started or is not yet complete. 1248func (page RegistryListResultPage) NotDone() bool { 1249 return !page.rlr.IsEmpty() 1250} 1251 1252// Response returns the raw server response from the last page request. 1253func (page RegistryListResultPage) Response() RegistryListResult { 1254 return page.rlr 1255} 1256 1257// Values returns the slice of values for the current page or nil if there are no values. 1258func (page RegistryListResultPage) Values() []Registry { 1259 if page.rlr.IsEmpty() { 1260 return nil 1261 } 1262 return *page.rlr.Value 1263} 1264 1265// Creates a new instance of the RegistryListResultPage type. 1266func NewRegistryListResultPage(getNextPage func(context.Context, RegistryListResult) (RegistryListResult, error)) RegistryListResultPage { 1267 return RegistryListResultPage{fn: getNextPage} 1268} 1269 1270// RegistryNameCheckRequest a request to check whether a container registry name is available. 1271type RegistryNameCheckRequest struct { 1272 // Name - The name of the container registry. 1273 Name *string `json:"name,omitempty"` 1274 // Type - The resource type of the container registry. This field must be set to 'Microsoft.ContainerRegistry/registries'. 1275 Type *string `json:"type,omitempty"` 1276} 1277 1278// RegistryNameStatus the result of a request to check the availability of a container registry name. 1279type RegistryNameStatus struct { 1280 autorest.Response `json:"-"` 1281 // NameAvailable - The value that indicates whether the name is available. 1282 NameAvailable *bool `json:"nameAvailable,omitempty"` 1283 // Reason - If any, the reason that the name is not available. 1284 Reason *string `json:"reason,omitempty"` 1285 // Message - If any, the error message that provides more detail for the reason that the name is not available. 1286 Message *string `json:"message,omitempty"` 1287} 1288 1289// RegistryPassword the login password for the container registry. 1290type RegistryPassword struct { 1291 // Name - The password name. Possible values include: 'Password', 'Password2' 1292 Name PasswordName `json:"name,omitempty"` 1293 // Value - The password value. 1294 Value *string `json:"value,omitempty"` 1295} 1296 1297// RegistryPolicies an object that represents policies for a container registry. 1298type RegistryPolicies struct { 1299 autorest.Response `json:"-"` 1300 // QuarantinePolicy - An object that represents quarantine policy for a container registry. 1301 QuarantinePolicy *QuarantinePolicy `json:"quarantinePolicy,omitempty"` 1302 // TrustPolicy - An object that represents content trust policy for a container registry. 1303 TrustPolicy *TrustPolicy `json:"trustPolicy,omitempty"` 1304} 1305 1306// RegistryProperties the properties of a container registry. 1307type RegistryProperties struct { 1308 // LoginServer - READ-ONLY; The URL that can be used to log into the container registry. 1309 LoginServer *string `json:"loginServer,omitempty"` 1310 // CreationDate - READ-ONLY; The creation date of the container registry in ISO8601 format. 1311 CreationDate *date.Time `json:"creationDate,omitempty"` 1312 // ProvisioningState - READ-ONLY; The provisioning state of the container registry at the time the operation was called. Possible values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', 'Canceled' 1313 ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` 1314 // Status - READ-ONLY; The status of the container registry at the time the operation was called. 1315 Status *Status `json:"status,omitempty"` 1316 // AdminUserEnabled - The value that indicates whether the admin user is enabled. 1317 AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` 1318 // StorageAccount - The properties of the storage account for the container registry. Only applicable to Classic SKU. 1319 StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` 1320 // NetworkRuleSet - The network rule set for a container registry. 1321 NetworkRuleSet *NetworkRuleSet `json:"networkRuleSet,omitempty"` 1322} 1323 1324// RegistryPropertiesUpdateParameters the parameters for updating the properties of a container registry. 1325type RegistryPropertiesUpdateParameters struct { 1326 // AdminUserEnabled - The value that indicates whether the admin user is enabled. 1327 AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` 1328 // StorageAccount - The parameters of a storage account for the container registry. Only applicable to Classic SKU. If specified, the storage account must be in the same physical location as the container registry. 1329 StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` 1330 // NetworkRuleSet - The network rule set for a container registry. 1331 NetworkRuleSet *NetworkRuleSet `json:"networkRuleSet,omitempty"` 1332} 1333 1334// RegistryUpdateParameters the parameters for updating a container registry. 1335type RegistryUpdateParameters struct { 1336 // Tags - The tags for the container registry. 1337 Tags map[string]*string `json:"tags"` 1338 // Sku - The SKU of the container registry. 1339 Sku *Sku `json:"sku,omitempty"` 1340 // Identity - The identity of the container registry. 1341 Identity *RegistryIdentity `json:"identity,omitempty"` 1342 // RegistryPropertiesUpdateParameters - The properties that the container registry will be updated with. 1343 *RegistryPropertiesUpdateParameters `json:"properties,omitempty"` 1344} 1345 1346// MarshalJSON is the custom marshaler for RegistryUpdateParameters. 1347func (rup RegistryUpdateParameters) MarshalJSON() ([]byte, error) { 1348 objectMap := make(map[string]interface{}) 1349 if rup.Tags != nil { 1350 objectMap["tags"] = rup.Tags 1351 } 1352 if rup.Sku != nil { 1353 objectMap["sku"] = rup.Sku 1354 } 1355 if rup.Identity != nil { 1356 objectMap["identity"] = rup.Identity 1357 } 1358 if rup.RegistryPropertiesUpdateParameters != nil { 1359 objectMap["properties"] = rup.RegistryPropertiesUpdateParameters 1360 } 1361 return json.Marshal(objectMap) 1362} 1363 1364// UnmarshalJSON is the custom unmarshaler for RegistryUpdateParameters struct. 1365func (rup *RegistryUpdateParameters) UnmarshalJSON(body []byte) error { 1366 var m map[string]*json.RawMessage 1367 err := json.Unmarshal(body, &m) 1368 if err != nil { 1369 return err 1370 } 1371 for k, v := range m { 1372 switch k { 1373 case "tags": 1374 if v != nil { 1375 var tags map[string]*string 1376 err = json.Unmarshal(*v, &tags) 1377 if err != nil { 1378 return err 1379 } 1380 rup.Tags = tags 1381 } 1382 case "sku": 1383 if v != nil { 1384 var sku Sku 1385 err = json.Unmarshal(*v, &sku) 1386 if err != nil { 1387 return err 1388 } 1389 rup.Sku = &sku 1390 } 1391 case "identity": 1392 if v != nil { 1393 var identity RegistryIdentity 1394 err = json.Unmarshal(*v, &identity) 1395 if err != nil { 1396 return err 1397 } 1398 rup.Identity = &identity 1399 } 1400 case "properties": 1401 if v != nil { 1402 var registryPropertiesUpdateParameters RegistryPropertiesUpdateParameters 1403 err = json.Unmarshal(*v, ®istryPropertiesUpdateParameters) 1404 if err != nil { 1405 return err 1406 } 1407 rup.RegistryPropertiesUpdateParameters = ®istryPropertiesUpdateParameters 1408 } 1409 } 1410 } 1411 1412 return nil 1413} 1414 1415// RegistryUsage the quota usage for a container registry. 1416type RegistryUsage struct { 1417 // Name - The name of the usage. 1418 Name *string `json:"name,omitempty"` 1419 // Limit - The limit of the usage. 1420 Limit *int64 `json:"limit,omitempty"` 1421 // CurrentValue - The current value of the usage. 1422 CurrentValue *int64 `json:"currentValue,omitempty"` 1423 // Unit - The unit of measurement. Possible values include: 'Count', 'Bytes' 1424 Unit RegistryUsageUnit `json:"unit,omitempty"` 1425} 1426 1427// RegistryUsageListResult the result of a request to get container registry quota usages. 1428type RegistryUsageListResult struct { 1429 autorest.Response `json:"-"` 1430 // Value - The list of container registry quota usages. 1431 Value *[]RegistryUsage `json:"value,omitempty"` 1432} 1433 1434// Replication an object that represents a replication for a container registry. 1435type Replication struct { 1436 autorest.Response `json:"-"` 1437 // ReplicationProperties - The properties of the replication. 1438 *ReplicationProperties `json:"properties,omitempty"` 1439 // ID - READ-ONLY; The resource ID. 1440 ID *string `json:"id,omitempty"` 1441 // Name - READ-ONLY; The name of the resource. 1442 Name *string `json:"name,omitempty"` 1443 // Type - READ-ONLY; The type of the resource. 1444 Type *string `json:"type,omitempty"` 1445 // Location - The location of the resource. This cannot be changed after the resource is created. 1446 Location *string `json:"location,omitempty"` 1447 // Tags - The tags of the resource. 1448 Tags map[string]*string `json:"tags"` 1449} 1450 1451// MarshalJSON is the custom marshaler for Replication. 1452func (r Replication) MarshalJSON() ([]byte, error) { 1453 objectMap := make(map[string]interface{}) 1454 if r.ReplicationProperties != nil { 1455 objectMap["properties"] = r.ReplicationProperties 1456 } 1457 if r.Location != nil { 1458 objectMap["location"] = r.Location 1459 } 1460 if r.Tags != nil { 1461 objectMap["tags"] = r.Tags 1462 } 1463 return json.Marshal(objectMap) 1464} 1465 1466// UnmarshalJSON is the custom unmarshaler for Replication struct. 1467func (r *Replication) UnmarshalJSON(body []byte) error { 1468 var m map[string]*json.RawMessage 1469 err := json.Unmarshal(body, &m) 1470 if err != nil { 1471 return err 1472 } 1473 for k, v := range m { 1474 switch k { 1475 case "properties": 1476 if v != nil { 1477 var replicationProperties ReplicationProperties 1478 err = json.Unmarshal(*v, &replicationProperties) 1479 if err != nil { 1480 return err 1481 } 1482 r.ReplicationProperties = &replicationProperties 1483 } 1484 case "id": 1485 if v != nil { 1486 var ID string 1487 err = json.Unmarshal(*v, &ID) 1488 if err != nil { 1489 return err 1490 } 1491 r.ID = &ID 1492 } 1493 case "name": 1494 if v != nil { 1495 var name string 1496 err = json.Unmarshal(*v, &name) 1497 if err != nil { 1498 return err 1499 } 1500 r.Name = &name 1501 } 1502 case "type": 1503 if v != nil { 1504 var typeVar string 1505 err = json.Unmarshal(*v, &typeVar) 1506 if err != nil { 1507 return err 1508 } 1509 r.Type = &typeVar 1510 } 1511 case "location": 1512 if v != nil { 1513 var location string 1514 err = json.Unmarshal(*v, &location) 1515 if err != nil { 1516 return err 1517 } 1518 r.Location = &location 1519 } 1520 case "tags": 1521 if v != nil { 1522 var tags map[string]*string 1523 err = json.Unmarshal(*v, &tags) 1524 if err != nil { 1525 return err 1526 } 1527 r.Tags = tags 1528 } 1529 } 1530 } 1531 1532 return nil 1533} 1534 1535// ReplicationListResult the result of a request to list replications for a container registry. 1536type ReplicationListResult struct { 1537 autorest.Response `json:"-"` 1538 // Value - The list of replications. Since this list may be incomplete, the nextLink field should be used to request the next list of replications. 1539 Value *[]Replication `json:"value,omitempty"` 1540 // NextLink - The URI that can be used to request the next list of replications. 1541 NextLink *string `json:"nextLink,omitempty"` 1542} 1543 1544// ReplicationListResultIterator provides access to a complete listing of Replication values. 1545type ReplicationListResultIterator struct { 1546 i int 1547 page ReplicationListResultPage 1548} 1549 1550// NextWithContext advances to the next value. If there was an error making 1551// the request the iterator does not advance and the error is returned. 1552func (iter *ReplicationListResultIterator) NextWithContext(ctx context.Context) (err error) { 1553 if tracing.IsEnabled() { 1554 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationListResultIterator.NextWithContext") 1555 defer func() { 1556 sc := -1 1557 if iter.Response().Response.Response != nil { 1558 sc = iter.Response().Response.Response.StatusCode 1559 } 1560 tracing.EndSpan(ctx, sc, err) 1561 }() 1562 } 1563 iter.i++ 1564 if iter.i < len(iter.page.Values()) { 1565 return nil 1566 } 1567 err = iter.page.NextWithContext(ctx) 1568 if err != nil { 1569 iter.i-- 1570 return err 1571 } 1572 iter.i = 0 1573 return nil 1574} 1575 1576// Next advances to the next value. If there was an error making 1577// the request the iterator does not advance and the error is returned. 1578// Deprecated: Use NextWithContext() instead. 1579func (iter *ReplicationListResultIterator) Next() error { 1580 return iter.NextWithContext(context.Background()) 1581} 1582 1583// NotDone returns true if the enumeration should be started or is not yet complete. 1584func (iter ReplicationListResultIterator) NotDone() bool { 1585 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 1586} 1587 1588// Response returns the raw server response from the last page request. 1589func (iter ReplicationListResultIterator) Response() ReplicationListResult { 1590 return iter.page.Response() 1591} 1592 1593// Value returns the current value or a zero-initialized value if the 1594// iterator has advanced beyond the end of the collection. 1595func (iter ReplicationListResultIterator) Value() Replication { 1596 if !iter.page.NotDone() { 1597 return Replication{} 1598 } 1599 return iter.page.Values()[iter.i] 1600} 1601 1602// Creates a new instance of the ReplicationListResultIterator type. 1603func NewReplicationListResultIterator(page ReplicationListResultPage) ReplicationListResultIterator { 1604 return ReplicationListResultIterator{page: page} 1605} 1606 1607// IsEmpty returns true if the ListResult contains no values. 1608func (rlr ReplicationListResult) IsEmpty() bool { 1609 return rlr.Value == nil || len(*rlr.Value) == 0 1610} 1611 1612// replicationListResultPreparer prepares a request to retrieve the next set of results. 1613// It returns nil if no more results exist. 1614func (rlr ReplicationListResult) replicationListResultPreparer(ctx context.Context) (*http.Request, error) { 1615 if rlr.NextLink == nil || len(to.String(rlr.NextLink)) < 1 { 1616 return nil, nil 1617 } 1618 return autorest.Prepare((&http.Request{}).WithContext(ctx), 1619 autorest.AsJSON(), 1620 autorest.AsGet(), 1621 autorest.WithBaseURL(to.String(rlr.NextLink))) 1622} 1623 1624// ReplicationListResultPage contains a page of Replication values. 1625type ReplicationListResultPage struct { 1626 fn func(context.Context, ReplicationListResult) (ReplicationListResult, error) 1627 rlr ReplicationListResult 1628} 1629 1630// NextWithContext advances to the next page of values. If there was an error making 1631// the request the page does not advance and the error is returned. 1632func (page *ReplicationListResultPage) NextWithContext(ctx context.Context) (err error) { 1633 if tracing.IsEnabled() { 1634 ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationListResultPage.NextWithContext") 1635 defer func() { 1636 sc := -1 1637 if page.Response().Response.Response != nil { 1638 sc = page.Response().Response.Response.StatusCode 1639 } 1640 tracing.EndSpan(ctx, sc, err) 1641 }() 1642 } 1643 next, err := page.fn(ctx, page.rlr) 1644 if err != nil { 1645 return err 1646 } 1647 page.rlr = next 1648 return nil 1649} 1650 1651// Next advances to the next page of values. If there was an error making 1652// the request the page does not advance and the error is returned. 1653// Deprecated: Use NextWithContext() instead. 1654func (page *ReplicationListResultPage) Next() error { 1655 return page.NextWithContext(context.Background()) 1656} 1657 1658// NotDone returns true if the page enumeration should be started or is not yet complete. 1659func (page ReplicationListResultPage) NotDone() bool { 1660 return !page.rlr.IsEmpty() 1661} 1662 1663// Response returns the raw server response from the last page request. 1664func (page ReplicationListResultPage) Response() ReplicationListResult { 1665 return page.rlr 1666} 1667 1668// Values returns the slice of values for the current page or nil if there are no values. 1669func (page ReplicationListResultPage) Values() []Replication { 1670 if page.rlr.IsEmpty() { 1671 return nil 1672 } 1673 return *page.rlr.Value 1674} 1675 1676// Creates a new instance of the ReplicationListResultPage type. 1677func NewReplicationListResultPage(getNextPage func(context.Context, ReplicationListResult) (ReplicationListResult, error)) ReplicationListResultPage { 1678 return ReplicationListResultPage{fn: getNextPage} 1679} 1680 1681// ReplicationProperties the properties of a replication. 1682type ReplicationProperties struct { 1683 // ProvisioningState - READ-ONLY; The provisioning state of the replication at the time the operation was called. Possible values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', 'Canceled' 1684 ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` 1685 // Status - READ-ONLY; The status of the replication at the time the operation was called. 1686 Status *Status `json:"status,omitempty"` 1687} 1688 1689// ReplicationsCreateFuture an abstraction for monitoring and retrieving the results of a long-running 1690// operation. 1691type ReplicationsCreateFuture struct { 1692 azure.Future 1693} 1694 1695// Result returns the result of the asynchronous operation. 1696// If the operation has not completed it will return an error. 1697func (future *ReplicationsCreateFuture) Result(client ReplicationsClient) (r Replication, err error) { 1698 var done bool 1699 done, err = future.DoneWithContext(context.Background(), client) 1700 if err != nil { 1701 err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsCreateFuture", "Result", future.Response(), "Polling failure") 1702 return 1703 } 1704 if !done { 1705 err = azure.NewAsyncOpIncompleteError("containerregistry.ReplicationsCreateFuture") 1706 return 1707 } 1708 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1709 if r.Response.Response, err = future.GetResult(sender); err == nil && r.Response.Response.StatusCode != http.StatusNoContent { 1710 r, err = client.CreateResponder(r.Response.Response) 1711 if err != nil { 1712 err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsCreateFuture", "Result", r.Response.Response, "Failure responding to request") 1713 } 1714 } 1715 return 1716} 1717 1718// ReplicationsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running 1719// operation. 1720type ReplicationsDeleteFuture struct { 1721 azure.Future 1722} 1723 1724// Result returns the result of the asynchronous operation. 1725// If the operation has not completed it will return an error. 1726func (future *ReplicationsDeleteFuture) Result(client ReplicationsClient) (ar autorest.Response, err error) { 1727 var done bool 1728 done, err = future.DoneWithContext(context.Background(), client) 1729 if err != nil { 1730 err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsDeleteFuture", "Result", future.Response(), "Polling failure") 1731 return 1732 } 1733 if !done { 1734 err = azure.NewAsyncOpIncompleteError("containerregistry.ReplicationsDeleteFuture") 1735 return 1736 } 1737 ar.Response = future.Response() 1738 return 1739} 1740 1741// ReplicationsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running 1742// operation. 1743type ReplicationsUpdateFuture struct { 1744 azure.Future 1745} 1746 1747// Result returns the result of the asynchronous operation. 1748// If the operation has not completed it will return an error. 1749func (future *ReplicationsUpdateFuture) Result(client ReplicationsClient) (r Replication, err error) { 1750 var done bool 1751 done, err = future.DoneWithContext(context.Background(), client) 1752 if err != nil { 1753 err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsUpdateFuture", "Result", future.Response(), "Polling failure") 1754 return 1755 } 1756 if !done { 1757 err = azure.NewAsyncOpIncompleteError("containerregistry.ReplicationsUpdateFuture") 1758 return 1759 } 1760 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 1761 if r.Response.Response, err = future.GetResult(sender); err == nil && r.Response.Response.StatusCode != http.StatusNoContent { 1762 r, err = client.UpdateResponder(r.Response.Response) 1763 if err != nil { 1764 err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsUpdateFuture", "Result", r.Response.Response, "Failure responding to request") 1765 } 1766 } 1767 return 1768} 1769 1770// ReplicationUpdateParameters the parameters for updating a replication. 1771type ReplicationUpdateParameters struct { 1772 // Tags - The tags for the replication. 1773 Tags map[string]*string `json:"tags"` 1774} 1775 1776// MarshalJSON is the custom marshaler for ReplicationUpdateParameters. 1777func (rup ReplicationUpdateParameters) MarshalJSON() ([]byte, error) { 1778 objectMap := make(map[string]interface{}) 1779 if rup.Tags != nil { 1780 objectMap["tags"] = rup.Tags 1781 } 1782 return json.Marshal(objectMap) 1783} 1784 1785// Request the request that generated the event. 1786type Request struct { 1787 // ID - The ID of the request that initiated the event. 1788 ID *string `json:"id,omitempty"` 1789 // Addr - The IP or hostname and possibly port of the client connection that initiated the event. This is the RemoteAddr from the standard http request. 1790 Addr *string `json:"addr,omitempty"` 1791 // Host - The externally accessible hostname of the registry instance, as specified by the http host header on incoming requests. 1792 Host *string `json:"host,omitempty"` 1793 // Method - The request method that generated the event. 1794 Method *string `json:"method,omitempty"` 1795 // Useragent - The user agent header of the request. 1796 Useragent *string `json:"useragent,omitempty"` 1797} 1798 1799// Resource an Azure resource. 1800type Resource struct { 1801 // ID - READ-ONLY; The resource ID. 1802 ID *string `json:"id,omitempty"` 1803 // Name - READ-ONLY; The name of the resource. 1804 Name *string `json:"name,omitempty"` 1805 // Type - READ-ONLY; The type of the resource. 1806 Type *string `json:"type,omitempty"` 1807 // Location - The location of the resource. This cannot be changed after the resource is created. 1808 Location *string `json:"location,omitempty"` 1809 // Tags - The tags of the resource. 1810 Tags map[string]*string `json:"tags"` 1811} 1812 1813// MarshalJSON is the custom marshaler for Resource. 1814func (r Resource) MarshalJSON() ([]byte, error) { 1815 objectMap := make(map[string]interface{}) 1816 if r.Location != nil { 1817 objectMap["location"] = r.Location 1818 } 1819 if r.Tags != nil { 1820 objectMap["tags"] = r.Tags 1821 } 1822 return json.Marshal(objectMap) 1823} 1824 1825// Sku the SKU of a container registry. 1826type Sku struct { 1827 // Name - The SKU name of the container registry. Required for registry creation. Possible values include: 'Classic', 'Basic', 'Standard', 'Premium' 1828 Name SkuName `json:"name,omitempty"` 1829 // Tier - READ-ONLY; The SKU tier based on the SKU name. Possible values include: 'SkuTierClassic', 'SkuTierBasic', 'SkuTierStandard', 'SkuTierPremium' 1830 Tier SkuTier `json:"tier,omitempty"` 1831} 1832 1833// Source the registry node that generated the event. Put differently, while the actor initiates the event, 1834// the source generates it. 1835type Source struct { 1836 // Addr - The IP or hostname and the port of the registry node that generated the event. Generally, this will be resolved by os.Hostname() along with the running port. 1837 Addr *string `json:"addr,omitempty"` 1838 // InstanceID - The running instance of an application. Changes after each restart. 1839 InstanceID *string `json:"instanceID,omitempty"` 1840} 1841 1842// Status the status of an Azure resource at the time the operation was called. 1843type Status struct { 1844 // DisplayStatus - READ-ONLY; The short label for the status. 1845 DisplayStatus *string `json:"displayStatus,omitempty"` 1846 // Message - READ-ONLY; The detailed message for the status, including alerts and error messages. 1847 Message *string `json:"message,omitempty"` 1848 // Timestamp - READ-ONLY; The timestamp when the status was changed to the current value. 1849 Timestamp *date.Time `json:"timestamp,omitempty"` 1850} 1851 1852// StorageAccountProperties the properties of a storage account for a container registry. Only applicable 1853// to Classic SKU. 1854type StorageAccountProperties struct { 1855 // ID - The resource ID of the storage account. 1856 ID *string `json:"id,omitempty"` 1857} 1858 1859// Target the target of the event. 1860type Target struct { 1861 // MediaType - The MIME type of the referenced object. 1862 MediaType *string `json:"mediaType,omitempty"` 1863 // Size - The number of bytes of the content. Same as Length field. 1864 Size *int64 `json:"size,omitempty"` 1865 // Digest - The digest of the content, as defined by the Registry V2 HTTP API Specification. 1866 Digest *string `json:"digest,omitempty"` 1867 // Length - The number of bytes of the content. Same as Size field. 1868 Length *int64 `json:"length,omitempty"` 1869 // Repository - The repository name. 1870 Repository *string `json:"repository,omitempty"` 1871 // URL - The direct URL to the content. 1872 URL *string `json:"url,omitempty"` 1873 // Tag - The tag name. 1874 Tag *string `json:"tag,omitempty"` 1875 // Name - The name of the artifact. 1876 Name *string `json:"name,omitempty"` 1877 // Version - The version of the artifact. 1878 Version *string `json:"version,omitempty"` 1879} 1880 1881// TrustPolicy an object that represents content trust policy for a container registry. 1882type TrustPolicy struct { 1883 // Type - The type of trust policy. Possible values include: 'Notary' 1884 Type TrustPolicyType `json:"type,omitempty"` 1885 // Status - The value that indicates whether the policy is enabled or not. Possible values include: 'Enabled', 'Disabled' 1886 Status PolicyStatus `json:"status,omitempty"` 1887} 1888 1889// VirtualNetworkRule virtual network rule. 1890type VirtualNetworkRule struct { 1891 // Action - The action of virtual network rule. Possible values include: 'Allow' 1892 Action Action `json:"action,omitempty"` 1893 // VirtualNetworkResourceID - Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. 1894 VirtualNetworkResourceID *string `json:"id,omitempty"` 1895} 1896 1897// Webhook an object that represents a webhook for a container registry. 1898type Webhook struct { 1899 autorest.Response `json:"-"` 1900 // WebhookProperties - The properties of the webhook. 1901 *WebhookProperties `json:"properties,omitempty"` 1902 // ID - READ-ONLY; The resource ID. 1903 ID *string `json:"id,omitempty"` 1904 // Name - READ-ONLY; The name of the resource. 1905 Name *string `json:"name,omitempty"` 1906 // Type - READ-ONLY; The type of the resource. 1907 Type *string `json:"type,omitempty"` 1908 // Location - The location of the resource. This cannot be changed after the resource is created. 1909 Location *string `json:"location,omitempty"` 1910 // Tags - The tags of the resource. 1911 Tags map[string]*string `json:"tags"` 1912} 1913 1914// MarshalJSON is the custom marshaler for Webhook. 1915func (w Webhook) MarshalJSON() ([]byte, error) { 1916 objectMap := make(map[string]interface{}) 1917 if w.WebhookProperties != nil { 1918 objectMap["properties"] = w.WebhookProperties 1919 } 1920 if w.Location != nil { 1921 objectMap["location"] = w.Location 1922 } 1923 if w.Tags != nil { 1924 objectMap["tags"] = w.Tags 1925 } 1926 return json.Marshal(objectMap) 1927} 1928 1929// UnmarshalJSON is the custom unmarshaler for Webhook struct. 1930func (w *Webhook) UnmarshalJSON(body []byte) error { 1931 var m map[string]*json.RawMessage 1932 err := json.Unmarshal(body, &m) 1933 if err != nil { 1934 return err 1935 } 1936 for k, v := range m { 1937 switch k { 1938 case "properties": 1939 if v != nil { 1940 var webhookProperties WebhookProperties 1941 err = json.Unmarshal(*v, &webhookProperties) 1942 if err != nil { 1943 return err 1944 } 1945 w.WebhookProperties = &webhookProperties 1946 } 1947 case "id": 1948 if v != nil { 1949 var ID string 1950 err = json.Unmarshal(*v, &ID) 1951 if err != nil { 1952 return err 1953 } 1954 w.ID = &ID 1955 } 1956 case "name": 1957 if v != nil { 1958 var name string 1959 err = json.Unmarshal(*v, &name) 1960 if err != nil { 1961 return err 1962 } 1963 w.Name = &name 1964 } 1965 case "type": 1966 if v != nil { 1967 var typeVar string 1968 err = json.Unmarshal(*v, &typeVar) 1969 if err != nil { 1970 return err 1971 } 1972 w.Type = &typeVar 1973 } 1974 case "location": 1975 if v != nil { 1976 var location string 1977 err = json.Unmarshal(*v, &location) 1978 if err != nil { 1979 return err 1980 } 1981 w.Location = &location 1982 } 1983 case "tags": 1984 if v != nil { 1985 var tags map[string]*string 1986 err = json.Unmarshal(*v, &tags) 1987 if err != nil { 1988 return err 1989 } 1990 w.Tags = tags 1991 } 1992 } 1993 } 1994 1995 return nil 1996} 1997 1998// WebhookCreateParameters the parameters for creating a webhook. 1999type WebhookCreateParameters struct { 2000 // Tags - The tags for the webhook. 2001 Tags map[string]*string `json:"tags"` 2002 // Location - The location of the webhook. This cannot be changed after the resource is created. 2003 Location *string `json:"location,omitempty"` 2004 // WebhookPropertiesCreateParameters - The properties that the webhook will be created with. 2005 *WebhookPropertiesCreateParameters `json:"properties,omitempty"` 2006} 2007 2008// MarshalJSON is the custom marshaler for WebhookCreateParameters. 2009func (wcp WebhookCreateParameters) MarshalJSON() ([]byte, error) { 2010 objectMap := make(map[string]interface{}) 2011 if wcp.Tags != nil { 2012 objectMap["tags"] = wcp.Tags 2013 } 2014 if wcp.Location != nil { 2015 objectMap["location"] = wcp.Location 2016 } 2017 if wcp.WebhookPropertiesCreateParameters != nil { 2018 objectMap["properties"] = wcp.WebhookPropertiesCreateParameters 2019 } 2020 return json.Marshal(objectMap) 2021} 2022 2023// UnmarshalJSON is the custom unmarshaler for WebhookCreateParameters struct. 2024func (wcp *WebhookCreateParameters) UnmarshalJSON(body []byte) error { 2025 var m map[string]*json.RawMessage 2026 err := json.Unmarshal(body, &m) 2027 if err != nil { 2028 return err 2029 } 2030 for k, v := range m { 2031 switch k { 2032 case "tags": 2033 if v != nil { 2034 var tags map[string]*string 2035 err = json.Unmarshal(*v, &tags) 2036 if err != nil { 2037 return err 2038 } 2039 wcp.Tags = tags 2040 } 2041 case "location": 2042 if v != nil { 2043 var location string 2044 err = json.Unmarshal(*v, &location) 2045 if err != nil { 2046 return err 2047 } 2048 wcp.Location = &location 2049 } 2050 case "properties": 2051 if v != nil { 2052 var webhookPropertiesCreateParameters WebhookPropertiesCreateParameters 2053 err = json.Unmarshal(*v, &webhookPropertiesCreateParameters) 2054 if err != nil { 2055 return err 2056 } 2057 wcp.WebhookPropertiesCreateParameters = &webhookPropertiesCreateParameters 2058 } 2059 } 2060 } 2061 2062 return nil 2063} 2064 2065// WebhookListResult the result of a request to list webhooks for a container registry. 2066type WebhookListResult struct { 2067 autorest.Response `json:"-"` 2068 // Value - The list of webhooks. Since this list may be incomplete, the nextLink field should be used to request the next list of webhooks. 2069 Value *[]Webhook `json:"value,omitempty"` 2070 // NextLink - The URI that can be used to request the next list of webhooks. 2071 NextLink *string `json:"nextLink,omitempty"` 2072} 2073 2074// WebhookListResultIterator provides access to a complete listing of Webhook values. 2075type WebhookListResultIterator struct { 2076 i int 2077 page WebhookListResultPage 2078} 2079 2080// NextWithContext advances to the next value. If there was an error making 2081// the request the iterator does not advance and the error is returned. 2082func (iter *WebhookListResultIterator) NextWithContext(ctx context.Context) (err error) { 2083 if tracing.IsEnabled() { 2084 ctx = tracing.StartSpan(ctx, fqdn+"/WebhookListResultIterator.NextWithContext") 2085 defer func() { 2086 sc := -1 2087 if iter.Response().Response.Response != nil { 2088 sc = iter.Response().Response.Response.StatusCode 2089 } 2090 tracing.EndSpan(ctx, sc, err) 2091 }() 2092 } 2093 iter.i++ 2094 if iter.i < len(iter.page.Values()) { 2095 return nil 2096 } 2097 err = iter.page.NextWithContext(ctx) 2098 if err != nil { 2099 iter.i-- 2100 return err 2101 } 2102 iter.i = 0 2103 return nil 2104} 2105 2106// Next advances to the next value. If there was an error making 2107// the request the iterator does not advance and the error is returned. 2108// Deprecated: Use NextWithContext() instead. 2109func (iter *WebhookListResultIterator) Next() error { 2110 return iter.NextWithContext(context.Background()) 2111} 2112 2113// NotDone returns true if the enumeration should be started or is not yet complete. 2114func (iter WebhookListResultIterator) NotDone() bool { 2115 return iter.page.NotDone() && iter.i < len(iter.page.Values()) 2116} 2117 2118// Response returns the raw server response from the last page request. 2119func (iter WebhookListResultIterator) Response() WebhookListResult { 2120 return iter.page.Response() 2121} 2122 2123// Value returns the current value or a zero-initialized value if the 2124// iterator has advanced beyond the end of the collection. 2125func (iter WebhookListResultIterator) Value() Webhook { 2126 if !iter.page.NotDone() { 2127 return Webhook{} 2128 } 2129 return iter.page.Values()[iter.i] 2130} 2131 2132// Creates a new instance of the WebhookListResultIterator type. 2133func NewWebhookListResultIterator(page WebhookListResultPage) WebhookListResultIterator { 2134 return WebhookListResultIterator{page: page} 2135} 2136 2137// IsEmpty returns true if the ListResult contains no values. 2138func (wlr WebhookListResult) IsEmpty() bool { 2139 return wlr.Value == nil || len(*wlr.Value) == 0 2140} 2141 2142// webhookListResultPreparer prepares a request to retrieve the next set of results. 2143// It returns nil if no more results exist. 2144func (wlr WebhookListResult) webhookListResultPreparer(ctx context.Context) (*http.Request, error) { 2145 if wlr.NextLink == nil || len(to.String(wlr.NextLink)) < 1 { 2146 return nil, nil 2147 } 2148 return autorest.Prepare((&http.Request{}).WithContext(ctx), 2149 autorest.AsJSON(), 2150 autorest.AsGet(), 2151 autorest.WithBaseURL(to.String(wlr.NextLink))) 2152} 2153 2154// WebhookListResultPage contains a page of Webhook values. 2155type WebhookListResultPage struct { 2156 fn func(context.Context, WebhookListResult) (WebhookListResult, error) 2157 wlr WebhookListResult 2158} 2159 2160// NextWithContext advances to the next page of values. If there was an error making 2161// the request the page does not advance and the error is returned. 2162func (page *WebhookListResultPage) NextWithContext(ctx context.Context) (err error) { 2163 if tracing.IsEnabled() { 2164 ctx = tracing.StartSpan(ctx, fqdn+"/WebhookListResultPage.NextWithContext") 2165 defer func() { 2166 sc := -1 2167 if page.Response().Response.Response != nil { 2168 sc = page.Response().Response.Response.StatusCode 2169 } 2170 tracing.EndSpan(ctx, sc, err) 2171 }() 2172 } 2173 next, err := page.fn(ctx, page.wlr) 2174 if err != nil { 2175 return err 2176 } 2177 page.wlr = next 2178 return nil 2179} 2180 2181// Next advances to the next page of values. If there was an error making 2182// the request the page does not advance and the error is returned. 2183// Deprecated: Use NextWithContext() instead. 2184func (page *WebhookListResultPage) Next() error { 2185 return page.NextWithContext(context.Background()) 2186} 2187 2188// NotDone returns true if the page enumeration should be started or is not yet complete. 2189func (page WebhookListResultPage) NotDone() bool { 2190 return !page.wlr.IsEmpty() 2191} 2192 2193// Response returns the raw server response from the last page request. 2194func (page WebhookListResultPage) Response() WebhookListResult { 2195 return page.wlr 2196} 2197 2198// Values returns the slice of values for the current page or nil if there are no values. 2199func (page WebhookListResultPage) Values() []Webhook { 2200 if page.wlr.IsEmpty() { 2201 return nil 2202 } 2203 return *page.wlr.Value 2204} 2205 2206// Creates a new instance of the WebhookListResultPage type. 2207func NewWebhookListResultPage(getNextPage func(context.Context, WebhookListResult) (WebhookListResult, error)) WebhookListResultPage { 2208 return WebhookListResultPage{fn: getNextPage} 2209} 2210 2211// WebhookProperties the properties of a webhook. 2212type WebhookProperties struct { 2213 // Status - The status of the webhook at the time the operation was called. Possible values include: 'WebhookStatusEnabled', 'WebhookStatusDisabled' 2214 Status WebhookStatus `json:"status,omitempty"` 2215 // Scope - The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. 'foo' is equivalent to 'foo:latest'. Empty means all events. 2216 Scope *string `json:"scope,omitempty"` 2217 // Actions - The list of actions that trigger the webhook to post notifications. 2218 Actions *[]WebhookAction `json:"actions,omitempty"` 2219 // ProvisioningState - READ-ONLY; The provisioning state of the webhook at the time the operation was called. Possible values include: 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', 'Canceled' 2220 ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` 2221} 2222 2223// WebhookPropertiesCreateParameters the parameters for creating the properties of a webhook. 2224type WebhookPropertiesCreateParameters struct { 2225 // ServiceURI - The service URI for the webhook to post notifications. 2226 ServiceURI *string `json:"serviceUri,omitempty"` 2227 // CustomHeaders - Custom headers that will be added to the webhook notifications. 2228 CustomHeaders map[string]*string `json:"customHeaders"` 2229 // Status - The status of the webhook at the time the operation was called. Possible values include: 'WebhookStatusEnabled', 'WebhookStatusDisabled' 2230 Status WebhookStatus `json:"status,omitempty"` 2231 // Scope - The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. 'foo' is equivalent to 'foo:latest'. Empty means all events. 2232 Scope *string `json:"scope,omitempty"` 2233 // Actions - The list of actions that trigger the webhook to post notifications. 2234 Actions *[]WebhookAction `json:"actions,omitempty"` 2235} 2236 2237// MarshalJSON is the custom marshaler for WebhookPropertiesCreateParameters. 2238func (wpcp WebhookPropertiesCreateParameters) MarshalJSON() ([]byte, error) { 2239 objectMap := make(map[string]interface{}) 2240 if wpcp.ServiceURI != nil { 2241 objectMap["serviceUri"] = wpcp.ServiceURI 2242 } 2243 if wpcp.CustomHeaders != nil { 2244 objectMap["customHeaders"] = wpcp.CustomHeaders 2245 } 2246 if wpcp.Status != "" { 2247 objectMap["status"] = wpcp.Status 2248 } 2249 if wpcp.Scope != nil { 2250 objectMap["scope"] = wpcp.Scope 2251 } 2252 if wpcp.Actions != nil { 2253 objectMap["actions"] = wpcp.Actions 2254 } 2255 return json.Marshal(objectMap) 2256} 2257 2258// WebhookPropertiesUpdateParameters the parameters for updating the properties of a webhook. 2259type WebhookPropertiesUpdateParameters struct { 2260 // ServiceURI - The service URI for the webhook to post notifications. 2261 ServiceURI *string `json:"serviceUri,omitempty"` 2262 // CustomHeaders - Custom headers that will be added to the webhook notifications. 2263 CustomHeaders map[string]*string `json:"customHeaders"` 2264 // Status - The status of the webhook at the time the operation was called. Possible values include: 'WebhookStatusEnabled', 'WebhookStatusDisabled' 2265 Status WebhookStatus `json:"status,omitempty"` 2266 // Scope - The scope of repositories where the event can be triggered. For example, 'foo:*' means events for all tags under repository 'foo'. 'foo:bar' means events for 'foo:bar' only. 'foo' is equivalent to 'foo:latest'. Empty means all events. 2267 Scope *string `json:"scope,omitempty"` 2268 // Actions - The list of actions that trigger the webhook to post notifications. 2269 Actions *[]WebhookAction `json:"actions,omitempty"` 2270} 2271 2272// MarshalJSON is the custom marshaler for WebhookPropertiesUpdateParameters. 2273func (wpup WebhookPropertiesUpdateParameters) MarshalJSON() ([]byte, error) { 2274 objectMap := make(map[string]interface{}) 2275 if wpup.ServiceURI != nil { 2276 objectMap["serviceUri"] = wpup.ServiceURI 2277 } 2278 if wpup.CustomHeaders != nil { 2279 objectMap["customHeaders"] = wpup.CustomHeaders 2280 } 2281 if wpup.Status != "" { 2282 objectMap["status"] = wpup.Status 2283 } 2284 if wpup.Scope != nil { 2285 objectMap["scope"] = wpup.Scope 2286 } 2287 if wpup.Actions != nil { 2288 objectMap["actions"] = wpup.Actions 2289 } 2290 return json.Marshal(objectMap) 2291} 2292 2293// WebhooksCreateFuture an abstraction for monitoring and retrieving the results of a long-running 2294// operation. 2295type WebhooksCreateFuture struct { 2296 azure.Future 2297} 2298 2299// Result returns the result of the asynchronous operation. 2300// If the operation has not completed it will return an error. 2301func (future *WebhooksCreateFuture) Result(client WebhooksClient) (w Webhook, err error) { 2302 var done bool 2303 done, err = future.DoneWithContext(context.Background(), client) 2304 if err != nil { 2305 err = autorest.NewErrorWithError(err, "containerregistry.WebhooksCreateFuture", "Result", future.Response(), "Polling failure") 2306 return 2307 } 2308 if !done { 2309 err = azure.NewAsyncOpIncompleteError("containerregistry.WebhooksCreateFuture") 2310 return 2311 } 2312 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 2313 if w.Response.Response, err = future.GetResult(sender); err == nil && w.Response.Response.StatusCode != http.StatusNoContent { 2314 w, err = client.CreateResponder(w.Response.Response) 2315 if err != nil { 2316 err = autorest.NewErrorWithError(err, "containerregistry.WebhooksCreateFuture", "Result", w.Response.Response, "Failure responding to request") 2317 } 2318 } 2319 return 2320} 2321 2322// WebhooksDeleteFuture an abstraction for monitoring and retrieving the results of a long-running 2323// operation. 2324type WebhooksDeleteFuture struct { 2325 azure.Future 2326} 2327 2328// Result returns the result of the asynchronous operation. 2329// If the operation has not completed it will return an error. 2330func (future *WebhooksDeleteFuture) Result(client WebhooksClient) (ar autorest.Response, err error) { 2331 var done bool 2332 done, err = future.DoneWithContext(context.Background(), client) 2333 if err != nil { 2334 err = autorest.NewErrorWithError(err, "containerregistry.WebhooksDeleteFuture", "Result", future.Response(), "Polling failure") 2335 return 2336 } 2337 if !done { 2338 err = azure.NewAsyncOpIncompleteError("containerregistry.WebhooksDeleteFuture") 2339 return 2340 } 2341 ar.Response = future.Response() 2342 return 2343} 2344 2345// WebhooksUpdateFuture an abstraction for monitoring and retrieving the results of a long-running 2346// operation. 2347type WebhooksUpdateFuture struct { 2348 azure.Future 2349} 2350 2351// Result returns the result of the asynchronous operation. 2352// If the operation has not completed it will return an error. 2353func (future *WebhooksUpdateFuture) Result(client WebhooksClient) (w Webhook, err error) { 2354 var done bool 2355 done, err = future.DoneWithContext(context.Background(), client) 2356 if err != nil { 2357 err = autorest.NewErrorWithError(err, "containerregistry.WebhooksUpdateFuture", "Result", future.Response(), "Polling failure") 2358 return 2359 } 2360 if !done { 2361 err = azure.NewAsyncOpIncompleteError("containerregistry.WebhooksUpdateFuture") 2362 return 2363 } 2364 sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) 2365 if w.Response.Response, err = future.GetResult(sender); err == nil && w.Response.Response.StatusCode != http.StatusNoContent { 2366 w, err = client.UpdateResponder(w.Response.Response) 2367 if err != nil { 2368 err = autorest.NewErrorWithError(err, "containerregistry.WebhooksUpdateFuture", "Result", w.Response.Response, "Failure responding to request") 2369 } 2370 } 2371 return 2372} 2373 2374// WebhookUpdateParameters the parameters for updating a webhook. 2375type WebhookUpdateParameters struct { 2376 // Tags - The tags for the webhook. 2377 Tags map[string]*string `json:"tags"` 2378 // WebhookPropertiesUpdateParameters - The properties that the webhook will be updated with. 2379 *WebhookPropertiesUpdateParameters `json:"properties,omitempty"` 2380} 2381 2382// MarshalJSON is the custom marshaler for WebhookUpdateParameters. 2383func (wup WebhookUpdateParameters) MarshalJSON() ([]byte, error) { 2384 objectMap := make(map[string]interface{}) 2385 if wup.Tags != nil { 2386 objectMap["tags"] = wup.Tags 2387 } 2388 if wup.WebhookPropertiesUpdateParameters != nil { 2389 objectMap["properties"] = wup.WebhookPropertiesUpdateParameters 2390 } 2391 return json.Marshal(objectMap) 2392} 2393 2394// UnmarshalJSON is the custom unmarshaler for WebhookUpdateParameters struct. 2395func (wup *WebhookUpdateParameters) UnmarshalJSON(body []byte) error { 2396 var m map[string]*json.RawMessage 2397 err := json.Unmarshal(body, &m) 2398 if err != nil { 2399 return err 2400 } 2401 for k, v := range m { 2402 switch k { 2403 case "tags": 2404 if v != nil { 2405 var tags map[string]*string 2406 err = json.Unmarshal(*v, &tags) 2407 if err != nil { 2408 return err 2409 } 2410 wup.Tags = tags 2411 } 2412 case "properties": 2413 if v != nil { 2414 var webhookPropertiesUpdateParameters WebhookPropertiesUpdateParameters 2415 err = json.Unmarshal(*v, &webhookPropertiesUpdateParameters) 2416 if err != nil { 2417 return err 2418 } 2419 wup.WebhookPropertiesUpdateParameters = &webhookPropertiesUpdateParameters 2420 } 2421 } 2422 } 2423 2424 return nil 2425} 2426