diff --git a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/client.go b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/client.go index 8d9d8f1ad809..6a100d585e60 100644 --- a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/client.go +++ b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/client.go @@ -21,32 +21,32 @@ package containerregistry // Changes may cause incorrect behavior and will be lost if the code is regenerated. import ( - "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest" ) const ( - // DefaultBaseURI is the default URI used for the service Containerregistry - DefaultBaseURI = "https://management.azure.com" -) +// DefaultBaseURI is the default URI used for the service Containerregistry +DefaultBaseURI = "https://management.azure.com") // BaseClient is the base client for Containerregistry. type BaseClient struct { - autorest.Client - BaseURI string - SubscriptionID string + autorest.Client + BaseURI string + SubscriptionID string } // New creates an instance of the BaseClient client. -func New(subscriptionID string) BaseClient { - return NewWithBaseURI(DefaultBaseURI, subscriptionID) +func New(subscriptionID string)BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) } // NewWithBaseURI creates an instance of the BaseClient client using a custom endpoint. Use this when interacting with // an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { - return BaseClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - SubscriptionID: subscriptionID, - } + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } } + diff --git a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/containerregistryapi/interfaces.go b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/containerregistryapi/interfaces.go index 75d9a34b0f90..af73f8355fc1 100644 --- a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/containerregistryapi/interfaces.go +++ b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/containerregistryapi/interfaces.go @@ -18,60 +18,57 @@ package containerregistryapi // Changes may cause incorrect behavior and will be lost if the code is regenerated. import ( - "context" - "github.com/Azure/azure-sdk-for-go/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry" + "context" + "github.com/Azure/azure-sdk-for-go/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry" ) -// RegistriesClientAPI contains the set of methods on the RegistriesClient type. -type RegistriesClientAPI interface { - CheckNameAvailability(ctx context.Context, registryNameCheckRequest containerregistry.RegistryNameCheckRequest) (result containerregistry.RegistryNameStatus, err error) - Create(ctx context.Context, resourceGroupName string, registryName string, registry containerregistry.Registry) (result containerregistry.RegistriesCreateFuture, err error) - Delete(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.RegistriesDeleteFuture, err error) - Get(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.Registry, err error) - List(ctx context.Context) (result containerregistry.RegistryListResultPage, err error) - ListComplete(ctx context.Context) (result containerregistry.RegistryListResultIterator, err error) - ListByResourceGroup(ctx context.Context, resourceGroupName string) (result containerregistry.RegistryListResultPage, err error) - ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result containerregistry.RegistryListResultIterator, err error) - ListCredentials(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.RegistryListCredentialsResult, err error) - ListUsages(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.RegistryUsageListResult, err error) - RegenerateCredential(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters containerregistry.RegenerateCredentialParameters) (result containerregistry.RegistryListCredentialsResult, err error) - Update(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters containerregistry.RegistryUpdateParameters) (result containerregistry.RegistriesUpdateFuture, err error) -} + // RegistriesClientAPI contains the set of methods on the RegistriesClient type. + type RegistriesClientAPI interface { + CheckNameAvailability(ctx context.Context, registryNameCheckRequest containerregistry.RegistryNameCheckRequest) (result containerregistry.RegistryNameStatus, err error) + Create(ctx context.Context, resourceGroupName string, registryName string, registry containerregistry.Registry) (result containerregistry.RegistriesCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.RegistriesDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.Registry, err error) + List(ctx context.Context) (result containerregistry.RegistryListResultPage, err error) + ListComplete(ctx context.Context) (result containerregistry.RegistryListResultIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result containerregistry.RegistryListResultPage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result containerregistry.RegistryListResultIterator, err error) + ListCredentials(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.RegistryListCredentialsResult, err error) + ListUsages(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.RegistryUsageListResult, err error) + RegenerateCredential(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters containerregistry.RegenerateCredentialParameters) (result containerregistry.RegistryListCredentialsResult, err error) + Update(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters containerregistry.RegistryUpdateParameters) (result containerregistry.RegistriesUpdateFuture, err error) + } -var _ RegistriesClientAPI = (*containerregistry.RegistriesClient)(nil) + var _ RegistriesClientAPI = (*containerregistry.RegistriesClient)(nil) + // OperationsClientAPI contains the set of methods on the OperationsClient type. + type OperationsClientAPI interface { + List(ctx context.Context) (result containerregistry.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result containerregistry.OperationListResultIterator, err error) + } -// OperationsClientAPI contains the set of methods on the OperationsClient type. -type OperationsClientAPI interface { - List(ctx context.Context) (result containerregistry.OperationListResultPage, err error) - ListComplete(ctx context.Context) (result containerregistry.OperationListResultIterator, err error) -} + var _ OperationsClientAPI = (*containerregistry.OperationsClient)(nil) + // ReplicationsClientAPI contains the set of methods on the ReplicationsClient type. + type ReplicationsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replication containerregistry.Replication) (result containerregistry.ReplicationsCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, registryName string, replicationName string) (result containerregistry.ReplicationsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, registryName string, replicationName string) (result containerregistry.Replication, err error) + List(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.ReplicationListResultPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.ReplicationListResultIterator, err error) + Update(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replicationUpdateParameters containerregistry.ReplicationUpdateParameters) (result containerregistry.ReplicationsUpdateFuture, err error) + } -var _ OperationsClientAPI = (*containerregistry.OperationsClient)(nil) + var _ ReplicationsClientAPI = (*containerregistry.ReplicationsClient)(nil) + // WebhooksClientAPI contains the set of methods on the WebhooksClient type. + type WebhooksClientAPI interface { + Create(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookCreateParameters containerregistry.WebhookCreateParameters) (result containerregistry.WebhooksCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result containerregistry.WebhooksDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result containerregistry.Webhook, err error) + GetCallbackConfig(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result containerregistry.CallbackConfig, err error) + List(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.WebhookListResultPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.WebhookListResultIterator, err error) + ListEvents(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result containerregistry.EventListResultPage, err error) + ListEventsComplete(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result containerregistry.EventListResultIterator, err error) + Ping(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result containerregistry.EventInfo, err error) + Update(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookUpdateParameters containerregistry.WebhookUpdateParameters) (result containerregistry.WebhooksUpdateFuture, err error) + } -// ReplicationsClientAPI contains the set of methods on the ReplicationsClient type. -type ReplicationsClientAPI interface { - Create(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replication containerregistry.Replication) (result containerregistry.ReplicationsCreateFuture, err error) - Delete(ctx context.Context, resourceGroupName string, registryName string, replicationName string) (result containerregistry.ReplicationsDeleteFuture, err error) - Get(ctx context.Context, resourceGroupName string, registryName string, replicationName string) (result containerregistry.Replication, err error) - List(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.ReplicationListResultPage, err error) - ListComplete(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.ReplicationListResultIterator, err error) - Update(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replicationUpdateParameters containerregistry.ReplicationUpdateParameters) (result containerregistry.ReplicationsUpdateFuture, err error) -} - -var _ ReplicationsClientAPI = (*containerregistry.ReplicationsClient)(nil) - -// WebhooksClientAPI contains the set of methods on the WebhooksClient type. -type WebhooksClientAPI interface { - Create(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookCreateParameters containerregistry.WebhookCreateParameters) (result containerregistry.WebhooksCreateFuture, err error) - Delete(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result containerregistry.WebhooksDeleteFuture, err error) - Get(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result containerregistry.Webhook, err error) - GetCallbackConfig(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result containerregistry.CallbackConfig, err error) - List(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.WebhookListResultPage, err error) - ListComplete(ctx context.Context, resourceGroupName string, registryName string) (result containerregistry.WebhookListResultIterator, err error) - ListEvents(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result containerregistry.EventListResultPage, err error) - ListEventsComplete(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result containerregistry.EventListResultIterator, err error) - Ping(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result containerregistry.EventInfo, err error) - Update(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookUpdateParameters containerregistry.WebhookUpdateParameters) (result containerregistry.WebhooksUpdateFuture, err error) -} - -var _ WebhooksClientAPI = (*containerregistry.WebhooksClient)(nil) + var _ WebhooksClientAPI = (*containerregistry.WebhooksClient)(nil) diff --git a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/models.go b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/models.go index 3db0ef8d247e..c8ba79e300fe 100644 --- a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/models.go +++ b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/models.go @@ -18,2044 +18,1978 @@ package containerregistry // Changes may cause incorrect behavior and will be lost if the code is regenerated. import ( - "context" - "encoding/json" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/date" - "github.com/Azure/go-autorest/autorest/to" - "github.com/Azure/go-autorest/tracing" - "net/http" + "context" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/date" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" ) // The package's fully qualified name. const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry" -// PasswordName enumerates the values for password name. -type PasswordName string + // PasswordName enumerates the values for password name. + type PasswordName string + + const ( + // Password ... + Password PasswordName = "password" + // Password2 ... + Password2 PasswordName = "password2" + ) + // PossiblePasswordNameValues returns an array of possible values for the PasswordName const type. + func PossiblePasswordNameValues() []PasswordName { + return []PasswordName{Password,Password2} + } + + // ProvisioningState enumerates the values for provisioning state. + type ProvisioningState string + + const ( + // Canceled ... + Canceled ProvisioningState = "Canceled" + // Creating ... + Creating ProvisioningState = "Creating" + // Deleting ... + Deleting ProvisioningState = "Deleting" + // Failed ... + Failed ProvisioningState = "Failed" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" + // Updating ... + Updating ProvisioningState = "Updating" + ) + // PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. + func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Canceled,Creating,Deleting,Failed,Succeeded,Updating} + } + + // RegistryUsageUnit enumerates the values for registry usage unit. + type RegistryUsageUnit string + + const ( + // Bytes ... + Bytes RegistryUsageUnit = "Bytes" + // Count ... + Count RegistryUsageUnit = "Count" + ) + // PossibleRegistryUsageUnitValues returns an array of possible values for the RegistryUsageUnit const type. + func PossibleRegistryUsageUnitValues() []RegistryUsageUnit { + return []RegistryUsageUnit{Bytes,Count} + } + + // SkuName enumerates the values for sku name. + type SkuName string + + const ( + // Basic ... + Basic SkuName = "Basic" + // ManagedBasic ... + ManagedBasic SkuName = "Managed_Basic" + // ManagedPremium ... + ManagedPremium SkuName = "Managed_Premium" + // ManagedStandard ... + ManagedStandard SkuName = "Managed_Standard" + ) + // PossibleSkuNameValues returns an array of possible values for the SkuName const type. + func PossibleSkuNameValues() []SkuName { + return []SkuName{Basic,ManagedBasic,ManagedPremium,ManagedStandard} + } + + // SkuTier enumerates the values for sku tier. + type SkuTier string + + const ( + // SkuTierBasic ... + SkuTierBasic SkuTier = "Basic" + // SkuTierManaged ... + SkuTierManaged SkuTier = "Managed" + ) + // PossibleSkuTierValues returns an array of possible values for the SkuTier const type. + func PossibleSkuTierValues() []SkuTier { + return []SkuTier{SkuTierBasic,SkuTierManaged} + } + + // WebhookAction enumerates the values for webhook action. + type WebhookAction string + + const ( + // Delete ... + Delete WebhookAction = "delete" + // Push ... + Push WebhookAction = "push" + ) + // PossibleWebhookActionValues returns an array of possible values for the WebhookAction const type. + func PossibleWebhookActionValues() []WebhookAction { + return []WebhookAction{Delete,Push} + } + + // WebhookStatus enumerates the values for webhook status. + type WebhookStatus string + + const ( + // Disabled ... + Disabled WebhookStatus = "disabled" + // Enabled ... + Enabled WebhookStatus = "enabled" + ) + // PossibleWebhookStatusValues returns an array of possible values for the WebhookStatus const type. + func PossibleWebhookStatusValues() []WebhookStatus { + return []WebhookStatus{Disabled,Enabled} + } + + // Actor the agent that initiated the event. For most situations, this could be from the authorization + // context of the request. + type Actor struct { + // Name - The subject or username associated with the request context that generated the event. + Name *string `json:"name,omitempty"` + } + + // CallbackConfig the configuration of service URI and custom headers for the webhook. + type CallbackConfig struct { + autorest.Response `json:"-"` + // ServiceURI - The service URI for the webhook to post notifications. + ServiceURI *string `json:"serviceUri,omitempty"` + // CustomHeaders - Custom headers that will be added to the webhook notifications. + CustomHeaders map[string]*string `json:"customHeaders"` + } + + // MarshalJSON is the custom marshaler for CallbackConfig. + func (cc CallbackConfig)MarshalJSON() ([]byte, error){ + objectMap := make(map[string]interface{}) + if(cc.ServiceURI != nil) { + objectMap["serviceUri"] = cc.ServiceURI + } + if(cc.CustomHeaders != nil) { + objectMap["customHeaders"] = cc.CustomHeaders + } + return json.Marshal(objectMap) + } + + // Event the event for a webhook. + type Event struct { + // EventRequestMessage - The event request message sent to the service URI. + EventRequestMessage *EventRequestMessage `json:"eventRequestMessage,omitempty"` + // EventResponseMessage - The event response message received from the service URI. + EventResponseMessage *EventResponseMessage `json:"eventResponseMessage,omitempty"` + // ID - The event ID. + ID *string `json:"id,omitempty"` + } + + // EventContent the content of the event request message. + type EventContent struct { + // ID - The event ID. + ID *string `json:"id,omitempty"` + // Timestamp - The time at which the event occurred. + Timestamp *date.Time `json:"timestamp,omitempty"` + // Action - The action that encompasses the provided event. + Action *string `json:"action,omitempty"` + // Target - The target of the event. + Target *Target `json:"target,omitempty"` + // Request - The request that generated the event. + Request *Request `json:"request,omitempty"` + // Actor - The agent that initiated the event. For most situations, this could be from the authorization context of the request. + Actor *Actor `json:"actor,omitempty"` + // Source - The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. + Source *Source `json:"source,omitempty"` + } + + // EventInfo the basic information of an event. + type EventInfo struct { + autorest.Response `json:"-"` + // ID - The event ID. + ID *string `json:"id,omitempty"` + } + + // EventListResult the result of a request to list events for a webhook. + type EventListResult struct { + autorest.Response `json:"-"` + // Value - The list of events. Since this list may be incomplete, the nextLink field should be used to request the next list of events. + Value *[]Event `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next list of events. + NextLink *string `json:"nextLink,omitempty"` + } + + // EventListResultIterator provides access to a complete listing of Event values. + type EventListResultIterator struct { + i int + page EventListResultPage + } + // NextWithContext advances to the next value. If there was an error making + // the request the iterator does not advance and the error is returned. + func (iter * EventListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/EventListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter. page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter. i-- + return err + } + iter.i = 0 + return nil + } + // Next advances to the next value. If there was an error making + // the request the iterator does not advance and the error is returned. + // Deprecated: Use NextWithContext() instead. + func (iter * EventListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) + } + // NotDone returns true if the enumeration should be started or is not yet complete. + func (iter EventListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter. page.Values()) + } + // Response returns the raw server response from the last page request. + func (iter EventListResultIterator) Response() EventListResult { + return iter.page.Response() + } + // Value returns the current value or a zero-initialized value if the + // iterator has advanced beyond the end of the collection. + func (iter EventListResultIterator) Value() Event { + if !iter.page.NotDone() { + return Event{} + } + return iter.page.Values()[iter.i] + } + // Creates a new instance of the EventListResultIterator type. + func NewEventListResultIterator (page EventListResultPage) EventListResultIterator { + return EventListResultIterator{page: page} + } + + + // IsEmpty returns true if the ListResult contains no values. + func (elr EventListResult) IsEmpty() bool { + return elr.Value == nil || len(*elr.Value) == 0 + } + + // eventListResultPreparer prepares a request to retrieve the next set of results. + // It returns nil if no more results exist. + func (elr EventListResult) eventListResultPreparer(ctx context.Context) (*http.Request, error) { + if elr.NextLink == nil || len(to.String(elr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String( elr.NextLink))); + } + + // EventListResultPage contains a page of Event values. + type EventListResultPage struct { + fn func(context.Context, EventListResult) (EventListResult, error) + elr EventListResult + } + + // NextWithContext advances to the next page of values. If there was an error making + // the request the page does not advance and the error is returned. + func (page * EventListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/EventListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.elr) + if err != nil { + return err + } + page.elr = next + return nil + } + + // Next advances to the next page of values. If there was an error making + // the request the page does not advance and the error is returned. + // Deprecated: Use NextWithContext() instead. + func (page * EventListResultPage) Next() error { + return page.NextWithContext(context.Background()) + } + // NotDone returns true if the page enumeration should be started or is not yet complete. + func (page EventListResultPage) NotDone() bool { + return !page.elr.IsEmpty() + } + // Response returns the raw server response from the last page request. + func (page EventListResultPage) Response() EventListResult { + return page.elr + } + // Values returns the slice of values for the current page or nil if there are no values. + func (page EventListResultPage) Values() []Event { + if page.elr.IsEmpty() { + return nil + } + return *page.elr.Value + } + // Creates a new instance of the EventListResultPage type. + func NewEventListResultPage (getNextPage func(context.Context, EventListResult) (EventListResult, error)) EventListResultPage { + return EventListResultPage{fn: getNextPage} + } + + // EventRequestMessage the event request message sent to the service URI. + type EventRequestMessage struct { + // Content - The content of the event request message. + Content *EventContent `json:"content,omitempty"` + // Headers - The headers of the event request message. + Headers map[string]*string `json:"headers"` + // Method - The HTTP method used to send the event request message. + Method *string `json:"method,omitempty"` + // RequestURI - The URI used to send the event request message. + RequestURI *string `json:"requestUri,omitempty"` + // Version - The HTTP message version. + Version *string `json:"version,omitempty"` + } + + // MarshalJSON is the custom marshaler for EventRequestMessage. + func (erm EventRequestMessage)MarshalJSON() ([]byte, error){ + objectMap := make(map[string]interface{}) + if(erm.Content != nil) { + objectMap["content"] = erm.Content + } + if(erm.Headers != nil) { + objectMap["headers"] = erm.Headers + } + if(erm.Method != nil) { + objectMap["method"] = erm.Method + } + if(erm.RequestURI != nil) { + objectMap["requestUri"] = erm.RequestURI + } + if(erm.Version != nil) { + objectMap["version"] = erm.Version + } + return json.Marshal(objectMap) + } + + // EventResponseMessage the event response message received from the service URI. + type EventResponseMessage struct { + // Content - The content of the event response message. + Content *string `json:"content,omitempty"` + // Headers - The headers of the event response message. + Headers map[string]*string `json:"headers"` + // ReasonPhrase - The reason phrase of the event response message. + ReasonPhrase *string `json:"reasonPhrase,omitempty"` + // StatusCode - The status code of the event response message. + StatusCode *string `json:"statusCode,omitempty"` + // Version - The HTTP message version. + Version *string `json:"version,omitempty"` + } + + // MarshalJSON is the custom marshaler for EventResponseMessage. + func (erm EventResponseMessage)MarshalJSON() ([]byte, error){ + objectMap := make(map[string]interface{}) + if(erm.Content != nil) { + objectMap["content"] = erm.Content + } + if(erm.Headers != nil) { + objectMap["headers"] = erm.Headers + } + if(erm.ReasonPhrase != nil) { + objectMap["reasonPhrase"] = erm.ReasonPhrase + } + if(erm.StatusCode != nil) { + objectMap["statusCode"] = erm.StatusCode + } + if(erm.Version != nil) { + objectMap["version"] = erm.Version + } + return json.Marshal(objectMap) + } + + // OperationDefinition the definition of a container registry operation. + type OperationDefinition struct { + // Name - Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + // Display - The display information for the container registry operation. + Display *OperationDisplayDefinition `json:"display,omitempty"` + } + + // OperationDisplayDefinition the display information for a container registry operation. + type OperationDisplayDefinition struct { + // Provider - The resource provider name: Microsoft.ContainerRegistry. + Provider *string `json:"provider,omitempty"` + // Resource - The resource on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - The operation that users can perform. + Operation *string `json:"operation,omitempty"` + // Description - The description for the operation. + Description *string `json:"description,omitempty"` + } + + // OperationListResult the result of a request to list container registry operations. + type OperationListResult struct { + autorest.Response `json:"-"` + // 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. + Value *[]OperationDefinition `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next list of container registry operations. + NextLink *string `json:"nextLink,omitempty"` + } + + // OperationListResultIterator provides access to a complete listing of OperationDefinition values. + type OperationListResultIterator struct { + i int + page OperationListResultPage + } + // NextWithContext advances to the next value. If there was an error making + // the request the iterator does not advance and the error is returned. + func (iter * OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/OperationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter. page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter. i-- + return err + } + iter.i = 0 + return nil + } + // Next advances to the next value. If there was an error making + // the request the iterator does not advance and the error is returned. + // Deprecated: Use NextWithContext() instead. + func (iter * OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) + } + // NotDone returns true if the enumeration should be started or is not yet complete. + func (iter OperationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter. page.Values()) + } + // Response returns the raw server response from the last page request. + func (iter OperationListResultIterator) Response() OperationListResult { + return iter.page.Response() + } + // Value returns the current value or a zero-initialized value if the + // iterator has advanced beyond the end of the collection. + func (iter OperationListResultIterator) Value() OperationDefinition { + if !iter.page.NotDone() { + return OperationDefinition{} + } + return iter.page.Values()[iter.i] + } + // Creates a new instance of the OperationListResultIterator type. + func NewOperationListResultIterator (page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} + } + + + // IsEmpty returns true if the ListResult contains no values. + func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 + } + + // operationListResultPreparer prepares a request to retrieve the next set of results. + // It returns nil if no more results exist. + func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String( olr.NextLink))); + } + + // OperationListResultPage contains a page of OperationDefinition values. + type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult + } + + // NextWithContext advances to the next page of values. If there was an error making + // the request the page does not advance and the error is returned. + func (page * OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/OperationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + return nil + } + + // Next advances to the next page of values. If there was an error making + // the request the page does not advance and the error is returned. + // Deprecated: Use NextWithContext() instead. + func (page * OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) + } + // NotDone returns true if the page enumeration should be started or is not yet complete. + func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() + } + // Response returns the raw server response from the last page request. + func (page OperationListResultPage) Response() OperationListResult { + return page.olr + } + // Values returns the slice of values for the current page or nil if there are no values. + func (page OperationListResultPage) Values() []OperationDefinition { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value + } + // Creates a new instance of the OperationListResultPage type. + func NewOperationListResultPage (getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{fn: getNextPage} + } + + // RegenerateCredentialParameters the parameters used to regenerate the login credential. + type RegenerateCredentialParameters struct { + // Name - Specifies name of the password which should be regenerated -- password or password2. Possible values include: 'Password', 'Password2' + Name PasswordName `json:"name,omitempty"` + } + + // RegistriesCreateFuture an abstraction for monitoring and retrieving the results of a long-running + // operation. + type RegistriesCreateFuture struct { + azure.Future + } + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + func (future *RegistriesCreateFuture) Result(client RegistriesClient) (r Registry, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("containerregistry.RegistriesCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if r.Response.Response, err = future.GetResult(sender); err == nil && r.Response.Response.StatusCode != http.StatusNoContent { + r, err = client.CreateResponder(r.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesCreateFuture", "Result", r.Response.Response, "Failure responding to request") + } + } + return + } + + // RegistriesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running + // operation. + type RegistriesDeleteFuture struct { + azure.Future + } + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + func (future *RegistriesDeleteFuture) Result(client RegistriesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("containerregistry.RegistriesDeleteFuture") + return + } + ar.Response = future.Response() + return + } + + // RegistriesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running + // operation. + type RegistriesUpdateFuture struct { + azure.Future + } + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + func (future *RegistriesUpdateFuture) Result(client RegistriesClient) (r Registry, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("containerregistry.RegistriesUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if r.Response.Response, err = future.GetResult(sender); err == nil && r.Response.Response.StatusCode != http.StatusNoContent { + r, err = client.UpdateResponder(r.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesUpdateFuture", "Result", r.Response.Response, "Failure responding to request") + } + } + return + } + + // Registry an object that represents a container registry. + type Registry struct { + autorest.Response `json:"-"` + // Sku - The SKU of the container registry. + Sku *Sku `json:"sku,omitempty"` + // RegistryProperties - The properties of the container registry. + *RegistryProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource. This cannot be changed after the resource is created. + Location *string `json:"location,omitempty"` + // Tags - The tags of the resource. + Tags map[string]*string `json:"tags"` + } + + // MarshalJSON is the custom marshaler for Registry. + func (r Registry)MarshalJSON() ([]byte, error){ + objectMap := make(map[string]interface{}) + if(r.Sku != nil) { + objectMap["sku"] = r.Sku + } + if(r.RegistryProperties != nil) { + objectMap["properties"] = r.RegistryProperties + } + if(r.Location != nil) { + objectMap["location"] = r.Location + } + if(r.Tags != nil) { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) + } + // UnmarshalJSON is the custom unmarshaler for Registry struct. + func (r *Registry) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + r.Sku = &sku + } + case "properties": + if v != nil { + var registryProperties RegistryProperties + err = json.Unmarshal(*v, ®istryProperties) + if err != nil { + return err + } + r.RegistryProperties = ®istryProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + r.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + r.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + r.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + r.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + r.Tags = tags + } + } + } + + return nil + } + + // RegistryListCredentialsResult the response from the ListCredentials operation. + type RegistryListCredentialsResult struct { + autorest.Response `json:"-"` + // Username - The username for a container registry. + Username *string `json:"username,omitempty"` + // Passwords - The list of passwords for a container registry. + Passwords *[]RegistryPassword `json:"passwords,omitempty"` + } + + // RegistryListResult the result of a request to list container registries. + type RegistryListResult struct { + autorest.Response `json:"-"` + // 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. + Value *[]Registry `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next list of container registries. + NextLink *string `json:"nextLink,omitempty"` + } + + // RegistryListResultIterator provides access to a complete listing of Registry values. + type RegistryListResultIterator struct { + i int + page RegistryListResultPage + } + // NextWithContext advances to the next value. If there was an error making + // the request the iterator does not advance and the error is returned. + func (iter * RegistryListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/RegistryListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter. page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter. i-- + return err + } + iter.i = 0 + return nil + } + // Next advances to the next value. If there was an error making + // the request the iterator does not advance and the error is returned. + // Deprecated: Use NextWithContext() instead. + func (iter * RegistryListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) + } + // NotDone returns true if the enumeration should be started or is not yet complete. + func (iter RegistryListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter. page.Values()) + } + // Response returns the raw server response from the last page request. + func (iter RegistryListResultIterator) Response() RegistryListResult { + return iter.page.Response() + } + // Value returns the current value or a zero-initialized value if the + // iterator has advanced beyond the end of the collection. + func (iter RegistryListResultIterator) Value() Registry { + if !iter.page.NotDone() { + return Registry{} + } + return iter.page.Values()[iter.i] + } + // Creates a new instance of the RegistryListResultIterator type. + func NewRegistryListResultIterator (page RegistryListResultPage) RegistryListResultIterator { + return RegistryListResultIterator{page: page} + } + + + // IsEmpty returns true if the ListResult contains no values. + func (rlr RegistryListResult) IsEmpty() bool { + return rlr.Value == nil || len(*rlr.Value) == 0 + } + + // registryListResultPreparer prepares a request to retrieve the next set of results. + // It returns nil if no more results exist. + func (rlr RegistryListResult) registryListResultPreparer(ctx context.Context) (*http.Request, error) { + if rlr.NextLink == nil || len(to.String(rlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String( rlr.NextLink))); + } + + // RegistryListResultPage contains a page of Registry values. + type RegistryListResultPage struct { + fn func(context.Context, RegistryListResult) (RegistryListResult, error) + rlr RegistryListResult + } + + // NextWithContext advances to the next page of values. If there was an error making + // the request the page does not advance and the error is returned. + func (page * RegistryListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/RegistryListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rlr) + if err != nil { + return err + } + page.rlr = next + return nil + } + + // Next advances to the next page of values. If there was an error making + // the request the page does not advance and the error is returned. + // Deprecated: Use NextWithContext() instead. + func (page * RegistryListResultPage) Next() error { + return page.NextWithContext(context.Background()) + } + // NotDone returns true if the page enumeration should be started or is not yet complete. + func (page RegistryListResultPage) NotDone() bool { + return !page.rlr.IsEmpty() + } + // Response returns the raw server response from the last page request. + func (page RegistryListResultPage) Response() RegistryListResult { + return page.rlr + } + // Values returns the slice of values for the current page or nil if there are no values. + func (page RegistryListResultPage) Values() []Registry { + if page.rlr.IsEmpty() { + return nil + } + return *page.rlr.Value + } + // Creates a new instance of the RegistryListResultPage type. + func NewRegistryListResultPage (getNextPage func(context.Context, RegistryListResult) (RegistryListResult, error)) RegistryListResultPage { + return RegistryListResultPage{fn: getNextPage} + } + + // RegistryNameCheckRequest a request to check whether a container registry name is available. + type RegistryNameCheckRequest struct { + // Name - The name of the container registry. + Name *string `json:"name,omitempty"` + // Type - The resource type of the container registry. This field must be set to 'Microsoft.ContainerRegistry/registries'. + Type *string `json:"type,omitempty"` + } + + // RegistryNameStatus the result of a request to check the availability of a container registry name. + type RegistryNameStatus struct { + autorest.Response `json:"-"` + // NameAvailable - The value that indicates whether the name is available. + NameAvailable *bool `json:"nameAvailable,omitempty"` + // Reason - If any, the reason that the name is not available. + Reason *string `json:"reason,omitempty"` + // Message - If any, the error message that provides more detail for the reason that the name is not available. + Message *string `json:"message,omitempty"` + } + + // RegistryPassword the login password for the container registry. + type RegistryPassword struct { + // Name - The password name. Possible values include: 'Password', 'Password2' + Name PasswordName `json:"name,omitempty"` + // Value - The password value. + Value *string `json:"value,omitempty"` + } + + // RegistryProperties the properties of a container registry. + type RegistryProperties struct { + // LoginServer - READ-ONLY; The URL that can be used to log into the container registry. + LoginServer *string `json:"loginServer,omitempty"` + // CreationDate - READ-ONLY; The creation date of the container registry in ISO8601 format. + CreationDate *date.Time `json:"creationDate,omitempty"` + // 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' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // Status - READ-ONLY; The status of the container registry at the time the operation was called. + Status *Status `json:"status,omitempty"` + // AdminUserEnabled - The value that indicates whether the admin user is enabled. + AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` + // StorageAccount - The properties of the storage account for the container registry. Only applicable to Basic SKU. + StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` + } + + // RegistryPropertiesUpdateParameters the parameters for updating the properties of a container registry. + type RegistryPropertiesUpdateParameters struct { + // AdminUserEnabled - The value that indicates whether the admin user is enabled. + AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` + // StorageAccount - The parameters of a storage account for the container registry. Only applicable to Basic SKU. If specified, the storage account must be in the same physical location as the container registry. + StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` + } + + // RegistryUpdateParameters the parameters for updating a container registry. + type RegistryUpdateParameters struct { + // Tags - The tags for the container registry. + Tags map[string]*string `json:"tags"` + // Sku - The SKU of the container registry. + Sku *Sku `json:"sku,omitempty"` + // RegistryPropertiesUpdateParameters - The properties that the container registry will be updated with. + *RegistryPropertiesUpdateParameters `json:"properties,omitempty"` + } + + // MarshalJSON is the custom marshaler for RegistryUpdateParameters. + func (rup RegistryUpdateParameters)MarshalJSON() ([]byte, error){ + objectMap := make(map[string]interface{}) + if(rup.Tags != nil) { + objectMap["tags"] = rup.Tags + } + if(rup.Sku != nil) { + objectMap["sku"] = rup.Sku + } + if(rup.RegistryPropertiesUpdateParameters != nil) { + objectMap["properties"] = rup.RegistryPropertiesUpdateParameters + } + return json.Marshal(objectMap) + } + // UnmarshalJSON is the custom unmarshaler for RegistryUpdateParameters struct. + func (rup *RegistryUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + rup.Tags = tags + } + case "sku": + if v != nil { + var sku Sku + err = json.Unmarshal(*v, &sku) + if err != nil { + return err + } + rup.Sku = &sku + } + case "properties": + if v != nil { + var registryPropertiesUpdateParameters RegistryPropertiesUpdateParameters + err = json.Unmarshal(*v, ®istryPropertiesUpdateParameters) + if err != nil { + return err + } + rup.RegistryPropertiesUpdateParameters = ®istryPropertiesUpdateParameters + } + } + } + + return nil + } + + // RegistryUsage the quota usage for a container registry. + type RegistryUsage struct { + // Name - The name of the usage. + Name *string `json:"name,omitempty"` + // Limit - The limit of the usage. + Limit *int64 `json:"limit,omitempty"` + // CurrentValue - The current value of the usage. + CurrentValue *int64 `json:"currentValue,omitempty"` + // Unit - The unit of measurement. Possible values include: 'Count', 'Bytes' + Unit RegistryUsageUnit `json:"unit,omitempty"` + } + + // RegistryUsageListResult the result of a request to get container registry quota usages. + type RegistryUsageListResult struct { + autorest.Response `json:"-"` + // Value - The list of container registry quota usages. + Value *[]RegistryUsage `json:"value,omitempty"` + } + + // Replication an object that represents a replication for a container registry. + type Replication struct { + autorest.Response `json:"-"` + // ReplicationProperties - The properties of the replication. + *ReplicationProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource. This cannot be changed after the resource is created. + Location *string `json:"location,omitempty"` + // Tags - The tags of the resource. + Tags map[string]*string `json:"tags"` + } + + // MarshalJSON is the custom marshaler for Replication. + func (r Replication)MarshalJSON() ([]byte, error){ + objectMap := make(map[string]interface{}) + if(r.ReplicationProperties != nil) { + objectMap["properties"] = r.ReplicationProperties + } + if(r.Location != nil) { + objectMap["location"] = r.Location + } + if(r.Tags != nil) { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) + } + // UnmarshalJSON is the custom unmarshaler for Replication struct. + func (r *Replication) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var replicationProperties ReplicationProperties + err = json.Unmarshal(*v, &replicationProperties) + if err != nil { + return err + } + r.ReplicationProperties = &replicationProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + r.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + r.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + r.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + r.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + r.Tags = tags + } + } + } + + return nil + } + + // ReplicationListResult the result of a request to list replications for a container registry. + type ReplicationListResult struct { + autorest.Response `json:"-"` + // Value - The list of replications. Since this list may be incomplete, the nextLink field should be used to request the next list of replications. + Value *[]Replication `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next list of replications. + NextLink *string `json:"nextLink,omitempty"` + } + + // ReplicationListResultIterator provides access to a complete listing of Replication values. + type ReplicationListResultIterator struct { + i int + page ReplicationListResultPage + } + // NextWithContext advances to the next value. If there was an error making + // the request the iterator does not advance and the error is returned. + func (iter * ReplicationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/ReplicationListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter. page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter. i-- + return err + } + iter.i = 0 + return nil + } + // Next advances to the next value. If there was an error making + // the request the iterator does not advance and the error is returned. + // Deprecated: Use NextWithContext() instead. + func (iter * ReplicationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) + } + // NotDone returns true if the enumeration should be started or is not yet complete. + func (iter ReplicationListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter. page.Values()) + } + // Response returns the raw server response from the last page request. + func (iter ReplicationListResultIterator) Response() ReplicationListResult { + return iter.page.Response() + } + // Value returns the current value or a zero-initialized value if the + // iterator has advanced beyond the end of the collection. + func (iter ReplicationListResultIterator) Value() Replication { + if !iter.page.NotDone() { + return Replication{} + } + return iter.page.Values()[iter.i] + } + // Creates a new instance of the ReplicationListResultIterator type. + func NewReplicationListResultIterator (page ReplicationListResultPage) ReplicationListResultIterator { + return ReplicationListResultIterator{page: page} + } + + + // IsEmpty returns true if the ListResult contains no values. + func (rlr ReplicationListResult) IsEmpty() bool { + return rlr.Value == nil || len(*rlr.Value) == 0 + } + + // replicationListResultPreparer prepares a request to retrieve the next set of results. + // It returns nil if no more results exist. + func (rlr ReplicationListResult) replicationListResultPreparer(ctx context.Context) (*http.Request, error) { + if rlr.NextLink == nil || len(to.String(rlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String( rlr.NextLink))); + } + + // ReplicationListResultPage contains a page of Replication values. + type ReplicationListResultPage struct { + fn func(context.Context, ReplicationListResult) (ReplicationListResult, error) + rlr ReplicationListResult + } + + // NextWithContext advances to the next page of values. If there was an error making + // the request the page does not advance and the error is returned. + func (page * ReplicationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/ReplicationListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.rlr) + if err != nil { + return err + } + page.rlr = next + return nil + } + + // Next advances to the next page of values. If there was an error making + // the request the page does not advance and the error is returned. + // Deprecated: Use NextWithContext() instead. + func (page * ReplicationListResultPage) Next() error { + return page.NextWithContext(context.Background()) + } + // NotDone returns true if the page enumeration should be started or is not yet complete. + func (page ReplicationListResultPage) NotDone() bool { + return !page.rlr.IsEmpty() + } + // Response returns the raw server response from the last page request. + func (page ReplicationListResultPage) Response() ReplicationListResult { + return page.rlr + } + // Values returns the slice of values for the current page or nil if there are no values. + func (page ReplicationListResultPage) Values() []Replication { + if page.rlr.IsEmpty() { + return nil + } + return *page.rlr.Value + } + // Creates a new instance of the ReplicationListResultPage type. + func NewReplicationListResultPage (getNextPage func(context.Context, ReplicationListResult) (ReplicationListResult, error)) ReplicationListResultPage { + return ReplicationListResultPage{fn: getNextPage} + } + + // ReplicationProperties the properties of a replication. + type ReplicationProperties struct { + // 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' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // Status - READ-ONLY; The status of the replication at the time the operation was called. + Status *Status `json:"status,omitempty"` + } + + // ReplicationsCreateFuture an abstraction for monitoring and retrieving the results of a long-running + // operation. + type ReplicationsCreateFuture struct { + azure.Future + } + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + func (future *ReplicationsCreateFuture) Result(client ReplicationsClient) (r Replication, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("containerregistry.ReplicationsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if r.Response.Response, err = future.GetResult(sender); err == nil && r.Response.Response.StatusCode != http.StatusNoContent { + r, err = client.CreateResponder(r.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsCreateFuture", "Result", r.Response.Response, "Failure responding to request") + } + } + return + } + + // ReplicationsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running + // operation. + type ReplicationsDeleteFuture struct { + azure.Future + } + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + func (future *ReplicationsDeleteFuture) Result(client ReplicationsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("containerregistry.ReplicationsDeleteFuture") + return + } + ar.Response = future.Response() + return + } + + // ReplicationsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running + // operation. + type ReplicationsUpdateFuture struct { + azure.Future + } + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + func (future *ReplicationsUpdateFuture) Result(client ReplicationsClient) (r Replication, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("containerregistry.ReplicationsUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if r.Response.Response, err = future.GetResult(sender); err == nil && r.Response.Response.StatusCode != http.StatusNoContent { + r, err = client.UpdateResponder(r.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsUpdateFuture", "Result", r.Response.Response, "Failure responding to request") + } + } + return + } + + // ReplicationUpdateParameters the parameters for updating a replication. + type ReplicationUpdateParameters struct { + // Tags - The tags for the replication. + Tags map[string]*string `json:"tags"` + } + + // MarshalJSON is the custom marshaler for ReplicationUpdateParameters. + func (rup ReplicationUpdateParameters)MarshalJSON() ([]byte, error){ + objectMap := make(map[string]interface{}) + if(rup.Tags != nil) { + objectMap["tags"] = rup.Tags + } + return json.Marshal(objectMap) + } + + // Request the request that generated the event. + type Request struct { + // ID - The ID of the request that initiated the event. + ID *string `json:"id,omitempty"` + // 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. + Addr *string `json:"addr,omitempty"` + // Host - The externally accessible hostname of the registry instance, as specified by the http host header on incoming requests. + Host *string `json:"host,omitempty"` + // Method - The request method that generated the event. + Method *string `json:"method,omitempty"` + // Useragent - The user agent header of the request. + Useragent *string `json:"useragent,omitempty"` + } + + // Resource an Azure resource. + type Resource struct { + // ID - READ-ONLY; The resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource. This cannot be changed after the resource is created. + Location *string `json:"location,omitempty"` + // Tags - The tags of the resource. + Tags map[string]*string `json:"tags"` + } + + // MarshalJSON is the custom marshaler for Resource. + func (r Resource)MarshalJSON() ([]byte, error){ + objectMap := make(map[string]interface{}) + if(r.Location != nil) { + objectMap["location"] = r.Location + } + if(r.Tags != nil) { + objectMap["tags"] = r.Tags + } + return json.Marshal(objectMap) + } + + // Sku the SKU of a container registry. + type Sku struct { + // Name - The SKU name of the container registry. Required for registry creation. Possible values include: 'Basic', 'ManagedBasic', 'ManagedStandard', 'ManagedPremium' + Name SkuName `json:"name,omitempty"` + // Tier - READ-ONLY; The SKU tier based on the SKU name. Possible values include: 'SkuTierBasic', 'SkuTierManaged' + Tier SkuTier `json:"tier,omitempty"` + } + + // Source the registry node that generated the event. Put differently, while the actor initiates the event, + // the source generates it. + type Source struct { + // 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. + Addr *string `json:"addr,omitempty"` + // InstanceID - The running instance of an application. Changes after each restart. + InstanceID *string `json:"instanceID,omitempty"` + } + + // Status the status of an Azure resource at the time the operation was called. + type Status struct { + // DisplayStatus - READ-ONLY; The short label for the status. + DisplayStatus *string `json:"displayStatus,omitempty"` + // Message - READ-ONLY; The detailed message for the status, including alerts and error messages. + Message *string `json:"message,omitempty"` + // Timestamp - READ-ONLY; The timestamp when the status was changed to the current value. + Timestamp *date.Time `json:"timestamp,omitempty"` + } + + // StorageAccountProperties the properties of a storage account for a container registry. Only applicable + // to Basic SKU. + type StorageAccountProperties struct { + // ID - The resource ID of the storage account. + ID *string `json:"id,omitempty"` + } + + // Target the target of the event. + type Target struct { + // MediaType - The MIME type of the referenced object. + MediaType *string `json:"mediaType,omitempty"` + // Size - The number of bytes of the content. Same as Length field. + Size *int64 `json:"size,omitempty"` + // Digest - The digest of the content, as defined by the Registry V2 HTTP API Specification. + Digest *string `json:"digest,omitempty"` + // Length - The number of bytes of the content. Same as Size field. + Length *int64 `json:"length,omitempty"` + // Repository - The repository name. + Repository *string `json:"repository,omitempty"` + // URL - The direct URL to the content. + URL *string `json:"url,omitempty"` + // Tag - The tag name. + Tag *string `json:"tag,omitempty"` + } + + // Webhook an object that represents a webhook for a container registry. + type Webhook struct { + autorest.Response `json:"-"` + // WebhookProperties - The properties of the webhook. + *WebhookProperties `json:"properties,omitempty"` + // ID - READ-ONLY; The resource ID. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` + // Location - The location of the resource. This cannot be changed after the resource is created. + Location *string `json:"location,omitempty"` + // Tags - The tags of the resource. + Tags map[string]*string `json:"tags"` + } + + // MarshalJSON is the custom marshaler for Webhook. + func (w Webhook)MarshalJSON() ([]byte, error){ + objectMap := make(map[string]interface{}) + if(w.WebhookProperties != nil) { + objectMap["properties"] = w.WebhookProperties + } + if(w.Location != nil) { + objectMap["location"] = w.Location + } + if(w.Tags != nil) { + objectMap["tags"] = w.Tags + } + return json.Marshal(objectMap) + } + // UnmarshalJSON is the custom unmarshaler for Webhook struct. + func (w *Webhook) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var webhookProperties WebhookProperties + err = json.Unmarshal(*v, &webhookProperties) + if err != nil { + return err + } + w.WebhookProperties = &webhookProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + w.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + w.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + w.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + w.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + w.Tags = tags + } + } + } + + return nil + } + + // WebhookCreateParameters the parameters for creating a webhook. + type WebhookCreateParameters struct { + // Tags - The tags for the webhook. + Tags map[string]*string `json:"tags"` + // Location - The location of the webhook. This cannot be changed after the resource is created. + Location *string `json:"location,omitempty"` + // WebhookPropertiesCreateParameters - The properties that the webhook will be created with. + *WebhookPropertiesCreateParameters `json:"properties,omitempty"` + } + + // MarshalJSON is the custom marshaler for WebhookCreateParameters. + func (wcp WebhookCreateParameters)MarshalJSON() ([]byte, error){ + objectMap := make(map[string]interface{}) + if(wcp.Tags != nil) { + objectMap["tags"] = wcp.Tags + } + if(wcp.Location != nil) { + objectMap["location"] = wcp.Location + } + if(wcp.WebhookPropertiesCreateParameters != nil) { + objectMap["properties"] = wcp.WebhookPropertiesCreateParameters + } + return json.Marshal(objectMap) + } + // UnmarshalJSON is the custom unmarshaler for WebhookCreateParameters struct. + func (wcp *WebhookCreateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + wcp.Tags = tags + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + wcp.Location = &location + } + case "properties": + if v != nil { + var webhookPropertiesCreateParameters WebhookPropertiesCreateParameters + err = json.Unmarshal(*v, &webhookPropertiesCreateParameters) + if err != nil { + return err + } + wcp.WebhookPropertiesCreateParameters = &webhookPropertiesCreateParameters + } + } + } + + return nil + } + + // WebhookListResult the result of a request to list webhooks for a container registry. + type WebhookListResult struct { + autorest.Response `json:"-"` + // Value - The list of webhooks. Since this list may be incomplete, the nextLink field should be used to request the next list of webhooks. + Value *[]Webhook `json:"value,omitempty"` + // NextLink - The URI that can be used to request the next list of webhooks. + NextLink *string `json:"nextLink,omitempty"` + } + + // WebhookListResultIterator provides access to a complete listing of Webhook values. + type WebhookListResultIterator struct { + i int + page WebhookListResultPage + } + // NextWithContext advances to the next value. If there was an error making + // the request the iterator does not advance and the error is returned. + func (iter * WebhookListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/WebhookListResultIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter. page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter. i-- + return err + } + iter.i = 0 + return nil + } + // Next advances to the next value. If there was an error making + // the request the iterator does not advance and the error is returned. + // Deprecated: Use NextWithContext() instead. + func (iter * WebhookListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) + } + // NotDone returns true if the enumeration should be started or is not yet complete. + func (iter WebhookListResultIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter. page.Values()) + } + // Response returns the raw server response from the last page request. + func (iter WebhookListResultIterator) Response() WebhookListResult { + return iter.page.Response() + } + // Value returns the current value or a zero-initialized value if the + // iterator has advanced beyond the end of the collection. + func (iter WebhookListResultIterator) Value() Webhook { + if !iter.page.NotDone() { + return Webhook{} + } + return iter.page.Values()[iter.i] + } + // Creates a new instance of the WebhookListResultIterator type. + func NewWebhookListResultIterator (page WebhookListResultPage) WebhookListResultIterator { + return WebhookListResultIterator{page: page} + } + + + // IsEmpty returns true if the ListResult contains no values. + func (wlr WebhookListResult) IsEmpty() bool { + return wlr.Value == nil || len(*wlr.Value) == 0 + } + + // webhookListResultPreparer prepares a request to retrieve the next set of results. + // It returns nil if no more results exist. + func (wlr WebhookListResult) webhookListResultPreparer(ctx context.Context) (*http.Request, error) { + if wlr.NextLink == nil || len(to.String(wlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String( wlr.NextLink))); + } + + // WebhookListResultPage contains a page of Webhook values. + type WebhookListResultPage struct { + fn func(context.Context, WebhookListResult) (WebhookListResult, error) + wlr WebhookListResult + } + + // NextWithContext advances to the next page of values. If there was an error making + // the request the page does not advance and the error is returned. + func (page * WebhookListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/WebhookListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.wlr) + if err != nil { + return err + } + page.wlr = next + return nil + } + + // Next advances to the next page of values. If there was an error making + // the request the page does not advance and the error is returned. + // Deprecated: Use NextWithContext() instead. + func (page * WebhookListResultPage) Next() error { + return page.NextWithContext(context.Background()) + } + // NotDone returns true if the page enumeration should be started or is not yet complete. + func (page WebhookListResultPage) NotDone() bool { + return !page.wlr.IsEmpty() + } + // Response returns the raw server response from the last page request. + func (page WebhookListResultPage) Response() WebhookListResult { + return page.wlr + } + // Values returns the slice of values for the current page or nil if there are no values. + func (page WebhookListResultPage) Values() []Webhook { + if page.wlr.IsEmpty() { + return nil + } + return *page.wlr.Value + } + // Creates a new instance of the WebhookListResultPage type. + func NewWebhookListResultPage (getNextPage func(context.Context, WebhookListResult) (WebhookListResult, error)) WebhookListResultPage { + return WebhookListResultPage{fn: getNextPage} + } + + // WebhookProperties the properties of a webhook. + type WebhookProperties struct { + // Status - The status of the webhook at the time the operation was called. Possible values include: 'Enabled', 'Disabled' + Status WebhookStatus `json:"status,omitempty"` + // 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. + Scope *string `json:"scope,omitempty"` + // Actions - The list of actions that trigger the webhook to post notifications. + Actions *[]WebhookAction `json:"actions,omitempty"` + // 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' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + } + + // WebhookPropertiesCreateParameters the parameters for creating the properties of a webhook. + type WebhookPropertiesCreateParameters struct { + // ServiceURI - The service URI for the webhook to post notifications. + ServiceURI *string `json:"serviceUri,omitempty"` + // CustomHeaders - Custom headers that will be added to the webhook notifications. + CustomHeaders map[string]*string `json:"customHeaders"` + // Status - The status of the webhook at the time the operation was called. Possible values include: 'Enabled', 'Disabled' + Status WebhookStatus `json:"status,omitempty"` + // 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. + Scope *string `json:"scope,omitempty"` + // Actions - The list of actions that trigger the webhook to post notifications. + Actions *[]WebhookAction `json:"actions,omitempty"` + } + + // MarshalJSON is the custom marshaler for WebhookPropertiesCreateParameters. + func (wpcp WebhookPropertiesCreateParameters)MarshalJSON() ([]byte, error){ + objectMap := make(map[string]interface{}) + if(wpcp.ServiceURI != nil) { + objectMap["serviceUri"] = wpcp.ServiceURI + } + if(wpcp.CustomHeaders != nil) { + objectMap["customHeaders"] = wpcp.CustomHeaders + } + if(wpcp.Status != "") { + objectMap["status"] = wpcp.Status + } + if(wpcp.Scope != nil) { + objectMap["scope"] = wpcp.Scope + } + if(wpcp.Actions != nil) { + objectMap["actions"] = wpcp.Actions + } + return json.Marshal(objectMap) + } + + // WebhookPropertiesUpdateParameters the parameters for updating the properties of a webhook. + type WebhookPropertiesUpdateParameters struct { + // ServiceURI - The service URI for the webhook to post notifications. + ServiceURI *string `json:"serviceUri,omitempty"` + // CustomHeaders - Custom headers that will be added to the webhook notifications. + CustomHeaders map[string]*string `json:"customHeaders"` + // Status - The status of the webhook at the time the operation was called. Possible values include: 'Enabled', 'Disabled' + Status WebhookStatus `json:"status,omitempty"` + // 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. + Scope *string `json:"scope,omitempty"` + // Actions - The list of actions that trigger the webhook to post notifications. + Actions *[]WebhookAction `json:"actions,omitempty"` + } + + // MarshalJSON is the custom marshaler for WebhookPropertiesUpdateParameters. + func (wpup WebhookPropertiesUpdateParameters)MarshalJSON() ([]byte, error){ + objectMap := make(map[string]interface{}) + if(wpup.ServiceURI != nil) { + objectMap["serviceUri"] = wpup.ServiceURI + } + if(wpup.CustomHeaders != nil) { + objectMap["customHeaders"] = wpup.CustomHeaders + } + if(wpup.Status != "") { + objectMap["status"] = wpup.Status + } + if(wpup.Scope != nil) { + objectMap["scope"] = wpup.Scope + } + if(wpup.Actions != nil) { + objectMap["actions"] = wpup.Actions + } + return json.Marshal(objectMap) + } + + // WebhooksCreateFuture an abstraction for monitoring and retrieving the results of a long-running + // operation. + type WebhooksCreateFuture struct { + azure.Future + } + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + func (future *WebhooksCreateFuture) Result(client WebhooksClient) (w Webhook, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("containerregistry.WebhooksCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if w.Response.Response, err = future.GetResult(sender); err == nil && w.Response.Response.StatusCode != http.StatusNoContent { + w, err = client.CreateResponder(w.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksCreateFuture", "Result", w.Response.Response, "Failure responding to request") + } + } + return + } + + // WebhooksDeleteFuture an abstraction for monitoring and retrieving the results of a long-running + // operation. + type WebhooksDeleteFuture struct { + azure.Future + } + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + func (future *WebhooksDeleteFuture) Result(client WebhooksClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("containerregistry.WebhooksDeleteFuture") + return + } + ar.Response = future.Response() + return + } + + // WebhooksUpdateFuture an abstraction for monitoring and retrieving the results of a long-running + // operation. + type WebhooksUpdateFuture struct { + azure.Future + } + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + func (future *WebhooksUpdateFuture) Result(client WebhooksClient) (w Webhook, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("containerregistry.WebhooksUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if w.Response.Response, err = future.GetResult(sender); err == nil && w.Response.Response.StatusCode != http.StatusNoContent { + w, err = client.UpdateResponder(w.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksUpdateFuture", "Result", w.Response.Response, "Failure responding to request") + } + } + return + } + + // WebhookUpdateParameters the parameters for updating a webhook. + type WebhookUpdateParameters struct { + // Tags - The tags for the webhook. + Tags map[string]*string `json:"tags"` + // WebhookPropertiesUpdateParameters - The properties that the webhook will be updated with. + *WebhookPropertiesUpdateParameters `json:"properties,omitempty"` + } + + // MarshalJSON is the custom marshaler for WebhookUpdateParameters. + func (wup WebhookUpdateParameters)MarshalJSON() ([]byte, error){ + objectMap := make(map[string]interface{}) + if(wup.Tags != nil) { + objectMap["tags"] = wup.Tags + } + if(wup.WebhookPropertiesUpdateParameters != nil) { + objectMap["properties"] = wup.WebhookPropertiesUpdateParameters + } + return json.Marshal(objectMap) + } + // UnmarshalJSON is the custom unmarshaler for WebhookUpdateParameters struct. + func (wup *WebhookUpdateParameters) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + wup.Tags = tags + } + case "properties": + if v != nil { + var webhookPropertiesUpdateParameters WebhookPropertiesUpdateParameters + err = json.Unmarshal(*v, &webhookPropertiesUpdateParameters) + if err != nil { + return err + } + wup.WebhookPropertiesUpdateParameters = &webhookPropertiesUpdateParameters + } + } + } + + return nil + } -const ( - // Password ... - Password PasswordName = "password" - // Password2 ... - Password2 PasswordName = "password2" -) - -// PossiblePasswordNameValues returns an array of possible values for the PasswordName const type. -func PossiblePasswordNameValues() []PasswordName { - return []PasswordName{Password, Password2} -} - -// ProvisioningState enumerates the values for provisioning state. -type ProvisioningState string - -const ( - // Canceled ... - Canceled ProvisioningState = "Canceled" - // Creating ... - Creating ProvisioningState = "Creating" - // Deleting ... - Deleting ProvisioningState = "Deleting" - // Failed ... - Failed ProvisioningState = "Failed" - // Succeeded ... - Succeeded ProvisioningState = "Succeeded" - // Updating ... - Updating ProvisioningState = "Updating" -) - -// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. -func PossibleProvisioningStateValues() []ProvisioningState { - return []ProvisioningState{Canceled, Creating, Deleting, Failed, Succeeded, Updating} -} - -// RegistryUsageUnit enumerates the values for registry usage unit. -type RegistryUsageUnit string - -const ( - // Bytes ... - Bytes RegistryUsageUnit = "Bytes" - // Count ... - Count RegistryUsageUnit = "Count" -) - -// PossibleRegistryUsageUnitValues returns an array of possible values for the RegistryUsageUnit const type. -func PossibleRegistryUsageUnitValues() []RegistryUsageUnit { - return []RegistryUsageUnit{Bytes, Count} -} - -// SkuName enumerates the values for sku name. -type SkuName string - -const ( - // Basic ... - Basic SkuName = "Basic" - // ManagedBasic ... - ManagedBasic SkuName = "Managed_Basic" - // ManagedPremium ... - ManagedPremium SkuName = "Managed_Premium" - // ManagedStandard ... - ManagedStandard SkuName = "Managed_Standard" -) - -// PossibleSkuNameValues returns an array of possible values for the SkuName const type. -func PossibleSkuNameValues() []SkuName { - return []SkuName{Basic, ManagedBasic, ManagedPremium, ManagedStandard} -} - -// SkuTier enumerates the values for sku tier. -type SkuTier string - -const ( - // SkuTierBasic ... - SkuTierBasic SkuTier = "Basic" - // SkuTierManaged ... - SkuTierManaged SkuTier = "Managed" -) - -// PossibleSkuTierValues returns an array of possible values for the SkuTier const type. -func PossibleSkuTierValues() []SkuTier { - return []SkuTier{SkuTierBasic, SkuTierManaged} -} - -// WebhookAction enumerates the values for webhook action. -type WebhookAction string - -const ( - // Delete ... - Delete WebhookAction = "delete" - // Push ... - Push WebhookAction = "push" -) - -// PossibleWebhookActionValues returns an array of possible values for the WebhookAction const type. -func PossibleWebhookActionValues() []WebhookAction { - return []WebhookAction{Delete, Push} -} - -// WebhookStatus enumerates the values for webhook status. -type WebhookStatus string - -const ( - // Disabled ... - Disabled WebhookStatus = "disabled" - // Enabled ... - Enabled WebhookStatus = "enabled" -) - -// PossibleWebhookStatusValues returns an array of possible values for the WebhookStatus const type. -func PossibleWebhookStatusValues() []WebhookStatus { - return []WebhookStatus{Disabled, Enabled} -} - -// Actor the agent that initiated the event. For most situations, this could be from the authorization -// context of the request. -type Actor struct { - // Name - The subject or username associated with the request context that generated the event. - Name *string `json:"name,omitempty"` -} - -// CallbackConfig the configuration of service URI and custom headers for the webhook. -type CallbackConfig struct { - autorest.Response `json:"-"` - // ServiceURI - The service URI for the webhook to post notifications. - ServiceURI *string `json:"serviceUri,omitempty"` - // CustomHeaders - Custom headers that will be added to the webhook notifications. - CustomHeaders map[string]*string `json:"customHeaders"` -} - -// MarshalJSON is the custom marshaler for CallbackConfig. -func (cc CallbackConfig) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cc.ServiceURI != nil { - objectMap["serviceUri"] = cc.ServiceURI - } - if cc.CustomHeaders != nil { - objectMap["customHeaders"] = cc.CustomHeaders - } - return json.Marshal(objectMap) -} - -// Event the event for a webhook. -type Event struct { - // EventRequestMessage - The event request message sent to the service URI. - EventRequestMessage *EventRequestMessage `json:"eventRequestMessage,omitempty"` - // EventResponseMessage - The event response message received from the service URI. - EventResponseMessage *EventResponseMessage `json:"eventResponseMessage,omitempty"` - // ID - The event ID. - ID *string `json:"id,omitempty"` -} - -// EventContent the content of the event request message. -type EventContent struct { - // ID - The event ID. - ID *string `json:"id,omitempty"` - // Timestamp - The time at which the event occurred. - Timestamp *date.Time `json:"timestamp,omitempty"` - // Action - The action that encompasses the provided event. - Action *string `json:"action,omitempty"` - // Target - The target of the event. - Target *Target `json:"target,omitempty"` - // Request - The request that generated the event. - Request *Request `json:"request,omitempty"` - // Actor - The agent that initiated the event. For most situations, this could be from the authorization context of the request. - Actor *Actor `json:"actor,omitempty"` - // Source - The registry node that generated the event. Put differently, while the actor initiates the event, the source generates it. - Source *Source `json:"source,omitempty"` -} - -// EventInfo the basic information of an event. -type EventInfo struct { - autorest.Response `json:"-"` - // ID - The event ID. - ID *string `json:"id,omitempty"` -} - -// EventListResult the result of a request to list events for a webhook. -type EventListResult struct { - autorest.Response `json:"-"` - // Value - The list of events. Since this list may be incomplete, the nextLink field should be used to request the next list of events. - Value *[]Event `json:"value,omitempty"` - // NextLink - The URI that can be used to request the next list of events. - NextLink *string `json:"nextLink,omitempty"` -} - -// EventListResultIterator provides access to a complete listing of Event values. -type EventListResultIterator struct { - i int - page EventListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *EventListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/EventListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *EventListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter EventListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter EventListResultIterator) Response() EventListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter EventListResultIterator) Value() Event { - if !iter.page.NotDone() { - return Event{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the EventListResultIterator type. -func NewEventListResultIterator(page EventListResultPage) EventListResultIterator { - return EventListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (elr EventListResult) IsEmpty() bool { - return elr.Value == nil || len(*elr.Value) == 0 -} - -// eventListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (elr EventListResult) eventListResultPreparer(ctx context.Context) (*http.Request, error) { - if elr.NextLink == nil || len(to.String(elr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(elr.NextLink))) -} - -// EventListResultPage contains a page of Event values. -type EventListResultPage struct { - fn func(context.Context, EventListResult) (EventListResult, error) - elr EventListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *EventListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/EventListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.elr) - if err != nil { - return err - } - page.elr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *EventListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page EventListResultPage) NotDone() bool { - return !page.elr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page EventListResultPage) Response() EventListResult { - return page.elr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page EventListResultPage) Values() []Event { - if page.elr.IsEmpty() { - return nil - } - return *page.elr.Value -} - -// Creates a new instance of the EventListResultPage type. -func NewEventListResultPage(getNextPage func(context.Context, EventListResult) (EventListResult, error)) EventListResultPage { - return EventListResultPage{fn: getNextPage} -} - -// EventRequestMessage the event request message sent to the service URI. -type EventRequestMessage struct { - // Content - The content of the event request message. - Content *EventContent `json:"content,omitempty"` - // Headers - The headers of the event request message. - Headers map[string]*string `json:"headers"` - // Method - The HTTP method used to send the event request message. - Method *string `json:"method,omitempty"` - // RequestURI - The URI used to send the event request message. - RequestURI *string `json:"requestUri,omitempty"` - // Version - The HTTP message version. - Version *string `json:"version,omitempty"` -} - -// MarshalJSON is the custom marshaler for EventRequestMessage. -func (erm EventRequestMessage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if erm.Content != nil { - objectMap["content"] = erm.Content - } - if erm.Headers != nil { - objectMap["headers"] = erm.Headers - } - if erm.Method != nil { - objectMap["method"] = erm.Method - } - if erm.RequestURI != nil { - objectMap["requestUri"] = erm.RequestURI - } - if erm.Version != nil { - objectMap["version"] = erm.Version - } - return json.Marshal(objectMap) -} - -// EventResponseMessage the event response message received from the service URI. -type EventResponseMessage struct { - // Content - The content of the event response message. - Content *string `json:"content,omitempty"` - // Headers - The headers of the event response message. - Headers map[string]*string `json:"headers"` - // ReasonPhrase - The reason phrase of the event response message. - ReasonPhrase *string `json:"reasonPhrase,omitempty"` - // StatusCode - The status code of the event response message. - StatusCode *string `json:"statusCode,omitempty"` - // Version - The HTTP message version. - Version *string `json:"version,omitempty"` -} - -// MarshalJSON is the custom marshaler for EventResponseMessage. -func (erm EventResponseMessage) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if erm.Content != nil { - objectMap["content"] = erm.Content - } - if erm.Headers != nil { - objectMap["headers"] = erm.Headers - } - if erm.ReasonPhrase != nil { - objectMap["reasonPhrase"] = erm.ReasonPhrase - } - if erm.StatusCode != nil { - objectMap["statusCode"] = erm.StatusCode - } - if erm.Version != nil { - objectMap["version"] = erm.Version - } - return json.Marshal(objectMap) -} - -// OperationDefinition the definition of a container registry operation. -type OperationDefinition struct { - // Name - Operation name: {provider}/{resource}/{operation}. - Name *string `json:"name,omitempty"` - // Display - The display information for the container registry operation. - Display *OperationDisplayDefinition `json:"display,omitempty"` -} - -// OperationDisplayDefinition the display information for a container registry operation. -type OperationDisplayDefinition struct { - // Provider - The resource provider name: Microsoft.ContainerRegistry. - Provider *string `json:"provider,omitempty"` - // Resource - The resource on which the operation is performed. - Resource *string `json:"resource,omitempty"` - // Operation - The operation that users can perform. - Operation *string `json:"operation,omitempty"` - // Description - The description for the operation. - Description *string `json:"description,omitempty"` -} - -// OperationListResult the result of a request to list container registry operations. -type OperationListResult struct { - autorest.Response `json:"-"` - // 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. - Value *[]OperationDefinition `json:"value,omitempty"` - // NextLink - The URI that can be used to request the next list of container registry operations. - NextLink *string `json:"nextLink,omitempty"` -} - -// OperationListResultIterator provides access to a complete listing of OperationDefinition values. -type OperationListResultIterator struct { - i int - page OperationListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *OperationListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter OperationListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter OperationListResultIterator) Response() OperationListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter OperationListResultIterator) Value() OperationDefinition { - if !iter.page.NotDone() { - return OperationDefinition{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the OperationListResultIterator type. -func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { - return OperationListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (olr OperationListResult) IsEmpty() bool { - return olr.Value == nil || len(*olr.Value) == 0 -} - -// operationListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { - if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(olr.NextLink))) -} - -// OperationListResultPage contains a page of OperationDefinition values. -type OperationListResultPage struct { - fn func(context.Context, OperationListResult) (OperationListResult, error) - olr OperationListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.olr) - if err != nil { - return err - } - page.olr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *OperationListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page OperationListResultPage) NotDone() bool { - return !page.olr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page OperationListResultPage) Response() OperationListResult { - return page.olr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page OperationListResultPage) Values() []OperationDefinition { - if page.olr.IsEmpty() { - return nil - } - return *page.olr.Value -} - -// Creates a new instance of the OperationListResultPage type. -func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { - return OperationListResultPage{fn: getNextPage} -} - -// RegenerateCredentialParameters the parameters used to regenerate the login credential. -type RegenerateCredentialParameters struct { - // Name - Specifies name of the password which should be regenerated -- password or password2. Possible values include: 'Password', 'Password2' - Name PasswordName `json:"name,omitempty"` -} - -// RegistriesCreateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type RegistriesCreateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *RegistriesCreateFuture) Result(client RegistriesClient) (r Registry, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesCreateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("containerregistry.RegistriesCreateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if r.Response.Response, err = future.GetResult(sender); err == nil && r.Response.Response.StatusCode != http.StatusNoContent { - r, err = client.CreateResponder(r.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesCreateFuture", "Result", r.Response.Response, "Failure responding to request") - } - } - return -} - -// RegistriesDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type RegistriesDeleteFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *RegistriesDeleteFuture) Result(client RegistriesClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("containerregistry.RegistriesDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// RegistriesUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type RegistriesUpdateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *RegistriesUpdateFuture) Result(client RegistriesClient) (r Registry, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("containerregistry.RegistriesUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if r.Response.Response, err = future.GetResult(sender); err == nil && r.Response.Response.StatusCode != http.StatusNoContent { - r, err = client.UpdateResponder(r.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesUpdateFuture", "Result", r.Response.Response, "Failure responding to request") - } - } - return -} - -// Registry an object that represents a container registry. -type Registry struct { - autorest.Response `json:"-"` - // Sku - The SKU of the container registry. - Sku *Sku `json:"sku,omitempty"` - // RegistryProperties - The properties of the container registry. - *RegistryProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource. This cannot be changed after the resource is created. - Location *string `json:"location,omitempty"` - // Tags - The tags of the resource. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for Registry. -func (r Registry) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if r.Sku != nil { - objectMap["sku"] = r.Sku - } - if r.RegistryProperties != nil { - objectMap["properties"] = r.RegistryProperties - } - if r.Location != nil { - objectMap["location"] = r.Location - } - if r.Tags != nil { - objectMap["tags"] = r.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Registry struct. -func (r *Registry) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "sku": - if v != nil { - var sku Sku - err = json.Unmarshal(*v, &sku) - if err != nil { - return err - } - r.Sku = &sku - } - case "properties": - if v != nil { - var registryProperties RegistryProperties - err = json.Unmarshal(*v, ®istryProperties) - if err != nil { - return err - } - r.RegistryProperties = ®istryProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - r.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - r.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - r.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - r.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - r.Tags = tags - } - } - } - - return nil -} - -// RegistryListCredentialsResult the response from the ListCredentials operation. -type RegistryListCredentialsResult struct { - autorest.Response `json:"-"` - // Username - The username for a container registry. - Username *string `json:"username,omitempty"` - // Passwords - The list of passwords for a container registry. - Passwords *[]RegistryPassword `json:"passwords,omitempty"` -} - -// RegistryListResult the result of a request to list container registries. -type RegistryListResult struct { - autorest.Response `json:"-"` - // 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. - Value *[]Registry `json:"value,omitempty"` - // NextLink - The URI that can be used to request the next list of container registries. - NextLink *string `json:"nextLink,omitempty"` -} - -// RegistryListResultIterator provides access to a complete listing of Registry values. -type RegistryListResultIterator struct { - i int - page RegistryListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *RegistryListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RegistryListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *RegistryListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter RegistryListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter RegistryListResultIterator) Response() RegistryListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter RegistryListResultIterator) Value() Registry { - if !iter.page.NotDone() { - return Registry{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the RegistryListResultIterator type. -func NewRegistryListResultIterator(page RegistryListResultPage) RegistryListResultIterator { - return RegistryListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (rlr RegistryListResult) IsEmpty() bool { - return rlr.Value == nil || len(*rlr.Value) == 0 -} - -// registryListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (rlr RegistryListResult) registryListResultPreparer(ctx context.Context) (*http.Request, error) { - if rlr.NextLink == nil || len(to.String(rlr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(rlr.NextLink))) -} - -// RegistryListResultPage contains a page of Registry values. -type RegistryListResultPage struct { - fn func(context.Context, RegistryListResult) (RegistryListResult, error) - rlr RegistryListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *RegistryListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RegistryListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.rlr) - if err != nil { - return err - } - page.rlr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *RegistryListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page RegistryListResultPage) NotDone() bool { - return !page.rlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page RegistryListResultPage) Response() RegistryListResult { - return page.rlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page RegistryListResultPage) Values() []Registry { - if page.rlr.IsEmpty() { - return nil - } - return *page.rlr.Value -} - -// Creates a new instance of the RegistryListResultPage type. -func NewRegistryListResultPage(getNextPage func(context.Context, RegistryListResult) (RegistryListResult, error)) RegistryListResultPage { - return RegistryListResultPage{fn: getNextPage} -} - -// RegistryNameCheckRequest a request to check whether a container registry name is available. -type RegistryNameCheckRequest struct { - // Name - The name of the container registry. - Name *string `json:"name,omitempty"` - // Type - The resource type of the container registry. This field must be set to 'Microsoft.ContainerRegistry/registries'. - Type *string `json:"type,omitempty"` -} - -// RegistryNameStatus the result of a request to check the availability of a container registry name. -type RegistryNameStatus struct { - autorest.Response `json:"-"` - // NameAvailable - The value that indicates whether the name is available. - NameAvailable *bool `json:"nameAvailable,omitempty"` - // Reason - If any, the reason that the name is not available. - Reason *string `json:"reason,omitempty"` - // Message - If any, the error message that provides more detail for the reason that the name is not available. - Message *string `json:"message,omitempty"` -} - -// RegistryPassword the login password for the container registry. -type RegistryPassword struct { - // Name - The password name. Possible values include: 'Password', 'Password2' - Name PasswordName `json:"name,omitempty"` - // Value - The password value. - Value *string `json:"value,omitempty"` -} - -// RegistryProperties the properties of a container registry. -type RegistryProperties struct { - // LoginServer - READ-ONLY; The URL that can be used to log into the container registry. - LoginServer *string `json:"loginServer,omitempty"` - // CreationDate - READ-ONLY; The creation date of the container registry in ISO8601 format. - CreationDate *date.Time `json:"creationDate,omitempty"` - // 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' - ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` - // Status - READ-ONLY; The status of the container registry at the time the operation was called. - Status *Status `json:"status,omitempty"` - // AdminUserEnabled - The value that indicates whether the admin user is enabled. - AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` - // StorageAccount - The properties of the storage account for the container registry. Only applicable to Basic SKU. - StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` -} - -// RegistryPropertiesUpdateParameters the parameters for updating the properties of a container registry. -type RegistryPropertiesUpdateParameters struct { - // AdminUserEnabled - The value that indicates whether the admin user is enabled. - AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` - // StorageAccount - The parameters of a storage account for the container registry. Only applicable to Basic SKU. If specified, the storage account must be in the same physical location as the container registry. - StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` -} - -// RegistryUpdateParameters the parameters for updating a container registry. -type RegistryUpdateParameters struct { - // Tags - The tags for the container registry. - Tags map[string]*string `json:"tags"` - // Sku - The SKU of the container registry. - Sku *Sku `json:"sku,omitempty"` - // RegistryPropertiesUpdateParameters - The properties that the container registry will be updated with. - *RegistryPropertiesUpdateParameters `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for RegistryUpdateParameters. -func (rup RegistryUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rup.Tags != nil { - objectMap["tags"] = rup.Tags - } - if rup.Sku != nil { - objectMap["sku"] = rup.Sku - } - if rup.RegistryPropertiesUpdateParameters != nil { - objectMap["properties"] = rup.RegistryPropertiesUpdateParameters - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for RegistryUpdateParameters struct. -func (rup *RegistryUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - rup.Tags = tags - } - case "sku": - if v != nil { - var sku Sku - err = json.Unmarshal(*v, &sku) - if err != nil { - return err - } - rup.Sku = &sku - } - case "properties": - if v != nil { - var registryPropertiesUpdateParameters RegistryPropertiesUpdateParameters - err = json.Unmarshal(*v, ®istryPropertiesUpdateParameters) - if err != nil { - return err - } - rup.RegistryPropertiesUpdateParameters = ®istryPropertiesUpdateParameters - } - } - } - - return nil -} - -// RegistryUsage the quota usage for a container registry. -type RegistryUsage struct { - // Name - The name of the usage. - Name *string `json:"name,omitempty"` - // Limit - The limit of the usage. - Limit *int64 `json:"limit,omitempty"` - // CurrentValue - The current value of the usage. - CurrentValue *int64 `json:"currentValue,omitempty"` - // Unit - The unit of measurement. Possible values include: 'Count', 'Bytes' - Unit RegistryUsageUnit `json:"unit,omitempty"` -} - -// RegistryUsageListResult the result of a request to get container registry quota usages. -type RegistryUsageListResult struct { - autorest.Response `json:"-"` - // Value - The list of container registry quota usages. - Value *[]RegistryUsage `json:"value,omitempty"` -} - -// Replication an object that represents a replication for a container registry. -type Replication struct { - autorest.Response `json:"-"` - // ReplicationProperties - The properties of the replication. - *ReplicationProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource. This cannot be changed after the resource is created. - Location *string `json:"location,omitempty"` - // Tags - The tags of the resource. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for Replication. -func (r Replication) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if r.ReplicationProperties != nil { - objectMap["properties"] = r.ReplicationProperties - } - if r.Location != nil { - objectMap["location"] = r.Location - } - if r.Tags != nil { - objectMap["tags"] = r.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Replication struct. -func (r *Replication) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var replicationProperties ReplicationProperties - err = json.Unmarshal(*v, &replicationProperties) - if err != nil { - return err - } - r.ReplicationProperties = &replicationProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - r.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - r.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - r.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - r.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - r.Tags = tags - } - } - } - - return nil -} - -// ReplicationListResult the result of a request to list replications for a container registry. -type ReplicationListResult struct { - autorest.Response `json:"-"` - // Value - The list of replications. Since this list may be incomplete, the nextLink field should be used to request the next list of replications. - Value *[]Replication `json:"value,omitempty"` - // NextLink - The URI that can be used to request the next list of replications. - NextLink *string `json:"nextLink,omitempty"` -} - -// ReplicationListResultIterator provides access to a complete listing of Replication values. -type ReplicationListResultIterator struct { - i int - page ReplicationListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *ReplicationListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *ReplicationListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter ReplicationListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter ReplicationListResultIterator) Response() ReplicationListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter ReplicationListResultIterator) Value() Replication { - if !iter.page.NotDone() { - return Replication{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the ReplicationListResultIterator type. -func NewReplicationListResultIterator(page ReplicationListResultPage) ReplicationListResultIterator { - return ReplicationListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (rlr ReplicationListResult) IsEmpty() bool { - return rlr.Value == nil || len(*rlr.Value) == 0 -} - -// replicationListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (rlr ReplicationListResult) replicationListResultPreparer(ctx context.Context) (*http.Request, error) { - if rlr.NextLink == nil || len(to.String(rlr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(rlr.NextLink))) -} - -// ReplicationListResultPage contains a page of Replication values. -type ReplicationListResultPage struct { - fn func(context.Context, ReplicationListResult) (ReplicationListResult, error) - rlr ReplicationListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *ReplicationListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.rlr) - if err != nil { - return err - } - page.rlr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *ReplicationListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page ReplicationListResultPage) NotDone() bool { - return !page.rlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page ReplicationListResultPage) Response() ReplicationListResult { - return page.rlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page ReplicationListResultPage) Values() []Replication { - if page.rlr.IsEmpty() { - return nil - } - return *page.rlr.Value -} - -// Creates a new instance of the ReplicationListResultPage type. -func NewReplicationListResultPage(getNextPage func(context.Context, ReplicationListResult) (ReplicationListResult, error)) ReplicationListResultPage { - return ReplicationListResultPage{fn: getNextPage} -} - -// ReplicationProperties the properties of a replication. -type ReplicationProperties struct { - // 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' - ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` - // Status - READ-ONLY; The status of the replication at the time the operation was called. - Status *Status `json:"status,omitempty"` -} - -// ReplicationsCreateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ReplicationsCreateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *ReplicationsCreateFuture) Result(client ReplicationsClient) (r Replication, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsCreateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("containerregistry.ReplicationsCreateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if r.Response.Response, err = future.GetResult(sender); err == nil && r.Response.Response.StatusCode != http.StatusNoContent { - r, err = client.CreateResponder(r.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsCreateFuture", "Result", r.Response.Response, "Failure responding to request") - } - } - return -} - -// ReplicationsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ReplicationsDeleteFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *ReplicationsDeleteFuture) Result(client ReplicationsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("containerregistry.ReplicationsDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// ReplicationsUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type ReplicationsUpdateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *ReplicationsUpdateFuture) Result(client ReplicationsClient) (r Replication, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("containerregistry.ReplicationsUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if r.Response.Response, err = future.GetResult(sender); err == nil && r.Response.Response.StatusCode != http.StatusNoContent { - r, err = client.UpdateResponder(r.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsUpdateFuture", "Result", r.Response.Response, "Failure responding to request") - } - } - return -} - -// ReplicationUpdateParameters the parameters for updating a replication. -type ReplicationUpdateParameters struct { - // Tags - The tags for the replication. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for ReplicationUpdateParameters. -func (rup ReplicationUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if rup.Tags != nil { - objectMap["tags"] = rup.Tags - } - return json.Marshal(objectMap) -} - -// Request the request that generated the event. -type Request struct { - // ID - The ID of the request that initiated the event. - ID *string `json:"id,omitempty"` - // 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. - Addr *string `json:"addr,omitempty"` - // Host - The externally accessible hostname of the registry instance, as specified by the http host header on incoming requests. - Host *string `json:"host,omitempty"` - // Method - The request method that generated the event. - Method *string `json:"method,omitempty"` - // Useragent - The user agent header of the request. - Useragent *string `json:"useragent,omitempty"` -} - -// Resource an Azure resource. -type Resource struct { - // ID - READ-ONLY; The resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource. This cannot be changed after the resource is created. - Location *string `json:"location,omitempty"` - // Tags - The tags of the resource. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for Resource. -func (r Resource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if r.Location != nil { - objectMap["location"] = r.Location - } - if r.Tags != nil { - objectMap["tags"] = r.Tags - } - return json.Marshal(objectMap) -} - -// Sku the SKU of a container registry. -type Sku struct { - // Name - The SKU name of the container registry. Required for registry creation. Possible values include: 'Basic', 'ManagedBasic', 'ManagedStandard', 'ManagedPremium' - Name SkuName `json:"name,omitempty"` - // Tier - READ-ONLY; The SKU tier based on the SKU name. Possible values include: 'SkuTierBasic', 'SkuTierManaged' - Tier SkuTier `json:"tier,omitempty"` -} - -// Source the registry node that generated the event. Put differently, while the actor initiates the event, -// the source generates it. -type Source struct { - // 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. - Addr *string `json:"addr,omitempty"` - // InstanceID - The running instance of an application. Changes after each restart. - InstanceID *string `json:"instanceID,omitempty"` -} - -// Status the status of an Azure resource at the time the operation was called. -type Status struct { - // DisplayStatus - READ-ONLY; The short label for the status. - DisplayStatus *string `json:"displayStatus,omitempty"` - // Message - READ-ONLY; The detailed message for the status, including alerts and error messages. - Message *string `json:"message,omitempty"` - // Timestamp - READ-ONLY; The timestamp when the status was changed to the current value. - Timestamp *date.Time `json:"timestamp,omitempty"` -} - -// StorageAccountProperties the properties of a storage account for a container registry. Only applicable -// to Basic SKU. -type StorageAccountProperties struct { - // ID - The resource ID of the storage account. - ID *string `json:"id,omitempty"` -} - -// Target the target of the event. -type Target struct { - // MediaType - The MIME type of the referenced object. - MediaType *string `json:"mediaType,omitempty"` - // Size - The number of bytes of the content. Same as Length field. - Size *int64 `json:"size,omitempty"` - // Digest - The digest of the content, as defined by the Registry V2 HTTP API Specification. - Digest *string `json:"digest,omitempty"` - // Length - The number of bytes of the content. Same as Size field. - Length *int64 `json:"length,omitempty"` - // Repository - The repository name. - Repository *string `json:"repository,omitempty"` - // URL - The direct URL to the content. - URL *string `json:"url,omitempty"` - // Tag - The tag name. - Tag *string `json:"tag,omitempty"` -} - -// Webhook an object that represents a webhook for a container registry. -type Webhook struct { - autorest.Response `json:"-"` - // WebhookProperties - The properties of the webhook. - *WebhookProperties `json:"properties,omitempty"` - // ID - READ-ONLY; The resource ID. - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The name of the resource. - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the resource. - Type *string `json:"type,omitempty"` - // Location - The location of the resource. This cannot be changed after the resource is created. - Location *string `json:"location,omitempty"` - // Tags - The tags of the resource. - Tags map[string]*string `json:"tags"` -} - -// MarshalJSON is the custom marshaler for Webhook. -func (w Webhook) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if w.WebhookProperties != nil { - objectMap["properties"] = w.WebhookProperties - } - if w.Location != nil { - objectMap["location"] = w.Location - } - if w.Tags != nil { - objectMap["tags"] = w.Tags - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for Webhook struct. -func (w *Webhook) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "properties": - if v != nil { - var webhookProperties WebhookProperties - err = json.Unmarshal(*v, &webhookProperties) - if err != nil { - return err - } - w.WebhookProperties = &webhookProperties - } - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - w.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - w.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - w.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - w.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - w.Tags = tags - } - } - } - - return nil -} - -// WebhookCreateParameters the parameters for creating a webhook. -type WebhookCreateParameters struct { - // Tags - The tags for the webhook. - Tags map[string]*string `json:"tags"` - // Location - The location of the webhook. This cannot be changed after the resource is created. - Location *string `json:"location,omitempty"` - // WebhookPropertiesCreateParameters - The properties that the webhook will be created with. - *WebhookPropertiesCreateParameters `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for WebhookCreateParameters. -func (wcp WebhookCreateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if wcp.Tags != nil { - objectMap["tags"] = wcp.Tags - } - if wcp.Location != nil { - objectMap["location"] = wcp.Location - } - if wcp.WebhookPropertiesCreateParameters != nil { - objectMap["properties"] = wcp.WebhookPropertiesCreateParameters - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for WebhookCreateParameters struct. -func (wcp *WebhookCreateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - wcp.Tags = tags - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - wcp.Location = &location - } - case "properties": - if v != nil { - var webhookPropertiesCreateParameters WebhookPropertiesCreateParameters - err = json.Unmarshal(*v, &webhookPropertiesCreateParameters) - if err != nil { - return err - } - wcp.WebhookPropertiesCreateParameters = &webhookPropertiesCreateParameters - } - } - } - - return nil -} - -// WebhookListResult the result of a request to list webhooks for a container registry. -type WebhookListResult struct { - autorest.Response `json:"-"` - // Value - The list of webhooks. Since this list may be incomplete, the nextLink field should be used to request the next list of webhooks. - Value *[]Webhook `json:"value,omitempty"` - // NextLink - The URI that can be used to request the next list of webhooks. - NextLink *string `json:"nextLink,omitempty"` -} - -// WebhookListResultIterator provides access to a complete listing of Webhook values. -type WebhookListResultIterator struct { - i int - page WebhookListResultPage -} - -// NextWithContext advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -func (iter *WebhookListResultIterator) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/WebhookListResultIterator.NextWithContext") - defer func() { - sc := -1 - if iter.Response().Response.Response != nil { - sc = iter.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - iter.i++ - if iter.i < len(iter.page.Values()) { - return nil - } - err = iter.page.NextWithContext(ctx) - if err != nil { - iter.i-- - return err - } - iter.i = 0 - return nil -} - -// Next advances to the next value. If there was an error making -// the request the iterator does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (iter *WebhookListResultIterator) Next() error { - return iter.NextWithContext(context.Background()) -} - -// NotDone returns true if the enumeration should be started or is not yet complete. -func (iter WebhookListResultIterator) NotDone() bool { - return iter.page.NotDone() && iter.i < len(iter.page.Values()) -} - -// Response returns the raw server response from the last page request. -func (iter WebhookListResultIterator) Response() WebhookListResult { - return iter.page.Response() -} - -// Value returns the current value or a zero-initialized value if the -// iterator has advanced beyond the end of the collection. -func (iter WebhookListResultIterator) Value() Webhook { - if !iter.page.NotDone() { - return Webhook{} - } - return iter.page.Values()[iter.i] -} - -// Creates a new instance of the WebhookListResultIterator type. -func NewWebhookListResultIterator(page WebhookListResultPage) WebhookListResultIterator { - return WebhookListResultIterator{page: page} -} - -// IsEmpty returns true if the ListResult contains no values. -func (wlr WebhookListResult) IsEmpty() bool { - return wlr.Value == nil || len(*wlr.Value) == 0 -} - -// webhookListResultPreparer prepares a request to retrieve the next set of results. -// It returns nil if no more results exist. -func (wlr WebhookListResult) webhookListResultPreparer(ctx context.Context) (*http.Request, error) { - if wlr.NextLink == nil || len(to.String(wlr.NextLink)) < 1 { - return nil, nil - } - return autorest.Prepare((&http.Request{}).WithContext(ctx), - autorest.AsJSON(), - autorest.AsGet(), - autorest.WithBaseURL(to.String(wlr.NextLink))) -} - -// WebhookListResultPage contains a page of Webhook values. -type WebhookListResultPage struct { - fn func(context.Context, WebhookListResult) (WebhookListResult, error) - wlr WebhookListResult -} - -// NextWithContext advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -func (page *WebhookListResultPage) NextWithContext(ctx context.Context) (err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/WebhookListResultPage.NextWithContext") - defer func() { - sc := -1 - if page.Response().Response.Response != nil { - sc = page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - next, err := page.fn(ctx, page.wlr) - if err != nil { - return err - } - page.wlr = next - return nil -} - -// Next advances to the next page of values. If there was an error making -// the request the page does not advance and the error is returned. -// Deprecated: Use NextWithContext() instead. -func (page *WebhookListResultPage) Next() error { - return page.NextWithContext(context.Background()) -} - -// NotDone returns true if the page enumeration should be started or is not yet complete. -func (page WebhookListResultPage) NotDone() bool { - return !page.wlr.IsEmpty() -} - -// Response returns the raw server response from the last page request. -func (page WebhookListResultPage) Response() WebhookListResult { - return page.wlr -} - -// Values returns the slice of values for the current page or nil if there are no values. -func (page WebhookListResultPage) Values() []Webhook { - if page.wlr.IsEmpty() { - return nil - } - return *page.wlr.Value -} - -// Creates a new instance of the WebhookListResultPage type. -func NewWebhookListResultPage(getNextPage func(context.Context, WebhookListResult) (WebhookListResult, error)) WebhookListResultPage { - return WebhookListResultPage{fn: getNextPage} -} - -// WebhookProperties the properties of a webhook. -type WebhookProperties struct { - // Status - The status of the webhook at the time the operation was called. Possible values include: 'Enabled', 'Disabled' - Status WebhookStatus `json:"status,omitempty"` - // 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. - Scope *string `json:"scope,omitempty"` - // Actions - The list of actions that trigger the webhook to post notifications. - Actions *[]WebhookAction `json:"actions,omitempty"` - // 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' - ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` -} - -// WebhookPropertiesCreateParameters the parameters for creating the properties of a webhook. -type WebhookPropertiesCreateParameters struct { - // ServiceURI - The service URI for the webhook to post notifications. - ServiceURI *string `json:"serviceUri,omitempty"` - // CustomHeaders - Custom headers that will be added to the webhook notifications. - CustomHeaders map[string]*string `json:"customHeaders"` - // Status - The status of the webhook at the time the operation was called. Possible values include: 'Enabled', 'Disabled' - Status WebhookStatus `json:"status,omitempty"` - // 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. - Scope *string `json:"scope,omitempty"` - // Actions - The list of actions that trigger the webhook to post notifications. - Actions *[]WebhookAction `json:"actions,omitempty"` -} - -// MarshalJSON is the custom marshaler for WebhookPropertiesCreateParameters. -func (wpcp WebhookPropertiesCreateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if wpcp.ServiceURI != nil { - objectMap["serviceUri"] = wpcp.ServiceURI - } - if wpcp.CustomHeaders != nil { - objectMap["customHeaders"] = wpcp.CustomHeaders - } - if wpcp.Status != "" { - objectMap["status"] = wpcp.Status - } - if wpcp.Scope != nil { - objectMap["scope"] = wpcp.Scope - } - if wpcp.Actions != nil { - objectMap["actions"] = wpcp.Actions - } - return json.Marshal(objectMap) -} - -// WebhookPropertiesUpdateParameters the parameters for updating the properties of a webhook. -type WebhookPropertiesUpdateParameters struct { - // ServiceURI - The service URI for the webhook to post notifications. - ServiceURI *string `json:"serviceUri,omitempty"` - // CustomHeaders - Custom headers that will be added to the webhook notifications. - CustomHeaders map[string]*string `json:"customHeaders"` - // Status - The status of the webhook at the time the operation was called. Possible values include: 'Enabled', 'Disabled' - Status WebhookStatus `json:"status,omitempty"` - // 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. - Scope *string `json:"scope,omitempty"` - // Actions - The list of actions that trigger the webhook to post notifications. - Actions *[]WebhookAction `json:"actions,omitempty"` -} - -// MarshalJSON is the custom marshaler for WebhookPropertiesUpdateParameters. -func (wpup WebhookPropertiesUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if wpup.ServiceURI != nil { - objectMap["serviceUri"] = wpup.ServiceURI - } - if wpup.CustomHeaders != nil { - objectMap["customHeaders"] = wpup.CustomHeaders - } - if wpup.Status != "" { - objectMap["status"] = wpup.Status - } - if wpup.Scope != nil { - objectMap["scope"] = wpup.Scope - } - if wpup.Actions != nil { - objectMap["actions"] = wpup.Actions - } - return json.Marshal(objectMap) -} - -// WebhooksCreateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type WebhooksCreateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *WebhooksCreateFuture) Result(client WebhooksClient) (w Webhook, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksCreateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("containerregistry.WebhooksCreateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if w.Response.Response, err = future.GetResult(sender); err == nil && w.Response.Response.StatusCode != http.StatusNoContent { - w, err = client.CreateResponder(w.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksCreateFuture", "Result", w.Response.Response, "Failure responding to request") - } - } - return -} - -// WebhooksDeleteFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type WebhooksDeleteFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *WebhooksDeleteFuture) Result(client WebhooksClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("containerregistry.WebhooksDeleteFuture") - return - } - ar.Response = future.Response() - return -} - -// WebhooksUpdateFuture an abstraction for monitoring and retrieving the results of a long-running -// operation. -type WebhooksUpdateFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *WebhooksUpdateFuture) Result(client WebhooksClient) (w Webhook, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("containerregistry.WebhooksUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if w.Response.Response, err = future.GetResult(sender); err == nil && w.Response.Response.StatusCode != http.StatusNoContent { - w, err = client.UpdateResponder(w.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksUpdateFuture", "Result", w.Response.Response, "Failure responding to request") - } - } - return -} - -// WebhookUpdateParameters the parameters for updating a webhook. -type WebhookUpdateParameters struct { - // Tags - The tags for the webhook. - Tags map[string]*string `json:"tags"` - // WebhookPropertiesUpdateParameters - The properties that the webhook will be updated with. - *WebhookPropertiesUpdateParameters `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for WebhookUpdateParameters. -func (wup WebhookUpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if wup.Tags != nil { - objectMap["tags"] = wup.Tags - } - if wup.WebhookPropertiesUpdateParameters != nil { - objectMap["properties"] = wup.WebhookPropertiesUpdateParameters - } - return json.Marshal(objectMap) -} - -// UnmarshalJSON is the custom unmarshaler for WebhookUpdateParameters struct. -func (wup *WebhookUpdateParameters) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - wup.Tags = tags - } - case "properties": - if v != nil { - var webhookPropertiesUpdateParameters WebhookPropertiesUpdateParameters - err = json.Unmarshal(*v, &webhookPropertiesUpdateParameters) - if err != nil { - return err - } - wup.WebhookPropertiesUpdateParameters = &webhookPropertiesUpdateParameters - } - } - } - - return nil -} diff --git a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/operations.go b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/operations.go index f9bc1f0edc1e..29aac0aa7bc0 100644 --- a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/operations.go +++ b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/operations.go @@ -18,130 +18,130 @@ package containerregistry // Changes may cause incorrect behavior and will be lost if the code is regenerated. import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/tracing" - "net/http" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" + "context" + "github.com/Azure/go-autorest/tracing" ) // OperationsClient is the client for the Operations methods of the Containerregistry service. type OperationsClient struct { - BaseClient + BaseClient } - // NewOperationsClient creates an instance of the OperationsClient client. func NewOperationsClient(subscriptionID string) OperationsClient { - return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) } // NewOperationsClientWithBaseURI creates an instance of the OperationsClient client using a custom endpoint. Use this // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { - return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} + func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{ NewWithBaseURI(baseURI, subscriptionID)} + } // List lists all of the available Azure Container Registry REST API operations. func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") - defer func() { - sc := -1 - if result.olr.Response.Response != nil { - sc = result.olr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", nil, "Failure preparing request") - return - } + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", nil , "Failure preparing request") + return + } - resp, err := client.ListSender(req) - if err != nil { - result.olr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", resp, "Failure sending request") - return - } + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", resp, "Failure sending request") + return + } - result.olr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", resp, "Failure responding to request") - } + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "List", resp, "Failure responding to request") + } - return -} + return + } -// ListPreparer prepares the List request. -func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } + // ListPreparer prepares the List request. + func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.ContainerRegistry/operations"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.ContainerRegistry/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) -} + // ListSender sends the List request. The method will close the + // http.Response Body if it receives an error. + func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + } // ListResponder handles the response to the List request. The method always // closes the http.Response Body. func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } -// listNextResults retrieves the next set of results, if any. -func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { - req, err := lastResults.operationListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} + // listNextResults retrieves the next set of results, if any. + func (client OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "listNextResults", nil , "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return + } + + // ListComplete enumerates all values, automatically crossing page boundaries as required. + func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/OperationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return + } -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx) - return -} diff --git a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/registries.go b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/registries.go index 54bc3dfe1237..d6a286f6bd1c 100644 --- a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/registries.go +++ b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/registries.go @@ -18,937 +18,938 @@ package containerregistry // Changes may cause incorrect behavior and will be lost if the code is regenerated. import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" + "context" + "github.com/Azure/go-autorest/tracing" + "github.com/Azure/go-autorest/autorest/validation" ) // RegistriesClient is the client for the Registries methods of the Containerregistry service. type RegistriesClient struct { - BaseClient + BaseClient } - // NewRegistriesClient creates an instance of the RegistriesClient client. func NewRegistriesClient(subscriptionID string) RegistriesClient { - return NewRegistriesClientWithBaseURI(DefaultBaseURI, subscriptionID) + return NewRegistriesClientWithBaseURI(DefaultBaseURI, subscriptionID) } // NewRegistriesClientWithBaseURI creates an instance of the RegistriesClient client using a custom endpoint. Use this // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewRegistriesClientWithBaseURI(baseURI string, subscriptionID string) RegistriesClient { - return RegistriesClient{NewWithBaseURI(baseURI, subscriptionID)} -} + func NewRegistriesClientWithBaseURI(baseURI string, subscriptionID string) RegistriesClient { + return RegistriesClient{ NewWithBaseURI(baseURI, subscriptionID)} + } // CheckNameAvailability checks whether the container registry name is available for use. The name must contain only // alphanumeric characters, be globally unique, and between 5 and 50 characters in length. -// Parameters: -// registryNameCheckRequest - the object containing information for the availability request. + // Parameters: + // registryNameCheckRequest - the object containing information for the availability request. func (client RegistriesClient) CheckNameAvailability(ctx context.Context, registryNameCheckRequest RegistryNameCheckRequest) (result RegistryNameStatus, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.CheckNameAvailability") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryNameCheckRequest, - Constraints: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.Null, Rule: true, - Chain: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryNameCheckRequest.Name", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryNameCheckRequest.Name", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}, - }}, - {Target: "registryNameCheckRequest.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.RegistriesClient", "CheckNameAvailability", err.Error()) - } - - req, err := client.CheckNameAvailabilityPreparer(ctx, registryNameCheckRequest) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", nil, "Failure preparing request") - return - } - - resp, err := client.CheckNameAvailabilitySender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure sending request") - return - } - - result, err = client.CheckNameAvailabilityResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure responding to request") - } - - return -} - -// CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. -func (client RegistriesClient) CheckNameAvailabilityPreparer(ctx context.Context, registryNameCheckRequest RegistryNameCheckRequest) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability", pathParameters), - autorest.WithJSON(registryNameCheckRequest), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the -// http.Response Body if it receives an error. -func (client RegistriesClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/RegistriesClient.CheckNameAvailability") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryNameCheckRequest, + Constraints: []validation.Constraint{ {Target: "registryNameCheckRequest.Name", Name: validation.Null, Rule: true , + Chain: []validation.Constraint{ {Target: "registryNameCheckRequest.Name", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryNameCheckRequest.Name", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryNameCheckRequest.Name", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }, + }}, + {Target: "registryNameCheckRequest.Type", Name: validation.Null, Rule: true, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.RegistriesClient", "CheckNameAvailability", err.Error()) + } + + req, err := client.CheckNameAvailabilityPreparer(ctx, registryNameCheckRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", nil , "Failure preparing request") + return + } + + resp, err := client.CheckNameAvailabilitySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure sending request") + return + } + + result, err = client.CheckNameAvailabilityResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure responding to request") + } + + return + } + + // CheckNameAvailabilityPreparer prepares the CheckNameAvailability request. + func (client RegistriesClient) CheckNameAvailabilityPreparer(ctx context.Context, registryNameCheckRequest RegistryNameCheckRequest) (*http.Request, error) { + pathParameters := map[string]interface{} { + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/checkNameAvailability",pathParameters), + autorest.WithJSON(registryNameCheckRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // CheckNameAvailabilitySender sends the CheckNameAvailability request. The method will close the + // http.Response Body if it receives an error. + func (client RegistriesClient) CheckNameAvailabilitySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) + } // CheckNameAvailabilityResponder handles the response to the CheckNameAvailability request. The method always // closes the http.Response Body. func (client RegistriesClient) CheckNameAvailabilityResponder(resp *http.Response) (result RegistryNameStatus, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } // Create creates a container registry with the specified parameters. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. -// registry - the parameters for creating a container registry. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. + // registry - the parameters for creating a container registry. func (client RegistriesClient) Create(ctx context.Context, resourceGroupName string, registryName string, registry Registry) (result RegistriesCreateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.Create") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, - {TargetValue: registry, - Constraints: []validation.Constraint{{Target: "registry.Sku", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "registry.RegistryProperties", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "registry.RegistryProperties.StorageAccount", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "registry.RegistryProperties.StorageAccount.ID", Name: validation.Null, Rule: true, Chain: nil}}}, - }}}}}); err != nil { - return result, validation.NewError("containerregistry.RegistriesClient", "Create", err.Error()) - } - - req, err := client.CreatePreparer(ctx, resourceGroupName, registryName, registry) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", nil, "Failure preparing request") - return - } - - result, err = client.CreateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", result.Response(), "Failure sending request") - return - } - - return -} - -// CreatePreparer prepares the Create request. -func (client RegistriesClient) CreatePreparer(ctx context.Context, resourceGroupName string, registryName string, registry Registry) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), - autorest.WithJSON(registry), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client RegistriesClient) CreateSender(req *http.Request) (future RegistriesCreateFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/RegistriesClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}, + { TargetValue: registry, + Constraints: []validation.Constraint{ {Target: "registry.Sku", Name: validation.Null, Rule: true, Chain: nil }, + {Target: "registry.RegistryProperties", Name: validation.Null, Rule: false , + Chain: []validation.Constraint{ {Target: "registry.RegistryProperties.StorageAccount", Name: validation.Null, Rule: false , + Chain: []validation.Constraint{ {Target: "registry.RegistryProperties.StorageAccount.ID", Name: validation.Null, Rule: true, Chain: nil }, + }}, + }}}}}); err != nil { + return result, validation.NewError("containerregistry.RegistriesClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, registryName, registry) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", nil , "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", result.Response(), "Failure sending request") + return + } + + return + } + + // CreatePreparer prepares the Create request. + func (client RegistriesClient) CreatePreparer(ctx context.Context, resourceGroupName string, registryName string, registry Registry) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}",pathParameters), + autorest.WithJSON(registry), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // CreateSender sends the Create request. The method will close the + // http.Response Body if it receives an error. + func (client RegistriesClient) CreateSender(req *http.Request) (future RegistriesCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return + } // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. func (client RegistriesClient) CreateResponder(resp *http.Response) (result Registry, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } // Delete deletes a container registry. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. func (client RegistriesClient) Delete(ctx context.Context, resourceGroupName string, registryName string) (result RegistriesDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.Delete") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.RegistriesClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, registryName) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client RegistriesClient) DeletePreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client RegistriesClient) DeleteSender(req *http.Request) (future RegistriesDeleteFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/RegistriesClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.RegistriesClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, registryName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", nil , "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", result.Response(), "Failure sending request") + return + } + + return + } + + // DeletePreparer prepares the Delete request. + func (client RegistriesClient) DeletePreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}",pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // DeleteSender sends the Delete request. The method will close the + // http.Response Body if it receives an error. + func (client RegistriesClient) DeleteSender(req *http.Request) (future RegistriesDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return + } // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. func (client RegistriesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusAccepted,http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return + } // Get gets the properties of the specified container registry. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. func (client RegistriesClient) Get(ctx context.Context, resourceGroupName string, registryName string) (result Registry, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.RegistriesClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, registryName) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client RegistriesClient) GetPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client RegistriesClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/RegistriesClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.RegistriesClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, registryName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", nil , "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure responding to request") + } + + return + } + + // GetPreparer prepares the Get request. + func (client RegistriesClient) GetPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}",pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // GetSender sends the Get request. The method will close the + // http.Response Body if it receives an error. + func (client RegistriesClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) + } // GetResponder handles the response to the Get request. The method always // closes the http.Response Body. func (client RegistriesClient) GetResponder(resp *http.Response) (result Registry, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } // List lists all the container registries under the specified subscription. func (client RegistriesClient) List(ctx context.Context) (result RegistryListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.List") - defer func() { - sc := -1 - if result.rlr.Response.Response != nil { - sc = result.rlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.rlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure sending request") - return - } - - result.rlr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client RegistriesClient) ListPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client RegistriesClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/RegistriesClient.List") + defer func() { + sc := -1 + if result.rlr.Response.Response != nil { + sc = result.rlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", nil , "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure sending request") + return + } + + result.rlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure responding to request") + } + + return + } + + // ListPreparer prepares the List request. + func (client RegistriesClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{} { + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerRegistry/registries",pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // ListSender sends the List request. The method will close the + // http.Response Body if it receives an error. + func (client RegistriesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) + } // ListResponder handles the response to the List request. The method always // closes the http.Response Body. func (client RegistriesClient) ListResponder(resp *http.Response) (result RegistryListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client RegistriesClient) listNextResults(ctx context.Context, lastResults RegistryListResult) (result RegistryListResult, err error) { - req, err := lastResults.registryListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client RegistriesClient) ListComplete(ctx context.Context) (result RegistryListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx) - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } + + // listNextResults retrieves the next set of results, if any. + func (client RegistriesClient) listNextResults(ctx context.Context, lastResults RegistryListResult) (result RegistryListResult, err error) { + req, err := lastResults.registryListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", nil , "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listNextResults", resp, "Failure responding to next results request") + } + return + } + + // ListComplete enumerates all values, automatically crossing page boundaries as required. + func (client RegistriesClient) ListComplete(ctx context.Context) (result RegistryListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/RegistriesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx) + return + } // ListByResourceGroup lists all the container registries under the specified resource group. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. func (client RegistriesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result RegistryListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListByResourceGroup") - defer func() { - sc := -1 - if result.rlr.Response.Response != nil { - sc = result.rlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.fn = client.listByResourceGroupNextResults - req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", nil, "Failure preparing request") - return - } - - resp, err := client.ListByResourceGroupSender(req) - if err != nil { - result.rlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure sending request") - return - } - - result.rlr, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure responding to request") - } - - return -} - -// ListByResourceGroupPreparer prepares the ListByResourceGroup request. -func (client RegistriesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the -// http.Response Body if it receives an error. -func (client RegistriesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/RegistriesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.rlr.Response.Response != nil { + sc = result.rlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", nil , "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.rlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.rlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return + } + + // ListByResourceGroupPreparer prepares the ListByResourceGroup request. + func (client RegistriesClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{} { + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries",pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the + // http.Response Body if it receives an error. + func (client RegistriesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) + } // ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always // closes the http.Response Body. func (client RegistriesClient) ListByResourceGroupResponder(resp *http.Response) (result RegistryListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listByResourceGroupNextResults retrieves the next set of results, if any. -func (client RegistriesClient) listByResourceGroupNextResults(ctx context.Context, lastResults RegistryListResult) (result RegistryListResult, err error) { - req, err := lastResults.registryListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListByResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") - } - result, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. -func (client RegistriesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result RegistryListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListByResourceGroup") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } + + // listByResourceGroupNextResults retrieves the next set of results, if any. + func (client RegistriesClient) listByResourceGroupNextResults(ctx context.Context, lastResults RegistryListResult) (result RegistryListResult, err error) { + req, err := lastResults.registryListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", nil , "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return + } + + // ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. + func (client RegistriesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result RegistryListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/RegistriesClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListByResourceGroup(ctx, resourceGroupName) + return + } // ListCredentials lists the login credentials for the specified container registry. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. func (client RegistriesClient) ListCredentials(ctx context.Context, resourceGroupName string, registryName string) (result RegistryListCredentialsResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListCredentials") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.RegistriesClient", "ListCredentials", err.Error()) - } - - req, err := client.ListCredentialsPreparer(ctx, resourceGroupName, registryName) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", nil, "Failure preparing request") - return - } - - resp, err := client.ListCredentialsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure sending request") - return - } - - result, err = client.ListCredentialsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure responding to request") - } - - return -} - -// ListCredentialsPreparer prepares the ListCredentials request. -func (client RegistriesClient) ListCredentialsPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListCredentialsSender sends the ListCredentials request. The method will close the -// http.Response Body if it receives an error. -func (client RegistriesClient) ListCredentialsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/RegistriesClient.ListCredentials") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.RegistriesClient", "ListCredentials", err.Error()) + } + + req, err := client.ListCredentialsPreparer(ctx, resourceGroupName, registryName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", nil , "Failure preparing request") + return + } + + resp, err := client.ListCredentialsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure sending request") + return + } + + result, err = client.ListCredentialsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure responding to request") + } + + return + } + + // ListCredentialsPreparer prepares the ListCredentials request. + func (client RegistriesClient) ListCredentialsPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials",pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // ListCredentialsSender sends the ListCredentials request. The method will close the + // http.Response Body if it receives an error. + func (client RegistriesClient) ListCredentialsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) + } // ListCredentialsResponder handles the response to the ListCredentials request. The method always // closes the http.Response Body. func (client RegistriesClient) ListCredentialsResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } // ListUsages gets the quota usages for the specified container registry. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. func (client RegistriesClient) ListUsages(ctx context.Context, resourceGroupName string, registryName string) (result RegistryUsageListResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.ListUsages") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.RegistriesClient", "ListUsages", err.Error()) - } - - req, err := client.ListUsagesPreparer(ctx, resourceGroupName, registryName) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListUsages", nil, "Failure preparing request") - return - } - - resp, err := client.ListUsagesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListUsages", resp, "Failure sending request") - return - } - - result, err = client.ListUsagesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListUsages", resp, "Failure responding to request") - } - - return -} - -// ListUsagesPreparer prepares the ListUsages request. -func (client RegistriesClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListUsagesSender sends the ListUsages request. The method will close the -// http.Response Body if it receives an error. -func (client RegistriesClient) ListUsagesSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/RegistriesClient.ListUsages") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.RegistriesClient", "ListUsages", err.Error()) + } + + req, err := client.ListUsagesPreparer(ctx, resourceGroupName, registryName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListUsages", nil , "Failure preparing request") + return + } + + resp, err := client.ListUsagesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListUsages", resp, "Failure sending request") + return + } + + result, err = client.ListUsagesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListUsages", resp, "Failure responding to request") + } + + return + } + + // ListUsagesPreparer prepares the ListUsages request. + func (client RegistriesClient) ListUsagesPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listUsages",pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // ListUsagesSender sends the ListUsages request. The method will close the + // http.Response Body if it receives an error. + func (client RegistriesClient) ListUsagesSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) + } // ListUsagesResponder handles the response to the ListUsages request. The method always // closes the http.Response Body. func (client RegistriesClient) ListUsagesResponder(resp *http.Response) (result RegistryUsageListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } // RegenerateCredential regenerates one of the login credentials for the specified container registry. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. -// regenerateCredentialParameters - specifies name of the password which should be regenerated -- password or -// password2. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. + // regenerateCredentialParameters - specifies name of the password which should be regenerated -- password or + // password2. func (client RegistriesClient) RegenerateCredential(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (result RegistryListCredentialsResult, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.RegenerateCredential") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.RegistriesClient", "RegenerateCredential", err.Error()) - } - - req, err := client.RegenerateCredentialPreparer(ctx, resourceGroupName, registryName, regenerateCredentialParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", nil, "Failure preparing request") - return - } - - resp, err := client.RegenerateCredentialSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure sending request") - return - } - - result, err = client.RegenerateCredentialResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure responding to request") - } - - return -} - -// RegenerateCredentialPreparer prepares the RegenerateCredential request. -func (client RegistriesClient) RegenerateCredentialPreparer(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", pathParameters), - autorest.WithJSON(regenerateCredentialParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// RegenerateCredentialSender sends the RegenerateCredential request. The method will close the -// http.Response Body if it receives an error. -func (client RegistriesClient) RegenerateCredentialSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/RegistriesClient.RegenerateCredential") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.RegistriesClient", "RegenerateCredential", err.Error()) + } + + req, err := client.RegenerateCredentialPreparer(ctx, resourceGroupName, registryName, regenerateCredentialParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", nil , "Failure preparing request") + return + } + + resp, err := client.RegenerateCredentialSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure sending request") + return + } + + result, err = client.RegenerateCredentialResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure responding to request") + } + + return + } + + // RegenerateCredentialPreparer prepares the RegenerateCredential request. + func (client RegistriesClient) RegenerateCredentialPreparer(ctx context.Context, resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential",pathParameters), + autorest.WithJSON(regenerateCredentialParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // RegenerateCredentialSender sends the RegenerateCredential request. The method will close the + // http.Response Body if it receives an error. + func (client RegistriesClient) RegenerateCredentialSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) + } // RegenerateCredentialResponder handles the response to the RegenerateCredential request. The method always // closes the http.Response Body. func (client RegistriesClient) RegenerateCredentialResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } // Update updates a container registry with the specified parameters. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. -// registryUpdateParameters - the parameters for updating a container registry. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. + // registryUpdateParameters - the parameters for updating a container registry. func (client RegistriesClient) Update(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (result RegistriesUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/RegistriesClient.Update") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.RegistriesClient", "Update", err.Error()) - } - - req, err := client.UpdatePreparer(ctx, resourceGroupName, registryName, registryUpdateParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil, "Failure preparing request") - return - } - - result, err = client.UpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client RegistriesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), - autorest.WithJSON(registryUpdateParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSender sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (client RegistriesClient) UpdateSender(req *http.Request) (future RegistriesUpdateFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/RegistriesClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.RegistriesClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, registryName, registryUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil , "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", result.Response(), "Failure sending request") + return + } + + return + } + + // UpdatePreparer prepares the Update request. + func (client RegistriesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}",pathParameters), + autorest.WithJSON(registryUpdateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // UpdateSender sends the Update request. The method will close the + // http.Response Body if it receives an error. + func (client RegistriesClient) UpdateSender(req *http.Request) (future RegistriesUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return + } // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. func (client RegistriesClient) UpdateResponder(resp *http.Response) (result Registry, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } + diff --git a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/replications.go b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/replications.go index c9ef0ed1f616..dd2977d5d064 100644 --- a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/replications.go +++ b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/replications.go @@ -18,513 +18,513 @@ package containerregistry // Changes may cause incorrect behavior and will be lost if the code is regenerated. import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" + "context" + "github.com/Azure/go-autorest/tracing" + "github.com/Azure/go-autorest/autorest/validation" ) // ReplicationsClient is the client for the Replications methods of the Containerregistry service. type ReplicationsClient struct { - BaseClient + BaseClient } - // NewReplicationsClient creates an instance of the ReplicationsClient client. func NewReplicationsClient(subscriptionID string) ReplicationsClient { - return NewReplicationsClientWithBaseURI(DefaultBaseURI, subscriptionID) + return NewReplicationsClientWithBaseURI(DefaultBaseURI, subscriptionID) } // NewReplicationsClientWithBaseURI creates an instance of the ReplicationsClient client using a custom endpoint. Use // this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewReplicationsClientWithBaseURI(baseURI string, subscriptionID string) ReplicationsClient { - return ReplicationsClient{NewWithBaseURI(baseURI, subscriptionID)} -} + func NewReplicationsClientWithBaseURI(baseURI string, subscriptionID string) ReplicationsClient { + return ReplicationsClient{ NewWithBaseURI(baseURI, subscriptionID)} + } // Create creates a replication for a container registry with the specified parameters. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. -// replicationName - the name of the replication. -// replication - the parameters for creating a replication. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. + // replicationName - the name of the replication. + // replication - the parameters for creating a replication. func (client ReplicationsClient) Create(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replication Replication) (result ReplicationsCreateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationsClient.Create") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, - {TargetValue: replicationName, - Constraints: []validation.Constraint{{Target: "replicationName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "replicationName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "replicationName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.ReplicationsClient", "Create", err.Error()) - } - - req, err := client.CreatePreparer(ctx, resourceGroupName, registryName, replicationName, replication) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Create", nil, "Failure preparing request") - return - } - - result, err = client.CreateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Create", result.Response(), "Failure sending request") - return - } - - return -} - -// CreatePreparer prepares the Create request. -func (client ReplicationsClient) CreatePreparer(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replication Replication) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "replicationName": autorest.Encode("path", replicationName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", pathParameters), - autorest.WithJSON(replication), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client ReplicationsClient) CreateSender(req *http.Request) (future ReplicationsCreateFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/ReplicationsClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}, + { TargetValue: replicationName, + Constraints: []validation.Constraint{ {Target: "replicationName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "replicationName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "replicationName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.ReplicationsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, registryName, replicationName, replication) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Create", nil , "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Create", result.Response(), "Failure sending request") + return + } + + return + } + + // CreatePreparer prepares the Create request. + func (client ReplicationsClient) CreatePreparer(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replication Replication) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "replicationName": autorest.Encode("path",replicationName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}",pathParameters), + autorest.WithJSON(replication), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // CreateSender sends the Create request. The method will close the + // http.Response Body if it receives an error. + func (client ReplicationsClient) CreateSender(req *http.Request) (future ReplicationsCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return + } // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. func (client ReplicationsClient) CreateResponder(resp *http.Response) (result Replication, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } // Delete deletes a replication from a container registry. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. -// replicationName - the name of the replication. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. + // replicationName - the name of the replication. func (client ReplicationsClient) Delete(ctx context.Context, resourceGroupName string, registryName string, replicationName string) (result ReplicationsDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationsClient.Delete") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, - {TargetValue: replicationName, - Constraints: []validation.Constraint{{Target: "replicationName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "replicationName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "replicationName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.ReplicationsClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, registryName, replicationName) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client ReplicationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, registryName string, replicationName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "replicationName": autorest.Encode("path", replicationName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client ReplicationsClient) DeleteSender(req *http.Request) (future ReplicationsDeleteFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/ReplicationsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}, + { TargetValue: replicationName, + Constraints: []validation.Constraint{ {Target: "replicationName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "replicationName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "replicationName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.ReplicationsClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, registryName, replicationName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Delete", nil , "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return + } + + // DeletePreparer prepares the Delete request. + func (client ReplicationsClient) DeletePreparer(ctx context.Context, resourceGroupName string, registryName string, replicationName string) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "replicationName": autorest.Encode("path",replicationName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}",pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // DeleteSender sends the Delete request. The method will close the + // http.Response Body if it receives an error. + func (client ReplicationsClient) DeleteSender(req *http.Request) (future ReplicationsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return + } // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. func (client ReplicationsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusAccepted,http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return + } // Get gets the properties of the specified replication. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. -// replicationName - the name of the replication. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. + // replicationName - the name of the replication. func (client ReplicationsClient) Get(ctx context.Context, resourceGroupName string, registryName string, replicationName string) (result Replication, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationsClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, - {TargetValue: replicationName, - Constraints: []validation.Constraint{{Target: "replicationName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "replicationName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "replicationName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.ReplicationsClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, registryName, replicationName) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client ReplicationsClient) GetPreparer(ctx context.Context, resourceGroupName string, registryName string, replicationName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "replicationName": autorest.Encode("path", replicationName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client ReplicationsClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/ReplicationsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}, + { TargetValue: replicationName, + Constraints: []validation.Constraint{ {Target: "replicationName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "replicationName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "replicationName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.ReplicationsClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, registryName, replicationName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Get", nil , "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Get", resp, "Failure responding to request") + } + + return + } + + // GetPreparer prepares the Get request. + func (client ReplicationsClient) GetPreparer(ctx context.Context, resourceGroupName string, registryName string, replicationName string) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "replicationName": autorest.Encode("path",replicationName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}",pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // GetSender sends the Get request. The method will close the + // http.Response Body if it receives an error. + func (client ReplicationsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) + } // GetResponder handles the response to the Get request. The method always // closes the http.Response Body. func (client ReplicationsClient) GetResponder(resp *http.Response) (result Replication, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } // List lists all the replications for the specified container registry. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. func (client ReplicationsClient) List(ctx context.Context, resourceGroupName string, registryName string) (result ReplicationListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationsClient.List") - defer func() { - sc := -1 - if result.rlr.Response.Response != nil { - sc = result.rlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.ReplicationsClient", "List", err.Error()) - } - - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, resourceGroupName, registryName) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.rlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "List", resp, "Failure sending request") - return - } - - result.rlr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client ReplicationsClient) ListPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client ReplicationsClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/ReplicationsClient.List") + defer func() { + sc := -1 + if result.rlr.Response.Response != nil { + sc = result.rlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.ReplicationsClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, registryName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "List", nil , "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.rlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "List", resp, "Failure sending request") + return + } + + result.rlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "List", resp, "Failure responding to request") + } + + return + } + + // ListPreparer prepares the List request. + func (client ReplicationsClient) ListPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications",pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // ListSender sends the List request. The method will close the + // http.Response Body if it receives an error. + func (client ReplicationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) + } // ListResponder handles the response to the List request. The method always // closes the http.Response Body. func (client ReplicationsClient) ListResponder(resp *http.Response) (result ReplicationListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client ReplicationsClient) listNextResults(ctx context.Context, lastResults ReplicationListResult) (result ReplicationListResult, err error) { - req, err := lastResults.replicationListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client ReplicationsClient) ListComplete(ctx context.Context, resourceGroupName string, registryName string) (result ReplicationListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationsClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, resourceGroupName, registryName) - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } + + // listNextResults retrieves the next set of results, if any. + func (client ReplicationsClient) listNextResults(ctx context.Context, lastResults ReplicationListResult) (result ReplicationListResult, err error) { + req, err := lastResults.replicationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "listNextResults", nil , "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return + } + + // ListComplete enumerates all values, automatically crossing page boundaries as required. + func (client ReplicationsClient) ListComplete(ctx context.Context, resourceGroupName string, registryName string) (result ReplicationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/ReplicationsClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, registryName) + return + } // Update updates a replication for a container registry with the specified parameters. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. -// replicationName - the name of the replication. -// replicationUpdateParameters - the parameters for updating a replication. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. + // replicationName - the name of the replication. + // replicationUpdateParameters - the parameters for updating a replication. func (client ReplicationsClient) Update(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replicationUpdateParameters ReplicationUpdateParameters) (result ReplicationsUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/ReplicationsClient.Update") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, - {TargetValue: replicationName, - Constraints: []validation.Constraint{{Target: "replicationName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "replicationName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "replicationName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.ReplicationsClient", "Update", err.Error()) - } - - req, err := client.UpdatePreparer(ctx, resourceGroupName, registryName, replicationName, replicationUpdateParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Update", nil, "Failure preparing request") - return - } - - result, err = client.UpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Update", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client ReplicationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replicationUpdateParameters ReplicationUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "replicationName": autorest.Encode("path", replicationName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}", pathParameters), - autorest.WithJSON(replicationUpdateParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSender sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (client ReplicationsClient) UpdateSender(req *http.Request) (future ReplicationsUpdateFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/ReplicationsClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}, + { TargetValue: replicationName, + Constraints: []validation.Constraint{ {Target: "replicationName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "replicationName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "replicationName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.ReplicationsClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, registryName, replicationName, replicationUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Update", nil , "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.ReplicationsClient", "Update", result.Response(), "Failure sending request") + return + } + + return + } + + // UpdatePreparer prepares the Update request. + func (client ReplicationsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, registryName string, replicationName string, replicationUpdateParameters ReplicationUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "replicationName": autorest.Encode("path",replicationName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/replications/{replicationName}",pathParameters), + autorest.WithJSON(replicationUpdateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // UpdateSender sends the Update request. The method will close the + // http.Response Body if it receives an error. + func (client ReplicationsClient) UpdateSender(req *http.Request) (future ReplicationsUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return + } // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. func (client ReplicationsClient) UpdateResponder(resp *http.Response) (result Replication, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } + diff --git a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/version.go b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/version.go index e7c5789678e8..4a77a36af2cd 100644 --- a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/version.go +++ b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/version.go @@ -19,12 +19,13 @@ import "github.com/Azure/azure-sdk-for-go/version" // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. + // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/" + version.Number + " containerregistry/2017-06-01-preview" + return "Azure-SDK-For-Go/" + version.Number + " containerregistry/2017-06-01-preview" } // Version returns the semantic version (see http://semver.org) of the client. func Version() string { - return version.Number + return version.Number } diff --git a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/webhooks.go b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/webhooks.go index f69e4bff0c2c..1b1dcc064f5c 100644 --- a/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/webhooks.go +++ b/services/preview/containerregistry/mgmt/2017-06-01-preview/containerregistry/webhooks.go @@ -18,827 +18,827 @@ package containerregistry // Changes may cause incorrect behavior and will be lost if the code is regenerated. import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/Azure/go-autorest/tracing" - "net/http" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" + "context" + "github.com/Azure/go-autorest/tracing" + "github.com/Azure/go-autorest/autorest/validation" ) // WebhooksClient is the client for the Webhooks methods of the Containerregistry service. type WebhooksClient struct { - BaseClient + BaseClient } - // NewWebhooksClient creates an instance of the WebhooksClient client. func NewWebhooksClient(subscriptionID string) WebhooksClient { - return NewWebhooksClientWithBaseURI(DefaultBaseURI, subscriptionID) + return NewWebhooksClientWithBaseURI(DefaultBaseURI, subscriptionID) } // NewWebhooksClientWithBaseURI creates an instance of the WebhooksClient client using a custom endpoint. Use this // when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). -func NewWebhooksClientWithBaseURI(baseURI string, subscriptionID string) WebhooksClient { - return WebhooksClient{NewWithBaseURI(baseURI, subscriptionID)} -} + func NewWebhooksClientWithBaseURI(baseURI string, subscriptionID string) WebhooksClient { + return WebhooksClient{ NewWithBaseURI(baseURI, subscriptionID)} + } // Create creates a webhook for a container registry with the specified parameters. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. -// webhookName - the name of the webhook. -// webhookCreateParameters - the parameters for creating a webhook. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. + // webhookName - the name of the webhook. + // webhookCreateParameters - the parameters for creating a webhook. func (client WebhooksClient) Create(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookCreateParameters WebhookCreateParameters) (result WebhooksCreateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/WebhooksClient.Create") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, - {TargetValue: webhookName, - Constraints: []validation.Constraint{{Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, - {TargetValue: webhookCreateParameters, - Constraints: []validation.Constraint{{Target: "webhookCreateParameters.Location", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "webhookCreateParameters.WebhookPropertiesCreateParameters", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "webhookCreateParameters.WebhookPropertiesCreateParameters.ServiceURI", Name: validation.Null, Rule: true, Chain: nil}, - {Target: "webhookCreateParameters.WebhookPropertiesCreateParameters.Actions", Name: validation.Null, Rule: true, Chain: nil}, - }}}}}); err != nil { - return result, validation.NewError("containerregistry.WebhooksClient", "Create", err.Error()) - } - - req, err := client.CreatePreparer(ctx, resourceGroupName, registryName, webhookName, webhookCreateParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Create", nil, "Failure preparing request") - return - } - - result, err = client.CreateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Create", result.Response(), "Failure sending request") - return - } - - return -} - -// CreatePreparer prepares the Create request. -func (client WebhooksClient) CreatePreparer(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookCreateParameters WebhookCreateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "webhookName": autorest.Encode("path", webhookName), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", pathParameters), - autorest.WithJSON(webhookCreateParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client WebhooksClient) CreateSender(req *http.Request) (future WebhooksCreateFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/WebhooksClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}, + { TargetValue: webhookName, + Constraints: []validation.Constraint{ {Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}, + { TargetValue: webhookCreateParameters, + Constraints: []validation.Constraint{ {Target: "webhookCreateParameters.Location", Name: validation.Null, Rule: true, Chain: nil }, + {Target: "webhookCreateParameters.WebhookPropertiesCreateParameters", Name: validation.Null, Rule: false , + Chain: []validation.Constraint{ {Target: "webhookCreateParameters.WebhookPropertiesCreateParameters.ServiceURI", Name: validation.Null, Rule: true, Chain: nil }, + {Target: "webhookCreateParameters.WebhookPropertiesCreateParameters.Actions", Name: validation.Null, Rule: true, Chain: nil }, + }}}}}); err != nil { + return result, validation.NewError("containerregistry.WebhooksClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, registryName, webhookName, webhookCreateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Create", nil , "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Create", result.Response(), "Failure sending request") + return + } + + return + } + + // CreatePreparer prepares the Create request. + func (client WebhooksClient) CreatePreparer(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookCreateParameters WebhookCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + "webhookName": autorest.Encode("path",webhookName), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}",pathParameters), + autorest.WithJSON(webhookCreateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // CreateSender sends the Create request. The method will close the + // http.Response Body if it receives an error. + func (client WebhooksClient) CreateSender(req *http.Request) (future WebhooksCreateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return + } // CreateResponder handles the response to the Create request. The method always // closes the http.Response Body. func (client WebhooksClient) CreateResponder(resp *http.Response) (result Webhook, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } // Delete deletes a webhook from a container registry. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. -// webhookName - the name of the webhook. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. + // webhookName - the name of the webhook. func (client WebhooksClient) Delete(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result WebhooksDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/WebhooksClient.Delete") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, - {TargetValue: webhookName, - Constraints: []validation.Constraint{{Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.WebhooksClient", "Delete", err.Error()) - } - - req, err := client.DeletePreparer(ctx, resourceGroupName, registryName, webhookName) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Delete", nil, "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Delete", result.Response(), "Failure sending request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client WebhooksClient) DeletePreparer(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "webhookName": autorest.Encode("path", webhookName), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client WebhooksClient) DeleteSender(req *http.Request) (future WebhooksDeleteFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/WebhooksClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}, + { TargetValue: webhookName, + Constraints: []validation.Constraint{ {Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.WebhooksClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, registryName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Delete", nil , "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Delete", result.Response(), "Failure sending request") + return + } + + return + } + + // DeletePreparer prepares the Delete request. + func (client WebhooksClient) DeletePreparer(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + "webhookName": autorest.Encode("path",webhookName), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}",pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // DeleteSender sends the Delete request. The method will close the + // http.Response Body if it receives an error. + func (client WebhooksClient) DeleteSender(req *http.Request) (future WebhooksDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return + } // DeleteResponder handles the response to the Delete request. The method always // closes the http.Response Body. func (client WebhooksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusAccepted,http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return + } // Get gets the properties of the specified webhook. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. -// webhookName - the name of the webhook. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. + // webhookName - the name of the webhook. func (client WebhooksClient) Get(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result Webhook, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/WebhooksClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, - {TargetValue: webhookName, - Constraints: []validation.Constraint{{Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.WebhooksClient", "Get", err.Error()) - } - - req, err := client.GetPreparer(ctx, resourceGroupName, registryName, webhookName) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Get", resp, "Failure responding to request") - } - - return -} - -// GetPreparer prepares the Get request. -func (client WebhooksClient) GetPreparer(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "webhookName": autorest.Encode("path", webhookName), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client WebhooksClient) GetSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/WebhooksClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}, + { TargetValue: webhookName, + Constraints: []validation.Constraint{ {Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.WebhooksClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, registryName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Get", nil , "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Get", resp, "Failure responding to request") + } + + return + } + + // GetPreparer prepares the Get request. + func (client WebhooksClient) GetPreparer(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + "webhookName": autorest.Encode("path",webhookName), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}",pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // GetSender sends the Get request. The method will close the + // http.Response Body if it receives an error. + func (client WebhooksClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) + } // GetResponder handles the response to the Get request. The method always // closes the http.Response Body. func (client WebhooksClient) GetResponder(resp *http.Response) (result Webhook, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } // GetCallbackConfig gets the configuration of service URI and custom headers for the webhook. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. -// webhookName - the name of the webhook. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. + // webhookName - the name of the webhook. func (client WebhooksClient) GetCallbackConfig(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result CallbackConfig, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/WebhooksClient.GetCallbackConfig") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, - {TargetValue: webhookName, - Constraints: []validation.Constraint{{Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.WebhooksClient", "GetCallbackConfig", err.Error()) - } - - req, err := client.GetCallbackConfigPreparer(ctx, resourceGroupName, registryName, webhookName) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "GetCallbackConfig", nil, "Failure preparing request") - return - } - - resp, err := client.GetCallbackConfigSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "GetCallbackConfig", resp, "Failure sending request") - return - } - - result, err = client.GetCallbackConfigResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "GetCallbackConfig", resp, "Failure responding to request") - } - - return -} - -// GetCallbackConfigPreparer prepares the GetCallbackConfig request. -func (client WebhooksClient) GetCallbackConfigPreparer(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "webhookName": autorest.Encode("path", webhookName), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetCallbackConfigSender sends the GetCallbackConfig request. The method will close the -// http.Response Body if it receives an error. -func (client WebhooksClient) GetCallbackConfigSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/WebhooksClient.GetCallbackConfig") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}, + { TargetValue: webhookName, + Constraints: []validation.Constraint{ {Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.WebhooksClient", "GetCallbackConfig", err.Error()) + } + + req, err := client.GetCallbackConfigPreparer(ctx, resourceGroupName, registryName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "GetCallbackConfig", nil , "Failure preparing request") + return + } + + resp, err := client.GetCallbackConfigSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "GetCallbackConfig", resp, "Failure sending request") + return + } + + result, err = client.GetCallbackConfigResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "GetCallbackConfig", resp, "Failure responding to request") + } + + return + } + + // GetCallbackConfigPreparer prepares the GetCallbackConfig request. + func (client WebhooksClient) GetCallbackConfigPreparer(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + "webhookName": autorest.Encode("path",webhookName), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/getCallbackConfig",pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // GetCallbackConfigSender sends the GetCallbackConfig request. The method will close the + // http.Response Body if it receives an error. + func (client WebhooksClient) GetCallbackConfigSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) + } // GetCallbackConfigResponder handles the response to the GetCallbackConfig request. The method always // closes the http.Response Body. func (client WebhooksClient) GetCallbackConfigResponder(resp *http.Response) (result CallbackConfig, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } // List lists all the webhooks for the specified container registry. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. func (client WebhooksClient) List(ctx context.Context, resourceGroupName string, registryName string) (result WebhookListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/WebhooksClient.List") - defer func() { - sc := -1 - if result.wlr.Response.Response != nil { - sc = result.wlr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.WebhooksClient", "List", err.Error()) - } - - result.fn = client.listNextResults - req, err := client.ListPreparer(ctx, resourceGroupName, registryName) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.wlr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "List", resp, "Failure sending request") - return - } - - result.wlr, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client WebhooksClient) ListPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client WebhooksClient) ListSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/WebhooksClient.List") + defer func() { + sc := -1 + if result.wlr.Response.Response != nil { + sc = result.wlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.WebhooksClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, registryName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "List", nil , "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.wlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "List", resp, "Failure sending request") + return + } + + result.wlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "List", resp, "Failure responding to request") + } + + return + } + + // ListPreparer prepares the List request. + func (client WebhooksClient) ListPreparer(ctx context.Context, resourceGroupName string, registryName string) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks",pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // ListSender sends the List request. The method will close the + // http.Response Body if it receives an error. + func (client WebhooksClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) + } // ListResponder handles the response to the List request. The method always // closes the http.Response Body. func (client WebhooksClient) ListResponder(resp *http.Response) (result WebhookListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listNextResults retrieves the next set of results, if any. -func (client WebhooksClient) listNextResults(ctx context.Context, lastResults WebhookListResult) (result WebhookListResult, err error) { - req, err := lastResults.webhookListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "listNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "listNextResults", resp, "Failure sending next results request") - } - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "listNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListComplete enumerates all values, automatically crossing page boundaries as required. -func (client WebhooksClient) ListComplete(ctx context.Context, resourceGroupName string, registryName string) (result WebhookListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/WebhooksClient.List") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.List(ctx, resourceGroupName, registryName) - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } + + // listNextResults retrieves the next set of results, if any. + func (client WebhooksClient) listNextResults(ctx context.Context, lastResults WebhookListResult) (result WebhookListResult, err error) { + req, err := lastResults.webhookListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "listNextResults", nil , "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "listNextResults", resp, "Failure responding to next results request") + } + return + } + + // ListComplete enumerates all values, automatically crossing page boundaries as required. + func (client WebhooksClient) ListComplete(ctx context.Context, resourceGroupName string, registryName string) (result WebhookListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/WebhooksClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, registryName) + return + } // ListEvents lists recent events for the specified webhook. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. -// webhookName - the name of the webhook. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. + // webhookName - the name of the webhook. func (client WebhooksClient) ListEvents(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result EventListResultPage, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/WebhooksClient.ListEvents") - defer func() { - sc := -1 - if result.elr.Response.Response != nil { - sc = result.elr.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, - {TargetValue: webhookName, - Constraints: []validation.Constraint{{Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.WebhooksClient", "ListEvents", err.Error()) - } - - result.fn = client.listEventsNextResults - req, err := client.ListEventsPreparer(ctx, resourceGroupName, registryName, webhookName) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "ListEvents", nil, "Failure preparing request") - return - } - - resp, err := client.ListEventsSender(req) - if err != nil { - result.elr.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "ListEvents", resp, "Failure sending request") - return - } - - result.elr, err = client.ListEventsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "ListEvents", resp, "Failure responding to request") - } - - return -} - -// ListEventsPreparer prepares the ListEvents request. -func (client WebhooksClient) ListEventsPreparer(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "webhookName": autorest.Encode("path", webhookName), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListEventsSender sends the ListEvents request. The method will close the -// http.Response Body if it receives an error. -func (client WebhooksClient) ListEventsSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/WebhooksClient.ListEvents") + defer func() { + sc := -1 + if result.elr.Response.Response != nil { + sc = result.elr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}, + { TargetValue: webhookName, + Constraints: []validation.Constraint{ {Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.WebhooksClient", "ListEvents", err.Error()) + } + + result.fn = client.listEventsNextResults + req, err := client.ListEventsPreparer(ctx, resourceGroupName, registryName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "ListEvents", nil , "Failure preparing request") + return + } + + resp, err := client.ListEventsSender(req) + if err != nil { + result.elr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "ListEvents", resp, "Failure sending request") + return + } + + result.elr, err = client.ListEventsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "ListEvents", resp, "Failure responding to request") + } + + return + } + + // ListEventsPreparer prepares the ListEvents request. + func (client WebhooksClient) ListEventsPreparer(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + "webhookName": autorest.Encode("path",webhookName), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/listEvents",pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // ListEventsSender sends the ListEvents request. The method will close the + // http.Response Body if it receives an error. + func (client WebhooksClient) ListEventsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) + } // ListEventsResponder handles the response to the ListEvents request. The method always // closes the http.Response Body. func (client WebhooksClient) ListEventsResponder(resp *http.Response) (result EventListResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -// listEventsNextResults retrieves the next set of results, if any. -func (client WebhooksClient) listEventsNextResults(ctx context.Context, lastResults EventListResult) (result EventListResult, err error) { - req, err := lastResults.eventListResultPreparer(ctx) - if err != nil { - return result, autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "listEventsNextResults", nil, "Failure preparing next results request") - } - if req == nil { - return - } - resp, err := client.ListEventsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - return result, autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "listEventsNextResults", resp, "Failure sending next results request") - } - result, err = client.ListEventsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "listEventsNextResults", resp, "Failure responding to next results request") - } - return -} - -// ListEventsComplete enumerates all values, automatically crossing page boundaries as required. -func (client WebhooksClient) ListEventsComplete(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result EventListResultIterator, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/WebhooksClient.ListEvents") - defer func() { - sc := -1 - if result.Response().Response.Response != nil { - sc = result.page.Response().Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - result.page, err = client.ListEvents(ctx, resourceGroupName, registryName, webhookName) - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } + + // listEventsNextResults retrieves the next set of results, if any. + func (client WebhooksClient) listEventsNextResults(ctx context.Context, lastResults EventListResult) (result EventListResult, err error) { + req, err := lastResults.eventListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "listEventsNextResults", nil , "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListEventsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "listEventsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListEventsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "listEventsNextResults", resp, "Failure responding to next results request") + } + return + } + + // ListEventsComplete enumerates all values, automatically crossing page boundaries as required. + func (client WebhooksClient) ListEventsComplete(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result EventListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/WebhooksClient.ListEvents") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListEvents(ctx, resourceGroupName, registryName, webhookName) + return + } // Ping triggers a ping event to be sent to the webhook. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. -// webhookName - the name of the webhook. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. + // webhookName - the name of the webhook. func (client WebhooksClient) Ping(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (result EventInfo, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/WebhooksClient.Ping") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, - {TargetValue: webhookName, - Constraints: []validation.Constraint{{Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.WebhooksClient", "Ping", err.Error()) - } - - req, err := client.PingPreparer(ctx, resourceGroupName, registryName, webhookName) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Ping", nil, "Failure preparing request") - return - } - - resp, err := client.PingSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Ping", resp, "Failure sending request") - return - } - - result, err = client.PingResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Ping", resp, "Failure responding to request") - } - - return -} - -// PingPreparer prepares the Ping request. -func (client WebhooksClient) PingPreparer(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "webhookName": autorest.Encode("path", webhookName), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// PingSender sends the Ping request. The method will close the -// http.Response Body if it receives an error. -func (client WebhooksClient) PingSender(req *http.Request) (*http.Response, error) { - return client.Send(req, azure.DoRetryWithRegistration(client.Client)) -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/WebhooksClient.Ping") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}, + { TargetValue: webhookName, + Constraints: []validation.Constraint{ {Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.WebhooksClient", "Ping", err.Error()) + } + + req, err := client.PingPreparer(ctx, resourceGroupName, registryName, webhookName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Ping", nil , "Failure preparing request") + return + } + + resp, err := client.PingSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Ping", resp, "Failure sending request") + return + } + + result, err = client.PingResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Ping", resp, "Failure responding to request") + } + + return + } + + // PingPreparer prepares the Ping request. + func (client WebhooksClient) PingPreparer(ctx context.Context, resourceGroupName string, registryName string, webhookName string) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + "webhookName": autorest.Encode("path",webhookName), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}/ping",pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // PingSender sends the Ping request. The method will close the + // http.Response Body if it receives an error. + func (client WebhooksClient) PingSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) + } // PingResponder handles the response to the Ping request. The method always // closes the http.Response Body. func (client WebhooksClient) PingResponder(resp *http.Response) (result EventInfo, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } // Update updates a webhook with the specified parameters. -// Parameters: -// resourceGroupName - the name of the resource group to which the container registry belongs. -// registryName - the name of the container registry. -// webhookName - the name of the webhook. -// webhookUpdateParameters - the parameters for updating a webhook. + // Parameters: + // resourceGroupName - the name of the resource group to which the container registry belongs. + // registryName - the name of the container registry. + // webhookName - the name of the webhook. + // webhookUpdateParameters - the parameters for updating a webhook. func (client WebhooksClient) Update(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookUpdateParameters WebhookUpdateParameters) (result WebhooksUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn+"/WebhooksClient.Update") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - if err := validation.Validate([]validation.Validation{ - {TargetValue: registryName, - Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}, - {TargetValue: webhookName, - Constraints: []validation.Constraint{{Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil}, - {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil}, - {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil { - return result, validation.NewError("containerregistry.WebhooksClient", "Update", err.Error()) - } - - req, err := client.UpdatePreparer(ctx, resourceGroupName, registryName, webhookName, webhookUpdateParameters) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Update", nil, "Failure preparing request") - return - } - - result, err = client.UpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Update", result.Response(), "Failure sending request") - return - } - - return -} - -// UpdatePreparer prepares the Update request. -func (client WebhooksClient) UpdatePreparer(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookUpdateParameters WebhookUpdateParameters) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "registryName": autorest.Encode("path", registryName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - "webhookName": autorest.Encode("path", webhookName), - } - - const APIVersion = "2017-06-01-preview" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}", pathParameters), - autorest.WithJSON(webhookUpdateParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UpdateSender sends the Update request. The method will close the -// http.Response Body if it receives an error. -func (client WebhooksClient) UpdateSender(req *http.Request) (future WebhooksUpdateFuture, err error) { - var resp *http.Response - resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return -} + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn + "/WebhooksClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + { TargetValue: registryName, + Constraints: []validation.Constraint{ {Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}, + { TargetValue: webhookName, + Constraints: []validation.Constraint{ {Target: "webhookName", Name: validation.MaxLength, Rule: 50, Chain: nil }, + {Target: "webhookName", Name: validation.MinLength, Rule: 5, Chain: nil }, + {Target: "webhookName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil }}}}); err != nil { + return result, validation.NewError("containerregistry.WebhooksClient", "Update", err.Error()) + } + + req, err := client.UpdatePreparer(ctx, resourceGroupName, registryName, webhookName, webhookUpdateParameters) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Update", nil , "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "containerregistry.WebhooksClient", "Update", result.Response(), "Failure sending request") + return + } + + return + } + + // UpdatePreparer prepares the Update request. + func (client WebhooksClient) UpdatePreparer(ctx context.Context, resourceGroupName string, registryName string, webhookName string, webhookUpdateParameters WebhookUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{} { + "registryName": autorest.Encode("path",registryName), + "resourceGroupName": autorest.Encode("path",resourceGroupName), + "subscriptionId": autorest.Encode("path",client.SubscriptionID), + "webhookName": autorest.Encode("path",webhookName), + } + + const APIVersion = "2017-06-01-preview" + queryParameters := map[string]interface{} { + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/webhooks/{webhookName}",pathParameters), + autorest.WithJSON(webhookUpdateParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) + } + + // UpdateSender sends the Update request. The method will close the + // http.Response Body if it receives an error. + func (client WebhooksClient) UpdateSender(req *http.Request) (future WebhooksUpdateFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return + } // UpdateResponder handles the response to the Update request. The method always // closes the http.Response Body. func (client WebhooksClient) UpdateResponder(resp *http.Response) (result Webhook, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return + } +