Class: Fastly::PurgeApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ PurgeApi

Returns a new instance of PurgeApi.



17
18
19
# File 'lib/fastly/api/purge_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/purge_api.rb', line 15

def api_client
  @api_client
end

Instance Method Details

#bulk_purge_tag(opts = {}) ⇒ Hash<String, String>

Purge multiple surrogate key tags Instant Purge a particular service of items tagged with surrogate keys. Up to 256 surrogate keys can be purged in one batch request. As an alternative to sending the keys in a JSON object in the body of the request, this endpoint also supports listing keys in a Surrogate-Key request header, e.g. Surrogate-Key: key_1 key_2 key_3.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :service_id (String)

    Alphanumeric string identifying the service. (required)

  • :fastly_soft_purge (Integer)

    If present, this header triggers the purge to be &#39;soft&#39;, which marks the affected object as stale rather than making it inaccessible. Typically set to &quot;1&quot; when used, but the value is not important.

  • :surrogate_key (String)

    Purge multiple surrogate key tags using a request header. Not required if a JSON POST body is specified.

  • :purge_response (PurgeResponse)

Returns:

  • (Hash<String, String>)


27
28
29
30
# File 'lib/fastly/api/purge_api.rb', line 27

def bulk_purge_tag(opts = {})
  data, _status_code, _headers = bulk_purge_tag_with_http_info(opts)
  data
end

#bulk_purge_tag_with_http_info(opts = {}) ⇒ Array<(Hash<String, String>, Integer, Hash)>

Purge multiple surrogate key tags Instant Purge a particular service of items tagged with surrogate keys. Up to 256 surrogate keys can be purged in one batch request. As an alternative to sending the keys in a JSON object in the body of the request, this endpoint also supports listing keys in a &lt;code&gt;Surrogate-Key&lt;/code&gt; request header, e.g. &lt;code&gt;Surrogate-Key: key_1 key_2 key_3&lt;/code&gt;.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :service_id (String)

    Alphanumeric string identifying the service. (required)

  • :fastly_soft_purge (Integer)

    If present, this header triggers the purge to be &#39;soft&#39;, which marks the affected object as stale rather than making it inaccessible. Typically set to &quot;1&quot; when used, but the value is not important.

  • :surrogate_key (String)

    Purge multiple surrogate key tags using a request header. Not required if a JSON POST body is specified.

  • :purge_response (PurgeResponse)

Returns:

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

    Hash<String, String> data, response status code and response headers



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
92
93
94
# File 'lib/fastly/api/purge_api.rb', line 39

def bulk_purge_tag_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PurgeApi.bulk_purge_tag ...'
  end
  # unbox the parameters from the hash
  service_id = opts[:'service_id']
  # verify the required parameter 'service_id' is set
  if @api_client.config.client_side_validation && service_id.nil?
    fail ArgumentError, "Missing the required parameter 'service_id' when calling PurgeApi.bulk_purge_tag"
  end
  # resource path
  local_var_path = '/service/{service_id}/purge'.sub('{' + 'service_id' + '}', CGI.escape(service_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'fastly-soft-purge'] = opts[:'fastly_soft_purge'] if !opts[:'fastly_soft_purge'].nil?
  header_params[:'surrogate-key'] = opts[:'surrogate_key'] if !opts[:'surrogate_key'].nil?

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

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'purge_response'])

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, String>'

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

  new_options = opts.merge(
    :operation => :"PurgeApi.bulk_purge_tag",
    :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(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PurgeApi#bulk_purge_tag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#purge_all(opts = {}) ⇒ InlineResponse200

Purge everything from a service Instant Purge everything from a service. Purge-all requests cannot be done in soft mode and will always immediately invalidate all cached content associated with the service. To do a soft-purge-all, consider applying a constant [surrogate key](docs.fastly.com/en/guides/getting-started-with-surrogate-keys) tag (e.g., ‘"all"`) to all objects.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :service_id (String)

    Alphanumeric string identifying the service. (required)

Returns:



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

def purge_all(opts = {})
  data, _status_code, _headers = purge_all_with_http_info(opts)
  data
end

#purge_all_with_http_info(opts = {}) ⇒ Array<(InlineResponse200, Integer, Hash)>

Purge everything from a service Instant Purge everything from a service. Purge-all requests cannot be done in soft mode and will always immediately invalidate all cached content associated with the service. To do a soft-purge-all, consider applying a constant [surrogate key](docs.fastly.com/en/guides/getting-started-with-surrogate-keys) tag (e.g., &#x60;&quot;all&quot;&#x60;) to all objects.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :service_id (String)

    Alphanumeric string identifying the service. (required)

Returns:

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

    InlineResponse200 data, response status code and response headers



109
110
111
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
# File 'lib/fastly/api/purge_api.rb', line 109

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

  # query parameters
  query_params = opts[:query_params] || {}

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

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

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

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

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

  new_options = opts.merge(
    :operation => :"PurgeApi.purge_all",
    :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(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PurgeApi#purge_all\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#purge_single_url(opts = {}) ⇒ PurgeResponse

Purge a URL Instant Purge an individual URL.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :cached_url (String)

    URL of object in cache to be purged. (required)

  • :fastly_soft_purge (Integer)

    If present, this header triggers the purge to be &#39;soft&#39;, which marks the affected object as stale rather than making it inaccessible. Typically set to &quot;1&quot; when used, but the value is not important.

Returns:



164
165
166
167
# File 'lib/fastly/api/purge_api.rb', line 164

def purge_single_url(opts = {})
  data, _status_code, _headers = purge_single_url_with_http_info(opts)
  data
end

#purge_single_url_with_http_info(opts = {}) ⇒ Array<(PurgeResponse, Integer, Hash)>

Purge a URL Instant Purge an individual URL.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :cached_url (String)

    URL of object in cache to be purged. (required)

  • :fastly_soft_purge (Integer)

    If present, this header triggers the purge to be &#39;soft&#39;, which marks the affected object as stale rather than making it inaccessible. Typically set to &quot;1&quot; when used, but the value is not important.

Returns:

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

    PurgeResponse data, response status code and response headers



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/fastly/api/purge_api.rb', line 174

def purge_single_url_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PurgeApi.purge_single_url ...'
  end
  # unbox the parameters from the hash
  cached_url = opts[:'cached_url']
  # verify the required parameter 'cached_url' is set
  if @api_client.config.client_side_validation && cached_url.nil?
    fail ArgumentError, "Missing the required parameter 'cached_url' when calling PurgeApi.purge_single_url"
  end
  # resource path
  local_var_path = '/purge/{cached_url}'.sub('{' + 'cached_url' + '}', cached_url.to_s)

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  header_params[:'fastly-soft-purge'] = opts[:'fastly_soft_purge'] if !opts[:'fastly_soft_purge'].nil?

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

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

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

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

  new_options = opts.merge(
    :operation => :"PurgeApi.purge_single_url",
    :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(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PurgeApi#purge_single_url\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#purge_tag(opts = {}) ⇒ PurgeResponse

Purge by surrogate key tag Instant Purge a particular service of items tagged with a Surrogate Key. Only one surrogate key can be purged at a time. Multiple keys can be purged using a batch surrogate key purge request.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :service_id (String)

    Alphanumeric string identifying the service. (required)

  • :surrogate_key (String)

    Surrogate keys are used to efficiently purge content from cache. Instead of purging your entire site or individual URLs, you can tag related assets (like all images and descriptions associated with a single product) with surrogate keys, and these grouped URLs can be purged in a single request. (required)

  • :fastly_soft_purge (Integer)

    If present, this header triggers the purge to be &#39;soft&#39;, which marks the affected object as stale rather than making it inaccessible. Typically set to &quot;1&quot; when used, but the value is not important.

Returns:



231
232
233
234
# File 'lib/fastly/api/purge_api.rb', line 231

def purge_tag(opts = {})
  data, _status_code, _headers = purge_tag_with_http_info(opts)
  data
end

#purge_tag_with_http_info(opts = {}) ⇒ Array<(PurgeResponse, Integer, Hash)>

Purge by surrogate key tag Instant Purge a particular service of items tagged with a Surrogate Key. Only one surrogate key can be purged at a time. Multiple keys can be purged using a batch surrogate key purge request.

Parameters:

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

    a customizable set of options

Options Hash (opts):

  • :service_id (String)

    Alphanumeric string identifying the service. (required)

  • :surrogate_key (String)

    Surrogate keys are used to efficiently purge content from cache. Instead of purging your entire site or individual URLs, you can tag related assets (like all images and descriptions associated with a single product) with surrogate keys, and these grouped URLs can be purged in a single request. (required)

  • :fastly_soft_purge (Integer)

    If present, this header triggers the purge to be &#39;soft&#39;, which marks the affected object as stale rather than making it inaccessible. Typically set to &quot;1&quot; when used, but the value is not important.

Returns:

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

    PurgeResponse data, response status code and response headers



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/fastly/api/purge_api.rb', line 242

def purge_tag_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PurgeApi.purge_tag ...'
  end
  # unbox the parameters from the hash
  service_id = opts[:'service_id']
  surrogate_key = opts[:'surrogate_key']
  # verify the required parameter 'service_id' is set
  if @api_client.config.client_side_validation && service_id.nil?
    fail ArgumentError, "Missing the required parameter 'service_id' when calling PurgeApi.purge_tag"
  end
  # verify the required parameter 'surrogate_key' is set
  if @api_client.config.client_side_validation && surrogate_key.nil?
    fail ArgumentError, "Missing the required parameter 'surrogate_key' when calling PurgeApi.purge_tag"
  end
  # resource path
  local_var_path = '/service/{service_id}/purge/{surrogate_key}'.sub('{' + 'service_id' + '}', CGI.escape(service_id.to_s)).sub('{' + 'surrogate_key' + '}', surrogate_key.to_s)

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  header_params[:'fastly-soft-purge'] = opts[:'fastly_soft_purge'] if !opts[:'fastly_soft_purge'].nil?

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

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

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

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

  new_options = opts.merge(
    :operation => :"PurgeApi.purge_tag",
    :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(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PurgeApi#purge_tag\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end