fastly_api/apis/
iam_service_groups_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 [`add_service_group_services`]
15#[derive(Clone, Debug, Default)]
16pub struct AddServiceGroupServicesParams {
17    /// Alphanumeric string identifying the service group.
18    pub service_group_id: String,
19    pub request_body: Option<::std::collections::HashMap<String, serde_json::Value>>
20}
21
22/// struct for passing parameters to the method [`create_a_service_group`]
23#[derive(Clone, Debug, Default)]
24pub struct CreateAServiceGroupParams {
25    pub request_body: Option<::std::collections::HashMap<String, serde_json::Value>>
26}
27
28/// struct for passing parameters to the method [`delete_a_service_group`]
29#[derive(Clone, Debug, Default)]
30pub struct DeleteAServiceGroupParams {
31    /// Alphanumeric string identifying the service group.
32    pub service_group_id: String
33}
34
35/// struct for passing parameters to the method [`get_a_service_group`]
36#[derive(Clone, Debug, Default)]
37pub struct GetAServiceGroupParams {
38    /// Alphanumeric string identifying the service group.
39    pub service_group_id: String
40}
41
42/// struct for passing parameters to the method [`list_service_group_services`]
43#[derive(Clone, Debug, Default)]
44pub struct ListServiceGroupServicesParams {
45    /// Alphanumeric string identifying the service group.
46    pub service_group_id: String,
47    /// Number of records per page.
48    pub per_page: Option<i32>,
49    /// Current page.
50    pub page: Option<i32>
51}
52
53/// struct for passing parameters to the method [`list_service_groups`]
54#[derive(Clone, Debug, Default)]
55pub struct ListServiceGroupsParams {
56    /// Number of records per page.
57    pub per_page: Option<i32>,
58    /// Current page.
59    pub page: Option<i32>
60}
61
62/// struct for passing parameters to the method [`remove_service_group_services`]
63#[derive(Clone, Debug, Default)]
64pub struct RemoveServiceGroupServicesParams {
65    /// Alphanumeric string identifying the service group.
66    pub service_group_id: String,
67    pub request_body: Option<::std::collections::HashMap<String, serde_json::Value>>
68}
69
70/// struct for passing parameters to the method [`update_a_service_group`]
71#[derive(Clone, Debug, Default)]
72pub struct UpdateAServiceGroupParams {
73    /// Alphanumeric string identifying the service group.
74    pub service_group_id: String,
75    pub request_body: Option<::std::collections::HashMap<String, serde_json::Value>>
76}
77
78
79/// struct for typed errors of method [`add_service_group_services`]
80#[derive(Debug, Clone, Serialize, Deserialize)]
81#[serde(untagged)]
82pub enum AddServiceGroupServicesError {
83    UnknownValue(serde_json::Value),
84}
85
86/// struct for typed errors of method [`create_a_service_group`]
87#[derive(Debug, Clone, Serialize, Deserialize)]
88#[serde(untagged)]
89pub enum CreateAServiceGroupError {
90    UnknownValue(serde_json::Value),
91}
92
93/// struct for typed errors of method [`delete_a_service_group`]
94#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum DeleteAServiceGroupError {
97    UnknownValue(serde_json::Value),
98}
99
100/// struct for typed errors of method [`get_a_service_group`]
101#[derive(Debug, Clone, Serialize, Deserialize)]
102#[serde(untagged)]
103pub enum GetAServiceGroupError {
104    UnknownValue(serde_json::Value),
105}
106
107/// struct for typed errors of method [`list_service_group_services`]
108#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(untagged)]
110pub enum ListServiceGroupServicesError {
111    UnknownValue(serde_json::Value),
112}
113
114/// struct for typed errors of method [`list_service_groups`]
115#[derive(Debug, Clone, Serialize, Deserialize)]
116#[serde(untagged)]
117pub enum ListServiceGroupsError {
118    UnknownValue(serde_json::Value),
119}
120
121/// struct for typed errors of method [`remove_service_group_services`]
122#[derive(Debug, Clone, Serialize, Deserialize)]
123#[serde(untagged)]
124pub enum RemoveServiceGroupServicesError {
125    UnknownValue(serde_json::Value),
126}
127
128/// struct for typed errors of method [`update_a_service_group`]
129#[derive(Debug, Clone, Serialize, Deserialize)]
130#[serde(untagged)]
131pub enum UpdateAServiceGroupError {
132    UnknownValue(serde_json::Value),
133}
134
135
136/// Add services in a service group.
137pub async fn add_service_group_services(configuration: &mut configuration::Configuration, params: AddServiceGroupServicesParams) -> Result<serde_json::Value, Error<AddServiceGroupServicesError>> {
138    let local_var_configuration = configuration;
139
140    // unbox the parameters
141    let service_group_id = params.service_group_id;
142    let request_body = params.request_body;
143
144
145    let local_var_client = &local_var_configuration.client;
146
147    let local_var_uri_str = format!("{}/service-groups/{service_group_id}/services", local_var_configuration.base_path, service_group_id=crate::apis::urlencode(service_group_id));
148    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
149
150    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
151        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
152    }
153    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
154        let local_var_key = local_var_apikey.key.clone();
155        let local_var_value = match local_var_apikey.prefix {
156            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
157            None => local_var_key,
158        };
159        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
160    };
161    local_var_req_builder = local_var_req_builder.json(&request_body);
162
163    let local_var_req = local_var_req_builder.build()?;
164    let local_var_resp = local_var_client.execute(local_var_req).await?;
165
166    if "POST" != "GET" && "POST" != "HEAD" {
167      let headers = local_var_resp.headers();
168      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
169          Some(v) => v.to_str().unwrap().parse().unwrap(),
170          None => configuration::DEFAULT_RATELIMIT,
171      };
172      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
173          Some(v) => v.to_str().unwrap().parse().unwrap(),
174          None => 0,
175      };
176    }
177
178    let local_var_status = local_var_resp.status();
179    let local_var_content = local_var_resp.text().await?;
180
181    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
182        serde_json::from_str(&local_var_content).map_err(Error::from)
183    } else {
184        let local_var_entity: Option<AddServiceGroupServicesError> = serde_json::from_str(&local_var_content).ok();
185        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
186        Err(Error::ResponseError(local_var_error))
187    }
188}
189
190/// Create a service group.
191pub async fn create_a_service_group(configuration: &mut configuration::Configuration, params: CreateAServiceGroupParams) -> Result<serde_json::Value, Error<CreateAServiceGroupError>> {
192    let local_var_configuration = configuration;
193
194    // unbox the parameters
195    let request_body = params.request_body;
196
197
198    let local_var_client = &local_var_configuration.client;
199
200    let local_var_uri_str = format!("{}/service-groups", local_var_configuration.base_path);
201    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
202
203    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
204        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
205    }
206    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
207        let local_var_key = local_var_apikey.key.clone();
208        let local_var_value = match local_var_apikey.prefix {
209            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
210            None => local_var_key,
211        };
212        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
213    };
214    local_var_req_builder = local_var_req_builder.json(&request_body);
215
216    let local_var_req = local_var_req_builder.build()?;
217    let local_var_resp = local_var_client.execute(local_var_req).await?;
218
219    if "POST" != "GET" && "POST" != "HEAD" {
220      let headers = local_var_resp.headers();
221      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
222          Some(v) => v.to_str().unwrap().parse().unwrap(),
223          None => configuration::DEFAULT_RATELIMIT,
224      };
225      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
226          Some(v) => v.to_str().unwrap().parse().unwrap(),
227          None => 0,
228      };
229    }
230
231    let local_var_status = local_var_resp.status();
232    let local_var_content = local_var_resp.text().await?;
233
234    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
235        serde_json::from_str(&local_var_content).map_err(Error::from)
236    } else {
237        let local_var_entity: Option<CreateAServiceGroupError> = serde_json::from_str(&local_var_content).ok();
238        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
239        Err(Error::ResponseError(local_var_error))
240    }
241}
242
243/// Delete a service group.
244pub async fn delete_a_service_group(configuration: &mut configuration::Configuration, params: DeleteAServiceGroupParams) -> Result<(), Error<DeleteAServiceGroupError>> {
245    let local_var_configuration = configuration;
246
247    // unbox the parameters
248    let service_group_id = params.service_group_id;
249
250
251    let local_var_client = &local_var_configuration.client;
252
253    let local_var_uri_str = format!("{}/service-groups/{service_group_id}", local_var_configuration.base_path, service_group_id=crate::apis::urlencode(service_group_id));
254    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
255
256    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
257        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
258    }
259    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
260        let local_var_key = local_var_apikey.key.clone();
261        let local_var_value = match local_var_apikey.prefix {
262            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
263            None => local_var_key,
264        };
265        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
266    };
267
268    let local_var_req = local_var_req_builder.build()?;
269    let local_var_resp = local_var_client.execute(local_var_req).await?;
270
271    if "DELETE" != "GET" && "DELETE" != "HEAD" {
272      let headers = local_var_resp.headers();
273      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
274          Some(v) => v.to_str().unwrap().parse().unwrap(),
275          None => configuration::DEFAULT_RATELIMIT,
276      };
277      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
278          Some(v) => v.to_str().unwrap().parse().unwrap(),
279          None => 0,
280      };
281    }
282
283    let local_var_status = local_var_resp.status();
284    let local_var_content = local_var_resp.text().await?;
285
286    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
287        Ok(())
288    } else {
289        let local_var_entity: Option<DeleteAServiceGroupError> = serde_json::from_str(&local_var_content).ok();
290        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
291        Err(Error::ResponseError(local_var_error))
292    }
293}
294
295/// Get a service group.
296pub async fn get_a_service_group(configuration: &mut configuration::Configuration, params: GetAServiceGroupParams) -> Result<serde_json::Value, Error<GetAServiceGroupError>> {
297    let local_var_configuration = configuration;
298
299    // unbox the parameters
300    let service_group_id = params.service_group_id;
301
302
303    let local_var_client = &local_var_configuration.client;
304
305    let local_var_uri_str = format!("{}/service-groups/{service_group_id}", local_var_configuration.base_path, service_group_id=crate::apis::urlencode(service_group_id));
306    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
307
308    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
309        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
310    }
311    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
312        let local_var_key = local_var_apikey.key.clone();
313        let local_var_value = match local_var_apikey.prefix {
314            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
315            None => local_var_key,
316        };
317        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
318    };
319
320    let local_var_req = local_var_req_builder.build()?;
321    let local_var_resp = local_var_client.execute(local_var_req).await?;
322
323    if "GET" != "GET" && "GET" != "HEAD" {
324      let headers = local_var_resp.headers();
325      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
326          Some(v) => v.to_str().unwrap().parse().unwrap(),
327          None => configuration::DEFAULT_RATELIMIT,
328      };
329      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
330          Some(v) => v.to_str().unwrap().parse().unwrap(),
331          None => 0,
332      };
333    }
334
335    let local_var_status = local_var_resp.status();
336    let local_var_content = local_var_resp.text().await?;
337
338    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
339        serde_json::from_str(&local_var_content).map_err(Error::from)
340    } else {
341        let local_var_entity: Option<GetAServiceGroupError> = serde_json::from_str(&local_var_content).ok();
342        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
343        Err(Error::ResponseError(local_var_error))
344    }
345}
346
347/// List services to a service group.
348pub async fn list_service_group_services(configuration: &mut configuration::Configuration, params: ListServiceGroupServicesParams) -> Result<serde_json::Value, Error<ListServiceGroupServicesError>> {
349    let local_var_configuration = configuration;
350
351    // unbox the parameters
352    let service_group_id = params.service_group_id;
353    let per_page = params.per_page;
354    let page = params.page;
355
356
357    let local_var_client = &local_var_configuration.client;
358
359    let local_var_uri_str = format!("{}/service-groups/{service_group_id}/services", local_var_configuration.base_path, service_group_id=crate::apis::urlencode(service_group_id));
360    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
361
362    if let Some(ref local_var_str) = per_page {
363        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
364    }
365    if let Some(ref local_var_str) = page {
366        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
367    }
368    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
369        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
370    }
371    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
372        let local_var_key = local_var_apikey.key.clone();
373        let local_var_value = match local_var_apikey.prefix {
374            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
375            None => local_var_key,
376        };
377        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
378    };
379
380    let local_var_req = local_var_req_builder.build()?;
381    let local_var_resp = local_var_client.execute(local_var_req).await?;
382
383    if "GET" != "GET" && "GET" != "HEAD" {
384      let headers = local_var_resp.headers();
385      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
386          Some(v) => v.to_str().unwrap().parse().unwrap(),
387          None => configuration::DEFAULT_RATELIMIT,
388      };
389      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
390          Some(v) => v.to_str().unwrap().parse().unwrap(),
391          None => 0,
392      };
393    }
394
395    let local_var_status = local_var_resp.status();
396    let local_var_content = local_var_resp.text().await?;
397
398    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
399        serde_json::from_str(&local_var_content).map_err(Error::from)
400    } else {
401        let local_var_entity: Option<ListServiceGroupServicesError> = serde_json::from_str(&local_var_content).ok();
402        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
403        Err(Error::ResponseError(local_var_error))
404    }
405}
406
407/// List all service groups.
408pub async fn list_service_groups(configuration: &mut configuration::Configuration, params: ListServiceGroupsParams) -> Result<serde_json::Value, Error<ListServiceGroupsError>> {
409    let local_var_configuration = configuration;
410
411    // unbox the parameters
412    let per_page = params.per_page;
413    let page = params.page;
414
415
416    let local_var_client = &local_var_configuration.client;
417
418    let local_var_uri_str = format!("{}/service-groups", local_var_configuration.base_path);
419    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
420
421    if let Some(ref local_var_str) = per_page {
422        local_var_req_builder = local_var_req_builder.query(&[("per_page", &local_var_str.to_string())]);
423    }
424    if let Some(ref local_var_str) = page {
425        local_var_req_builder = local_var_req_builder.query(&[("page", &local_var_str.to_string())]);
426    }
427    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
428        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
429    }
430    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
431        let local_var_key = local_var_apikey.key.clone();
432        let local_var_value = match local_var_apikey.prefix {
433            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
434            None => local_var_key,
435        };
436        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
437    };
438
439    let local_var_req = local_var_req_builder.build()?;
440    let local_var_resp = local_var_client.execute(local_var_req).await?;
441
442    if "GET" != "GET" && "GET" != "HEAD" {
443      let headers = local_var_resp.headers();
444      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
445          Some(v) => v.to_str().unwrap().parse().unwrap(),
446          None => configuration::DEFAULT_RATELIMIT,
447      };
448      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
449          Some(v) => v.to_str().unwrap().parse().unwrap(),
450          None => 0,
451      };
452    }
453
454    let local_var_status = local_var_resp.status();
455    let local_var_content = local_var_resp.text().await?;
456
457    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
458        serde_json::from_str(&local_var_content).map_err(Error::from)
459    } else {
460        let local_var_entity: Option<ListServiceGroupsError> = serde_json::from_str(&local_var_content).ok();
461        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
462        Err(Error::ResponseError(local_var_error))
463    }
464}
465
466/// Remove services from a service group.
467pub async fn remove_service_group_services(configuration: &mut configuration::Configuration, params: RemoveServiceGroupServicesParams) -> Result<(), Error<RemoveServiceGroupServicesError>> {
468    let local_var_configuration = configuration;
469
470    // unbox the parameters
471    let service_group_id = params.service_group_id;
472    let request_body = params.request_body;
473
474
475    let local_var_client = &local_var_configuration.client;
476
477    let local_var_uri_str = format!("{}/service-groups/{service_group_id}/services", local_var_configuration.base_path, service_group_id=crate::apis::urlencode(service_group_id));
478    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());
479
480    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
481        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
482    }
483    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
484        let local_var_key = local_var_apikey.key.clone();
485        let local_var_value = match local_var_apikey.prefix {
486            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
487            None => local_var_key,
488        };
489        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
490    };
491    local_var_req_builder = local_var_req_builder.json(&request_body);
492
493    let local_var_req = local_var_req_builder.build()?;
494    let local_var_resp = local_var_client.execute(local_var_req).await?;
495
496    if "DELETE" != "GET" && "DELETE" != "HEAD" {
497      let headers = local_var_resp.headers();
498      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
499          Some(v) => v.to_str().unwrap().parse().unwrap(),
500          None => configuration::DEFAULT_RATELIMIT,
501      };
502      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
503          Some(v) => v.to_str().unwrap().parse().unwrap(),
504          None => 0,
505      };
506    }
507
508    let local_var_status = local_var_resp.status();
509    let local_var_content = local_var_resp.text().await?;
510
511    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
512        Ok(())
513    } else {
514        let local_var_entity: Option<RemoveServiceGroupServicesError> = serde_json::from_str(&local_var_content).ok();
515        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
516        Err(Error::ResponseError(local_var_error))
517    }
518}
519
520/// Update a service group.
521pub async fn update_a_service_group(configuration: &mut configuration::Configuration, params: UpdateAServiceGroupParams) -> Result<serde_json::Value, Error<UpdateAServiceGroupError>> {
522    let local_var_configuration = configuration;
523
524    // unbox the parameters
525    let service_group_id = params.service_group_id;
526    let request_body = params.request_body;
527
528
529    let local_var_client = &local_var_configuration.client;
530
531    let local_var_uri_str = format!("{}/service-groups/{service_group_id}", local_var_configuration.base_path, service_group_id=crate::apis::urlencode(service_group_id));
532    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str());
533
534    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
535        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
536    }
537    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
538        let local_var_key = local_var_apikey.key.clone();
539        let local_var_value = match local_var_apikey.prefix {
540            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
541            None => local_var_key,
542        };
543        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
544    };
545    local_var_req_builder = local_var_req_builder.json(&request_body);
546
547    let local_var_req = local_var_req_builder.build()?;
548    let local_var_resp = local_var_client.execute(local_var_req).await?;
549
550    if "PATCH" != "GET" && "PATCH" != "HEAD" {
551      let headers = local_var_resp.headers();
552      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
553          Some(v) => v.to_str().unwrap().parse().unwrap(),
554          None => configuration::DEFAULT_RATELIMIT,
555      };
556      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
557          Some(v) => v.to_str().unwrap().parse().unwrap(),
558          None => 0,
559      };
560    }
561
562    let local_var_status = local_var_resp.status();
563    let local_var_content = local_var_resp.text().await?;
564
565    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
566        serde_json::from_str(&local_var_content).map_err(Error::from)
567    } else {
568        let local_var_entity: Option<UpdateAServiceGroupError> = serde_json::from_str(&local_var_content).ok();
569        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
570        Err(Error::ResponseError(local_var_error))
571    }
572}
573