Class: MockServer::HttpChaosProfile

Inherits:
Object
  • Object
show all
Defined in:
lib/mockserver/models.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_status: nil, error_probability: nil, drop_connection_probability: nil, retry_after: nil, latency: nil, seed: nil, succeed_first: nil, fail_request_count: nil, outage_after_millis: nil, outage_duration_millis: nil, truncate_body_at_fraction: nil, malformed_body: nil, slow_response_chunk_size: nil, slow_response_chunk_delay: nil, quota_name: nil, quota_limit: nil, quota_window_millis: nil, quota_error_status: nil, degradation_ramp_millis: nil, graphql_errors: nil, graphql_error_message: nil, graphql_error_code: nil, graphql_nullify_data: nil) ⇒ HttpChaosProfile

Returns a new instance of HttpChaosProfile.



1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
# File 'lib/mockserver/models.rb', line 1834

def initialize(error_status: nil, error_probability: nil, drop_connection_probability: nil,
               retry_after: nil, latency: nil, seed: nil, succeed_first: nil, fail_request_count: nil,
               outage_after_millis: nil, outage_duration_millis: nil,
               truncate_body_at_fraction: nil, malformed_body: nil,
               slow_response_chunk_size: nil, slow_response_chunk_delay: nil,
               quota_name: nil, quota_limit: nil, quota_window_millis: nil, quota_error_status: nil,
               degradation_ramp_millis: nil,
               graphql_errors: nil, graphql_error_message: nil, graphql_error_code: nil,
               graphql_nullify_data: nil)
  @error_status = error_status
  @error_probability = error_probability
  @drop_connection_probability = drop_connection_probability
  @retry_after = retry_after
  @latency = latency
  @seed = seed
  @succeed_first = succeed_first
  @fail_request_count = fail_request_count
  @outage_after_millis = outage_after_millis
  @outage_duration_millis = outage_duration_millis
  @truncate_body_at_fraction = truncate_body_at_fraction
  @malformed_body = malformed_body
  @slow_response_chunk_size = slow_response_chunk_size
  @slow_response_chunk_delay = slow_response_chunk_delay
  @quota_name = quota_name
  @quota_limit = quota_limit
  @quota_window_millis = quota_window_millis
  @quota_error_status = quota_error_status
  @degradation_ramp_millis = degradation_ramp_millis
  @graphql_errors = graphql_errors
  @graphql_error_message = graphql_error_message
  @graphql_error_code = graphql_error_code
  @graphql_nullify_data = graphql_nullify_data
end

Instance Attribute Details

#degradation_ramp_millisObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def degradation_ramp_millis
  @degradation_ramp_millis
end

#drop_connection_probabilityObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def drop_connection_probability
  @drop_connection_probability
end

#error_probabilityObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def error_probability
  @error_probability
end

#error_statusObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def error_status
  @error_status
end

#fail_request_countObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def fail_request_count
  @fail_request_count
end

#graphql_error_codeObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def graphql_error_code
  @graphql_error_code
end

#graphql_error_messageObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def graphql_error_message
  @graphql_error_message
end

#graphql_errorsObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def graphql_errors
  @graphql_errors
end

#graphql_nullify_dataObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def graphql_nullify_data
  @graphql_nullify_data
end

#latencyObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def latency
  @latency
end

#malformed_bodyObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def malformed_body
  @malformed_body
end

#outage_after_millisObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def outage_after_millis
  @outage_after_millis
end

#outage_duration_millisObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def outage_duration_millis
  @outage_duration_millis
end

#quota_error_statusObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def quota_error_status
  @quota_error_status
end

#quota_limitObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def quota_limit
  @quota_limit
end

#quota_nameObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def quota_name
  @quota_name
end

#quota_window_millisObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def quota_window_millis
  @quota_window_millis
end

#retry_afterObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def retry_after
  @retry_after
end

#seedObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def seed
  @seed
end

#slow_response_chunk_delayObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def slow_response_chunk_delay
  @slow_response_chunk_delay
end

#slow_response_chunk_sizeObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def slow_response_chunk_size
  @slow_response_chunk_size
end

#succeed_firstObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def succeed_first
  @succeed_first
end

#truncate_body_at_fractionObject

graphql_errors / graphql_error_message / graphql_error_code / graphql_nullify_data carry the GraphQL fault-injection knobs from the server HttpChaosProfileDTO: when graphqlErrors is set the mocked GraphQL response is rewritten to carry an "errors" array (message/code from graphqlErrorMessage / graphqlErrorCode) and, when graphqlNullifyData is true, a null "data" field.



1824
1825
1826
# File 'lib/mockserver/models.rb', line 1824

def truncate_body_at_fraction
  @truncate_body_at_fraction
end

Class Method Details

.from_hash(data) ⇒ Object



1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
# File 'lib/mockserver/models.rb', line 1896

def self.from_hash(data)
  return nil if data.nil?

  new(
    error_status:               data['errorStatus'],
    error_probability:           data['errorProbability'],
    drop_connection_probability: data['dropConnectionProbability'],
    retry_after:                 data['retryAfter'],
    latency:                     Delay.from_hash(data['latency']),
    seed:                        data['seed'],
    succeed_first:               data['succeedFirst'],
    fail_request_count:          data['failRequestCount'],
    outage_after_millis:         data['outageAfterMillis'],
    outage_duration_millis:      data['outageDurationMillis'],
    truncate_body_at_fraction:   data['truncateBodyAtFraction'],
    malformed_body:              data['malformedBody'],
    slow_response_chunk_size:    data['slowResponseChunkSize'],
    slow_response_chunk_delay:   Delay.from_hash(data['slowResponseChunkDelay']),
    quota_name:                  data['quotaName'],
    quota_limit:                 data['quotaLimit'],
    quota_window_millis:         data['quotaWindowMillis'],
    quota_error_status:          data['quotaErrorStatus'],
    degradation_ramp_millis:     data['degradationRampMillis'],
    graphql_errors:              data['graphqlErrors'],
    graphql_error_message:       data['graphqlErrorMessage'],
    graphql_error_code:          data['graphqlErrorCode'],
    graphql_nullify_data:        data['graphqlNullifyData']
  )
end

Instance Method Details

#to_hObject



1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
# File 'lib/mockserver/models.rb', line 1868

def to_h
  MockServer.strip_none({
    'errorStatus'               => @error_status,
    'errorProbability'           => @error_probability,
    'dropConnectionProbability'  => @drop_connection_probability,
    'retryAfter'                 => @retry_after,
    'latency'                    => @latency&.to_h,
    'seed'                       => @seed,
    'succeedFirst'               => @succeed_first,
    'failRequestCount'           => @fail_request_count,
    'outageAfterMillis'          => @outage_after_millis,
    'outageDurationMillis'       => @outage_duration_millis,
    'truncateBodyAtFraction'     => @truncate_body_at_fraction,
    'malformedBody'              => @malformed_body,
    'slowResponseChunkSize'      => @slow_response_chunk_size,
    'slowResponseChunkDelay'     => @slow_response_chunk_delay&.to_h,
    'quotaName'                  => @quota_name,
    'quotaLimit'                 => @quota_limit,
    'quotaWindowMillis'          => @quota_window_millis,
    'quotaErrorStatus'           => @quota_error_status,
    'degradationRampMillis'      => @degradation_ramp_millis,
    'graphqlErrors'              => @graphql_errors,
    'graphqlErrorMessage'        => @graphql_error_message,
    'graphqlErrorCode'           => @graphql_error_code,
    'graphqlNullifyData'         => @graphql_nullify_data
  })
end