示例#1
0
        public override void ExecuteCmdlet()
        {
            PSEventHubClusterAttributes cluster = new PSEventHubClusterAttributes();

            if (ParameterSetName.Equals(ClusterInputObjectParameterSet))
            {
                cluster          = InputObject;
                cluster.Name     = Name;
                cluster.Location = InputObject.Location;
            }

            if (ParameterSetName.Equals(ClusterPropertiesParameterSet))
            {
                if (this.IsParameterBound(c => c.Tag))
                {
                    cluster.Tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true);
                }

                if (this.IsParameterBound(c => c.Capacity))
                {
                    cluster.Sku.Capacity = Capacity;
                }
                else
                {
                    cluster.Sku.Capacity = 1;
                }

                if (this.IsParameterBound(c => c.Location))
                {
                    cluster.Location = Location;
                }
                else
                {
                    // Get a EventHub
                    PSEventHubClusterAttributes clusterGet = Client.GetEventHubCluster(ResourceGroupName, Name);
                    cluster.Location = clusterGet.Location;
                }
            }

            if (ShouldProcess(target: cluster.Name, action: string.Format("Update cluster {0} in ResourceGroup {1}", cluster.Name, ResourceGroupName)))
            {
                try
                {
                    WriteObject(Client.UpdateEventHubCluster(ResourceGroupName, Name, cluster));
                }
                catch (Management.EventHub.Models.ErrorResponseException ex)
                {
                    WriteError(Eventhub.EventHubsClient.WriteErrorforBadrequest(ex));
                }
            }
        }
示例#2
0
 /// <summary>
 ///
 /// </summary>
 public override void ExecuteCmdlet()
 {
     try
     {
         if (this.IsParameterBound(c => c.Name))
         {
             // Get a Cluster
             PSEventHubClusterAttributes cluster = Client.GetEventHubCluster(ResourceGroupName, Name);
             WriteObject(cluster);
         }
         else
         {
             // Get all Clusters
             IEnumerable <PSEventHubClusterAttributes> clusterList = Client.ListEventHubCluster(ResourceGroupName);
             WriteObject(clusterList.ToList(), true);
         }
     }
     catch (Management.EventHub.Models.ErrorResponseException ex)
     {
         WriteError(Eventhub.EventHubsClient.WriteErrorforBadrequest(ex));
     }
 }
示例#3
0
        public PSEventHubClusterAttributes UpdateEventHubCluster(string resourceGroupName, string clusterName, PSEventHubClusterAttributes parameter)
        {
            var parameterCluster = new Management.EventHub.Models.Cluster();

            parameterCluster.Location     = parameter.Location;
            parameterCluster.Sku          = new ClusterSku();
            parameterCluster.Sku.Capacity = parameter.Sku.Capacity;
            parameterCluster.Tags         = parameter.Tags;

            Management.EventHub.Models.Cluster response = Client.Clusters.Update(resourceGroupName, clusterName, parameterCluster);
            return(new PSEventHubClusterAttributes(response));
        }