fastly_api/apis/
logging_elasticsearch_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_log_elasticsearch`]
15#[derive(Clone, Debug, Default)]
16pub struct CreateLogElasticsearchParams {
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 real-time logging configuration.
22    pub name: Option<String>,
23    /// Where in the generated VCL the logging call should be placed. If not set, endpoints with `format_version` of 2 are placed in `vcl_log` and those with `format_version` of 1 are placed in `vcl_deliver`. 
24    pub placement: Option<String>,
25    /// The name of an existing condition in the configured endpoint, or leave blank to always execute.
26    pub response_condition: Option<String>,
27    /// A Fastly [log format string](https://www.fastly.com/documentation/guides/integrations/streaming-logs/custom-log-formats/). Must produce valid JSON that Elasticsearch can ingest.
28    pub format: Option<String>,
29    /// The geographic region where the logs will be processed before streaming. Valid values are `us`, `eu`, and `none` for global.
30    pub log_processing_region: Option<String>,
31    /// The version of the custom logging format used for the configured endpoint. The logging call gets placed by default in `vcl_log` if `format_version` is set to `2` and in `vcl_deliver` if `format_version` is set to `1`. 
32    pub format_version: Option<i32>,
33    /// A secure certificate to authenticate a server with. Must be in PEM format.
34    pub tls_ca_cert: Option<String>,
35    /// The client certificate used to make authenticated requests. Must be in PEM format.
36    pub tls_client_cert: Option<String>,
37    /// The client private key used to make authenticated requests. Must be in PEM format.
38    pub tls_client_key: Option<String>,
39    /// The hostname to verify the server's certificate. This should be one of the Subject Alternative Name (SAN) fields for the certificate. Common Names (CN) are not supported.
40    pub tls_hostname: Option<String>,
41    /// The maximum number of logs sent in one request. Defaults `0` for unbounded.
42    pub request_max_entries: Option<i32>,
43    /// The maximum number of bytes sent in one request. Defaults `0` for unbounded.
44    pub request_max_bytes: Option<i32>,
45    /// The name of the Elasticsearch index to send documents (logs) to. The index must follow the Elasticsearch [index format rules](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html). We support [strftime](https://www.man7.org/linux/man-pages/man3/strftime.3.html) interpolated variables inside braces prefixed with a pound symbol. For example, `#{%F}` will interpolate as `YYYY-MM-DD` with today's date.
46    pub index: Option<String>,
47    /// The URL to stream logs to. Must use HTTPS.
48    pub url: Option<String>,
49    /// The ID of the Elasticsearch ingest pipeline to apply pre-process transformations to before indexing. Learn more about creating a pipeline in the [Elasticsearch docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html).
50    pub pipeline: Option<String>,
51    /// Basic Auth username.
52    pub user: Option<String>,
53    /// Basic Auth password.
54    pub password: Option<String>
55}
56
57/// struct for passing parameters to the method [`delete_log_elasticsearch`]
58#[derive(Clone, Debug, Default)]
59pub struct DeleteLogElasticsearchParams {
60    /// Alphanumeric string identifying the service.
61    pub service_id: String,
62    /// Integer identifying a service version.
63    pub version_id: i32,
64    /// The name for the real-time logging configuration.
65    pub logging_elasticsearch_name: String
66}
67
68/// struct for passing parameters to the method [`get_log_elasticsearch`]
69#[derive(Clone, Debug, Default)]
70pub struct GetLogElasticsearchParams {
71    /// Alphanumeric string identifying the service.
72    pub service_id: String,
73    /// Integer identifying a service version.
74    pub version_id: i32,
75    /// The name for the real-time logging configuration.
76    pub logging_elasticsearch_name: String
77}
78
79/// struct for passing parameters to the method [`list_log_elasticsearch`]
80#[derive(Clone, Debug, Default)]
81pub struct ListLogElasticsearchParams {
82    /// Alphanumeric string identifying the service.
83    pub service_id: String,
84    /// Integer identifying a service version.
85    pub version_id: i32
86}
87
88/// struct for passing parameters to the method [`update_log_elasticsearch`]
89#[derive(Clone, Debug, Default)]
90pub struct UpdateLogElasticsearchParams {
91    /// Alphanumeric string identifying the service.
92    pub service_id: String,
93    /// Integer identifying a service version.
94    pub version_id: i32,
95    /// The name for the real-time logging configuration.
96    pub logging_elasticsearch_name: String,
97    /// The name for the real-time logging configuration.
98    pub name: Option<String>,
99    /// Where in the generated VCL the logging call should be placed. If not set, endpoints with `format_version` of 2 are placed in `vcl_log` and those with `format_version` of 1 are placed in `vcl_deliver`. 
100    pub placement: Option<String>,
101    /// The name of an existing condition in the configured endpoint, or leave blank to always execute.
102    pub response_condition: Option<String>,
103    /// A Fastly [log format string](https://www.fastly.com/documentation/guides/integrations/streaming-logs/custom-log-formats/). Must produce valid JSON that Elasticsearch can ingest.
104    pub format: Option<String>,
105    /// The geographic region where the logs will be processed before streaming. Valid values are `us`, `eu`, and `none` for global.
106    pub log_processing_region: Option<String>,
107    /// The version of the custom logging format used for the configured endpoint. The logging call gets placed by default in `vcl_log` if `format_version` is set to `2` and in `vcl_deliver` if `format_version` is set to `1`. 
108    pub format_version: Option<i32>,
109    /// A secure certificate to authenticate a server with. Must be in PEM format.
110    pub tls_ca_cert: Option<String>,
111    /// The client certificate used to make authenticated requests. Must be in PEM format.
112    pub tls_client_cert: Option<String>,
113    /// The client private key used to make authenticated requests. Must be in PEM format.
114    pub tls_client_key: Option<String>,
115    /// The hostname to verify the server's certificate. This should be one of the Subject Alternative Name (SAN) fields for the certificate. Common Names (CN) are not supported.
116    pub tls_hostname: Option<String>,
117    /// The maximum number of logs sent in one request. Defaults `0` for unbounded.
118    pub request_max_entries: Option<i32>,
119    /// The maximum number of bytes sent in one request. Defaults `0` for unbounded.
120    pub request_max_bytes: Option<i32>,
121    /// The name of the Elasticsearch index to send documents (logs) to. The index must follow the Elasticsearch [index format rules](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html). We support [strftime](https://www.man7.org/linux/man-pages/man3/strftime.3.html) interpolated variables inside braces prefixed with a pound symbol. For example, `#{%F}` will interpolate as `YYYY-MM-DD` with today's date.
122    pub index: Option<String>,
123    /// The URL to stream logs to. Must use HTTPS.
124    pub url: Option<String>,
125    /// The ID of the Elasticsearch ingest pipeline to apply pre-process transformations to before indexing. Learn more about creating a pipeline in the [Elasticsearch docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html).
126    pub pipeline: Option<String>,
127    /// Basic Auth username.
128    pub user: Option<String>,
129    /// Basic Auth password.
130    pub password: Option<String>
131}
132
133
134/// struct for typed errors of method [`create_log_elasticsearch`]
135#[derive(Debug, Clone, Serialize, Deserialize)]
136#[serde(untagged)]
137pub enum CreateLogElasticsearchError {
138    UnknownValue(serde_json::Value),
139}
140
141/// struct for typed errors of method [`delete_log_elasticsearch`]
142#[derive(Debug, Clone, Serialize, Deserialize)]
143#[serde(untagged)]
144pub enum DeleteLogElasticsearchError {
145    UnknownValue(serde_json::Value),
146}
147
148/// struct for typed errors of method [`get_log_elasticsearch`]
149#[derive(Debug, Clone, Serialize, Deserialize)]
150#[serde(untagged)]
151pub enum GetLogElasticsearchError {
152    UnknownValue(serde_json::Value),
153}
154
155/// struct for typed errors of method [`list_log_elasticsearch`]
156#[derive(Debug, Clone, Serialize, Deserialize)]
157#[serde(untagged)]
158pub enum ListLogElasticsearchError {
159    UnknownValue(serde_json::Value),
160}
161
162/// struct for typed errors of method [`update_log_elasticsearch`]
163#[derive(Debug, Clone, Serialize, Deserialize)]
164#[serde(untagged)]
165pub enum UpdateLogElasticsearchError {
166    UnknownValue(serde_json::Value),
167}
168
169
170/// Create a Elasticsearch logging endpoint for a particular service and version.
171pub async fn create_log_elasticsearch(configuration: &mut configuration::Configuration, params: CreateLogElasticsearchParams) -> Result<crate::models::LoggingElasticsearchResponse, Error<CreateLogElasticsearchError>> {
172    let local_var_configuration = configuration;
173
174    // unbox the parameters
175    let service_id = params.service_id;
176    let version_id = params.version_id;
177    let name = params.name;
178    let placement = params.placement;
179    let response_condition = params.response_condition;
180    let format = params.format;
181    let log_processing_region = params.log_processing_region;
182    let format_version = params.format_version;
183    let tls_ca_cert = params.tls_ca_cert;
184    let tls_client_cert = params.tls_client_cert;
185    let tls_client_key = params.tls_client_key;
186    let tls_hostname = params.tls_hostname;
187    let request_max_entries = params.request_max_entries;
188    let request_max_bytes = params.request_max_bytes;
189    let index = params.index;
190    let url = params.url;
191    let pipeline = params.pipeline;
192    let user = params.user;
193    let password = params.password;
194
195
196    let local_var_client = &local_var_configuration.client;
197
198    let local_var_uri_str = format!("{}/service/{service_id}/version/{version_id}/logging/elasticsearch", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), version_id=version_id);
199    let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
200
201    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
202        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
203    }
204    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
205        let local_var_key = local_var_apikey.key.clone();
206        let local_var_value = match local_var_apikey.prefix {
207            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
208            None => local_var_key,
209        };
210        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
211    };
212    let mut local_var_form_params = std::collections::HashMap::new();
213    if let Some(local_var_param_value) = name {
214        local_var_form_params.insert("name", local_var_param_value.to_string());
215    }
216    if let Some(local_var_param_value) = placement {
217        local_var_form_params.insert("placement", local_var_param_value.to_string());
218    }
219    if let Some(local_var_param_value) = response_condition {
220        local_var_form_params.insert("response_condition", local_var_param_value.to_string());
221    }
222    if let Some(local_var_param_value) = format {
223        local_var_form_params.insert("format", local_var_param_value.to_string());
224    }
225    if let Some(local_var_param_value) = log_processing_region {
226        local_var_form_params.insert("log_processing_region", local_var_param_value.to_string());
227    }
228    if let Some(local_var_param_value) = format_version {
229        local_var_form_params.insert("format_version", local_var_param_value.to_string());
230    }
231    if let Some(local_var_param_value) = tls_ca_cert {
232        local_var_form_params.insert("tls_ca_cert", local_var_param_value.to_string());
233    }
234    if let Some(local_var_param_value) = tls_client_cert {
235        local_var_form_params.insert("tls_client_cert", local_var_param_value.to_string());
236    }
237    if let Some(local_var_param_value) = tls_client_key {
238        local_var_form_params.insert("tls_client_key", local_var_param_value.to_string());
239    }
240    if let Some(local_var_param_value) = tls_hostname {
241        local_var_form_params.insert("tls_hostname", local_var_param_value.to_string());
242    }
243    if let Some(local_var_param_value) = request_max_entries {
244        local_var_form_params.insert("request_max_entries", local_var_param_value.to_string());
245    }
246    if let Some(local_var_param_value) = request_max_bytes {
247        local_var_form_params.insert("request_max_bytes", local_var_param_value.to_string());
248    }
249    if let Some(local_var_param_value) = index {
250        local_var_form_params.insert("index", local_var_param_value.to_string());
251    }
252    if let Some(local_var_param_value) = url {
253        local_var_form_params.insert("url", local_var_param_value.to_string());
254    }
255    if let Some(local_var_param_value) = pipeline {
256        local_var_form_params.insert("pipeline", local_var_param_value.to_string());
257    }
258    if let Some(local_var_param_value) = user {
259        local_var_form_params.insert("user", local_var_param_value.to_string());
260    }
261    if let Some(local_var_param_value) = password {
262        local_var_form_params.insert("password", local_var_param_value.to_string());
263    }
264    local_var_req_builder = local_var_req_builder.form(&local_var_form_params);
265
266    let local_var_req = local_var_req_builder.build()?;
267    let local_var_resp = local_var_client.execute(local_var_req).await?;
268
269    if "POST" != "GET" && "POST" != "HEAD" {
270      let headers = local_var_resp.headers();
271      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
272          Some(v) => v.to_str().unwrap().parse().unwrap(),
273          None => configuration::DEFAULT_RATELIMIT,
274      };
275      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
276          Some(v) => v.to_str().unwrap().parse().unwrap(),
277          None => 0,
278      };
279    }
280
281    let local_var_status = local_var_resp.status();
282    let local_var_content = local_var_resp.text().await?;
283
284    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
285        serde_json::from_str(&local_var_content).map_err(Error::from)
286    } else {
287        let local_var_entity: Option<CreateLogElasticsearchError> = serde_json::from_str(&local_var_content).ok();
288        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
289        Err(Error::ResponseError(local_var_error))
290    }
291}
292
293/// Delete the Elasticsearch logging endpoint for a particular service and version.
294pub async fn delete_log_elasticsearch(configuration: &mut configuration::Configuration, params: DeleteLogElasticsearchParams) -> Result<crate::models::InlineResponse200, Error<DeleteLogElasticsearchError>> {
295    let local_var_configuration = configuration;
296
297    // unbox the parameters
298    let service_id = params.service_id;
299    let version_id = params.version_id;
300    let logging_elasticsearch_name = params.logging_elasticsearch_name;
301
302
303    let local_var_client = &local_var_configuration.client;
304
305    let local_var_uri_str = format!("{}/service/{service_id}/version/{version_id}/logging/elasticsearch/{logging_elasticsearch_name}", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), version_id=version_id, logging_elasticsearch_name=crate::apis::urlencode(logging_elasticsearch_name));
306    let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, 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 "DELETE" != "GET" && "DELETE" != "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<DeleteLogElasticsearchError> = 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/// Get the Elasticsearch logging endpoint for a particular service and version.
348pub async fn get_log_elasticsearch(configuration: &mut configuration::Configuration, params: GetLogElasticsearchParams) -> Result<crate::models::LoggingElasticsearchResponse, Error<GetLogElasticsearchError>> {
349    let local_var_configuration = configuration;
350
351    // unbox the parameters
352    let service_id = params.service_id;
353    let version_id = params.version_id;
354    let logging_elasticsearch_name = params.logging_elasticsearch_name;
355
356
357    let local_var_client = &local_var_configuration.client;
358
359    let local_var_uri_str = format!("{}/service/{service_id}/version/{version_id}/logging/elasticsearch/{logging_elasticsearch_name}", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), version_id=version_id, logging_elasticsearch_name=crate::apis::urlencode(logging_elasticsearch_name));
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_user_agent) = local_var_configuration.user_agent {
363        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
364    }
365    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
366        let local_var_key = local_var_apikey.key.clone();
367        let local_var_value = match local_var_apikey.prefix {
368            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
369            None => local_var_key,
370        };
371        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
372    };
373
374    let local_var_req = local_var_req_builder.build()?;
375    let local_var_resp = local_var_client.execute(local_var_req).await?;
376
377    if "GET" != "GET" && "GET" != "HEAD" {
378      let headers = local_var_resp.headers();
379      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
380          Some(v) => v.to_str().unwrap().parse().unwrap(),
381          None => configuration::DEFAULT_RATELIMIT,
382      };
383      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
384          Some(v) => v.to_str().unwrap().parse().unwrap(),
385          None => 0,
386      };
387    }
388
389    let local_var_status = local_var_resp.status();
390    let local_var_content = local_var_resp.text().await?;
391
392    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
393        serde_json::from_str(&local_var_content).map_err(Error::from)
394    } else {
395        let local_var_entity: Option<GetLogElasticsearchError> = serde_json::from_str(&local_var_content).ok();
396        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
397        Err(Error::ResponseError(local_var_error))
398    }
399}
400
401/// List all of the Elasticsearch logging endpoints for a particular service and version.
402pub async fn list_log_elasticsearch(configuration: &mut configuration::Configuration, params: ListLogElasticsearchParams) -> Result<Vec<crate::models::LoggingElasticsearchResponse>, Error<ListLogElasticsearchError>> {
403    let local_var_configuration = configuration;
404
405    // unbox the parameters
406    let service_id = params.service_id;
407    let version_id = params.version_id;
408
409
410    let local_var_client = &local_var_configuration.client;
411
412    let local_var_uri_str = format!("{}/service/{service_id}/version/{version_id}/logging/elasticsearch", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), version_id=version_id);
413    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
414
415    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
416        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
417    }
418    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
419        let local_var_key = local_var_apikey.key.clone();
420        let local_var_value = match local_var_apikey.prefix {
421            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
422            None => local_var_key,
423        };
424        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
425    };
426
427    let local_var_req = local_var_req_builder.build()?;
428    let local_var_resp = local_var_client.execute(local_var_req).await?;
429
430    if "GET" != "GET" && "GET" != "HEAD" {
431      let headers = local_var_resp.headers();
432      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
433          Some(v) => v.to_str().unwrap().parse().unwrap(),
434          None => configuration::DEFAULT_RATELIMIT,
435      };
436      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
437          Some(v) => v.to_str().unwrap().parse().unwrap(),
438          None => 0,
439      };
440    }
441
442    let local_var_status = local_var_resp.status();
443    let local_var_content = local_var_resp.text().await?;
444
445    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
446        serde_json::from_str(&local_var_content).map_err(Error::from)
447    } else {
448        let local_var_entity: Option<ListLogElasticsearchError> = serde_json::from_str(&local_var_content).ok();
449        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
450        Err(Error::ResponseError(local_var_error))
451    }
452}
453
454/// Update the Elasticsearch logging endpoint for a particular service and version.
455pub async fn update_log_elasticsearch(configuration: &mut configuration::Configuration, params: UpdateLogElasticsearchParams) -> Result<crate::models::LoggingElasticsearchResponse, Error<UpdateLogElasticsearchError>> {
456    let local_var_configuration = configuration;
457
458    // unbox the parameters
459    let service_id = params.service_id;
460    let version_id = params.version_id;
461    let logging_elasticsearch_name = params.logging_elasticsearch_name;
462    let name = params.name;
463    let placement = params.placement;
464    let response_condition = params.response_condition;
465    let format = params.format;
466    let log_processing_region = params.log_processing_region;
467    let format_version = params.format_version;
468    let tls_ca_cert = params.tls_ca_cert;
469    let tls_client_cert = params.tls_client_cert;
470    let tls_client_key = params.tls_client_key;
471    let tls_hostname = params.tls_hostname;
472    let request_max_entries = params.request_max_entries;
473    let request_max_bytes = params.request_max_bytes;
474    let index = params.index;
475    let url = params.url;
476    let pipeline = params.pipeline;
477    let user = params.user;
478    let password = params.password;
479
480
481    let local_var_client = &local_var_configuration.client;
482
483    let local_var_uri_str = format!("{}/service/{service_id}/version/{version_id}/logging/elasticsearch/{logging_elasticsearch_name}", local_var_configuration.base_path, service_id=crate::apis::urlencode(service_id), version_id=version_id, logging_elasticsearch_name=crate::apis::urlencode(logging_elasticsearch_name));
484    let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
485
486    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
487        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
488    }
489    if let Some(ref local_var_apikey) = local_var_configuration.api_key {
490        let local_var_key = local_var_apikey.key.clone();
491        let local_var_value = match local_var_apikey.prefix {
492            Some(ref local_var_prefix) => format!("{} {}", local_var_prefix, local_var_key),
493            None => local_var_key,
494        };
495        local_var_req_builder = local_var_req_builder.header("Fastly-Key", local_var_value);
496    };
497    let mut local_var_form_params = std::collections::HashMap::new();
498    if let Some(local_var_param_value) = name {
499        local_var_form_params.insert("name", local_var_param_value.to_string());
500    }
501    if let Some(local_var_param_value) = placement {
502        local_var_form_params.insert("placement", local_var_param_value.to_string());
503    }
504    if let Some(local_var_param_value) = response_condition {
505        local_var_form_params.insert("response_condition", local_var_param_value.to_string());
506    }
507    if let Some(local_var_param_value) = format {
508        local_var_form_params.insert("format", local_var_param_value.to_string());
509    }
510    if let Some(local_var_param_value) = log_processing_region {
511        local_var_form_params.insert("log_processing_region", local_var_param_value.to_string());
512    }
513    if let Some(local_var_param_value) = format_version {
514        local_var_form_params.insert("format_version", local_var_param_value.to_string());
515    }
516    if let Some(local_var_param_value) = tls_ca_cert {
517        local_var_form_params.insert("tls_ca_cert", local_var_param_value.to_string());
518    }
519    if let Some(local_var_param_value) = tls_client_cert {
520        local_var_form_params.insert("tls_client_cert", local_var_param_value.to_string());
521    }
522    if let Some(local_var_param_value) = tls_client_key {
523        local_var_form_params.insert("tls_client_key", local_var_param_value.to_string());
524    }
525    if let Some(local_var_param_value) = tls_hostname {
526        local_var_form_params.insert("tls_hostname", local_var_param_value.to_string());
527    }
528    if let Some(local_var_param_value) = request_max_entries {
529        local_var_form_params.insert("request_max_entries", local_var_param_value.to_string());
530    }
531    if let Some(local_var_param_value) = request_max_bytes {
532        local_var_form_params.insert("request_max_bytes", local_var_param_value.to_string());
533    }
534    if let Some(local_var_param_value) = index {
535        local_var_form_params.insert("index", local_var_param_value.to_string());
536    }
537    if let Some(local_var_param_value) = url {
538        local_var_form_params.insert("url", local_var_param_value.to_string());
539    }
540    if let Some(local_var_param_value) = pipeline {
541        local_var_form_params.insert("pipeline", local_var_param_value.to_string());
542    }
543    if let Some(local_var_param_value) = user {
544        local_var_form_params.insert("user", local_var_param_value.to_string());
545    }
546    if let Some(local_var_param_value) = password {
547        local_var_form_params.insert("password", local_var_param_value.to_string());
548    }
549    local_var_req_builder = local_var_req_builder.form(&local_var_form_params);
550
551    let local_var_req = local_var_req_builder.build()?;
552    let local_var_resp = local_var_client.execute(local_var_req).await?;
553
554    if "PUT" != "GET" && "PUT" != "HEAD" {
555      let headers = local_var_resp.headers();
556      local_var_configuration.rate_limit_remaining = match headers.get("Fastly-RateLimit-Remaining") {
557          Some(v) => v.to_str().unwrap().parse().unwrap(),
558          None => configuration::DEFAULT_RATELIMIT,
559      };
560      local_var_configuration.rate_limit_reset = match headers.get("Fastly-RateLimit-Reset") {
561          Some(v) => v.to_str().unwrap().parse().unwrap(),
562          None => 0,
563      };
564    }
565
566    let local_var_status = local_var_resp.status();
567    let local_var_content = local_var_resp.text().await?;
568
569    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
570        serde_json::from_str(&local_var_content).map_err(Error::from)
571    } else {
572        let local_var_entity: Option<UpdateLogElasticsearchError> = serde_json::from_str(&local_var_content).ok();
573        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
574        Err(Error::ResponseError(local_var_error))
575    }
576}
577