public override void ExecuteCmdlet()
        {
            try
            {
                switch (ParameterSetName)
                {
                case ByResourceGroupAndCluster:
                    var managedServiceList = this.ReturnListByPageResponse(
                        this.SfrpMcClient.Services.ListByApplications(this.ResourceGroupName, this.ClusterName, this.ApplicationName),
                        this.SfrpMcClient.Services.ListByApplicationsNext);
                    WriteObject(managedServiceList.Select(service => PSManagedService.GetInstance(service)), true);
                    break;

                case ByName:
                    GetByName();
                    break;

                case ByResourceId:
                    SetParametersByResourceId(this.ResourceId);
                    GetByName();
                    break;

                default:
                    throw new PSArgumentException("Invalid ParameterSetName");
                }
            }
            catch (Exception ex)
            {
                this.PrintSdkExceptionDetail(ex);
                throw;
            }
        }
 public override void ExecuteCmdlet()
 {
     if (ShouldProcess(target: this.Name, action: $"Create new Service. name {this.Name} in application: {this.ApplicationName}, cluster {this.ClusterName} in resource group {this.ResourceGroupName}"))
     {
         try
         {
             ManagedCluster cluster = SafeGetResource(() => this.SfrpMcClient.ManagedClusters.Get(this.ResourceGroupName, this.ClusterName));
             if (cluster == null)
             {
                 WriteError(new ErrorRecord(new InvalidOperationException($"Parent cluster '{this.ClusterName}' does not exist."),
                                            "ResourceDoesNotExist", ErrorCategory.InvalidOperation, null));
             }
             else
             {
                 var service = CreateService(cluster.Location);
                 WriteObject(PSManagedService.GetInstance(service), false);
             }
         }
         catch (Exception ex)
         {
             PrintSdkExceptionDetail(ex);
             throw;
         }
     }
 }
        public override void ExecuteCmdlet()
        {
            try
            {
                this.SetParams();
                ServiceResource updatedServiceParams = null;
                switch (ParameterSetName)
                {
                case StatefulByResourceGroup:
                case StatelessByResourceGroup:
                case StatefulByResourceId:
                case StatelessByResourceId:
                    updatedServiceParams = this.GetUpdatedServiceParams();
                    break;

                case StatefulByInputObject:
                case StatelessByInputObject:
                    updatedServiceParams = this.GetUpdatedServiceParams(this.InputObject);
                    break;

                default:
                    throw new ArgumentException("Invalid parameter set", ParameterSetName);
                }
                if (updatedServiceParams != null && ShouldProcess(target: this.Name, action: $"Update managed service name {this.Name}, cluster: {this.ClusterName} in resource group {this.ResourceGroupName}"))
                {
                    var beginRequestResponse = this.SfrpMcClient.Services.BeginCreateOrUpdateWithHttpMessagesAsync(this.ResourceGroupName, this.ClusterName, this.ApplicationName, this.Name, updatedServiceParams)
                                               .GetAwaiter().GetResult();

                    var managedService = this.PollLongRunningOperation(beginRequestResponse);

                    WriteObject(PSManagedService.GetInstance(managedService), false);
                }
            }
            catch (Exception ex)
            {
                PrintSdkExceptionDetail(ex);
                throw;
            }
        }
        private void GetByName()
        {
            var managedService = this.SfrpMcClient.Services.Get(this.ResourceGroupName, this.ClusterName, this.ApplicationName, this.Name);

            WriteObject(PSManagedService.GetInstance(managedService), false);
        }