public override void ExecuteCmdlet() { if (string.Equals(ParameterSetName, RegistryObjectParameterSet)) { ResourceGroupName = Registry.ResourceGroupName; RegistryName = Registry.Name; } else if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId)) { string resourceGroup, registryName, childResourceName; if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName)) { WriteInvalidResourceIdError(InvalidRegistryResourceIdErrorMessage); return; } ResourceGroupName = resourceGroup; RegistryName = registryName; } var tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true); if (string.IsNullOrEmpty(Name)) { Name = Location.Replace(" ", string.Empty).ToLower(); } if (ShouldProcess(Name, "Create a replication for the container registry")) { var replication = RegistryClient.CreateReplication(ResourceGroupName, RegistryName, Name, Location, tags); WriteObject(new PSContainerRegistryReplication(replication)); } }
public override void ExecuteCmdlet() { if (string.Equals(ParameterSetName, ListWebhookEventsByWebhookObjectParameterSet)) { ResourceId = Webhook.Id; } if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId)) { string resourceGroup, registryName, childResourceName; if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName) || string.IsNullOrEmpty(childResourceName)) { WriteInvalidResourceIdError(InvalidWebhookResourceIdErrorMessage); return; } ResourceGroupName = resourceGroup; WebhookName = childResourceName; RegistryName = registryName; } var webhookEvents = RegistryClient.ListAllWebhookEvent(ResourceGroupName, RegistryName, WebhookName); WriteObject(webhookEvents, true); }
public override void ExecuteCmdlet() { if (string.Equals(ParameterSetName, ReplicationObjectParameterSet)) { ResourceId = Replicatoin.Id; } if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId)) { string resourceGroup, registryName, childResourceName; if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName) || string.IsNullOrEmpty(childResourceName)) { WriteInvalidResourceIdError(InvalidReplicationResourceIdErrorMessage); return; } ResourceGroupName = resourceGroup; RegistryName = registryName; Name = childResourceName; } if (ShouldProcess(Name, "Delete the replication from the container registry. This will also delete all the webhooks in this replication.")) { RegistryClient.DeleteReplication(ResourceGroupName, RegistryName, Name); if (PassThru) { WriteObject(true); } } }
public override void ExecuteCmdlet() { if (string.Equals(ParameterSetName, RegistryObjectParameterSet)) { ResourceGroupName = Registry.ResourceGroupName; Name = Registry.Name; } else if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId)) { string resourceGroup, registryName, childResourceName; if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName)) { WriteInvalidResourceIdError(InvalidRegistryResourceIdErrorMessage); return; } ResourceGroupName = resourceGroup; Name = registryName; } if (ShouldProcess(Name, string.Format("Update Container Registry Credential '{0}'", PasswordName))) { var credentials = RegistryClient.RegenerateRegistryCredential(ResourceGroupName, Name, PasswordName); WriteObject(new PSContainerRegistryCredential(credentials)); } }
public override void ExecuteCmdlet() { if (string.Equals(ParameterSetName, RegistryObjectParameterSet)) { ResourceGroupName = Registry.ResourceGroupName; Name = Registry.Name; } else if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId)) { string resourceGroup, registryName, childResourceName; if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName)) { WriteInvalidResourceIdError(InvalidRegistryResourceIdErrorMessage); return; } ResourceGroupName = resourceGroup; Name = registryName; } if (ShouldProcess(Name, "Remove Container Registry")) { RegistryClient.DeleteRegistry(ResourceGroupName, Name); if (PassThru) { WriteObject(true); } } }
public override void ExecuteCmdlet() { if (string.Equals(ParameterSetName, WebhookObjectParameterSet)) { ResourceId = Webhook.Id; } if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId)) { string resourceGroup, registryName, childResourceName; if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName) || string.IsNullOrEmpty(childResourceName)) { WriteInvalidResourceIdError(InvalidWebhookResourceIdErrorMessage); return; } ResourceGroupName = resourceGroup; Name = childResourceName; RegistryName = registryName; } var tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true); var headers = ConversionUtilities.ToDictionary(Header); var parameters = new WebhookUpdateParameters() { Actions = Action, CustomHeaders = headers, ServiceUri = Uri?.ToString(), Tags = tags, Status = Status, Scope = Scope }; if (ShouldProcess(Name, "Update Container Registry Webhook")) { var webhook = RegistryClient.UpdateWebhook(ResourceGroupName, RegistryName, Name, parameters); WriteObject(new PSContainerRegistryWebhook(webhook)); } }
private void ShowReplicationByResourceId() { string resourceGroup, registryName, childResourceName; if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName)) { WriteInvalidResourceIdError(InvalidRegistryOrReplicationResourceIdErrorMessage); return; } ResourceGroupName = resourceGroup; Name = childResourceName; RegistryName = registryName; if (string.IsNullOrEmpty(Name)) { ListReplication(); } else { ShowReplication(); } }
public override void ExecuteCmdlet() { if (string.Equals(ParameterSetName, ListRegistriesParameterSet)) { ListRegistry(); } else { if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId)) { string resourceGroup, registryName, childResourceName; if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName)) { WriteInvalidResourceIdError(InvalidRegistryResourceIdErrorMessage); return; } ResourceGroupName = resourceGroup; Name = registryName; } ShowRegistry(); } }
public override void ExecuteCmdlet() { var tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true); bool?adminUserEnabled = null; if (EnableAdminUser || DisableAdminUser) { adminUserEnabled = EnableAdminUser || !DisableAdminUser; } string storageAccountId = null; if (StorageAccountName != null) { storageAccountId = ResourceManagerClient.GetStorageAccountId(StorageAccountName); } if (MyInvocation.BoundParameters.ContainsKey("ResourceId") || !string.IsNullOrWhiteSpace(ResourceId)) { string resourceGroup, registryName, childResourceName; if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName)) { WriteInvalidResourceIdError(InvalidRegistryResourceIdErrorMessage); return; } ResourceGroupName = resourceGroup; Name = registryName; } if (ShouldProcess(Name, "Update Container Registry")) { var registry = RegistryClient.UpdateRegistry(ResourceGroupName, Name, adminUserEnabled, Sku, storageAccountId, NetworkRuleSet, tags); WriteObject(new PSContainerRegistry(registry)); } }
private void ShowWebhookByResourceId() { string resourceGroup, registryName, childResourceName; if (!ConversionUtilities.TryParseRegistryRelatedResourceId(ResourceId, out resourceGroup, out registryName, out childResourceName)) { WriteInvalidResourceIdError(InvalidRegistryOrWebhookResourceIdErrorMessage); return; } ResourceGroupName = resourceGroup; Name = childResourceName; RegistryName = registryName; // If the resourceid is a registry id, then list all the webhooks under that registry if (string.IsNullOrEmpty(Name)) { ListWebhook(); } else { ShowWebhook(); } }