Exemplo n.º 1
0
 private Amazon.WorkDocs.Model.AddResourcePermissionsResponse CallAWSServiceOperation(IAmazonWorkDocs client, Amazon.WorkDocs.Model.AddResourcePermissionsRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon WorkDocs", "AddResourcePermissions");
     try
     {
         #if DESKTOP
         return(client.AddResourcePermissions(request));
         #elif CORECLR
         return(client.AddResourcePermissionsAsync(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;
     }
 }
Exemplo n.º 2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.WorkDocs.Model.AddResourcePermissionsRequest();

            if (cmdletContext.AuthenticationToken != null)
            {
                request.AuthenticationToken = cmdletContext.AuthenticationToken;
            }

            // populate NotificationOptions
            var requestNotificationOptionsIsNull = true;

            request.NotificationOptions = new Amazon.WorkDocs.Model.NotificationOptions();
            System.String requestNotificationOptions_notificationOptions_EmailMessage = null;
            if (cmdletContext.NotificationOptions_EmailMessage != null)
            {
                requestNotificationOptions_notificationOptions_EmailMessage = cmdletContext.NotificationOptions_EmailMessage;
            }
            if (requestNotificationOptions_notificationOptions_EmailMessage != null)
            {
                request.NotificationOptions.EmailMessage = requestNotificationOptions_notificationOptions_EmailMessage;
                requestNotificationOptionsIsNull         = false;
            }
            System.Boolean?requestNotificationOptions_notificationOptions_SendEmail = null;
            if (cmdletContext.NotificationOptions_SendEmail != null)
            {
                requestNotificationOptions_notificationOptions_SendEmail = cmdletContext.NotificationOptions_SendEmail.Value;
            }
            if (requestNotificationOptions_notificationOptions_SendEmail != null)
            {
                request.NotificationOptions.SendEmail = requestNotificationOptions_notificationOptions_SendEmail.Value;
                requestNotificationOptionsIsNull      = false;
            }
            // determine if request.NotificationOptions should be set to null
            if (requestNotificationOptionsIsNull)
            {
                request.NotificationOptions = null;
            }
            if (cmdletContext.Principal != null)
            {
                request.Principals = cmdletContext.Principal;
            }
            if (cmdletContext.ResourceId != null)
            {
                request.ResourceId = cmdletContext.ResourceId;
            }

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