public override void ExecuteCmdlet()
        {
            // Create a new Event Grid Domain
            Dictionary <string, string> tagDictionary = TagsConversionHelper.CreateTagDictionary(this.Tag, true);
            Dictionary <string, string> inputMappingFieldsDictionary        = TagsConversionHelper.CreateTagDictionary(this.InputMappingField, true);
            Dictionary <string, string> inputMappingDefaultValuesDictionary = TagsConversionHelper.CreateTagDictionary(this.InputMappingDefaultValue, true);
            Dictionary <string, string> inboundIpRuleDictionary             = TagsConversionHelper.CreateTagDictionary(this.InboundIpRule, true);

            EventGridUtils.ValidateInputMappingInfo(this.InputSchema, inputMappingFieldsDictionary, inputMappingDefaultValuesDictionary);

            if (this.ShouldProcess(this.Name, $"Create a new EventGrid domain {this.Name} in Resource Group {this.ResourceGroupName}"))
            {
                Domain domain = this.Client.CreateDomain(
                    this.ResourceGroupName,
                    this.Name,
                    this.Location,
                    tagDictionary,
                    InputSchema,
                    inputMappingFieldsDictionary,
                    inputMappingDefaultValuesDictionary,
                    inboundIpRuleDictionary,
                    this.PublicNetworkAccess);

                PSDomain psDomain = new PSDomain(domain);
                this.WriteObject(psDomain);
            }
        }
        public override void ExecuteCmdlet()
        {
            IEnumerable <Domain> domainsList;
            string newNextLink = null;
            int?   providedTop = null;

            if (MyInvocation.BoundParameters.ContainsKey(nameof(this.Top)))
            {
                providedTop = this.Top;
            }

            if (!string.IsNullOrEmpty(this.ResourceId))
            {
                var resourceIdentifier = new ResourceIdentifier(this.ResourceId);
                this.ResourceGroupName = resourceIdentifier.ResourceGroupName;
                this.Name = resourceIdentifier.ResourceName;
            }

            // Other parameters should be null or ignored if this.NextLink is specified.
            if (!string.IsNullOrEmpty(this.NextLink))
            {
                // Get Next page of domains. Get the proper next API to be called based on the nextLink.
                Uri    uri  = new Uri(this.NextLink);
                string path = uri.AbsolutePath;

                if (path.IndexOf("/resourceGroups/", StringComparison.OrdinalIgnoreCase) != -1)
                {
                    (domainsList, newNextLink) = this.Client.ListDomainsByResourceGroupNext(this.NextLink);
                }
                else
                {
                    (domainsList, newNextLink) = this.Client.ListDomainBySubscriptionNext(this.NextLink);
                }

                PSDomainListPagedInstance pSDomainListPagedInstance = new PSDomainListPagedInstance(domainsList, newNextLink);
                this.WriteObject(pSDomainListPagedInstance, true);
            }
            else if (!string.IsNullOrEmpty(this.ResourceGroupName) && !string.IsNullOrEmpty(this.Name))
            {
                // Get details of the Event Grid domain
                Domain   domain   = this.Client.GetDomain(this.ResourceGroupName, this.Name);
                PSDomain psDomain = new PSDomain(domain);
                this.WriteObject(psDomain);
            }
            else if (!string.IsNullOrEmpty(this.ResourceGroupName) && string.IsNullOrEmpty(this.Name))
            {
                // List all Event Grid domains in the given resource group
                (domainsList, newNextLink) = this.Client.ListDomainsByResourceGroup(this.ResourceGroupName, this.ODataQuery, providedTop);
                PSDomainListPagedInstance pSDomainListPagedInstance = new PSDomainListPagedInstance(domainsList, newNextLink);
                this.WriteObject(pSDomainListPagedInstance, true);
            }
            else if (string.IsNullOrEmpty(this.ResourceGroupName) && string.IsNullOrEmpty(this.Name))
            {
                // List all Event Grid domains in the given subscription
                (domainsList, newNextLink) = this.Client.ListDomainsBySubscription(this.ODataQuery, providedTop);
                PSDomainListPagedInstance pSDomainListPagedInstance = new PSDomainListPagedInstance(domainsList, newNextLink);
                this.WriteObject(pSDomainListPagedInstance, true);
            }
        }
Exemplo n.º 3
0
        public override void ExecuteCmdlet()
        {
            // Create a new Event Grid Domain
            Dictionary <string, string> tagDictionary = TagsConversionHelper.CreateTagDictionary(this.Tag, true);

            if (this.ShouldProcess(this.Name, $"Create a new EventGrid domain {this.Name} in Resource Group {this.ResourceGroupName}"))
            {
                Domain   domain   = this.Client.CreateDomain(this.ResourceGroupName, this.Name, this.Location, tagDictionary);
                PSDomain psDomain = new PSDomain(domain);
                this.WriteObject(psDomain);
            }
        }
Exemplo n.º 4
0
        public override void ExecuteCmdlet()
        {
            // Create a new Event Grid Domain
            Dictionary <string, string> tagDictionary = TagsConversionHelper.CreateTagDictionary(this.Tag, true);
            Dictionary <string, string> inputMappingFieldsDictionary        = TagsConversionHelper.CreateTagDictionary(this.InputMappingField, true);
            Dictionary <string, string> inputMappingDefaultValuesDictionary = TagsConversionHelper.CreateTagDictionary(this.InputMappingDefaultValue, true);
            Dictionary <string, string> inboundIpRuleDictionary             = TagsConversionHelper.CreateTagDictionary(this.InboundIpRule, true);

            EventGridUtils.ValidateInputMappingInfo(this.InputSchema, inputMappingFieldsDictionary, inputMappingDefaultValuesDictionary);

            Dictionary <string, UserIdentityProperties> userAssignedIdentities = null;

            if (IdentityId != null && IdentityId.Length > 0)
            {
                userAssignedIdentities = new Dictionary <string, UserIdentityProperties>();
                foreach (string identityId in IdentityId)
                {
                    userAssignedIdentities.Add(identityId, new UserIdentityProperties());
                }
            }

            if (this.ShouldProcess(this.Name, $"Create a new EventGrid domain {this.Name} in Resource Group {this.ResourceGroupName}"))
            {
                Domain domain = this.Client.CreateDomain(
                    this.ResourceGroupName,
                    this.Name,
                    this.Location,
                    tagDictionary,
                    InputSchema,
                    inputMappingFieldsDictionary,
                    inputMappingDefaultValuesDictionary,
                    inboundIpRuleDictionary,
                    this.PublicNetworkAccess,
                    this.IdentityType,
                    userAssignedIdentities,
                    this.DisableLocalAuth.IsPresent,
                    this.AutoCreateTopicWithFirstSubscription.IsPresent,
                    this.AutoDeleteTopicWithLastSubscription.IsPresent);

                PSDomain psDomain = new PSDomain(domain);
                this.WriteObject(psDomain);
            }
        }