Beispiel #1
0
 private Amazon.EventBridge.Model.PutPermissionResponse CallAWSServiceOperation(IAmazonEventBridge client, Amazon.EventBridge.Model.PutPermissionRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon EventBridge", "PutPermission");
     try
     {
         #if DESKTOP
         return(client.PutPermission(request));
         #elif CORECLR
         return(client.PutPermissionAsync(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;
     }
 }
Beispiel #2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.EventBridge.Model.PutPermissionRequest();

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

            // populate Condition
            var requestConditionIsNull = true;

            request.Condition = new Amazon.EventBridge.Model.Condition();
            System.String requestCondition_condition_Key = null;
            if (cmdletContext.Condition_Key != null)
            {
                requestCondition_condition_Key = cmdletContext.Condition_Key;
            }
            if (requestCondition_condition_Key != null)
            {
                request.Condition.Key  = requestCondition_condition_Key;
                requestConditionIsNull = false;
            }
            System.String requestCondition_condition_Type = null;
            if (cmdletContext.Condition_Type != null)
            {
                requestCondition_condition_Type = cmdletContext.Condition_Type;
            }
            if (requestCondition_condition_Type != null)
            {
                request.Condition.Type = requestCondition_condition_Type;
                requestConditionIsNull = false;
            }
            System.String requestCondition_condition_Value = null;
            if (cmdletContext.Condition_Value != null)
            {
                requestCondition_condition_Value = cmdletContext.Condition_Value;
            }
            if (requestCondition_condition_Value != null)
            {
                request.Condition.Value = requestCondition_condition_Value;
                requestConditionIsNull  = false;
            }
            // determine if request.Condition should be set to null
            if (requestConditionIsNull)
            {
                request.Condition = null;
            }
            if (cmdletContext.EventBusName != null)
            {
                request.EventBusName = cmdletContext.EventBusName;
            }
            if (cmdletContext.Policy != null)
            {
                request.Policy = cmdletContext.Policy;
            }
            if (cmdletContext.Principal != null)
            {
                request.Principal = cmdletContext.Principal;
            }
            if (cmdletContext.StatementId != null)
            {
                request.StatementId = cmdletContext.StatementId;
            }

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