/// <summary>
 /// Unmarshaller error response to exception.
 /// </summary>  
 /// <param name="context"></param>
 /// <param name="innerException"></param>
 /// <param name="statusCode"></param>
 /// <returns></returns>
 public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
 {
     ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
     if (errorResponse.Code != null && errorResponse.Code.Equals("AccessDeniedException"))
     {
         return new AccessDeniedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("InternalException"))
     {
         return new InternalException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidInputException"))
     {
         return new InvalidInputException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchEntityException"))
     {
         return new NoSuchEntityException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("OperationInProgressException"))
     {
         return new OperationInProgressException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     return new AmazonInspectorException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
 }
 public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
 {
     ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
     if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterException"))
     {
         return new InvalidParameterException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("LimitExceededException"))
     {
         return new LimitExceededException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("OperationAbortedException"))
     {
         return new OperationAbortedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("ResourceAlreadyExistsException"))
     {
         return new ResourceAlreadyExistsException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("ServiceUnavailableException"))
     {
         return new ServiceUnavailableException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     return new AmazonCloudWatchLogsException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
 }
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterValue"))
            {
                return new InvalidParameterValueException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterCombination"))
            {
                return new InvalidParameterCombinationException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidCacheParameterGroupState"))
            {
                return new InvalidCacheParameterGroupStateException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            if (errorResponse.Code != null && errorResponse.Code.Equals("CacheParameterGroupNotFound"))
            {
                return new CacheParameterGroupNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            return new AmazonElastiCacheException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
        }
       public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
       {
         ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);                    
         
         if (errorResponse.Code != null && errorResponse.Code.Equals("ResourceNotFoundException"))
         {
           return new ResourceNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("MissingParameterValueException"))
         {
           return new MissingParameterValueException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("ServiceUnavailableException"))
         {
           return new ServiceUnavailableException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterValueException"))
         {
           return new InvalidParameterValueException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         return new AmazonGlacierException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
       }
 /// <summary>
 /// Creates a new instance of <see cref="MockClientHttpResponse"/>.
 /// </summary>
 /// <param name="body">The body of the response as a stream.</param>
 /// <param name="headers">The response headers.</param>
 /// <param name="statusCode">The response status code.</param>
 /// <param name="statusDescription">The response status description.</param>
 public MockClientHttpResponse(Stream body, HttpHeaders headers, HttpStatusCode statusCode, string statusDescription)
 {
     this.body = body;
     this.headers = headers;
     this.statusCode = statusCode;
     this.statusDescription = statusDescription;
 }
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            if (errorResponse.Code != null && errorResponse.Code.Equals("ListenerNotFound"))
            {
                return new ListenerNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            if (errorResponse.Code != null && errorResponse.Code.Equals("CertificateNotFound"))
            {
                return new CertificateNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            if (errorResponse.Code != null && errorResponse.Code.Equals("LoadBalancerNotFound"))
            {
                return new LoadBalancerNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidConfigurationRequest"))
            {
                return new InvalidConfigurationRequestException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
            }

            return new AmazonElasticLoadBalancingException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
        }
 /// <summary>
 /// Unmarshaller error response to exception.
 /// </summary>  
 /// <param name="context"></param>
 /// <param name="innerException"></param>
 /// <param name="statusCode"></param>
 /// <returns></returns>
 public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
 {
     ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
     if (errorResponse.Code != null && errorResponse.Code.Equals("InternalErrorException"))
     {
         return new InternalErrorException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterException"))
     {
         return new InvalidParameterException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("NotAuthorizedException"))
     {
         return new NotAuthorizedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("ResourceNotFoundException"))
     {
         return new ResourceNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyRequestsException"))
     {
         return new TooManyRequestsException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     return new AmazonCognitoIdentityException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
 }
 /// <summary>
 /// Constructs an <see cref="LinkedINHttpResponseException"/>.
 /// </summary>
 /// <param name="expectedStatusCode">The expected <see cref="HttpStatusCode"/> of the response.</param>
 /// <param name="actualStatusCode">The actual <see cref="HttpStatusCode"/> of the response.</param>
 /// <param name="message">The message descriving the cause of this exception.</param>
 /// <param name="inner">The inner <see cref="Exception"/>.</param>
 public LinkedINHttpResponseException( HttpStatusCode expectedStatusCode, HttpStatusCode actualStatusCode, string message, Exception inner )
     : base(message, inner)
 {
     // set values
     ExpectedStatusCode = expectedStatusCode;
     ActualStatusCode = actualStatusCode;
 }
 private void ReplyError(HttpStatusCode statusCode, string text, HttpResponse response)
 {
     response.StatusCode = (int)statusCode;
     response.ContentType = "text/html";
     response.Write(String.Format("<html><title>MovieInfo : ERROR</title><body><p>{0}</p></body></html>", text));
     for (int i = 0; i < 85; ++i) response.Write("&nbsp;");
 }
        /// <summary> 
        /// 
        /// <example> 
        ///  <code> 
        /// var result = CustomerAuthTicketFactory.CreateUserAuthTicket(handler : handler,  userAuthInfo :  userAuthInfo,  expectedCode: expectedCode, successCode: successCode); 
        /// var optionalCasting = ConvertClass<CustomerAuthTicket/>(result); 
        /// return optionalCasting;
        ///  </code> 
        /// </example> 
        /// </summary>
        public static Mozu.Api.Contracts.Customer.CustomerAuthTicket CreateUserAuthTicket(ServiceClientMessageHandler handler, 
 		 Mozu.Api.Contracts.Customer.CustomerUserAuthInfo userAuthInfo, 
		 HttpStatusCode expectedCode = HttpStatusCode.Created, HttpStatusCode successCode = HttpStatusCode.Created)
        {
            SetSdKparameters();
            var currentClassName = System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name;
            var currentMethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            Debug.WriteLine(currentMethodName  + '.' + currentMethodName );
            var apiClient = Mozu.Api.Clients.Commerce.Customer.CustomerAuthTicketClient.CreateUserAuthTicketClient(
                 userAuthInfo :  userAuthInfo		);
            try
            {
                apiClient.WithContext(handler.ApiContext).Execute();
            }
            catch (ApiException ex)
            {
                // Custom error handling for test cases can be placed here
                Exception customException = TestFailException.GetCustomTestException(ex, currentClassName, currentMethodName, expectedCode);
                if (customException != null)
                    throw customException;
                return null;
            }
            return ResponseMessageFactory.CheckResponseCodes(apiClient.HttpResponse.StatusCode, expectedCode, successCode)
                     ? (apiClient.Result())
                     : null;
        }
        /// <summary>
        /// Generates an HttpWebResponse that has the specified status code using reflection. 
        /// This is necessary because the constructors for HttpWebResponse are internal to the .NET framework.
        /// </summary>
        /// <param name="statusCode">Http status code of the response.</param>
        /// <returns>A new instance of <see cref="System.Net.HttpWebResponse"/></returns>
        public static HttpWebResponse GenerateHttpWebResponse(HttpStatusCode statusCode)
        {
            var response = (HttpWebResponse)FormatterServices.GetUninitializedObject(typeof(HttpWebResponse));

            SetPrivateField(response, "m_StatusCode", statusCode);
            return response;
        }
 /// <summary>
 /// Unmarshaller error response to exception.
 /// </summary>  
 /// <param name="context"></param>
 /// <param name="innerException"></param>
 /// <param name="statusCode"></param>
 /// <returns></returns>
 public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
 {
     ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
     if (errorResponse.Code != null && errorResponse.Code.Equals("BadRequestException"))
     {
         return new BadRequestException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("ConflictException"))
     {
         return new ConflictException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("NotFoundException"))
     {
         return new NotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyRequestsException"))
     {
         return new TooManyRequestsException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("UnauthorizedException"))
     {
         return new UnauthorizedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     return new AmazonAPIGatewayException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
 }
Example #13
0
        /*++

            GetWebStatusCodeString - Get a StatusCode-specific resource string

            This method is used to map a HTTP status code to a specific user
            readable error code.

            Input:

                statusCode      - Id for resource string.
                Status          - The WebExceptionStatus to be formatted.

            Returns:

                string for localized message.

        --*/
        public static string GetWebStatusCodeString(HttpStatusCode statusCode, string statusDescription) {
            string webStatusCode = "(" + ((int)statusCode).ToString(NumberFormatInfo.InvariantInfo) + ")";
            string statusMessage = null;
            //
            // Now combine the label with the base enum key and look up the status msg.
            //
            try {
                //
                // convert the HttpStatusCode to its label and look it up.
                //
                statusMessage = SR.GetString("net_httpstatuscode_" + statusCode.ToString(), null);
            }
            catch {
            }

            if (statusMessage!=null && statusMessage.Length>0) {
                webStatusCode += " " + statusMessage;
            }
            else {
                //
                // Otherwise try to map the base status.
                //
                if (statusDescription!=null && statusDescription.Length>0) {
                    webStatusCode += " " + statusDescription;
                }
            }

            return webStatusCode;
        }
       public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
       {
         ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);                    
         
         if (errorResponse.Code != null && errorResponse.Code.Equals("PipelineNotFoundException"))
         {
           return new PipelineNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("InternalServiceErrorException"))
         {
           return new InternalServiceErrorException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidRequestException"))
         {
           return new InvalidRequestException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("TaskNotFoundException"))
         {
           return new TaskNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("PipelineDeletedException"))
         {
           return new PipelineDeletedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         return new AmazonDataPipelineException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
       }
        /// <summary> 
        /// 
        /// <example> 
        ///  <code> 
        /// var result = ApplicationFactory.UpdateApplication(handler : handler,  application :  application,  appId :  appId,  expectedCode: expectedCode, successCode: successCode); 
        /// var optionalCasting = ConvertClass<Application/>(result); 
        /// return optionalCasting;
        ///  </code> 
        /// </example> 
        /// </summary>
        public static Mozu.Api.Contracts.InstalledApplications.Application UpdateApplication(ServiceClientMessageHandler handler, 
 		 Mozu.Api.Contracts.InstalledApplications.Application application, string appId, 
		 HttpStatusCode expectedCode = HttpStatusCode.OK, HttpStatusCode successCode = HttpStatusCode.OK)
        {
            SetSdKparameters();
            var currentClassName = System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name;
            var currentMethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            Debug.WriteLine(currentMethodName  + '.' + currentMethodName );
            var apiClient = Mozu.Api.Clients.Platform.ApplicationClient.UpdateApplicationClient(
                 application :  application,  appId :  appId		);
            try
            {
                apiClient.WithContext(handler.ApiContext).Execute();
            }
            catch (ApiException ex)
            {
                // Custom error handling for test cases can be placed here
                Exception customException = TestFailException.GetCustomTestException(ex, currentClassName, currentMethodName, expectedCode);
                if (customException != null)
                    throw customException;
                return null;
            }
            return ResponseMessageFactory.CheckResponseCodes(apiClient.HttpResponse.StatusCode, expectedCode, successCode)
                     ? (apiClient.Result())
                     : null;
        }
 /// <summary>
 /// Unmarshaller error response to exception.
 /// </summary>  
 /// <param name="context"></param>
 /// <param name="innerException"></param>
 /// <param name="statusCode"></param>
 /// <returns></returns>
 public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
 {
     ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
     if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidRequestContentException"))
     {
         return new InvalidRequestContentException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("RequestTooLargeException"))
     {
         return new RequestTooLargeException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("ResourceNotFoundException"))
     {
         return new ResourceNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("ServiceException"))
     {
         return new ServiceException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyRequestsException"))
     {
         return new TooManyRequestsException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("UnsupportedMediaTypeException"))
     {
         return new UnsupportedMediaTypeException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     return new AmazonLambdaException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
 }
        public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

              if (errorResponse.Code != null && errorResponse.Code.Equals("ProvisionedThroughputExceededException"))
              {
            return new ProvisionedThroughputExceededException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
              }

              if (errorResponse.Code != null && errorResponse.Code.Equals("ConditionalCheckFailedException"))
              {
            return new ConditionalCheckFailedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
              }

              if (errorResponse.Code != null && errorResponse.Code.Equals("InternalServerErrorException"))
              {
            return new InternalServerErrorException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
              }

              if (errorResponse.Code != null && errorResponse.Code.Equals("ResourceNotFoundException"))
              {
            return new ResourceNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
              }

              return new AmazonDynamoDBException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
        }
 /// <summary>
 /// Unmarshaller error response to exception.
 /// </summary>  
 /// <param name="context"></param>
 /// <param name="innerException"></param>
 /// <param name="statusCode"></param>
 /// <returns></returns>
 public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
 {
     ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
     if (errorResponse.Code != null && errorResponse.Code.Equals("ClientException"))
     {
         return new ClientException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("DirectoryLimitExceededException"))
     {
         return new DirectoryLimitExceededException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterException"))
     {
         return new InvalidParameterException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("ServiceException"))
     {
         return new ServiceException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("UnsupportedOperationException"))
     {
         return new UnsupportedOperationException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     return new AmazonDirectoryServiceException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
 }
		/// <summary> 
		/// Retrieves a list of events according to any specified filter criteria and sort options.
		/// <example> 
		///  <code> 
		/// var result = SubscriptionFactory.GetSubscriptions(handler : handler,  startIndex :  startIndex,  pageSize :  pageSize,  sortBy :  sortBy,  filter :  filter,  responseFields :  responseFields,  expectedCode: expectedCode, successCode: successCode); 
		/// var optionalCasting = ConvertClass<SubscriptionCollection/>(result); 
		/// return optionalCasting;
		///  </code> 
		/// </example> 
		/// </summary>
		public static Mozu.Api.Contracts.Event.SubscriptionCollection GetSubscriptions(ServiceClientMessageHandler handler, 
 		 int? startIndex = null, int? pageSize = null, string sortBy = null, string filter = null, string responseFields = null, 
		 HttpStatusCode expectedCode = HttpStatusCode.OK, HttpStatusCode successCode = HttpStatusCode.OK)
		{
			SetSdKparameters();
			var currentClassName = System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name;
			var currentMethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
			Debug.WriteLine(currentMethodName  + '.' + currentMethodName );
			var apiClient = Mozu.Api.Clients.Event.Push.SubscriptionClient.GetSubscriptionsClient(
				 startIndex :  startIndex,  pageSize :  pageSize,  sortBy :  sortBy,  filter :  filter,  responseFields :  responseFields		);
			try
			{
				apiClient.WithContext(handler.ApiContext).Execute();
			}
			catch (ApiException ex)
			{
				// Custom error handling for test cases can be placed here
				Exception customException = TestFailException.GetCustomTestException(ex, currentClassName, currentMethodName, expectedCode);
				if (customException != null)
					throw customException;
				return null;
			}
			return ResponseMessageFactory.CheckResponseCodes(apiClient.HttpResponse.StatusCode, expectedCode, successCode) 
					 ? (apiClient.Result()) 
					 : null;

		}
       public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
       {
         ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);                    
         
         if (errorResponse.Code != null && errorResponse.Code.Equals("ResourceNotFoundException"))
         {
           return new ResourceNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("AccessDeniedException"))
         {
           return new AccessDeniedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("InternalServiceException"))
         {
           return new InternalServiceException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("ValidationException"))
         {
           return new ValidationException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("IncompatibleVersionException"))
         {
           return new IncompatibleVersionException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         return new AmazonElasticTranscoderException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
       }
		/// <summary> 
		/// 
		/// <example> 
		///  <code> 
		/// var result = ListViewFactory.GetViewEntity(handler : handler,  entityListFullName :  entityListFullName,  viewName :  viewName,  entityId :  entityId,  responseFields :  responseFields,  expectedCode: expectedCode, successCode: successCode); 
		/// var optionalCasting = ConvertClass<JObject/>(result); 
		/// return optionalCasting;
		///  </code> 
		/// </example> 
		/// </summary>
		public static JObject GetViewEntity(ServiceClientMessageHandler handler, 
 		 string entityListFullName, string viewName, string entityId, string responseFields = null, 
		 HttpStatusCode expectedCode = HttpStatusCode.OK, HttpStatusCode successCode = HttpStatusCode.OK)
		{
			SetSdKparameters();
			var currentClassName = System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name;
			var currentMethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
			Debug.WriteLine(currentMethodName  + '.' + currentMethodName );
			var apiClient = Mozu.Api.Clients.Platform.Entitylists.ListViewClient.GetViewEntityClient(
				 entityListFullName :  entityListFullName,  viewName :  viewName,  entityId :  entityId,  responseFields :  responseFields		);
			try
			{
				apiClient.WithContext(handler.ApiContext).Execute();
			}
			catch (ApiException ex)
			{
				// Custom error handling for test cases can be placed here
				Exception customException = TestFailException.GetCustomTestException(ex, currentClassName, currentMethodName, expectedCode);
				if (customException != null)
					throw customException;
				return null;
			}
			return ResponseMessageFactory.CheckResponseCodes(apiClient.HttpResponse.StatusCode, expectedCode, successCode) 
					 ? (apiClient.Result()) 
					 : null;

		}
     public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
     {
         ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
         
         if (errorResponse.Code != null && errorResponse.Code.Equals("CacheSecurityGroupAlreadyExists"))
         {
             return new CacheSecurityGroupAlreadyExistsException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterValue"))
         {
             return new InvalidParameterValueException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("QuotaExceeded.CacheSecurityGroup"))
         {
             return new CacheSecurityGroupQuotaExceededException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterCombination"))
         {
             return new InvalidParameterCombinationException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
         }
 
         return new AmazonElastiCacheException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
 /// <summary>
 /// Unmarshaller error response to exception.
 /// </summary>  
 /// <param name="context"></param>
 /// <param name="innerException"></param>
 /// <param name="statusCode"></param>
 /// <returns></returns>
 public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
 {
     ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
     if (errorResponse.Code != null && errorResponse.Code.Equals("DeploymentDoesNotExistException"))
     {
         return new DeploymentDoesNotExistException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("DeploymentIdRequiredException"))
     {
         return new DeploymentIdRequiredException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("InstanceDoesNotExistException"))
     {
         return new InstanceDoesNotExistException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("InstanceIdRequiredException"))
     {
         return new InstanceIdRequiredException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidDeploymentIdException"))
     {
         return new InvalidDeploymentIdException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidInstanceNameException"))
     {
         return new InvalidInstanceNameException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     return new AmazonCodeDeployException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
 }
Example #24
0
        /// <summary> 
        /// Deletes a defined channel for the tenant and removes the defined site associations. After deleting this channel, assign its associated sites to another channel.
        /// <example> 
        ///  <code> 
        /// var result = ChannelFactory.DeleteChannel(handler : handler,  code :  code,  expectedCode: expectedCode, successCode: successCode); 
        /// var optionalCasting = ConvertClass<void/>(result); 
        /// return optionalCasting;
        ///  </code> 
        /// </example> 
        /// </summary>
        public static void DeleteChannel(ServiceClientMessageHandler handler, 
 		string code, 
		 HttpStatusCode expectedCode = HttpStatusCode.NoContent, HttpStatusCode successCode = HttpStatusCode.NoContent)
        {
            SetSdKparameters();
            var currentClassName = System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name;
            var currentMethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            Debug.WriteLine(currentMethodName  + '.' + currentMethodName );
            var apiClient = Mozu.Api.Clients.Commerce.ChannelClient.DeleteChannelClient(
                 code :  code		);
            try
            {
                apiClient.WithContext(handler.ApiContext).Execute();
            }
            catch (ApiException ex)
            {
                // Custom error handling for test cases can be placed here
                Exception customException = TestFailException.GetCustomTestException(ex, currentClassName, currentMethodName, expectedCode);
                if (customException != null)
                    throw customException;
            }
            var noResponse = ResponseMessageFactory.CheckResponseCodes(apiClient.HttpResponse.StatusCode, expectedCode, successCode)
                     ? (apiClient.Result())
                     : null;
        }
 /// <summary>
 /// Unmarshaller error response to exception.
 /// </summary>  
 /// <param name="context"></param>
 /// <param name="innerException"></param>
 /// <param name="statusCode"></param>
 /// <returns></returns>
 public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
 {
     ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
     if (errorResponse.Code != null && errorResponse.Code.Equals("AccessDeniedException"))
     {
         return new AccessDeniedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("AccountSetupInProgressException"))
     {
         return new AccountSetupInProgressException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidInputException"))
     {
         return new InvalidInputException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("NotFoundException"))
     {
         return new NotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("OperationFailureException"))
     {
         return new OperationFailureException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("ServiceException"))
     {
         return new ServiceException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("UnauthenticatedException"))
     {
         return new UnauthenticatedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     return new AmazonLightsailException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
 }
        /// <summary> 
        /// 
        /// <example> 
        ///  <code> 
        /// var result = DocumentTypeFactory.GetDocumentType(handler : handler,  documentTypeName :  documentTypeName,  dataViewMode: dataViewMode,  expectedCode: expectedCode, successCode: successCode); 
        /// var optionalCasting = ConvertClass<DocumentType/>(result); 
        /// return optionalCasting;
        ///  </code> 
        /// </example> 
        /// </summary>
        public static Mozu.Api.Contracts.Content.DocumentType GetDocumentType(ServiceClientMessageHandler handler, 
 		 string documentTypeName,  DataViewMode dataViewMode= DataViewMode.Live, 
		 HttpStatusCode expectedCode = HttpStatusCode.OK, HttpStatusCode successCode = HttpStatusCode.OK)
        {
            SetSdKparameters();
            var currentClassName = System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name;
            var currentMethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
            Debug.WriteLine(currentMethodName  + '.' + currentMethodName );
            var apiClient = Mozu.Api.Clients.Content.DocumentTypeClient.GetDocumentTypeClient(
                 documentTypeName :  documentTypeName, dataViewMode: dataViewMode		);
            try
            {
                apiClient.WithContext(handler.ApiContext).Execute();
            }
            catch (ApiException ex)
            {
                // Custom error handling for test cases can be placed here
                Exception customException = TestFailException.GetCustomTestException(ex, currentClassName, currentMethodName, expectedCode);
                if (customException != null)
                    throw customException;
                return null;
            }
            return ResponseMessageFactory.CheckResponseCodes(apiClient.HttpResponse.StatusCode, expectedCode, successCode)
                     ? (apiClient.Result())
                     : null;
        }
		/// <summary> 
		/// Applies a defined coupon to the cart specified in the request.
		/// <example> 
		///  <code> 
		/// var result = AppliedDiscountFactory.ApplyCoupon(handler : handler,  cartId :  cartId,  couponCode :  couponCode,  responseFields :  responseFields,  expectedCode: expectedCode, successCode: successCode); 
		/// var optionalCasting = ConvertClass<Cart/>(result); 
		/// return optionalCasting;
		///  </code> 
		/// </example> 
		/// </summary>
		public static Mozu.Api.Contracts.CommerceRuntime.Carts.Cart ApplyCoupon(ServiceClientMessageHandler handler, 
 		 string cartId, string couponCode, string responseFields = null, 
		 HttpStatusCode expectedCode = HttpStatusCode.OK, HttpStatusCode successCode = HttpStatusCode.OK)
		{
			SetSdKparameters();
			var currentClassName = System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType.Name;
			var currentMethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
			Debug.WriteLine(currentMethodName  + '.' + currentMethodName );
			var apiClient = Mozu.Api.Clients.Commerce.Carts.AppliedDiscountClient.ApplyCouponClient(
				 cartId :  cartId,  couponCode :  couponCode,  responseFields :  responseFields		);
			try
			{
				apiClient.WithContext(handler.ApiContext).Execute();
			}
			catch (ApiException ex)
			{
				// Custom error handling for test cases can be placed here
				Exception customException = TestFailException.GetCustomTestException(ex, currentClassName, currentMethodName, expectedCode);
				if (customException != null)
					throw customException;
				return null;
			}
			return ResponseMessageFactory.CheckResponseCodes(apiClient.HttpResponse.StatusCode, expectedCode, successCode) 
					 ? (apiClient.Result()) 
					 : null;

		}
 public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
 {
     ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
     if (errorResponse.Code != null && errorResponse.Code.Equals("AccessDenied"))
     {
         return new AccessDeniedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("BatchTooLarge"))
     {
         return new BatchTooLargeException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("InconsistentQuantities"))
     {
         return new InconsistentQuantitiesException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidArgument"))
     {
         return new InvalidArgumentException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("MissingBody"))
     {
         return new MissingBodyException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("NoSuchDistribution"))
     {
         return new NoSuchDistributionException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyInvalidationsInProgress"))
     {
         return new TooManyInvalidationsInProgressException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     return new AmazonCloudFrontException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
 }
 /// <summary>
 /// Unmarshaller error response to exception.
 /// </summary>  
 /// <param name="context"></param>
 /// <param name="innerException"></param>
 /// <param name="statusCode"></param>
 /// <returns></returns>
 public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
 {
     ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);
     if (errorResponse.Code != null && errorResponse.Code.Equals("InternalFailureException"))
     {
         return new InternalFailureException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidRequestException"))
     {
         return new InvalidRequestException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("ResourceNotFoundException"))
     {
         return new ResourceNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("ServiceUnavailableException"))
     {
         return new ServiceUnavailableException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("ThrottlingException"))
     {
         return new ThrottlingException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     if (errorResponse.Code != null && errorResponse.Code.Equals("UnauthorizedException"))
     {
         return new UnauthorizedException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
     }
     return new AmazonIoTException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode);
 }
Example #30
0
        public Step CheckStatusCodeIs(HttpStatusCode codeToMatch)
        {
            SetUpDefaultHeaders();
            Stopwatch stopWatch = Stopwatch.StartNew();
            var task = Get();
            string htmlContent = task.Result.Content.ReadAsStringAsync().Result;
            stopWatch.Stop();
            Console.WriteLine("Took {0} Milliseconds", stopWatch.ElapsedMilliseconds);
            if (!string.IsNullOrWhiteSpace(htmlContent))
            {
                if (htmlContent.Contains("__EVENTVALIDATION"))
                {
                    CurrentEventValidation = HttpScraper.GetEventValidationFromHtml(htmlContent);
                }

                if (htmlContent.Contains("__VIEWSTATE"))
                {
                    CurrentViewState = HttpScraper.GetViewStateFromHtml(htmlContent);
                }

                task.Result.StatusCode.Should().Be(codeToMatch);
            }
            else
            {
                throw new Exception("Status code was null");
            }
            Step.CurrentEventValidation = CurrentEventValidation;
            Step.CurrentViewState = CurrentViewState;
            Step.CurrentHtml = htmlContent;

            Dispose();
            return Step;
        }
Example #31
0
        /// <summary>
        /// Get bcgov_investigationstep_Annotations from bcgov_investigationsteps
        /// </summary>
        /// <param name='bcgovInvestigationstepid'>
        /// key: bcgov_investigationstepid of bcgov_investigationstep
        /// </param>
        /// <param name='top'>
        /// </param>
        /// <param name='skip'>
        /// </param>
        /// <param name='search'>
        /// </param>
        /// <param name='filter'>
        /// </param>
        /// <param name='count'>
        /// </param>
        /// <param name='orderby'>
        /// Order items by property values
        /// </param>
        /// <param name='select'>
        /// Select properties to be returned
        /// </param>
        /// <param name='expand'>
        /// Expand related entities
        /// </param>
        /// <param name='customHeaders'>
        /// Headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <exception cref="HttpOperationException">
        /// Thrown when the operation returned an invalid status code
        /// </exception>
        /// <exception cref="SerializationException">
        /// Thrown when unable to deserialize the response
        /// </exception>
        /// <exception cref="ValidationException">
        /// Thrown when a required parameter is null
        /// </exception>
        /// <exception cref="System.ArgumentNullException">
        /// Thrown when a required parameter is null
        /// </exception>
        /// <return>
        /// A response object containing the response body and response headers.
        /// </return>
        public async Task <HttpOperationResponse <MicrosoftDynamicsCRMannotationCollection> > GetWithHttpMessagesAsync(string bcgovInvestigationstepid, int?top = default(int?), int?skip = default(int?), string search = default(string), string filter = default(string), bool?count = default(bool?), IList <string> orderby = default(IList <string>), IList <string> select = default(IList <string>), IList <string> expand = default(IList <string>), Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (bcgovInvestigationstepid == null)
            {
                throw new ValidationException(ValidationRules.CannotBeNull, "bcgovInvestigationstepid");
            }
            // Tracing
            bool   _shouldTrace  = ServiceClientTracing.IsEnabled;
            string _invocationId = null;

            if (_shouldTrace)
            {
                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("bcgovInvestigationstepid", bcgovInvestigationstepid);
                tracingParameters.Add("top", top);
                tracingParameters.Add("skip", skip);
                tracingParameters.Add("search", search);
                tracingParameters.Add("filter", filter);
                tracingParameters.Add("count", count);
                tracingParameters.Add("orderby", orderby);
                tracingParameters.Add("select", select);
                tracingParameters.Add("expand", expand);
                tracingParameters.Add("cancellationToken", cancellationToken);
                ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
            }
            // Construct URL
            var _baseUrl = Client.BaseUri.AbsoluteUri;
            var _url     = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "bcgov_investigationsteps({bcgov_investigationstepid})/bcgov_investigationstep_Annotations").ToString();

            _url = _url.Replace("{bcgov_investigationstepid}", System.Uri.EscapeDataString(bcgovInvestigationstepid));
            List <string> _queryParameters = new List <string>();

            if (top != null)
            {
                _queryParameters.Add(string.Format("$top={0}", System.Uri.EscapeDataString(Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(top, Client.SerializationSettings).Trim('"'))));
            }
            if (skip != null)
            {
                _queryParameters.Add(string.Format("$skip={0}", System.Uri.EscapeDataString(Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(skip, Client.SerializationSettings).Trim('"'))));
            }
            if (search != null)
            {
                _queryParameters.Add(string.Format("$search={0}", System.Uri.EscapeDataString(search)));
            }
            if (filter != null)
            {
                _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter)));
            }
            if (count != null)
            {
                _queryParameters.Add(string.Format("$count={0}", System.Uri.EscapeDataString(Microsoft.Rest.Serialization.SafeJsonConvert.SerializeObject(count, Client.SerializationSettings).Trim('"'))));
            }
            if (orderby != null)
            {
                _queryParameters.Add(string.Format("$orderby={0}", System.Uri.EscapeDataString(string.Join(",", orderby))));
            }
            if (select != null)
            {
                _queryParameters.Add(string.Format("$select={0}", System.Uri.EscapeDataString(string.Join(",", select))));
            }
            if (expand != null)
            {
                _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(string.Join(",", expand))));
            }
            if (_queryParameters.Count > 0)
            {
                _url += "?" + string.Join("&", _queryParameters);
            }
            // Create HTTP transport objects
            var _httpRequest = new HttpRequestMessage();
            HttpResponseMessage _httpResponse = null;

            _httpRequest.Method     = new HttpMethod("GET");
            _httpRequest.RequestUri = new System.Uri(_url);
            // Set Headers


            if (customHeaders != null)
            {
                foreach (var _header in customHeaders)
                {
                    if (_httpRequest.Headers.Contains(_header.Key))
                    {
                        _httpRequest.Headers.Remove(_header.Key);
                    }
                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
                }
            }

            // Serialize Request
            string _requestContent = null;

            // Set Credentials
            if (Client.Credentials != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
            }
            // Send Request
            if (_shouldTrace)
            {
                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
            }
            cancellationToken.ThrowIfCancellationRequested();
            _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);

            if (_shouldTrace)
            {
                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
            }
            HttpStatusCode _statusCode = _httpResponse.StatusCode;

            cancellationToken.ThrowIfCancellationRequested();
            string _responseContent = null;

            if ((int)_statusCode != 200)
            {
                var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
                if (_httpResponse.Content != null)
                {
                    _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
                }
                else
                {
                    _responseContent = string.Empty;
                }
                ex.Request  = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
                if (_shouldTrace)
                {
                    ServiceClientTracing.Error(_invocationId, ex);
                }
                _httpRequest.Dispose();
                if (_httpResponse != null)
                {
                    _httpResponse.Dispose();
                }
                throw ex;
            }
            // Create Result
            var _result = new HttpOperationResponse <MicrosoftDynamicsCRMannotationCollection>();

            _result.Request  = _httpRequest;
            _result.Response = _httpResponse;
            // Deserialize Response
            if ((int)_statusCode == 200)
            {
                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                try
                {
                    _result.Body = Microsoft.Rest.Serialization.SafeJsonConvert.DeserializeObject <MicrosoftDynamicsCRMannotationCollection>(_responseContent, Client.DeserializationSettings);
                }
                catch (JsonException ex)
                {
                    _httpRequest.Dispose();
                    if (_httpResponse != null)
                    {
                        _httpResponse.Dispose();
                    }
                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
                }
            }
            if (_shouldTrace)
            {
                ServiceClientTracing.Exit(_invocationId, _result);
            }
            return(_result);
        }
Example #32
0
 /// <summary>
 /// Constructs MarketplaceWebServiceException with message and status code
 /// </summary>
 /// <param name="message">Overview of error</param>
 /// <param name="statusCode">HTTP status code for error response</param>
 public MarketplaceWebServiceException(String message, HttpStatusCode statusCode) : this (message)
 {
     this.statusCode = statusCode;
 }
Example #33
0
 public TwitterApiException(HttpStatusCode statusCode, string message, int code)
     : base(message)
 {
     this.StatusCode       = statusCode;
     this.TwitterErrorCode = code;
 }
 /// <summary>
 /// Construct instance of ValidationException
 /// </summary>
 /// <param name="message"></param>
 /// <param name="errorType"></param>
 /// <param name="errorCode"></param>
 /// <param name="requestId"></param>
 /// <param name="statusCode"></param>
 public ValidationException(string message, ErrorType errorType, string errorCode, string requestId, HttpStatusCode statusCode)
     : base(message, errorType, errorCode, requestId, statusCode)
 {
 }
Example #35
0
 /// <summary>
 /// Allow a specific HTTP status code.
 /// </summary>
 /// <param name="client">The client.</param>
 /// <param name="statusCode">The allowed status code.</param>
 /// <returns></returns>
 public static FlurlClient AllowHttpStatus(this FlurlClient client, HttpStatusCode statusCode)
 {
     return(client.AllowHttpStatus(((int)statusCode).ToString(CultureInfo.InvariantCulture)));
 }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            return(new AmazonEC2Exception(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
Example #37
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            var errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new JsonUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("AccessDeniedException"))
                    {
                        return(AccessDeniedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ConflictException"))
                    {
                        return(ConflictExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InternalServerException"))
                    {
                        return(InternalServerExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ThrottlingException"))
                    {
                        return(ThrottlingExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ValidationException"))
                    {
                        return(ValidationExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonFraudDetectorException(errorResponse.Message, errorResponse.InnerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode));
        }
Example #38
0
 /// <summary>
 /// Construct instance of ImageAlreadyExistsException
 /// </summary>
 /// <param name="message"></param>
 /// <param name="errorType"></param>
 /// <param name="errorCode"></param>
 /// <param name="requestId"></param>
 /// <param name="statusCode"></param>
 public ImageAlreadyExistsException(string message, ErrorType errorType, string errorCode, string requestId, HttpStatusCode statusCode)
     : base(message, errorType, errorCode, requestId, statusCode)
 {
 }
 /// <summary>
 /// Construct instance of AttachmentSetExpiredException
 /// </summary>
 /// <param name="message"></param>
 /// <param name="errorType"></param>
 /// <param name="errorCode"></param>
 /// <param name="requestId"></param>
 /// <param name="statusCode"></param>
 public AttachmentSetExpiredException(string message, ErrorType errorType, string errorCode, string requestId, HttpStatusCode statusCode)
     : base(message, errorType, errorCode, requestId, statusCode)
 {
 }
Example #40
0
        /// <param name='customHeaders'>
        /// Headers that will be added to request.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        /// <return>
        /// A response object containing the response body and response headers.
        /// </return>
        public async Task <HttpOperationResponse <IList <DeviceType> > > GetDeviceTypesWithHttpMessagesAsync(Dictionary <string, List <string> > customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            // Tracing
            bool   _shouldTrace  = ServiceClientTracing.IsEnabled;
            string _invocationId = null;

            if (_shouldTrace)
            {
                _invocationId = ServiceClientTracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("cancellationToken", cancellationToken);
                ServiceClientTracing.Enter(_invocationId, this, "GetDeviceTypes", tracingParameters);
            }
            // Construct URL
            var _baseUrl = this.Client.BaseUri.AbsoluteUri;
            var _url     = new Uri(new Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "Manage/DeviceTypes").ToString();
            // Create HTTP transport objects
            HttpRequestMessage  _httpRequest  = new HttpRequestMessage();
            HttpResponseMessage _httpResponse = null;

            _httpRequest.Method     = new HttpMethod("GET");
            _httpRequest.RequestUri = new Uri(_url);
            // Set Headers
            if (customHeaders != null)
            {
                foreach (var _header in customHeaders)
                {
                    if (_httpRequest.Headers.Contains(_header.Key))
                    {
                        _httpRequest.Headers.Remove(_header.Key);
                    }
                    _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
                }
            }

            // Serialize Request
            string _requestContent = null;

            // Set Credentials
            if (this.Client.Credentials != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
            }
            // Send Request
            if (_shouldTrace)
            {
                ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
            }
            cancellationToken.ThrowIfCancellationRequested();
            _httpResponse = await this.Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);

            if (_shouldTrace)
            {
                ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
            }
            HttpStatusCode _statusCode = _httpResponse.StatusCode;

            cancellationToken.ThrowIfCancellationRequested();
            string _responseContent = null;

            if ((int)_statusCode != 200)
            {
                var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                ex.Request  = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
                ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
                if (_shouldTrace)
                {
                    ServiceClientTracing.Error(_invocationId, ex);
                }
                _httpRequest.Dispose();
                if (_httpResponse != null)
                {
                    _httpResponse.Dispose();
                }
                throw ex;
            }
            // Create Result
            var _result = new HttpOperationResponse <IList <DeviceType> >();

            _result.Request  = _httpRequest;
            _result.Response = _httpResponse;
            // Deserialize Response
            if ((int)_statusCode == 200)
            {
                _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                try
                {
                    _result.Body = SafeJsonConvert.DeserializeObject <IList <DeviceType> >(_responseContent, this.Client.DeserializationSettings);
                }
                catch (JsonException ex)
                {
                    _httpRequest.Dispose();
                    if (_httpResponse != null)
                    {
                        _httpResponse.Dispose();
                    }
                    throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
                }
            }
            if (_shouldTrace)
            {
                ServiceClientTracing.Exit(_invocationId, _result);
            }
            return(_result);
        }
        public static void AppendVarDataModelOrListOfModel(
            int indentSpaces,
            StringBuilder sb,
            EndpointMethodMetadata endpointMethodMetadata,
            OpenApiSchema schema,
            HttpStatusCode httpStatusCode,
            SchemaMapLocatedAreaType locatedAreaType,
            KeyValuePair<string, OpenApiSchema>? badPropertySchema = null,
            bool asJsonBody = false,
            int maxItemsForList = 3,
            int depthHierarchy = 0,
            int maxDepthHierarchy = 2)
        {
            var trailingChar = TrailingCharType.SemiColon;
            if (asJsonBody)
            {
                trailingChar = TrailingCharType.None;
            }

            switch (locatedAreaType)
            {
                case SchemaMapLocatedAreaType.Parameter:
                    break;
                case SchemaMapLocatedAreaType.RequestBody:
                    if (schema.Type == OpenApiDataTypeConstants.Array)
                    {
                        int indentSpacesForData = indentSpaces;
                        if (asJsonBody)
                        {
                            sb.AppendLine(indentSpaces, "var sb = new StringBuilder();");
                            indentSpacesForData = indentSpacesForData - 4;
                        }

                        AppendVarDataEqualNewListOfModel(
                            indentSpacesForData,
                            sb,
                            endpointMethodMetadata,
                            new KeyValuePair<string, OpenApiSchema>("data", schema),
                            trailingChar,
                            maxItemsForList,
                            depthHierarchy,
                            maxDepthHierarchy,
                            badPropertySchema,
                            asJsonBody);

                        if (asJsonBody)
                        {
                            sb.AppendLine(indentSpaces, "var data = sb.ToString();");
                        }
                    }
                    else
                    {
                        if (asJsonBody)
                        {
                            sb.AppendLine(indentSpaces, "var sb = new StringBuilder();");
                        }
                        else
                        {
                            GenerateXunitTestPartsHelper.AppendPartVarDataEqualNew(12, sb);
                        }

                        var modelName = schema.GetModelName();
                        AppendModel(
                            indentSpaces,
                            sb,
                            endpointMethodMetadata,
                            modelName,
                            schema,
                            trailingChar,
                            0,
                            maxItemsForList,
                            depthHierarchy,
                            maxDepthHierarchy,
                            badPropertySchema,
                            asJsonBody);

                        if (asJsonBody)
                        {
                            sb.AppendLine(indentSpaces, "var data = sb.ToString();");
                        }
                    }

                    break;
                case SchemaMapLocatedAreaType.Response:
                    var contractReturnTypeName = endpointMethodMetadata.ContractReturnTypeNames.First(x => x.Item1 == httpStatusCode);
                    if (GenerateXunitTestPartsHelper.IsListKind(contractReturnTypeName.Item2))
                    {
                        AppendVarDataEqualNewListOfModel(
                            indentSpaces,
                            sb,
                            endpointMethodMetadata,
                            new KeyValuePair<string, OpenApiSchema>("data", contractReturnTypeName.Item3!),
                            trailingChar,
                            maxItemsForList,
                            depthHierarchy,
                            maxDepthHierarchy,
                            badPropertySchema,
                            asJsonBody);
                    }
                    else
                    {
                        GenerateXunitTestPartsHelper.AppendPartVarDataEqualNew(12, sb);
                        AppendModel(
                            indentSpaces,
                            sb,
                            endpointMethodMetadata,
                            contractReturnTypeName.Item2,
                            contractReturnTypeName.Item3!,
                            trailingChar,
                            0,
                            maxItemsForList,
                            depthHierarchy,
                            maxDepthHierarchy,
                            badPropertySchema,
                            asJsonBody);
                    }

                    break;
                default:
                    throw new ArgumentOutOfRangeException(nameof(locatedAreaType), locatedAreaType, null);
            }
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            var errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new JsonUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("AccessDeniedException"))
                    {
                        return(AccessDeniedExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InternalServerError"))
                    {
                        return(InternalServerErrorExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidPaginationTokenException"))
                    {
                        return(InvalidPaginationTokenExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidParameterException"))
                    {
                        return(InvalidParameterExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ProvisionedThroughputExceededException"))
                    {
                        return(ProvisionedThroughputExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ResourceNotFoundException"))
                    {
                        return(ResourceNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ThrottlingException"))
                    {
                        return(ThrottlingExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonRekognitionException(errorResponse.Message, errorResponse.InnerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode));
        }
 internal KeyPairMismatchException(string message, ErrorType errorType, string errorCode, string RequestId, HttpStatusCode statusCode)
     : base(message, errorType, errorCode, RequestId, statusCode)
 {
 }
Example #44
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            var errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new JsonUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("BadRequestException"))
                    {
                        return(BadRequestExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ConflictException"))
                    {
                        return(ConflictExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("NotFoundException"))
                    {
                        return(NotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("TooManyRequestsException"))
                    {
                        return(TooManyRequestsExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonApiGatewayV2Exception(errorResponse.Message, errorResponse.InnerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            var errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new JsonUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidArnException"))
                    {
                        return(InvalidArnExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("InvalidStateException"))
                    {
                        return(InvalidStateExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("LimitExceededException"))
                    {
                        return(LimitExceededExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ResourceNotFoundException"))
                    {
                        return(ResourceNotFoundExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonCertificateManagerException(errorResponse.Message, errorResponse.InnerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode));
        }
Example #46
0
 public TwitterApiException(HttpStatusCode statusCode, string message)
     : base(message)
 {
     this.StatusCode = statusCode;
 }
 /// <summary>
 /// Construct instance of InvalidRevisionException
 /// </summary>
 /// <param name="message"></param>
 /// <param name="innerException"></param>
 /// <param name="errorType"></param>
 /// <param name="errorCode"></param>
 /// <param name="requestId"></param>
 /// <param name="statusCode"></param>
 public InvalidRevisionException(string message, Exception innerException, ErrorType errorType, string errorCode, string requestId, HttpStatusCode statusCode) 
     : base(message, innerException, errorType, errorCode, requestId, statusCode) {}
 /// <summary>
 /// Construct instance of AmazonSecretsManagerException
 /// </summary>
 /// <param name="message"></param>
 /// <param name="innerException"></param>
 /// <param name="errorType"></param>
 /// <param name="errorCode"></param>
 /// <param name="requestId"></param>
 /// <param name="statusCode"></param>
 public AmazonSecretsManagerException(string message, Exception innerException, ErrorType errorType, string errorCode, string requestId, HttpStatusCode statusCode)
     : base(message, innerException, errorType, errorCode, requestId, statusCode)
 {
 }
 /// <summary>
 /// Construct instance of InvalidRepositoryNameException
 /// </summary>
 /// <param name="message"></param>
 /// <param name="errorType"></param>
 /// <param name="errorCode"></param>
 /// <param name="requestId"></param>
 /// <param name="statusCode"></param>
 public InvalidRepositoryNameException(string message, ErrorType errorType, string errorCode, string requestId, HttpStatusCode statusCode)
     : base(message, errorType, errorCode, requestId, statusCode)
 {
 }
 /// <summary>
 /// Construct instance of ParameterMaxVersionLimitExceededException
 /// </summary>
 /// <param name="message"></param>
 /// <param name="errorType"></param>
 /// <param name="errorCode"></param>
 /// <param name="requestId"></param>
 /// <param name="statusCode"></param>
 public ParameterMaxVersionLimitExceededException(string message, ErrorType errorType, string errorCode, string requestId, HttpStatusCode statusCode)
     : base(message, errorType, errorCode, requestId, statusCode)
 {
 }
Example #51
0
 /// <summary>
 /// Construct instance of WAFStaleDataException
 /// </summary>
 /// <param name="message"></param>
 /// <param name="errorType"></param>
 /// <param name="errorCode"></param>
 /// <param name="requestId"></param>
 /// <param name="statusCode"></param>
 public WAFStaleDataException(string message, ErrorType errorType, string errorCode, string requestId, HttpStatusCode statusCode)
     : base(message, errorType, errorCode, requestId, statusCode)
 {
 }
Example #52
0
 /// <summary>
 /// Construct instance of NotFoundException
 /// </summary>
 /// <param name="message"></param>
 /// <param name="innerException"></param>
 /// <param name="errorType"></param>
 /// <param name="errorCode"></param>
 /// <param name="requestId"></param>
 /// <param name="statusCode"></param>
 public NotFoundException(string message, Exception innerException, ErrorType errorType, string errorCode, string requestId, HttpStatusCode statusCode)
     : base(message, innerException, errorType, errorCode, requestId, statusCode)
 {
 }
Example #53
0
 /// <summary>
 /// Construct instance of AmazonCloudTrailException
 /// </summary>
 /// <param name="message"></param>
 /// <param name="errorType"></param>
 /// <param name="errorCode"></param>
 /// <param name="requestId"></param>
 /// <param name="statusCode"></param>
 public AmazonCloudTrailException(string message, ErrorType errorType, string errorCode, string requestId, HttpStatusCode statusCode)
     : base(message, errorType, errorCode, requestId, statusCode)
 {
 }
 /// <summary>
 /// Construct instance of TooManyDistributionsException
 /// </summary>
 /// <param name="message"></param>
 /// <param name="errorType"></param>
 /// <param name="errorCode"></param>
 /// <param name="requestId"></param>
 /// <param name="statusCode"></param>
 public TooManyDistributionsException(string message, ErrorType errorType, string errorCode, string requestId, HttpStatusCode statusCode)
     : base(message, errorType, errorCode, requestId, statusCode)
 {
 }
Example #55
0
 /// <summary>
 /// Allow a specific HTTP status code.
 /// </summary>
 /// <param name="url">The URL.</param>
 /// <param name="statusCode">The allowed status code.</param>
 /// <returns></returns>
 public static FlurlClient AllowHttpStatus(this Url url, HttpStatusCode statusCode)
 {
     return(new FlurlClient(url, autoDispose: true).AllowHttpStatus(statusCode));
 }
Example #56
0
        public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            if (errorResponse.Code != null && errorResponse.Code.Equals("ClientException"))
            {
                return(new ClientException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
            }
            if (errorResponse.Code != null && errorResponse.Code.Equals("ServerException"))
            {
                return(new ServerException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
            }
            return(new AmazonECSException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
Example #57
0
 /// <summary>
 /// Allow a specific HTTP status code.
 /// </summary>
 /// <param name="url">The URL.</param>
 /// <param name="statusCode">The allowed status code.</param>
 /// <returns></returns>
 public static FlurlClient AllowHttpStatus(this string url, HttpStatusCode statusCode)
 {
     return(new Url(url).AllowHttpStatus(statusCode));
 }
Example #58
0
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            var errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            errorResponse.InnerException = innerException;
            errorResponse.StatusCode     = statusCode;

            var responseBodyBytes = context.GetResponseBodyBytes();

            using (var streamCopy = new MemoryStream(responseBodyBytes))
                using (var contextCopy = new JsonUnmarshallerContext(streamCopy, false, null))
                {
                    if (errorResponse.Code != null && errorResponse.Code.Equals("BadRequestException"))
                    {
                        return(BadRequestExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ForbiddenException"))
                    {
                        return(ForbiddenExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ServiceFailureException"))
                    {
                        return(ServiceFailureExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ServiceUnavailableException"))
                    {
                        return(ServiceUnavailableExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("ThrottledClientException"))
                    {
                        return(ThrottledClientExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                    if (errorResponse.Code != null && errorResponse.Code.Equals("UnauthorizedClientException"))
                    {
                        return(UnauthorizedClientExceptionUnmarshaller.Instance.Unmarshall(contextCopy, errorResponse));
                    }
                }
            return(new AmazonChimeSDKIdentityException(errorResponse.Message, errorResponse.InnerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode));
        }
        /// <summary>
        /// Unmarshaller error response to exception.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="innerException"></param>
        /// <param name="statusCode"></param>
        /// <returns></returns>
        public override AmazonServiceException UnmarshallException(JsonUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = JsonErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            if (errorResponse.Code != null && errorResponse.Code.Equals("ActionTypeNotFoundException"))
            {
                return(new ActionTypeNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
            }
            if (errorResponse.Code != null && errorResponse.Code.Equals("ValidationException"))
            {
                return(new ValidationException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
            }
            return(new AmazonCodePipelineException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }
Example #60
0
        public override AmazonServiceException UnmarshallException(XmlUnmarshallerContext context, Exception innerException, HttpStatusCode statusCode)
        {
            ErrorResponse errorResponse = ErrorResponseUnmarshaller.GetInstance().Unmarshall(context);

            if (errorResponse.Code != null && errorResponse.Code.Equals("ReservedNodeAlreadyExists"))
            {
                return(new ReservedNodeAlreadyExistsException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
            }

            if (errorResponse.Code != null && errorResponse.Code.Equals("ReservedNodeOfferingNotFound"))
            {
                return(new ReservedNodeOfferingNotFoundException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
            }

            if (errorResponse.Code != null && errorResponse.Code.Equals("ReservedNodeQuotaExceeded"))
            {
                return(new ReservedNodeQuotaExceededException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
            }

            return(new AmazonRedshiftException(errorResponse.Message, innerException, errorResponse.Type, errorResponse.Code, errorResponse.RequestId, statusCode));
        }