fastly_api/apis/
snippet_api.rs

1/*
2 * Fastly API
3 *
4 * Via the Fastly API you can perform any of the operations that are possible within the management console,  including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The API is organized into collections of endpoints that allow manipulation of objects related to Fastly services and accounts. For the most accurate and up-to-date API reference content, visit our [Developer Hub](https://www.fastly.com/documentation/reference/api/) 
5 *
6 */
7
8
9use reqwest;
10
11use crate::apis::ResponseContent;
12use super::{Error, configuration};
13
14/// struct for passing parameters to the method [`create_snippet`]
15#[derive(Clone, Debug, Default)]
16pub struct CreateSnippetParams {
17    /// Alphanumeric string identifying the service.
18    pub service_id: String,
19    /// Integer identifying a service version.
20    pub version_id: i32,
21    /// The name for the snippet.
22    pub name: Option<String>,
23    /// The location in generated VCL where the snippet should be placed.
24    pub _type: Option<String>,
25    /// The VCL code that specifies exactly what the snippet does.
26    pub content: Option<String>,
27    /// Priority determines execution order. Lower numbers execute first.
28    pub priority: Option<String>,
29    /// Sets the snippet version.
30    pub dynamic: Option<String>
31}
32
33/// struct for passing parameters to the method [`delete_snippet`]
34#[derive(Clone, Debug, Default)]
35pub struct DeleteSnippetParams {
36    /// Alphanumeric string identifying the service.
37    pub service_id: String,
38    /// Integer identifying a service version.
39    pub version_id: i32,
40    /// The name for the snippet.
41    pub name: String
42}
43
44/// struct for passing parameters to the method [`get_snippet`]
45#[derive(Clone, Debug, Default)]
46pub struct GetSnippetParams {
47    /// Alphanumeric string identifying the service.
48    pub service_id: String,
49    /// Integer identifying a service version.
50    pub version_id: i32,
51    /// The name for the snippet.
52    pub name: String
53}
54
55/// struct for passing parameters to the method [`get_snippet_dynamic`]
56#[derive(Clone, Debug, Default)]
57pub struct GetSnippetDynamicParams {
58    /// Alphanumeric string identifying the service.
59    pub service_id: String,
60    /// Alphanumeric string identifying a VCL Snippet.
61    pub id: String
62}
63
64/// struct for passing parameters to the method [`list_snippets`]
65#[derive(Clone, Debug, Default)]
66pub struct ListSnippetsParams {
67    /// Alphanumeric string identifying the service.
68    pub service_id: String,
69    /// Integer identifying a service version.
70    pub version_id: i32
71}
72
73/// struct for passing parameters to the method [`update_snippet`]
74#[derive(Clone, Debug, Default)]
75pub struct UpdateSnippetParams {
76    /// Alphanumeric string identifying the service.
77    pub service_id: String,
78    /// Integer identifying a service version.
79    pub version_id: i32,
80    /// The name for the snippet.
81    pub name: String
82}
83
84/// struct for passing parameters to the method [`update_snippet_dynamic`]
85#[derive(Clone, Debug, Default)]
86pub struct UpdateSnippetDynamicParams {
87    /// Alphanumeric string identifying the service.
88    pub service_id: String,
89    /// Alphanumeric string identifying a VCL Snippet.
90    pub id: String,
91    /// The name for the snippet.
92    pub name: Option<String>,
93    /// The location in generated VCL where the snippet should be placed.
94    pub _type: Option<String>,
95    /// The VCL code that specifies exactly what the snippet does.
96    pub content: Option<String>,
97    /// Priority determines execution order. Lower numbers execute first.
98    pub priority: Option<String>,
99    /// Sets the snippet version.
100    pub dynamic: Option<String>
101}
102
103
104/// struct for typed errors of method [`create_snippet`]
105#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(untagged)]
107pub enum CreateSnippetError {
108    UnknownValue(serde_json::Value),
109}
110
111/// struct for typed errors of method [`delete_snippet`]
112#[derive(Debug, Clone, Serialize, Deserialize)]
113#[serde(untagged)]
114pub enum DeleteSnippetError {
115    UnknownValue(serde_json::Value),
116}
117
118/// struct for typed errors of method [`get_snippet`]
119#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(untagged)]
121pub enum GetSnippetError {
122    UnknownValue(serde_json::Value),
123}
124
125/// struct for typed errors of method [`get_snippet_dynamic`]
126#[derive(Debug, Clone, Serialize, Deserialize)]
127#[serde(untagged)]
128pub enum GetSnippetDynamicError {
129    UnknownValue(serde_json::Value),
130}
131
132/// struct for typed errors of method [`list_snippets`]
133#[derive(Debug, Clone, Serialize, Deserialize)]
134#[serde(untagged)]
135pub enum ListSnippetsError {
136    UnknownValue(serde_json::Value),
137}
138
139/// struct for typed errors of method [`update_snippet`]
140#[derive(Debug, Clone, Serialize, Deserialize)]
141#[serde(untagged)]
142pub enum UpdateSnippetError {
143    UnknownValue(serde_json::Value),
144}
145
146/// struct for typed errors of method [`update_snippet_dynamic`]
147#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum UpdateSnippetDynamicError {
150    UnknownValue(serde_json::Value),
151}
152
153
154/// Create a snippet for a particular service and version.
155pub async fn create_snippet(configuration: &mut configuration::Configuration, params: CreateSnippetParams) -> Result<crate::models::SnippetResponse, Error<CreateSnippetError>> {
156    let local_var_configuration = configuration;
157
158    // unbox the parameters
159    let service_id = params.service_id;
160    let version_id = params.version_id;
161    let name = params.name;
162    let _type = params._type;
163    let content = params.content;
164    let priority = params.priority;
165    let dynamic = params.dynamic;
166
167
168    let local_var_client = &local_var_configuration.client;
169
170    let local_var_uri_str = format!("{}/service/{service_id}/version/{version_id}/snippet", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), version_id=version_id);
171    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
172
173    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
174        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
175    }
176    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
177        let local_var_key = local_var_apikey.key.clone();
178        let local_var_value = match local_var_apikey.prefix {
179            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
180            None => local_var_key,
181        };
182        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
183    };
184    let mut local_var_form_params = std::collections::HashMap::new();
185    if let Some(local_var_param_value) = name {
186        local_var_form_params.insert("name", local_var_param_value.to_string());
187    }
188    if let Some(local_var_param_value) = _type {
189        local_var_form_params.insert("type", local_var_param_value.to_string());
190    }
191    if let Some(local_var_param_value) = content {
192        local_var_form_params.insert("content", local_var_param_value.to_string());
193    }
194    if let Some(local_var_param_value) = priority {
195        local_var_form_params.insert("priority", local_var_param_value.to_string());
196    }
197    if let Some(local_var_param_value) = dynamic {
198        local_var_form_params.insert("dynamic", local_var_param_value.to_string());
199    }
200    local_var_req_builder = local_var_req_builder.form(&local_var_form_params);
201
202    let local_var_req = local_var_req_builder.build()?;
203    let local_var_resp = local_var_client.execute(local_var_req).await?;
204
205    if "POST" != "GET" && "POST" != "HEAD" {
206      let headers = local_var_resp.headers();
207      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
208          Some(v) => v.to_str().unwrap().parse().unwrap(),
209          None => configuration::DEFAULT_RATELIMIT,
210      };
211      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
212          Some(v) => v.to_str().unwrap().parse().unwrap(),
213          None => 0,
214      };
215    }
216
217    let local_var_status = local_var_resp.status();
218    let local_var_content = local_var_resp.text().await?;
219
220    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
221        serde_json::from_str(&local_var_content).map_err(Error::from)
222    } else {
223        let local_var_entity: Option<CreateSnippetError> = serde_json::from_str(&local_var_content).ok();
224        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
225        Err(Error::ResponseError(local_var_error))
226    }
227}
228
229/// Delete a specific snippet for a particular service and version.
230pub async fn delete_snippet(configuration: &mut configuration::Configuration, params: DeleteSnippetParams) -> Result<crate::models::InlineResponse200, Error<DeleteSnippetError>> {
231    let local_var_configuration = configuration;
232
233    // unbox the parameters
234    let service_id = params.service_id;
235    let version_id = params.version_id;
236    let name = params.name;
237
238
239    let local_var_client = &local_var_configuration.client;
240
241    let local_var_uri_str = format!("{}/service/{service_id}/version/{version_id}/snippet/{name}", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), version_id=version_id, name=crate::apis::urlencode(name));
242    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
243
244    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
245        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
246    }
247    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
248        let local_var_key = local_var_apikey.key.clone();
249        let local_var_value = match local_var_apikey.prefix {
250            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
251            None => local_var_key,
252        };
253        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
254    };
255
256    let local_var_req = local_var_req_builder.build()?;
257    let local_var_resp = local_var_client.execute(local_var_req).await?;
258
259    if "DELETE" != "GET" && "DELETE" != "HEAD" {
260      let headers = local_var_resp.headers();
261      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
262          Some(v) => v.to_str().unwrap().parse().unwrap(),
263          None => configuration::DEFAULT_RATELIMIT,
264      };
265      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
266          Some(v) => v.to_str().unwrap().parse().unwrap(),
267          None => 0,
268      };
269    }
270
271    let local_var_status = local_var_resp.status();
272    let local_var_content = local_var_resp.text().await?;
273
274    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
275        serde_json::from_str(&local_var_content).map_err(Error::from)
276    } else {
277        let local_var_entity: Option<DeleteSnippetError> = serde_json::from_str(&local_var_content).ok();
278        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
279        Err(Error::ResponseError(local_var_error))
280    }
281}
282
283/// Get a single snippet for a particular service and version.
284pub async fn get_snippet(configuration: &mut configuration::Configuration, params: GetSnippetParams) -> Result<crate::models::SnippetResponse, Error<GetSnippetError>> {
285    let local_var_configuration = configuration;
286
287    // unbox the parameters
288    let service_id = params.service_id;
289    let version_id = params.version_id;
290    let name = params.name;
291
292
293    let local_var_client = &local_var_configuration.client;
294
295    let local_var_uri_str = format!("{}/service/{service_id}/version/{version_id}/snippet/{name}", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), version_id=version_id, name=crate::apis::urlencode(name));
296    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
297
298    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
299        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
300    }
301    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
302        let local_var_key = local_var_apikey.key.clone();
303        let local_var_value = match local_var_apikey.prefix {
304            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
305            None => local_var_key,
306        };
307        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
308    };
309
310    let local_var_req = local_var_req_builder.build()?;
311    let local_var_resp = local_var_client.execute(local_var_req).await?;
312
313    if "GET" != "GET" && "GET" != "HEAD" {
314      let headers = local_var_resp.headers();
315      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
316          Some(v) => v.to_str().unwrap().parse().unwrap(),
317          None => configuration::DEFAULT_RATELIMIT,
318      };
319      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
320          Some(v) => v.to_str().unwrap().parse().unwrap(),
321          None => 0,
322      };
323    }
324
325    let local_var_status = local_var_resp.status();
326    let local_var_content = local_var_resp.text().await?;
327
328    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
329        serde_json::from_str(&local_var_content).map_err(Error::from)
330    } else {
331        let local_var_entity: Option<GetSnippetError> = serde_json::from_str(&local_var_content).ok();
332        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
333        Err(Error::ResponseError(local_var_error))
334    }
335}
336
337/// Get a single dynamic snippet for a particular service.
338pub async fn get_snippet_dynamic(configuration: &mut configuration::Configuration, params: GetSnippetDynamicParams) -> Result<crate::models::SnippetResponse, Error<GetSnippetDynamicError>> {
339    let local_var_configuration = configuration;
340
341    // unbox the parameters
342    let service_id = params.service_id;
343    let id = params.id;
344
345
346    let local_var_client = &local_var_configuration.client;
347
348    let local_var_uri_str = format!("{}/service/{service_id}/snippet/{id}", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), id=crate::apis::urlencode(id));
349    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
350
351    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
352        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
353    }
354    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
355        let local_var_key = local_var_apikey.key.clone();
356        let local_var_value = match local_var_apikey.prefix {
357            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
358            None => local_var_key,
359        };
360        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
361    };
362
363    let local_var_req = local_var_req_builder.build()?;
364    let local_var_resp = local_var_client.execute(local_var_req).await?;
365
366    if "GET" != "GET" && "GET" != "HEAD" {
367      let headers = local_var_resp.headers();
368      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
369          Some(v) => v.to_str().unwrap().parse().unwrap(),
370          None => configuration::DEFAULT_RATELIMIT,
371      };
372      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
373          Some(v) => v.to_str().unwrap().parse().unwrap(),
374          None => 0,
375      };
376    }
377
378    let local_var_status = local_var_resp.status();
379    let local_var_content = local_var_resp.text().await?;
380
381    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
382        serde_json::from_str(&local_var_content).map_err(Error::from)
383    } else {
384        let local_var_entity: Option<GetSnippetDynamicError> = serde_json::from_str(&local_var_content).ok();
385        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
386        Err(Error::ResponseError(local_var_error))
387    }
388}
389
390/// List all snippets for a particular service and version.
391pub async fn list_snippets(configuration: &mut configuration::Configuration, params: ListSnippetsParams) -> Result<Vec<crate::models::SnippetResponse>, Error<ListSnippetsError>> {
392    let local_var_configuration = configuration;
393
394    // unbox the parameters
395    let service_id = params.service_id;
396    let version_id = params.version_id;
397
398
399    let local_var_client = &local_var_configuration.client;
400
401    let local_var_uri_str = format!("{}/service/{service_id}/version/{version_id}/snippet", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), version_id=version_id);
402    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
403
404    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
405        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
406    }
407    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
408        let local_var_key = local_var_apikey.key.clone();
409        let local_var_value = match local_var_apikey.prefix {
410            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
411            None => local_var_key,
412        };
413        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
414    };
415
416    let local_var_req = local_var_req_builder.build()?;
417    let local_var_resp = local_var_client.execute(local_var_req).await?;
418
419    if "GET" != "GET" && "GET" != "HEAD" {
420      let headers = local_var_resp.headers();
421      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
422          Some(v) => v.to_str().unwrap().parse().unwrap(),
423          None => configuration::DEFAULT_RATELIMIT,
424      };
425      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
426          Some(v) => v.to_str().unwrap().parse().unwrap(),
427          None => 0,
428      };
429    }
430
431    let local_var_status = local_var_resp.status();
432    let local_var_content = local_var_resp.text().await?;
433
434    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
435        serde_json::from_str(&local_var_content).map_err(Error::from)
436    } else {
437        let local_var_entity: Option<ListSnippetsError> = serde_json::from_str(&local_var_content).ok();
438        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
439        Err(Error::ResponseError(local_var_error))
440    }
441}
442
443/// Update a specific snippet for a particular service and version.
444pub async fn update_snippet(configuration: &mut configuration::Configuration, params: UpdateSnippetParams) -> Result<crate::models::SnippetResponse, Error<UpdateSnippetError>> {
445    let local_var_configuration = configuration;
446
447    // unbox the parameters
448    let service_id = params.service_id;
449    let version_id = params.version_id;
450    let name = params.name;
451
452
453    let local_var_client = &local_var_configuration.client;
454
455    let local_var_uri_str = format!("{}/service/{service_id}/version/{version_id}/snippet/{name}", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), version_id=version_id, name=crate::apis::urlencode(name));
456    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
457
458    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
459        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
460    }
461    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
462        let local_var_key = local_var_apikey.key.clone();
463        let local_var_value = match local_var_apikey.prefix {
464            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
465            None => local_var_key,
466        };
467        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
468    };
469
470    let local_var_req = local_var_req_builder.build()?;
471    let local_var_resp = local_var_client.execute(local_var_req).await?;
472
473    if "PUT" != "GET" && "PUT" != "HEAD" {
474      let headers = local_var_resp.headers();
475      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
476          Some(v) => v.to_str().unwrap().parse().unwrap(),
477          None => configuration::DEFAULT_RATELIMIT,
478      };
479      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
480          Some(v) => v.to_str().unwrap().parse().unwrap(),
481          None => 0,
482      };
483    }
484
485    let local_var_status = local_var_resp.status();
486    let local_var_content = local_var_resp.text().await?;
487
488    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
489        serde_json::from_str(&local_var_content).map_err(Error::from)
490    } else {
491        let local_var_entity: Option<UpdateSnippetError> = serde_json::from_str(&local_var_content).ok();
492        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
493        Err(Error::ResponseError(local_var_error))
494    }
495}
496
497/// Update a dynamic snippet for a particular service.
498pub async fn update_snippet_dynamic(configuration: &mut configuration::Configuration, params: UpdateSnippetDynamicParams) -> Result<crate::models::SnippetResponse, Error<UpdateSnippetDynamicError>> {
499    let local_var_configuration = configuration;
500
501    // unbox the parameters
502    let service_id = params.service_id;
503    let id = params.id;
504    let name = params.name;
505    let _type = params._type;
506    let content = params.content;
507    let priority = params.priority;
508    let dynamic = params.dynamic;
509
510
511    let local_var_client = &local_var_configuration.client;
512
513    let local_var_uri_str = format!("{}/service/{service_id}/snippet/{id}", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), id=crate::apis::urlencode(id));
514    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
515
516    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
517        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
518    }
519    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
520        let local_var_key = local_var_apikey.key.clone();
521        let local_var_value = match local_var_apikey.prefix {
522            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
523            None => local_var_key,
524        };
525        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
526    };
527    let mut local_var_form_params = std::collections::HashMap::new();
528    if let Some(local_var_param_value) = name {
529        local_var_form_params.insert("name", local_var_param_value.to_string());
530    }
531    if let Some(local_var_param_value) = _type {
532        local_var_form_params.insert("type", local_var_param_value.to_string());
533    }
534    if let Some(local_var_param_value) = content {
535        local_var_form_params.insert("content", local_var_param_value.to_string());
536    }
537    if let Some(local_var_param_value) = priority {
538        local_var_form_params.insert("priority", local_var_param_value.to_string());
539    }
540    if let Some(local_var_param_value) = dynamic {
541        local_var_form_params.insert("dynamic", local_var_param_value.to_string());
542    }
543    local_var_req_builder = local_var_req_builder.form(&local_var_form_params);
544
545    let local_var_req = local_var_req_builder.build()?;
546    let local_var_resp = local_var_client.execute(local_var_req).await?;
547
548    if "PUT" != "GET" && "PUT" != "HEAD" {
549      let headers = local_var_resp.headers();
550      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
551          Some(v) => v.to_str().unwrap().parse().unwrap(),
552          None => configuration::DEFAULT_RATELIMIT,
553      };
554      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
555          Some(v) => v.to_str().unwrap().parse().unwrap(),
556          None => 0,
557      };
558    }
559
560    let local_var_status = local_var_resp.status();
561    let local_var_content = local_var_resp.text().await?;
562
563    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
564        serde_json::from_str(&local_var_content).map_err(Error::from)
565    } else {
566        let local_var_entity: Option<UpdateSnippetDynamicError> = serde_json::from_str(&local_var_content).ok();
567        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
568        Err(Error::ResponseError(local_var_error))
569    }
570}
571