zap_api/
stats.rs

1/* Zed Attack Proxy (ZAP) and its related class files.
2 *
3 * ZAP is an HTTP/HTTPS proxy for assessing web application security.
4 *
5 * Copyright 2019 the ZAP development team
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20use super::ZapApiError;
21use super::ZapService;
22use serde_json::Value;
23use std::collections::HashMap;
24
25/**
26 * This file was automatically generated.
27 */
28/**
29 * Statistics
30*/
31pub fn stats(service: &ZapService, keyprefix: String) -> Result<Value, ZapApiError> {
32    let mut params = HashMap::new();
33    params.insert("keyPrefix".to_string(), keyprefix);
34    super::call(service, "stats", "view", "stats", params)
35}
36
37/**
38 * Gets all of the site based statistics, optionally filtered by a key prefix
39*/
40pub fn all_sites_stats(service: &ZapService, keyprefix: String) -> Result<Value, ZapApiError> {
41    let mut params = HashMap::new();
42    params.insert("keyPrefix".to_string(), keyprefix);
43    super::call(service, "stats", "view", "allSitesStats", params)
44}
45
46/**
47 * Gets all of the global statistics, optionally filtered by a key prefix
48*/
49pub fn site_stats(
50    service: &ZapService,
51    site: String,
52    keyprefix: String,
53) -> Result<Value, ZapApiError> {
54    let mut params = HashMap::new();
55    params.insert("site".to_string(), site);
56    params.insert("keyPrefix".to_string(), keyprefix);
57    super::call(service, "stats", "view", "siteStats", params)
58}
59
60/**
61 * Gets the Statsd service hostname
62*/
63pub fn option_statsd_host(service: &ZapService) -> Result<Value, ZapApiError> {
64    let params = HashMap::new();
65    super::call(service, "stats", "view", "optionStatsdHost", params)
66}
67
68/**
69 * Gets the Statsd service port
70*/
71pub fn option_statsd_port(service: &ZapService) -> Result<Value, ZapApiError> {
72    let params = HashMap::new();
73    super::call(service, "stats", "view", "optionStatsdPort", params)
74}
75
76/**
77 * Gets the prefix to be applied to all stats sent to the configured Statsd service
78*/
79pub fn option_statsd_prefix(service: &ZapService) -> Result<Value, ZapApiError> {
80    let params = HashMap::new();
81    super::call(service, "stats", "view", "optionStatsdPrefix", params)
82}
83
84/**
85 * Returns 'true' if in memory statistics are enabled, otherwise returns 'false'
86*/
87pub fn option_in_memory_enabled(service: &ZapService) -> Result<Value, ZapApiError> {
88    let params = HashMap::new();
89    super::call(service, "stats", "view", "optionInMemoryEnabled", params)
90}
91
92/**
93 * Returns 'true' if a Statsd server has been correctly configured, otherwise returns 'false'
94*/
95pub fn option_statsd_enabled(service: &ZapService) -> Result<Value, ZapApiError> {
96    let params = HashMap::new();
97    super::call(service, "stats", "view", "optionStatsdEnabled", params)
98}
99
100/**
101 * Clears all of the statistics
102*/
103pub fn clear_stats(service: &ZapService, keyprefix: String) -> Result<Value, ZapApiError> {
104    let mut params = HashMap::new();
105    params.insert("keyPrefix".to_string(), keyprefix);
106    super::call(service, "stats", "action", "clearStats", params)
107}
108
109/**
110 * Sets the Statsd service hostname, supply an empty string to stop using a Statsd service
111*/
112pub fn set_option_statsd_host(service: &ZapService, string: String) -> Result<Value, ZapApiError> {
113    let mut params = HashMap::new();
114    params.insert("String".to_string(), string);
115    super::call(service, "stats", "action", "setOptionStatsdHost", params)
116}
117
118/**
119 * Sets the prefix to be applied to all stats sent to the configured Statsd service
120*/
121pub fn set_option_statsd_prefix(
122    service: &ZapService,
123    string: String,
124) -> Result<Value, ZapApiError> {
125    let mut params = HashMap::new();
126    params.insert("String".to_string(), string);
127    super::call(service, "stats", "action", "setOptionStatsdPrefix", params)
128}
129
130/**
131 * Sets whether in memory statistics are enabled
132*/
133pub fn set_option_in_memory_enabled(
134    service: &ZapService,
135    boolean: String,
136) -> Result<Value, ZapApiError> {
137    let mut params = HashMap::new();
138    params.insert("Boolean".to_string(), boolean);
139    super::call(
140        service,
141        "stats",
142        "action",
143        "setOptionInMemoryEnabled",
144        params,
145    )
146}
147
148/**
149 * Sets the Statsd service port
150*/
151pub fn set_option_statsd_port(service: &ZapService, integer: String) -> Result<Value, ZapApiError> {
152    let mut params = HashMap::new();
153    params.insert("Integer".to_string(), integer);
154    super::call(service, "stats", "action", "setOptionStatsdPort", params)
155}