public override void ExecuteApiManagementCmdlet() { string resourceGroupName; string serviceName; string diagnosticId; string apiId; if (ParameterSetName.Equals(ContextParameterSet)) { resourceGroupName = Context.ResourceGroupName; serviceName = Context.ServiceName; diagnosticId = Utils.GetDiagnosticId(DiagnosticId); apiId = ApiId; } else { var diagnostic = new PsApiManagementDiagnostic(ResourceId); resourceGroupName = diagnostic.ResourceGroupName; serviceName = diagnostic.ServiceName; diagnosticId = diagnostic.DiagnosticId; apiId = diagnostic.ApiId; } if (string.IsNullOrEmpty(diagnosticId) && string.IsNullOrEmpty(apiId)) { WriteObject(Client.DiagnosticListTenantLevel(resourceGroupName, serviceName), true); } else if (string.IsNullOrEmpty(diagnosticId)) { // get all api diagnostics WriteObject(Client.DiagnosticListApiLevel(resourceGroupName, serviceName, apiId), true); } else if (string.IsNullOrEmpty(apiId)) { // get the global diagnostic WriteObject(Client.DiagnosticGetTenantLevel(resourceGroupName, serviceName, diagnosticId)); } else { WriteObject(Client.DiagnosticGetApiLevel(resourceGroupName, serviceName, apiId, diagnosticId)); } }
public override void ExecuteApiManagementCmdlet() { string resourcegroupName; string serviceName; string diagnosticId; string apiId; if (ParameterSetName.Equals(ByInputObjectParameterSet)) { resourcegroupName = InputObject.ResourceGroupName; serviceName = InputObject.ServiceName; diagnosticId = InputObject.DiagnosticId; apiId = InputObject.ApiId; } else if (ParameterSetName.Equals(ExpandedParameterSet)) { resourcegroupName = Context.ResourceGroupName; serviceName = Context.ServiceName; diagnosticId = Utils.GetDiagnosticId(DiagnosticId); apiId = ApiId; } else { var psDiagnostic = new PsApiManagementDiagnostic(ResourceId); resourcegroupName = psDiagnostic.ResourceGroupName; serviceName = psDiagnostic.ServiceName; diagnosticId = psDiagnostic.DiagnosticId; apiId = psDiagnostic.ApiId; } if (ShouldProcess(diagnosticId, Resources.SetDiagnostics)) { PsApiManagementDiagnostic diagnostic; if (string.IsNullOrEmpty(apiId)) { diagnostic = Client.DiagnosticSetTenantLevel( resourcegroupName, serviceName, diagnosticId, LoggerId, AlwaysLog, SamplingSetting, FrontEndSetting, BackendSetting, InputObject); } else { diagnostic = Client.DiagnosticSetApiLevel( resourcegroupName, serviceName, apiId, diagnosticId, LoggerId, AlwaysLog, SamplingSetting, FrontEndSetting, BackendSetting, InputObject); } if (PassThru.IsPresent) { WriteObject(diagnostic); } } }
public override void ExecuteApiManagementCmdlet() { string resourceGroupName; string serviceName; string diagnosticId; string apiId; if (ParameterSetName.Equals(ByInputObjectParameterSet)) { resourceGroupName = InputObject.ResourceGroupName; serviceName = InputObject.ServiceName; diagnosticId = InputObject.DiagnosticId; apiId = InputObject.ApiId; } else if (ParameterSetName.Equals(ByResourceIdParameterSet)) { var diagnostic = new PsApiManagementDiagnostic(ResourceId); resourceGroupName = diagnostic.ResourceGroupName; serviceName = diagnostic.ServiceName; diagnosticId = diagnostic.DiagnosticId; apiId = diagnostic.ApiId; } else { resourceGroupName = Context.ResourceGroupName; serviceName = Context.ServiceName; diagnosticId = Utils.GetDiagnosticId(DiagnosticId); apiId = ApiId; } // build description for cmdlet string actionDescription; string actionWarning; if (string.IsNullOrEmpty(apiId)) { actionDescription = string.Format(CultureInfo.CurrentCulture, Resources.DiagnosticRemoveDescription, DiagnosticId); actionWarning = string.Format(CultureInfo.CurrentCulture, Resources.DiagnosticRemoveWarning, DiagnosticId); } else { actionDescription = string.Format(CultureInfo.CurrentCulture, Resources.ApiDiagnosticRemoveDescription, DiagnosticId, ApiId); actionWarning = string.Format(CultureInfo.CurrentCulture, Resources.ApiDiagnosticRemoveWarning, DiagnosticId, ApiId); } // Do nothing if force is not specified and user cancelled the operation if (!ShouldProcess( actionDescription, actionWarning, Resources.ShouldProcessCaption)) { return; } if (string.IsNullOrEmpty(apiId)) { Client.DiagnosticRemoveTenantLevel(resourceGroupName, serviceName, diagnosticId); } else { Client.DiagnosticRemoveApiLevel(resourceGroupName, serviceName, apiId, diagnosticId); } if (PassThru.IsPresent) { WriteObject(true); } }