Class: Fastly::WafRuleRevisionsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/fastly/api/waf_rule_revisions_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ WafRuleRevisionsApi

Returns a new instance of WafRuleRevisionsApi.



17
18
19
# File 'lib/fastly/api/waf_rule_revisions_api.rb', line 17

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



15
16
17
# File 'lib/fastly/api/waf_rule_revisions_api.rb', line 15

def api_client
  @api_client
end

Instance Method Details

#get_waf_rule_revision(opts = {}) ⇒ WafRuleRevisionResponse

Get a revision of a rule Get a specific rule revision.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :waf_rule_id (String)

    Alphanumeric string identifying a WAF rule. (required)

  • :waf_rule_revision_number (Integer)

    Revision number. (required)

  • :include (String)

    Include relationships. Optional, comma-separated values. Permitted values: `waf_rule`, `vcl`, and `source`. The `vcl` and `source` relationships show the WAF VCL and corresponding ModSecurity source. These fields are blank unless the relationship is included.

Returns:



26
27
28
29
# File 'lib/fastly/api/waf_rule_revisions_api.rb', line 26

def get_waf_rule_revision(opts = {})
  data, _status_code, _headers = get_waf_rule_revision_with_http_info(opts)
  data
end

#get_waf_rule_revision_with_http_info(opts = {}) ⇒ Array<(WafRuleRevisionResponse, Integer, Hash)>

Get a revision of a rule Get a specific rule revision.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :waf_rule_id (String)

    Alphanumeric string identifying a WAF rule. (required)

  • :waf_rule_revision_number (Integer)

    Revision number. (required)

  • :include (String)

    Include relationships. Optional, comma-separated values. Permitted values: &#x60;waf_rule&#x60;, &#x60;vcl&#x60;, and &#x60;source&#x60;. The &#x60;vcl&#x60; and &#x60;source&#x60; relationships show the WAF VCL and corresponding ModSecurity source. These fields are blank unless the relationship is included.

Returns:

  • (Array<(WafRuleRevisionResponse, Integer, Hash)>)

    WafRuleRevisionResponse data, response status code and response headers



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/fastly/api/waf_rule_revisions_api.rb', line 37

def get_waf_rule_revision_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WafRuleRevisionsApi.get_waf_rule_revision ...'
  end
  # unbox the parameters from the hash
  waf_rule_id = opts[:'waf_rule_id']
  waf_rule_revision_number = opts[:'waf_rule_revision_number']
  # verify the required parameter 'waf_rule_id' is set
  if @api_client.config.client_side_validation && waf_rule_id.nil?
    fail ArgumentError, "Missing the required parameter 'waf_rule_id' when calling WafRuleRevisionsApi.get_waf_rule_revision"
  end
  # verify the required parameter 'waf_rule_revision_number' is set
  if @api_client.config.client_side_validation && waf_rule_revision_number.nil?
    fail ArgumentError, "Missing the required parameter 'waf_rule_revision_number' when calling WafRuleRevisionsApi.get_waf_rule_revision"
  end
  # resource path
  local_var_path = '/waf/rules/{waf_rule_id}/revisions/{waf_rule_revision_number}'.sub('{' + 'waf_rule_id' + '}', CGI.escape(waf_rule_id.to_s)).sub('{' + 'waf_rule_revision_number' + '}', CGI.escape(waf_rule_revision_number.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'include'] = opts[:'include'] if !opts[:'include'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'WafRuleRevisionResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"WafRuleRevisionsApi.get_waf_rule_revision",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WafRuleRevisionsApi#get_waf_rule_revision\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_waf_rule_revisions(opts = {}) ⇒ WafRuleRevisionsResponse

List revisions for a rule List all revisions for a specific rule. The ‘rule_id` provided can be the ModSecurity Rule ID or the Fastly generated rule ID.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :waf_rule_id (String)

    Alphanumeric string identifying a WAF rule. (required)

  • :page_number (Integer)

    Current page.

  • :page_size (Integer)

    Number of records per page. (default to 20)

  • :include (String)

    Include relationships. Optional. (default to ‘waf_rule’)

Returns:



100
101
102
103
# File 'lib/fastly/api/waf_rule_revisions_api.rb', line 100

def list_waf_rule_revisions(opts = {})
  data, _status_code, _headers = list_waf_rule_revisions_with_http_info(opts)
  data
end

#list_waf_rule_revisions_with_http_info(opts = {}) ⇒ Array<(WafRuleRevisionsResponse, Integer, Hash)>

List revisions for a rule List all revisions for a specific rule. The &#x60;rule_id&#x60; provided can be the ModSecurity Rule ID or the Fastly generated rule ID.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • :waf_rule_id (String)

    Alphanumeric string identifying a WAF rule. (required)

  • :page_number (Integer)

    Current page.

  • :page_size (Integer)

    Number of records per page. (default to 20)

  • :include (String)

    Include relationships. Optional. (default to ‘waf_rule’)

Returns:

  • (Array<(WafRuleRevisionsResponse, Integer, Hash)>)

    WafRuleRevisionsResponse data, response status code and response headers



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/fastly/api/waf_rule_revisions_api.rb', line 112

def list_waf_rule_revisions_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WafRuleRevisionsApi.list_waf_rule_revisions ...'
  end
  # unbox the parameters from the hash
  waf_rule_id = opts[:'waf_rule_id']
  # verify the required parameter 'waf_rule_id' is set
  if @api_client.config.client_side_validation && waf_rule_id.nil?
    fail ArgumentError, "Missing the required parameter 'waf_rule_id' when calling WafRuleRevisionsApi.list_waf_rule_revisions"
  end
  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling WafRuleRevisionsApi.list_waf_rule_revisions, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling WafRuleRevisionsApi.list_waf_rule_revisions, must be greater than or equal to 1.'
  end

  allowable_values = ["waf_rule"]
  if @api_client.config.client_side_validation && opts[:'include'] && !allowable_values.include?(opts[:'include'])
    fail ArgumentError, "invalid value for \"include\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/waf/rules/{waf_rule_id}/revisions'.sub('{' + 'waf_rule_id' + '}', CGI.escape(waf_rule_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'page[number]'] = opts[:'page_number'] if !opts[:'page_number'].nil?
  query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  query_params[:'include'] = opts[:'include'] if !opts[:'include'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'WafRuleRevisionsResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['token']

  new_options = opts.merge(
    :operation => :"WafRuleRevisionsApi.list_waf_rule_revisions",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WafRuleRevisionsApi#list_waf_rule_revisions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end