コード例 #1
0
 private Amazon.Greengrass.Model.CreateFunctionDefinitionResponse CallAWSServiceOperation(IAmazonGreengrass client, Amazon.Greengrass.Model.CreateFunctionDefinitionRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS Greengrass", "CreateFunctionDefinition");
     try
     {
         #if DESKTOP
         return(client.CreateFunctionDefinition(request));
         #elif CORECLR
         return(client.CreateFunctionDefinitionAsync(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.Greengrass.Model.CreateFunctionDefinitionRequest();

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

            // populate InitialVersion
            var requestInitialVersionIsNull = true;

            request.InitialVersion = new Amazon.Greengrass.Model.FunctionDefinitionVersion();
            List <Amazon.Greengrass.Model.Function> requestInitialVersion_initialVersion_Function = null;

            if (cmdletContext.InitialVersion_Function != null)
            {
                requestInitialVersion_initialVersion_Function = cmdletContext.InitialVersion_Function;
            }
            if (requestInitialVersion_initialVersion_Function != null)
            {
                request.InitialVersion.Functions = requestInitialVersion_initialVersion_Function;
                requestInitialVersionIsNull      = false;
            }
            Amazon.Greengrass.Model.FunctionDefaultConfig requestInitialVersion_initialVersion_DefaultConfig = null;

            // populate DefaultConfig
            var requestInitialVersion_initialVersion_DefaultConfigIsNull = true;

            requestInitialVersion_initialVersion_DefaultConfig = new Amazon.Greengrass.Model.FunctionDefaultConfig();
            Amazon.Greengrass.Model.FunctionDefaultExecutionConfig requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution = null;

            // populate Execution
            var requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_ExecutionIsNull = true;

            requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution = new Amazon.Greengrass.Model.FunctionDefaultExecutionConfig();
            Amazon.Greengrass.FunctionIsolationMode requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_execution_IsolationMode = null;
            if (cmdletContext.Execution_IsolationMode != null)
            {
                requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_execution_IsolationMode = cmdletContext.Execution_IsolationMode;
            }
            if (requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_execution_IsolationMode != null)
            {
                requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution.IsolationMode = requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_execution_IsolationMode;
                requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_ExecutionIsNull         = false;
            }
            Amazon.Greengrass.Model.FunctionRunAsConfig requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs = null;

            // populate RunAs
            var requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAsIsNull = true;

            requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs = new Amazon.Greengrass.Model.FunctionRunAsConfig();
            System.Int32?requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs_runAs_Gid = null;
            if (cmdletContext.RunAs_Gid != null)
            {
                requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs_runAs_Gid = cmdletContext.RunAs_Gid.Value;
            }
            if (requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs_runAs_Gid != null)
            {
                requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs.Gid   = requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs_runAs_Gid.Value;
                requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAsIsNull = false;
            }
            System.Int32?requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs_runAs_Uid = null;
            if (cmdletContext.RunAs_Uid != null)
            {
                requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs_runAs_Uid = cmdletContext.RunAs_Uid.Value;
            }
            if (requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs_runAs_Uid != null)
            {
                requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs.Uid   = requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs_runAs_Uid.Value;
                requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAsIsNull = false;
            }
            // determine if requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs should be set to null
            if (requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAsIsNull)
            {
                requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs = null;
            }
            if (requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs != null)
            {
                requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution.RunAs = requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution_initialVersion_DefaultConfig_Execution_RunAs;
                requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_ExecutionIsNull = false;
            }
            // determine if requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution should be set to null
            if (requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_ExecutionIsNull)
            {
                requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution = null;
            }
            if (requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution != null)
            {
                requestInitialVersion_initialVersion_DefaultConfig.Execution = requestInitialVersion_initialVersion_DefaultConfig_initialVersion_DefaultConfig_Execution;
                requestInitialVersion_initialVersion_DefaultConfigIsNull     = false;
            }
            // determine if requestInitialVersion_initialVersion_DefaultConfig should be set to null
            if (requestInitialVersion_initialVersion_DefaultConfigIsNull)
            {
                requestInitialVersion_initialVersion_DefaultConfig = null;
            }
            if (requestInitialVersion_initialVersion_DefaultConfig != null)
            {
                request.InitialVersion.DefaultConfig = requestInitialVersion_initialVersion_DefaultConfig;
                requestInitialVersionIsNull          = false;
            }
            // determine if request.InitialVersion should be set to null
            if (requestInitialVersionIsNull)
            {
                request.InitialVersion = null;
            }
            if (cmdletContext.Name != null)
            {
                request.Name = cmdletContext.Name;
            }
            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);
        }