private Amazon.Backup.Model.StartBackupJobResponse CallAWSServiceOperation(IAmazonBackup client, Amazon.Backup.Model.StartBackupJobRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Backup", "StartBackupJob"); try { #if DESKTOP return(client.StartBackupJob(request)); #elif CORECLR return(client.StartBackupJobAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.Backup.Model.StartBackupJobRequest(); if (cmdletContext.BackupOption != null) { request.BackupOptions = cmdletContext.BackupOption; } if (cmdletContext.BackupVaultName != null) { request.BackupVaultName = cmdletContext.BackupVaultName; } if (cmdletContext.CompleteWindowMinute != null) { request.CompleteWindowMinutes = cmdletContext.CompleteWindowMinute.Value; } if (cmdletContext.IamRoleArn != null) { request.IamRoleArn = cmdletContext.IamRoleArn; } if (cmdletContext.IdempotencyToken != null) { request.IdempotencyToken = cmdletContext.IdempotencyToken; } // populate Lifecycle var requestLifecycleIsNull = true; request.Lifecycle = new Amazon.Backup.Model.Lifecycle(); System.Int64?requestLifecycle_lifecycle_DeleteAfterDay = null; if (cmdletContext.Lifecycle_DeleteAfterDay != null) { requestLifecycle_lifecycle_DeleteAfterDay = cmdletContext.Lifecycle_DeleteAfterDay.Value; } if (requestLifecycle_lifecycle_DeleteAfterDay != null) { request.Lifecycle.DeleteAfterDays = requestLifecycle_lifecycle_DeleteAfterDay.Value; requestLifecycleIsNull = false; } System.Int64?requestLifecycle_lifecycle_MoveToColdStorageAfterDay = null; if (cmdletContext.Lifecycle_MoveToColdStorageAfterDay != null) { requestLifecycle_lifecycle_MoveToColdStorageAfterDay = cmdletContext.Lifecycle_MoveToColdStorageAfterDay.Value; } if (requestLifecycle_lifecycle_MoveToColdStorageAfterDay != null) { request.Lifecycle.MoveToColdStorageAfterDays = requestLifecycle_lifecycle_MoveToColdStorageAfterDay.Value; requestLifecycleIsNull = false; } // determine if request.Lifecycle should be set to null if (requestLifecycleIsNull) { request.Lifecycle = null; } if (cmdletContext.RecoveryPointTag != null) { request.RecoveryPointTags = cmdletContext.RecoveryPointTag; } if (cmdletContext.ResourceArn != null) { request.ResourceArn = cmdletContext.ResourceArn; } if (cmdletContext.StartWindowMinute != null) { request.StartWindowMinutes = cmdletContext.StartWindowMinute.Value; } CmdletOutput output; // issue call var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); try { var response = CallAWSServiceOperation(client, request); object pipelineOutput = null; pipelineOutput = cmdletContext.Select(response, this); output = new CmdletOutput { PipelineOutput = pipelineOutput, ServiceResponse = response }; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } return(output); }