private Amazon.DirectoryService.Model.ShareDirectoryResponse CallAWSServiceOperation(IAmazonDirectoryService client, Amazon.DirectoryService.Model.ShareDirectoryRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Directory Service", "ShareDirectory");
     try
     {
         #if DESKTOP
         return(client.ShareDirectory(request));
         #elif CORECLR
         return(client.ShareDirectoryAsync(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.DirectoryService.Model.ShareDirectoryRequest();

            if (cmdletContext.DirectoryId != null)
            {
                request.DirectoryId = cmdletContext.DirectoryId;
            }
            if (cmdletContext.ShareMethod != null)
            {
                request.ShareMethod = cmdletContext.ShareMethod;
            }
            if (cmdletContext.ShareNote != null)
            {
                request.ShareNotes = cmdletContext.ShareNote;
            }

            // populate ShareTarget
            var requestShareTargetIsNull = true;

            request.ShareTarget = new Amazon.DirectoryService.Model.ShareTarget();
            System.String requestShareTarget_shareTarget_Id = null;
            if (cmdletContext.ShareTarget_Id != null)
            {
                requestShareTarget_shareTarget_Id = cmdletContext.ShareTarget_Id;
            }
            if (requestShareTarget_shareTarget_Id != null)
            {
                request.ShareTarget.Id   = requestShareTarget_shareTarget_Id;
                requestShareTargetIsNull = false;
            }
            Amazon.DirectoryService.TargetType requestShareTarget_shareTarget_Type = null;
            if (cmdletContext.ShareTarget_Type != null)
            {
                requestShareTarget_shareTarget_Type = cmdletContext.ShareTarget_Type;
            }
            if (requestShareTarget_shareTarget_Type != null)
            {
                request.ShareTarget.Type = requestShareTarget_shareTarget_Type;
                requestShareTargetIsNull = false;
            }
            // determine if request.ShareTarget should be set to null
            if (requestShareTargetIsNull)
            {
                request.ShareTarget = null;
            }

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