コード例 #1
0
 private Amazon.Lightsail.Model.UpdateDistributionResponse CallAWSServiceOperation(IAmazonLightsail client, Amazon.Lightsail.Model.UpdateDistributionRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Lightsail", "UpdateDistribution");
     try
     {
         #if DESKTOP
         return(client.UpdateDistribution(request));
         #elif CORECLR
         return(client.UpdateDistributionAsync(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.Lightsail.Model.UpdateDistributionRequest();

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

            // populate CacheBehaviorSettings
            var requestCacheBehaviorSettingsIsNull = true;

            request.CacheBehaviorSettings = new Amazon.Lightsail.Model.CacheSettings();
            System.String requestCacheBehaviorSettings_cacheBehaviorSettings_AllowedHTTPMethod = null;
            if (cmdletContext.CacheBehaviorSettings_AllowedHTTPMethod != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_AllowedHTTPMethod = cmdletContext.CacheBehaviorSettings_AllowedHTTPMethod;
            }
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_AllowedHTTPMethod != null)
            {
                request.CacheBehaviorSettings.AllowedHTTPMethods = requestCacheBehaviorSettings_cacheBehaviorSettings_AllowedHTTPMethod;
                requestCacheBehaviorSettingsIsNull = false;
            }
            System.String requestCacheBehaviorSettings_cacheBehaviorSettings_CachedHTTPMethod = null;
            if (cmdletContext.CacheBehaviorSettings_CachedHTTPMethod != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_CachedHTTPMethod = cmdletContext.CacheBehaviorSettings_CachedHTTPMethod;
            }
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_CachedHTTPMethod != null)
            {
                request.CacheBehaviorSettings.CachedHTTPMethods = requestCacheBehaviorSettings_cacheBehaviorSettings_CachedHTTPMethod;
                requestCacheBehaviorSettingsIsNull = false;
            }
            System.Int64?requestCacheBehaviorSettings_cacheBehaviorSettings_DefaultTTL = null;
            if (cmdletContext.CacheBehaviorSettings_DefaultTTL != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_DefaultTTL = cmdletContext.CacheBehaviorSettings_DefaultTTL.Value;
            }
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_DefaultTTL != null)
            {
                request.CacheBehaviorSettings.DefaultTTL = requestCacheBehaviorSettings_cacheBehaviorSettings_DefaultTTL.Value;
                requestCacheBehaviorSettingsIsNull       = false;
            }
            System.Int64?requestCacheBehaviorSettings_cacheBehaviorSettings_MaximumTTL = null;
            if (cmdletContext.CacheBehaviorSettings_MaximumTTL != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_MaximumTTL = cmdletContext.CacheBehaviorSettings_MaximumTTL.Value;
            }
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_MaximumTTL != null)
            {
                request.CacheBehaviorSettings.MaximumTTL = requestCacheBehaviorSettings_cacheBehaviorSettings_MaximumTTL.Value;
                requestCacheBehaviorSettingsIsNull       = false;
            }
            System.Int64?requestCacheBehaviorSettings_cacheBehaviorSettings_MinimumTTL = null;
            if (cmdletContext.CacheBehaviorSettings_MinimumTTL != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_MinimumTTL = cmdletContext.CacheBehaviorSettings_MinimumTTL.Value;
            }
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_MinimumTTL != null)
            {
                request.CacheBehaviorSettings.MinimumTTL = requestCacheBehaviorSettings_cacheBehaviorSettings_MinimumTTL.Value;
                requestCacheBehaviorSettingsIsNull       = false;
            }
            Amazon.Lightsail.Model.CookieObject requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies = null;

            // populate ForwardedCookies
            var requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookiesIsNull = true;

            requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies = new Amazon.Lightsail.Model.CookieObject();
            List <System.String> requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies_forwardedCookies_CookiesAllowList = null;

            if (cmdletContext.ForwardedCookies_CookiesAllowList != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies_forwardedCookies_CookiesAllowList = cmdletContext.ForwardedCookies_CookiesAllowList;
            }
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies_forwardedCookies_CookiesAllowList != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies.CookiesAllowList = requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies_forwardedCookies_CookiesAllowList;
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookiesIsNull            = false;
            }
            Amazon.Lightsail.ForwardValues requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies_forwardedCookies_Option = null;
            if (cmdletContext.ForwardedCookies_Option != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies_forwardedCookies_Option = cmdletContext.ForwardedCookies_Option;
            }
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies_forwardedCookies_Option != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies.Option = requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies_forwardedCookies_Option;
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookiesIsNull  = false;
            }
            // determine if requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies should be set to null
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookiesIsNull)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies = null;
            }
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies != null)
            {
                request.CacheBehaviorSettings.ForwardedCookies = requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedCookies;
                requestCacheBehaviorSettingsIsNull             = false;
            }
            Amazon.Lightsail.Model.HeaderObject requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders = null;

            // populate ForwardedHeaders
            var requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeadersIsNull = true;

            requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders = new Amazon.Lightsail.Model.HeaderObject();
            List <System.String> requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders_forwardedHeaders_HeadersAllowList = null;

            if (cmdletContext.ForwardedHeaders_HeadersAllowList != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders_forwardedHeaders_HeadersAllowList = cmdletContext.ForwardedHeaders_HeadersAllowList;
            }
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders_forwardedHeaders_HeadersAllowList != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders.HeadersAllowList = requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders_forwardedHeaders_HeadersAllowList;
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeadersIsNull            = false;
            }
            Amazon.Lightsail.ForwardValues requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders_forwardedHeaders_Option = null;
            if (cmdletContext.ForwardedHeaders_Option != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders_forwardedHeaders_Option = cmdletContext.ForwardedHeaders_Option;
            }
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders_forwardedHeaders_Option != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders.Option = requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders_forwardedHeaders_Option;
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeadersIsNull  = false;
            }
            // determine if requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders should be set to null
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeadersIsNull)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders = null;
            }
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders != null)
            {
                request.CacheBehaviorSettings.ForwardedHeaders = requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedHeaders;
                requestCacheBehaviorSettingsIsNull             = false;
            }
            Amazon.Lightsail.Model.QueryStringObject requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings = null;

            // populate ForwardedQueryStrings
            var requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStringsIsNull = true;

            requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings = new Amazon.Lightsail.Model.QueryStringObject();
            System.Boolean?requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings_forwardedQueryStrings_Option = null;
            if (cmdletContext.ForwardedQueryStrings_Option != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings_forwardedQueryStrings_Option = cmdletContext.ForwardedQueryStrings_Option.Value;
            }
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings_forwardedQueryStrings_Option != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings.Option = requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings_forwardedQueryStrings_Option.Value;
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStringsIsNull  = false;
            }
            List <System.String> requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings_forwardedQueryStrings_QueryStringsAllowList = null;

            if (cmdletContext.ForwardedQueryStrings_QueryStringsAllowList != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings_forwardedQueryStrings_QueryStringsAllowList = cmdletContext.ForwardedQueryStrings_QueryStringsAllowList;
            }
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings_forwardedQueryStrings_QueryStringsAllowList != null)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings.QueryStringsAllowList = requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings_forwardedQueryStrings_QueryStringsAllowList;
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStringsIsNull = false;
            }
            // determine if requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings should be set to null
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStringsIsNull)
            {
                requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings = null;
            }
            if (requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings != null)
            {
                request.CacheBehaviorSettings.ForwardedQueryStrings = requestCacheBehaviorSettings_cacheBehaviorSettings_ForwardedQueryStrings;
                requestCacheBehaviorSettingsIsNull = false;
            }
            // determine if request.CacheBehaviorSettings should be set to null
            if (requestCacheBehaviorSettingsIsNull)
            {
                request.CacheBehaviorSettings = null;
            }

            // populate DefaultCacheBehavior
            var requestDefaultCacheBehaviorIsNull = true;

            request.DefaultCacheBehavior = new Amazon.Lightsail.Model.CacheBehavior();
            Amazon.Lightsail.BehaviorEnum requestDefaultCacheBehavior_defaultCacheBehavior_Behavior = null;
            if (cmdletContext.DefaultCacheBehavior_Behavior != null)
            {
                requestDefaultCacheBehavior_defaultCacheBehavior_Behavior = cmdletContext.DefaultCacheBehavior_Behavior;
            }
            if (requestDefaultCacheBehavior_defaultCacheBehavior_Behavior != null)
            {
                request.DefaultCacheBehavior.Behavior = requestDefaultCacheBehavior_defaultCacheBehavior_Behavior;
                requestDefaultCacheBehaviorIsNull     = false;
            }
            // determine if request.DefaultCacheBehavior should be set to null
            if (requestDefaultCacheBehaviorIsNull)
            {
                request.DefaultCacheBehavior = null;
            }
            if (cmdletContext.DistributionName != null)
            {
                request.DistributionName = cmdletContext.DistributionName;
            }
            if (cmdletContext.IsEnabled != null)
            {
                request.IsEnabled = cmdletContext.IsEnabled.Value;
            }

            // populate Origin
            var requestOriginIsNull = true;

            request.Origin = new Amazon.Lightsail.Model.InputOrigin();
            System.String requestOrigin_origin_Name = null;
            if (cmdletContext.Origin_Name != null)
            {
                requestOrigin_origin_Name = cmdletContext.Origin_Name;
            }
            if (requestOrigin_origin_Name != null)
            {
                request.Origin.Name = requestOrigin_origin_Name;
                requestOriginIsNull = false;
            }
            Amazon.Lightsail.OriginProtocolPolicyEnum requestOrigin_origin_ProtocolPolicy = null;
            if (cmdletContext.Origin_ProtocolPolicy != null)
            {
                requestOrigin_origin_ProtocolPolicy = cmdletContext.Origin_ProtocolPolicy;
            }
            if (requestOrigin_origin_ProtocolPolicy != null)
            {
                request.Origin.ProtocolPolicy = requestOrigin_origin_ProtocolPolicy;
                requestOriginIsNull           = false;
            }
            Amazon.Lightsail.RegionName requestOrigin_origin_RegionName = null;
            if (cmdletContext.Origin_RegionName != null)
            {
                requestOrigin_origin_RegionName = cmdletContext.Origin_RegionName;
            }
            if (requestOrigin_origin_RegionName != null)
            {
                request.Origin.RegionName = requestOrigin_origin_RegionName;
                requestOriginIsNull       = false;
            }
            // determine if request.Origin should be set to null
            if (requestOriginIsNull)
            {
                request.Origin = 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);
        }