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);
            var headers = ConversionUtilities.ToDictionary(Header);

            var parameters = new WebhookCreateParameters()
            {
                Actions       = Action,
                CustomHeaders = headers,
                ServiceUri    = Uri?.ToString(),
                Tags          = tags,
                Status        = Status ?? WebhookStatus.Enabled,
                Scope         = Scope,
                Location      = Location ?? RegistryClient.GetRegistryLocation(ResourceGroupName, RegistryName)
            };

            if (ShouldProcess(Name, "Create a webhook for the container registry"))
            {
                var webhook = RegistryClient.CreateWebhook(ResourceGroupName, RegistryName, Name, parameters);
                WriteObject(new PSContainerRegistryWebhook(webhook));
            }
        }
Пример #2
0
        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));
            }
        }
Пример #5
0
        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;
            }

            var credentials = RegistryClient.ListRegistryCredentials(ResourceGroupName, Name);

            WriteObject(new PSContainerRegistryCredential(credentials));
        }
        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();
            }
        }