| 1 | =begin comment | ||
| 2 | |||
| 3 | Fastly API | ||
| 4 | |||
| 5 | 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/) | ||
| 6 | |||
| 7 | The version of the API Spec document: 1.0.0 | ||
| 8 | Contact: oss@fastly.com | ||
| 9 | |||
| 10 | =end comment | ||
| 11 | |||
| 12 | =cut | ||
| 13 | |||
| 14 | # | ||
| 15 | # NOTE: This class is auto generated. | ||
| 16 | # Do not edit the class manually. | ||
| 17 | # | ||
| 18 | package WebService::Fastly::BotRequestsMetricsApi; | ||
| 19 | |||
| 20 | require 5.6.0; | ||
| 21 | use strict; | ||
| 22 | use warnings; | ||
| 23 | use utf8; | ||
| 24 | use Exporter; | ||
| 25 | use Carp qw( croak ); | ||
| 26 | use Log::Any qw($log); | ||
| 27 | |||
| 28 | use WebService::Fastly::ApiClient; | ||
| 29 | |||
| 30 | use base "Class::Data::Inheritable"; | ||
| 31 | |||
| 32 | __PACKAGE__->mk_classdata('method_documentation' => {}); | ||
| 33 | |||
| 34 | sub new { | ||
| 35 | my $class = shift; | ||
| 36 | my $api_client; | ||
| 37 | |||
| 38 | if ($_[0] && ref $_[0] && ref $_[0] eq 'WebService::Fastly::ApiClient' ) { | ||
| 39 | $api_client = $_[0]; | ||
| 40 | } else { | ||
| 41 | $api_client = WebService::Fastly::ApiClient->new(@_); | ||
| 42 | } | ||
| 43 | |||
| 44 | bless { api_client => $api_client }, $class; | ||
| 45 | |||
| 46 | } | ||
| 47 | |||
| 48 | |||
| 49 | # | ||
| 50 | # get_bot_request_metrics_service_historical | ||
| 51 | # | ||
| 52 | # Get per-service historical time series metrics for bot requests broken down by bot-type. | ||
| 53 | # | ||
| 54 | # @param string $granularity Duration of sample windows. (required) | ||
| 55 | # @param string $service_id Alphanumeric string identifying the service. (required) | ||
| 56 | # @param string $from A valid RFC-8339-formatted date and time indicating the inclusive start of the query time range. If not provided, a default is chosen based on the provided `granularity` value. (optional) | ||
| 57 | # @param string $to A valid RFC-8339-formatted date and time indicating the exclusive end of the query time range. If not provided, a default is chosen based on the provided `granularity` value. (optional) | ||
| 58 | # @param string $group_by Field to group by in the query. For example, `group_by=bot_id` will return entries grouped by `timestamp` and `bot_id`. (optional) | ||
| 59 | # @param string $datacenter Limit query to one or more specific POPs. Values should be comma-separated. (optional) | ||
| 60 | # @param string $bot Filter results based by Bot ID. (optional) | ||
| 61 | # @param string $region Limit query to one or more specific geographic regions. Values should be comma-separated. (optional) | ||
| 62 | # @param string $cursor Cursor value from the `next_cursor` field of a previous response, used to retrieve the next page. To request the first page, this should be empty. (optional) | ||
| 63 | # @param string $metric One or more metrics to retrieve. Multiple values should be comma-separated. (optional) | ||
| 64 | # @param string $metric_set The metric set to retrieve. (optional) | ||
| 65 | # @param string $limit Number of results per page. The maximum is 10000. (optional, default to '1000') | ||
| 66 | { | ||
| 67 | my $params = { | ||
| 68 | 'granularity' => { | ||
| 69 | data_type => 'string', | ||
| 70 | description => 'Duration of sample windows.', | ||
| 71 | required => '1', | ||
| 72 | }, | ||
| 73 | 'service_id' => { | ||
| 74 | data_type => 'string', | ||
| 75 | description => 'Alphanumeric string identifying the service.', | ||
| 76 | required => '1', | ||
| 77 | }, | ||
| 78 | 'from' => { | ||
| 79 | data_type => 'string', | ||
| 80 | description => 'A valid RFC-8339-formatted date and time indicating the inclusive start of the query time range. If not provided, a default is chosen based on the provided `granularity` value.', | ||
| 81 | required => '0', | ||
| 82 | }, | ||
| 83 | 'to' => { | ||
| 84 | data_type => 'string', | ||
| 85 | description => 'A valid RFC-8339-formatted date and time indicating the exclusive end of the query time range. If not provided, a default is chosen based on the provided `granularity` value.', | ||
| 86 | required => '0', | ||
| 87 | }, | ||
| 88 | 'group_by' => { | ||
| 89 | data_type => 'string', | ||
| 90 | description => 'Field to group by in the query. For example, `group_by=bot_id` will return entries grouped by `timestamp` and `bot_id`. ', | ||
| 91 | required => '0', | ||
| 92 | }, | ||
| 93 | 'datacenter' => { | ||
| 94 | data_type => 'string', | ||
| 95 | description => 'Limit query to one or more specific POPs. Values should be comma-separated.', | ||
| 96 | required => '0', | ||
| 97 | }, | ||
| 98 | 'bot' => { | ||
| 99 | data_type => 'string', | ||
| 100 | description => 'Filter results based by Bot ID.', | ||
| 101 | required => '0', | ||
| 102 | }, | ||
| 103 | 'region' => { | ||
| 104 | data_type => 'string', | ||
| 105 | description => 'Limit query to one or more specific geographic regions. Values should be comma-separated. ', | ||
| 106 | required => '0', | ||
| 107 | }, | ||
| 108 | 'cursor' => { | ||
| 109 | data_type => 'string', | ||
| 110 | description => 'Cursor value from the `next_cursor` field of a previous response, used to retrieve the next page. To request the first page, this should be empty.', | ||
| 111 | required => '0', | ||
| 112 | }, | ||
| 113 | 'metric' => { | ||
| 114 | data_type => 'string', | ||
| 115 | description => 'One or more metrics to retrieve. Multiple values should be comma-separated.', | ||
| 116 | required => '0', | ||
| 117 | }, | ||
| 118 | 'metric_set' => { | ||
| 119 | data_type => 'string', | ||
| 120 | description => 'The metric set to retrieve.', | ||
| 121 | required => '0', | ||
| 122 | }, | ||
| 123 | 'limit' => { | ||
| 124 | data_type => 'string', | ||
| 125 | description => 'Number of results per page. The maximum is 10000.', | ||
| 126 | required => '0', | ||
| 127 | }, | ||
| 128 | }; | ||
| 129 | __PACKAGE__->method_documentation->{ 'get_bot_request_metrics_service_historical' } = { | ||
| 130 | summary => 'Get per-service historical time series metrics for bot requests broken down by bot-type.', | ||
| 131 | params => $params, | ||
| 132 | returns => 'BotRequestMetricsResponse', | ||
| 133 | }; | ||
| 134 | } | ||
| 135 | # @return BotRequestMetricsResponse | ||
| 136 | # | ||
| 137 | sub get_bot_request_metrics_service_historical { | ||
| 138 | my ($self, %args) = @_; | ||
| 139 | |||
| 140 | # verify the required parameter 'granularity' is set | ||
| 141 | unless (exists $args{'granularity'}) { | ||
| 142 | croak("Missing the required parameter 'granularity' when calling get_bot_request_metrics_service_historical"); | ||
| 143 | } | ||
| 144 | |||
| 145 | # verify the required parameter 'service_id' is set | ||
| 146 | unless (exists $args{'service_id'}) { | ||
| 147 | croak("Missing the required parameter 'service_id' when calling get_bot_request_metrics_service_historical"); | ||
| 148 | } | ||
| 149 | |||
| 150 | # parse inputs | ||
| 151 | my $_resource_path = '/metrics/bots/entities/{service_id}/{granularity}'; | ||
| 152 | |||
| 153 | my $_method = 'GET'; | ||
| 154 | my $query_params = {}; | ||
| 155 | my $header_params = {}; | ||
| 156 | my $form_params = {}; | ||
| 157 | |||
| 158 | # 'Accept' and 'Content-Type' header | ||
| 159 | my $_header_accept = $self->{api_client}->select_header_accept('application/json'); | ||
| 160 | if ($_header_accept) { | ||
| 161 | $header_params->{'Accept'} = $_header_accept; | ||
| 162 | } | ||
| 163 | $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type(); | ||
| 164 | |||
| 165 | # query params | ||
| 166 | if ( exists $args{'from'}) { | ||
| 167 | $query_params->{'from'} = $self->{api_client}->to_query_value($args{'from'}); | ||
| 168 | } | ||
| 169 | |||
| 170 | # query params | ||
| 171 | if ( exists $args{'to'}) { | ||
| 172 | $query_params->{'to'} = $self->{api_client}->to_query_value($args{'to'}); | ||
| 173 | } | ||
| 174 | |||
| 175 | # query params | ||
| 176 | if ( exists $args{'group_by'}) { | ||
| 177 | $query_params->{'group_by'} = $self->{api_client}->to_query_value($args{'group_by'}); | ||
| 178 | } | ||
| 179 | |||
| 180 | # query params | ||
| 181 | if ( exists $args{'datacenter'}) { | ||
| 182 | $query_params->{'datacenter'} = $self->{api_client}->to_query_value($args{'datacenter'}); | ||
| 183 | } | ||
| 184 | |||
| 185 | # query params | ||
| 186 | if ( exists $args{'bot'}) { | ||
| 187 | $query_params->{'bot'} = $self->{api_client}->to_query_value($args{'bot'}); | ||
| 188 | } | ||
| 189 | |||
| 190 | # query params | ||
| 191 | if ( exists $args{'region'}) { | ||
| 192 | $query_params->{'region'} = $self->{api_client}->to_query_value($args{'region'}); | ||
| 193 | } | ||
| 194 | |||
| 195 | # query params | ||
| 196 | if ( exists $args{'cursor'}) { | ||
| 197 | $query_params->{'cursor'} = $self->{api_client}->to_query_value($args{'cursor'}); | ||
| 198 | } | ||
| 199 | |||
| 200 | # query params | ||
| 201 | if ( exists $args{'metric'}) { | ||
| 202 | $query_params->{'metric'} = $self->{api_client}->to_query_value($args{'metric'}); | ||
| 203 | } | ||
| 204 | |||
| 205 | # query params | ||
| 206 | if ( exists $args{'metric_set'}) { | ||
| 207 | $query_params->{'metric_set'} = $self->{api_client}->to_query_value($args{'metric_set'}); | ||
| 208 | } | ||
| 209 | |||
| 210 | # query params | ||
| 211 | if ( exists $args{'limit'}) { | ||
| 212 | $query_params->{'limit'} = $self->{api_client}->to_query_value($args{'limit'}); | ||
| 213 | } | ||
| 214 | |||
| 215 | # path params | ||
| 216 | if ( exists $args{'granularity'}) { | ||
| 217 | my $_base_variable = "{" . "granularity" . "}"; | ||
| 218 | my $_base_value = $self->{api_client}->to_path_value($args{'granularity'}); | ||
| 219 | $_resource_path =~ s/$_base_variable/$_base_value/g; | ||
| 220 | } | ||
| 221 | |||
| 222 | # path params | ||
| 223 | if ( exists $args{'service_id'}) { | ||
| 224 | my $_base_variable = "{" . "service_id" . "}"; | ||
| 225 | my $_base_value = $self->{api_client}->to_path_value($args{'service_id'}); | ||
| 226 | $_resource_path =~ s/$_base_variable/$_base_value/g; | ||
| 227 | } | ||
| 228 | |||
| 229 | my $_body_data; | ||
| 230 | # authentication setting, if any | ||
| 231 | my $auth_settings = [qw(token )]; | ||
| 232 | |||
| 233 | # make the API Call | ||
| 234 | my $response = $self->{api_client}->call_api($_resource_path, $_method, | ||
| 235 | $query_params, $form_params, | ||
| 236 | $header_params, $_body_data, $auth_settings); | ||
| 237 | if (!$response) { | ||
| 238 | return; | ||
| 239 | } | ||
| 240 | my $_response_object = $self->{api_client}->deserialize('BotRequestMetricsResponse', $response); | ||
| 241 | return $_response_object; | ||
| 242 | } | ||
| 243 | |||
| 244 | 1; |