/// <summary>
 /// Gets a Namespace from the service.
 /// </summary>
 /// <returns>A single Namespace</returns>
 public override void ExecuteCmdlet()
 {
     try
     {
         if (!string.IsNullOrEmpty(ResourceGroupName) && !string.IsNullOrEmpty(Name))
         {
             // Get a namespace
             PSNamespaceAttributes attributes = Client.GetNamespace(ResourceGroupName, Name);
             WriteObject(attributes);
         }
         else if (!string.IsNullOrEmpty(ResourceGroupName) && string.IsNullOrEmpty(Name))
         {
             // List all namespaces in given resource group
             IEnumerable <PSNamespaceAttributes> namespaceList = Client.ListNamespaces(ResourceGroupName);
             WriteObject(namespaceList.ToList(), true);
         }
         else
         {
             // List all namespaces in the given subscription
             IEnumerable <PSNamespaceAttributes> namespaceList = Client.ListAllNamespaces();
             WriteObject(namespaceList.ToList(), true);
         }
     }
     catch (Management.ServiceBus.Models.ErrorResponseException ex)
     {
         WriteError(ServiceBusClient.WriteErrorforBadrequest(ex));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        public override void ExecuteCmdlet()
        {
            try
            {
                // Create a new ServiceBus namespace
                Dictionary <string, string> tagDictionary = TagsConversionHelper.CreateTagDictionary(Tag, validate: true);

                if (ShouldProcess(target: Name, action: string.Format(Resources.CreateNamesapce, Name, ResourceGroupName)))
                {
                    try
                    {
                        PSNamespaceAttributes createresponse = Client.BeginCreateNamespace(resourceGroupName: ResourceGroupName,
                                                                                           namespaceName: Name,
                                                                                           location: Location,
                                                                                           skuName: SkuName,
                                                                                           tags: tagDictionary,
                                                                                           isZoneRedundant: ZoneRedundant.IsPresent,
                                                                                           isDisableLocalAuth: DisableLocalAuth.IsPresent,
                                                                                           identityType: IdentityType,
                                                                                           identityIds: IdentityId,
                                                                                           encryptionconfigs: EncryptionConfig,
                                                                                           skuCapacity: SkuCapacity);
                        WriteObject(createresponse);
                    }
                    catch (ErrorResponseException ex)
                    {
                        WriteError(ServiceBusClient.WriteErrorforBadrequest(ex));
                    }
                }
            }
            catch (Exception ex)
            {
                WriteError(new ErrorRecord(ex, ex.Message, ErrorCategory.OpenError, ex));
            }
        }
        public override void ExecuteCmdlet()
        {
            PSQueueAttributes queueAttributes = new PSQueueAttributes();

            if (InputObject != null)
            {
                PSNamespaceAttributes getNamespaceLoc = Client.GetNamespace(ResourceGroupName, Namespace);
                queueAttributes = InputObject;
            }

            if (ShouldProcess(target: Name, action: string.Format(Resources.UpdateQueue, Name, Namespace)))
            {
                WriteObject(Client.CreateUpdateQueue(ResourceGroupName, Namespace, queueAttributes.Name, queueAttributes));
            }
        }
        /// <summary>
        ///
        /// </summary>
        public override void ExecuteCmdlet()
        {
            // Create a new ServiceBus namespace
            Dictionary <string, string> tagDictionary = TagsConversionHelper.CreateTagDictionary(Tag, validate: true);

            if (ShouldProcess(target: Name, action: string.Format(Resources.CreateNamesapce, Name, ResourceGroupName)))
            {
                try
                {
                    PSNamespaceAttributes createresponse = Client.BeginCreateNamespace(ResourceGroupName, Name, Location, SkuName, tagDictionary, ZoneRedundant.IsPresent, DisableLocalAuth.IsPresent, SkuCapacity);
                    WriteObject(createresponse);
                }
                catch (ErrorResponseException ex)
                {
                    WriteError(ServiceBusClient.WriteErrorforBadrequest(ex));
                }
            }
        }
Ejemplo n.º 5
0
 public override void ExecuteCmdlet()
 {
     if (!string.IsNullOrEmpty(ResourceGroupName) && !string.IsNullOrEmpty(Name))
     {
         // Get EventHub namespace
         PSNamespaceAttributes attributes = Client.GetNamespace(ResourceGroupName, Name);
         WriteObject(attributes);
     }
     else if (!string.IsNullOrEmpty(ResourceGroupName) && string.IsNullOrEmpty(Name))
     {
         // List all EventHub namespace in given resource group
         IEnumerable <PSNamespaceAttributes> namespaceList = Client.ListNamespacesByResourceGroup(ResourceGroupName);
         WriteObject(namespaceList.ToList(), true);
     }
     else
     {
         // List all EventHub namespaces in the given subscription
         IEnumerable <PSNamespaceAttributes> namespaceList = Client.ListNamespacesBySubscription();
         WriteObject(namespaceList.ToList(), true);
     }
 }
        public override void ExecuteCmdlet()
        {
            PSQueueAttributes queueAttributes = new PSQueueAttributes();

            if (InputObject != null)
            {
                PSNamespaceAttributes getNamespaceLoc = Client.GetNamespace(ResourceGroupName, Namespace);
                queueAttributes = InputObject;
            }

            if (ShouldProcess(target: Name, action: string.Format(Resources.UpdateQueue, Name, Namespace)))
            {
                try
                {
                    WriteObject(Client.CreateUpdateQueue(ResourceGroupName, Namespace, queueAttributes.Name, queueAttributes));
                }
                catch (ErrorResponseException ex)
                {
                    WriteError(ServiceBusClient.WriteErrorforBadrequest(ex));
                }
            }
        }
        public override void ExecuteCmdlet()
        {
            PSSubscriptionAttributes subAttributes = new PSSubscriptionAttributes();

            PSNamespaceAttributes getNamespaceLoc = Client.GetNamespace(ResourceGroupName, Namespace);

            subAttributes.Name = Name;

            if (AutoDeleteOnIdle != null)
            {
                subAttributes.AutoDeleteOnIdle = AutoDeleteOnIdle;
            }

            if (DefaultMessageTimeToLive != null)
            {
                subAttributes.DefaultMessageTimeToLive = DefaultMessageTimeToLive;
            }

            if (LockDuration != null)
            {
                subAttributes.LockDuration = LockDuration;
            }

            if (DeadLetteringOnMessageExpiration != null)
            {
                subAttributes.DeadLetteringOnMessageExpiration = DeadLetteringOnMessageExpiration;
            }

            if (EnableBatchedOperations != null)
            {
                subAttributes.EnableBatchedOperations = EnableBatchedOperations;
            }

            if (DeadLetteringOnMessageExpiration != null)
            {
                subAttributes.DeadLetteringOnMessageExpiration = DeadLetteringOnMessageExpiration;
            }

            if (MaxDeliveryCount != null)
            {
                subAttributes.MaxDeliveryCount = MaxDeliveryCount;
            }

            if (RequiresSession != null)
            {
                subAttributes.RequiresSession = RequiresSession;
            }

            if (ForwardTo != null)
            {
                subAttributes.ForwardTo = ForwardTo;
            }

            if (ForwardDeadLetteredMessagesTo != null)
            {
                subAttributes.ForwardDeadLetteredMessagesTo = ForwardDeadLetteredMessagesTo;
            }

            if (ShouldProcess(target: Name, action: string.Format(Resources.CreateSubscription, Name, Topic, Namespace)))
            {
                WriteObject(Client.CreateUpdateSubscription(ResourceGroupName, Namespace, Topic, Name, subAttributes));
            }
        }
        public override void ExecuteCmdlet()
        {
            PSQueueAttributes queueAttributes = new PSQueueAttributes();

            PSNamespaceAttributes getNamespaceLoc = Client.GetNamespace(ResourceGroupName, Namespace);

            queueAttributes.Name = Name;

            queueAttributes.EnablePartitioning = EnablePartitioning;

            if (LockDuration != null)
            {
                queueAttributes.LockDuration = LockDuration;
            }

            if (AutoDeleteOnIdle != null)
            {
                queueAttributes.AutoDeleteOnIdle = AutoDeleteOnIdle;
            }

            if (DefaultMessageTimeToLive != null)
            {
                queueAttributes.DefaultMessageTimeToLive = DefaultMessageTimeToLive;
            }

            if (DuplicateDetectionHistoryTimeWindow != null)
            {
                queueAttributes.DuplicateDetectionHistoryTimeWindow = DuplicateDetectionHistoryTimeWindow;
            }

            if (DeadLetteringOnMessageExpiration != null)
            {
                queueAttributes.DeadLetteringOnMessageExpiration = DeadLetteringOnMessageExpiration;
            }

            queueAttributes.EnableBatchedOperations = EnableBatchedOperations.IsPresent;

            if (EnableExpress != null)
            {
                queueAttributes.EnableExpress = EnableExpress;
            }

            if (MaxDeliveryCount != null)
            {
                queueAttributes.MaxDeliveryCount = MaxDeliveryCount;
            }

            if (MaxSizeInMegabytes != null)
            {
                queueAttributes.MaxSizeInMegabytes = (int?)MaxSizeInMegabytes;
            }

            if (MessageCount != null)
            {
                queueAttributes.MessageCount = MessageCount;
            }

            if (RequiresDuplicateDetection != null)
            {
                queueAttributes.RequiresDuplicateDetection = RequiresDuplicateDetection;
            }

            if (RequiresSession != null)
            {
                queueAttributes.RequiresSession = RequiresSession;
            }

            if (SizeInBytes != null)
            {
                queueAttributes.SizeInBytes = SizeInBytes;
            }

            if (ForwardTo != null)
            {
                queueAttributes.ForwardTo = ForwardTo;
            }

            if (ForwardDeadLetteredMessagesTo != null)
            {
                queueAttributes.ForwardDeadLetteredMessagesTo = ForwardDeadLetteredMessagesTo;
            }


            if (ShouldProcess(target: Name, action: string.Format(Resources.CreateQueue, Name, Namespace)))
            {
                try
                {
                    WriteObject(Client.CreateUpdateQueue(ResourceGroupName, Namespace, Name, queueAttributes));
                }
                catch (ErrorResponseException ex)
                {
                    WriteError(ServiceBusClient.WriteErrorforBadrequest(ex));
                }
            }
        }
        public override void ExecuteCmdlet()
        {
            PSTopicAttributes topicAttributes = new PSTopicAttributes();

            PSNamespaceAttributes getNamespaceLoc = Client.GetNamespace(ResourceGroupName, Namespace);

            topicAttributes.Name = Name;

            if (EnablePartitioning != null)
            {
                topicAttributes.EnablePartitioning = EnablePartitioning;
            }

            if (AutoDeleteOnIdle != null)
            {
                topicAttributes.AutoDeleteOnIdle = AutoDeleteOnIdle;
            }

            if (DefaultMessageTimeToLive != null)
            {
                topicAttributes.DefaultMessageTimeToLive = DefaultMessageTimeToLive;
            }

            if (DuplicateDetectionHistoryTimeWindow != null)
            {
                topicAttributes.DuplicateDetectionHistoryTimeWindow = DuplicateDetectionHistoryTimeWindow;
            }

            if (EnableBatchedOperations != null)
            {
                topicAttributes.EnableBatchedOperations = EnableBatchedOperations;
            }

            if (EnableExpress != null)
            {
                topicAttributes.EnableExpress = EnableExpress;
            }

            if (MaxSizeInMegabytes != null)
            {
                topicAttributes.MaxSizeInMegabytes = (int?)MaxSizeInMegabytes;
            }

            if (RequiresDuplicateDetection != null)
            {
                topicAttributes.RequiresDuplicateDetection = RequiresDuplicateDetection;
            }

            if (SupportOrdering != null)
            {
                topicAttributes.SupportOrdering = SupportOrdering;
            }

            if (SizeInBytes != null)
            {
                topicAttributes.SizeInBytes = SizeInBytes;
            }

            if (ShouldProcess(target: Name, action: string.Format(Resources.CreateTopic, Name, Namespace)))
            {
                try
                {
                    WriteObject(Client.CreateUpdateTopic(ResourceGroupName, Namespace, Name, topicAttributes));
                }
                catch (ErrorResponseException ex)
                {
                    WriteError(ServiceBusClient.WriteErrorforBadrequest(ex));
                }
            }
        }