Пример #1
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.WorkSpaces.Model.RegisterWorkspaceDirectoryRequest();

            if (cmdletContext.DirectoryId != null)
            {
                request.DirectoryId = cmdletContext.DirectoryId;
            }
            if (cmdletContext.EnableSelfService != null)
            {
                request.EnableSelfService = cmdletContext.EnableSelfService.Value;
            }
            if (cmdletContext.EnableWorkDoc != null)
            {
                request.EnableWorkDocs = cmdletContext.EnableWorkDoc.Value;
            }
            if (cmdletContext.SubnetId != null)
            {
                request.SubnetIds = cmdletContext.SubnetId;
            }
            if (cmdletContext.Tag != null)
            {
                request.Tags = cmdletContext.Tag;
            }
            if (cmdletContext.Tenancy != null)
            {
                request.Tenancy = cmdletContext.Tenancy;
            }

            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);
        }
Пример #2
0
 private Amazon.WorkSpaces.Model.RegisterWorkspaceDirectoryResponse CallAWSServiceOperation(IAmazonWorkSpaces client, Amazon.WorkSpaces.Model.RegisterWorkspaceDirectoryRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon WorkSpaces", "RegisterWorkspaceDirectory");
     try
     {
         #if DESKTOP
         return(client.RegisterWorkspaceDirectory(request));
         #elif CORECLR
         return(client.RegisterWorkspaceDirectoryAsync(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;
     }
 }