예제 #1
0
 private Amazon.FSx.Model.CreateDataRepositoryAssociationResponse CallAWSServiceOperation(IAmazonFSx client, Amazon.FSx.Model.CreateDataRepositoryAssociationRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon FSx", "CreateDataRepositoryAssociation");
     try
     {
         #if DESKTOP
         return(client.CreateDataRepositoryAssociation(request));
         #elif CORECLR
         return(client.CreateDataRepositoryAssociationAsync(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;
     }
 }
예제 #2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.FSx.Model.CreateDataRepositoryAssociationRequest();

            if (cmdletContext.BatchImportMetaDataOnCreate != null)
            {
                request.BatchImportMetaDataOnCreate = cmdletContext.BatchImportMetaDataOnCreate.Value;
            }
            if (cmdletContext.ClientRequestToken != null)
            {
                request.ClientRequestToken = cmdletContext.ClientRequestToken;
            }
            if (cmdletContext.DataRepositoryPath != null)
            {
                request.DataRepositoryPath = cmdletContext.DataRepositoryPath;
            }
            if (cmdletContext.FileSystemId != null)
            {
                request.FileSystemId = cmdletContext.FileSystemId;
            }
            if (cmdletContext.FileSystemPath != null)
            {
                request.FileSystemPath = cmdletContext.FileSystemPath;
            }
            if (cmdletContext.ImportedFileChunkSize != null)
            {
                request.ImportedFileChunkSize = cmdletContext.ImportedFileChunkSize.Value;
            }

            // populate S3
            var requestS3IsNull = true;

            request.S3 = new Amazon.FSx.Model.S3DataRepositoryConfiguration();
            Amazon.FSx.Model.AutoExportPolicy requestS3_s3_AutoExportPolicy = null;

            // populate AutoExportPolicy
            var requestS3_s3_AutoExportPolicyIsNull = true;

            requestS3_s3_AutoExportPolicy = new Amazon.FSx.Model.AutoExportPolicy();
            List <System.String> requestS3_s3_AutoExportPolicy_autoExportPolicy_Event = null;

            if (cmdletContext.AutoExportPolicy_Event != null)
            {
                requestS3_s3_AutoExportPolicy_autoExportPolicy_Event = cmdletContext.AutoExportPolicy_Event;
            }
            if (requestS3_s3_AutoExportPolicy_autoExportPolicy_Event != null)
            {
                requestS3_s3_AutoExportPolicy.Events = requestS3_s3_AutoExportPolicy_autoExportPolicy_Event;
                requestS3_s3_AutoExportPolicyIsNull  = false;
            }
            // determine if requestS3_s3_AutoExportPolicy should be set to null
            if (requestS3_s3_AutoExportPolicyIsNull)
            {
                requestS3_s3_AutoExportPolicy = null;
            }
            if (requestS3_s3_AutoExportPolicy != null)
            {
                request.S3.AutoExportPolicy = requestS3_s3_AutoExportPolicy;
                requestS3IsNull             = false;
            }
            Amazon.FSx.Model.AutoImportPolicy requestS3_s3_AutoImportPolicy = null;

            // populate AutoImportPolicy
            var requestS3_s3_AutoImportPolicyIsNull = true;

            requestS3_s3_AutoImportPolicy = new Amazon.FSx.Model.AutoImportPolicy();
            List <System.String> requestS3_s3_AutoImportPolicy_autoImportPolicy_Event = null;

            if (cmdletContext.AutoImportPolicy_Event != null)
            {
                requestS3_s3_AutoImportPolicy_autoImportPolicy_Event = cmdletContext.AutoImportPolicy_Event;
            }
            if (requestS3_s3_AutoImportPolicy_autoImportPolicy_Event != null)
            {
                requestS3_s3_AutoImportPolicy.Events = requestS3_s3_AutoImportPolicy_autoImportPolicy_Event;
                requestS3_s3_AutoImportPolicyIsNull  = false;
            }
            // determine if requestS3_s3_AutoImportPolicy should be set to null
            if (requestS3_s3_AutoImportPolicyIsNull)
            {
                requestS3_s3_AutoImportPolicy = null;
            }
            if (requestS3_s3_AutoImportPolicy != null)
            {
                request.S3.AutoImportPolicy = requestS3_s3_AutoImportPolicy;
                requestS3IsNull             = false;
            }
            // determine if request.S3 should be set to null
            if (requestS3IsNull)
            {
                request.S3 = null;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }

            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);
        }