Exemple #1
0
 private Amazon.Lightsail.Model.EnableAddOnResponse CallAWSServiceOperation(IAmazonLightsail client, Amazon.Lightsail.Model.EnableAddOnRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Lightsail", "EnableAddOn");
     try
     {
         #if DESKTOP
         return(client.EnableAddOn(request));
         #elif CORECLR
         return(client.EnableAddOnAsync(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;
     }
 }
Exemple #2
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.Lightsail.Model.EnableAddOnRequest();


            // populate AddOnRequest
            var requestAddOnRequestIsNull = true;

            request.AddOnRequest = new Amazon.Lightsail.Model.AddOnRequest();
            Amazon.Lightsail.AddOnType requestAddOnRequest_addOnRequest_AddOnType = null;
            if (cmdletContext.AddOnRequest_AddOnType != null)
            {
                requestAddOnRequest_addOnRequest_AddOnType = cmdletContext.AddOnRequest_AddOnType;
            }
            if (requestAddOnRequest_addOnRequest_AddOnType != null)
            {
                request.AddOnRequest.AddOnType = requestAddOnRequest_addOnRequest_AddOnType;
                requestAddOnRequestIsNull      = false;
            }
            Amazon.Lightsail.Model.AutoSnapshotAddOnRequest requestAddOnRequest_addOnRequest_AutoSnapshotAddOnRequest = null;

            // populate AutoSnapshotAddOnRequest
            var requestAddOnRequest_addOnRequest_AutoSnapshotAddOnRequestIsNull = true;

            requestAddOnRequest_addOnRequest_AutoSnapshotAddOnRequest = new Amazon.Lightsail.Model.AutoSnapshotAddOnRequest();
            System.String requestAddOnRequest_addOnRequest_AutoSnapshotAddOnRequest_autoSnapshotAddOnRequest_SnapshotTimeOfDay = null;
            if (cmdletContext.AutoSnapshotAddOnRequest_SnapshotTimeOfDay != null)
            {
                requestAddOnRequest_addOnRequest_AutoSnapshotAddOnRequest_autoSnapshotAddOnRequest_SnapshotTimeOfDay = cmdletContext.AutoSnapshotAddOnRequest_SnapshotTimeOfDay;
            }
            if (requestAddOnRequest_addOnRequest_AutoSnapshotAddOnRequest_autoSnapshotAddOnRequest_SnapshotTimeOfDay != null)
            {
                requestAddOnRequest_addOnRequest_AutoSnapshotAddOnRequest.SnapshotTimeOfDay = requestAddOnRequest_addOnRequest_AutoSnapshotAddOnRequest_autoSnapshotAddOnRequest_SnapshotTimeOfDay;
                requestAddOnRequest_addOnRequest_AutoSnapshotAddOnRequestIsNull             = false;
            }
            // determine if requestAddOnRequest_addOnRequest_AutoSnapshotAddOnRequest should be set to null
            if (requestAddOnRequest_addOnRequest_AutoSnapshotAddOnRequestIsNull)
            {
                requestAddOnRequest_addOnRequest_AutoSnapshotAddOnRequest = null;
            }
            if (requestAddOnRequest_addOnRequest_AutoSnapshotAddOnRequest != null)
            {
                request.AddOnRequest.AutoSnapshotAddOnRequest = requestAddOnRequest_addOnRequest_AutoSnapshotAddOnRequest;
                requestAddOnRequestIsNull = false;
            }
            // determine if request.AddOnRequest should be set to null
            if (requestAddOnRequestIsNull)
            {
                request.AddOnRequest = null;
            }
            if (cmdletContext.ResourceName != null)
            {
                request.ResourceName = cmdletContext.ResourceName;
            }

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