public override void ExecuteCmdlet()
        {
            PSEventHubAttributes eventHub = new PSEventHubAttributes();

            if (ParameterSetName == EventhubInputObjectParameterSet)
            {
                eventHub = InputObject;
            }
            else
            {
                if (!string.IsNullOrEmpty(Name))
                {
                    eventHub.Name = Name;
                }

                if (MessageRetentionInDays.HasValue)
                {
                    eventHub.MessageRetentionInDays = MessageRetentionInDays;
                }

                if (PartitionCount.HasValue)
                {
                    eventHub.PartitionCount = PartitionCount;
                }
            }

            if (ShouldProcess(target: eventHub.Name, action: string.Format(Resources.CreateEventHub, eventHub.Name, Namespace)))
            {
                WriteObject(Client.CreateOrUpdateEventHub(ResourceGroupName, Namespace, eventHub.Name, eventHub));
            }
        }
Exemple #2
0
 /// <summary>
 ///
 /// </summary>
 public override void ExecuteCmdlet()
 {
     try
     {
         if (!string.IsNullOrEmpty(Name))
         {
             // Get a EventHub
             PSEventHubAttributes eventHub = Client.GetEventHub(ResourceGroupName, Namespace, Name);
             WriteObject(eventHub);
         }
         else
         {
             if (MaxCount.HasValue)
             {
                 IEnumerable <PSEventHubAttributes> eventHubsList = Client.ListAllEventHubs(ResourceGroupName, Namespace, MaxCount);
                 WriteObject(eventHubsList.ToList(), true);
             }
             else
             {
                 // Get all EventHubs
                 IEnumerable <PSEventHubAttributes> eventHubsList = Client.ListAllEventHubs(ResourceGroupName, Namespace);
                 WriteObject(eventHubsList.ToList(), true);
             }
         }
     }
     catch (Management.EventHub.Models.ErrorResponseException ex)
     {
         WriteError(Eventhub.EventHubsClient.WriteErrorforBadrequest(ex));
     }
 }
 /// <summary>
 ///
 /// </summary>
 public override void ExecuteCmdlet()
 {
     if (!string.IsNullOrEmpty(Name))
     {
         // Get a EventHub
         PSEventHubAttributes eventHub = Client.GetEventHub(ResourceGroupName, Namespace, Name);
         WriteObject(eventHub);
     }
     else
     {
         // Get all EventHubs
         IEnumerable <PSEventHubAttributes> eventHubsList = Client.ListAllEventHubs(ResourceGroupName, Namespace);
         WriteObject(eventHubsList.ToList(), true);
     }
 }
        public override void ExecuteCmdlet()
        {
            PSEventHubAttributes eventHub = new PSEventHubAttributes();

            if (InputObject != null)
            {
                eventHub = InputObject;
            }
            else
            {
                if (string.IsNullOrEmpty(Name))
                {
                    eventHub.Name = Name;
                }

                if (messageRetentionInDays.HasValue)
                {
                    eventHub.MessageRetentionInDays = messageRetentionInDays;
                }

                if (partitionCount.HasValue)
                {
                    eventHub.PartitionCount = partitionCount;
                }
            }


            if (ShouldProcess(target: Name, action: string.Format(Resources.UpdateEventHub, Name, Namespace)))
            {
                try
                {
                    WriteObject(Client.CreateOrUpdateEventHub(ResourceGroupName, Namespace, Name, eventHub));
                }
                catch (Management.EventHub.Models.ErrorResponseException ex)
                {
                    WriteError(Eventhub.EventHubsClient.WriteErrorforBadrequest(ex));
                }
            }
        }
        public PSEventHubAttributes CreateOrUpdateEventHub(string resourceGroupName, string namespaceName, string eventHubName, PSEventHubAttributes parameter)
        {
            var Parameter1 = new Management.EventHub.Models.Eventhub();

            if (parameter.MessageRetentionInDays.HasValue)
            {
                Parameter1.MessageRetentionInDays = parameter.MessageRetentionInDays;
            }

            if (parameter.PartitionCount.HasValue)
            {
                Parameter1.PartitionCount = parameter.PartitionCount;
            }

            if (parameter.Status.HasValue)
            {
                Parameter1.Status = parameter.Status;
            }

            if (parameter.CaptureDescription != null)
            {
                Parameter1.CaptureDescription                                      = new CaptureDescription();
                Parameter1.CaptureDescription.Destination                          = new Destination();
                Parameter1.CaptureDescription.Enabled                              = parameter.CaptureDescription.Enabled;
                Parameter1.CaptureDescription.Encoding                             = (Management.EventHub.Models.EncodingCaptureDescription?)parameter.CaptureDescription.Encoding;
                Parameter1.CaptureDescription.IntervalInSeconds                    = parameter.CaptureDescription.IntervalInSeconds;
                Parameter1.CaptureDescription.SizeLimitInBytes                     = parameter.CaptureDescription.SizeLimitInBytes;
                Parameter1.CaptureDescription.Destination.Name                     = parameter.CaptureDescription.Destination.Name;
                Parameter1.CaptureDescription.Destination.BlobContainer            = parameter.CaptureDescription.Destination.BlobContainer;
                Parameter1.CaptureDescription.Destination.ArchiveNameFormat        = parameter.CaptureDescription.Destination.ArchiveNameFormat;
                Parameter1.CaptureDescription.Destination.StorageAccountResourceId = parameter.CaptureDescription.Destination.StorageAccountResourceId;
            }

            var response = Client.EventHubs.CreateOrUpdate(resourceGroupName, namespaceName, eventHubName, Parameter1);

            return(new PSEventHubAttributes(response));
        }