File manager - Edit - /var/www/payraty/helpdesk/vendor/muxinc/mux-php/MuxPhp/Api/RealTimeApi.php
Back
<?php /** * RealTimeApi * PHP version 7.2 * * @category Class * @package MuxPhp * @author Mux API team * @link https://docs.mux.com */ /** * Mux API * * Mux is how developers build online video. This API encompasses both Mux Video and Mux Data functionality to help you build your video-related projects better and faster than ever before. * * The version of the OpenAPI document: v1 * Contact: devex@mux.com * Generated by: https://openapi-generator.tech * OpenAPI Generator version: 5.0.1 */ /** * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ namespace MuxPhp\Api; use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use GuzzleHttp\RequestOptions; use MuxPhp\ApiException; use MuxPhp\Configuration; use MuxPhp\HeaderSelector; use MuxPhp\ObjectSerializer; /** * RealTimeApi Class Doc Comment * * @category Class * @package MuxPhp * @author Mux API team * @link https://docs.mux.com */ class RealTimeApi { /** * @var ClientInterface */ protected $client; /** * @var Configuration */ protected $config; /** * @var HeaderSelector */ protected $headerSelector; /** * @var int Host index */ protected $hostIndex; /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ClientInterface $client = null, Configuration $config = null, HeaderSelector $selector = null, $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); $this->headerSelector = $selector ?: new HeaderSelector(); $this->hostIndex = $hostIndex; } /** * Set the host index * * @param int $hostIndex Host index (required) */ public function setHostIndex($hostIndex) { $this->hostIndex = $hostIndex; } /** * Get the host index * * @return int Host index */ public function getHostIndex() { return $this->hostIndex; } /** * @return Configuration */ public function getConfig() { return $this->config; } /** * Operation getRealtimeBreakdown * * Get Real-Time Breakdown * * @param string $realtime_metric_id ID of the Realtime Metric (required) * @param string $dimension Dimension the specified value belongs to (optional) * @param int $timestamp Timestamp to limit results by. This value must be provided as a unix timestamp. Defaults to the current unix timestamp. (optional) * @param string[] $filters Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` (optional) * @param string $order_by Value to order the results by (optional) * @param string $order_direction Sort order. (optional) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\GetRealTimeBreakdownResponse */ public function getRealtimeBreakdown($realtime_metric_id, $dimension = null, $timestamp = null, $filters = null, $order_by = null, $order_direction = null) { list($response) = $this->getRealtimeBreakdownWithHttpInfo($realtime_metric_id, $dimension, $timestamp, $filters, $order_by, $order_direction); return $response; } /** * Operation getRealtimeBreakdownWithHttpInfo * * Get Real-Time Breakdown * * @param string $realtime_metric_id ID of the Realtime Metric (required) * @param string $dimension Dimension the specified value belongs to (optional) * @param int $timestamp Timestamp to limit results by. This value must be provided as a unix timestamp. Defaults to the current unix timestamp. (optional) * @param string[] $filters Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` (optional) * @param string $order_by Value to order the results by (optional) * @param string $order_direction Sort order. (optional) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\GetRealTimeBreakdownResponse, HTTP status code, HTTP response headers (array of strings) */ public function getRealtimeBreakdownWithHttpInfo($realtime_metric_id, $dimension = null, $timestamp = null, $filters = null, $order_by = null, $order_direction = null) { $request = $this->getRealtimeBreakdownRequest($realtime_metric_id, $dimension, $timestamp, $filters, $order_by, $order_direction); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 200: if ('\MuxPhp\Models\GetRealTimeBreakdownResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\GetRealTimeBreakdownResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\GetRealTimeBreakdownResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\GetRealTimeBreakdownResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation getRealtimeBreakdownAsync * * Get Real-Time Breakdown * * @param string $realtime_metric_id ID of the Realtime Metric (required) * @param string $dimension Dimension the specified value belongs to (optional) * @param int $timestamp Timestamp to limit results by. This value must be provided as a unix timestamp. Defaults to the current unix timestamp. (optional) * @param string[] $filters Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` (optional) * @param string $order_by Value to order the results by (optional) * @param string $order_direction Sort order. (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getRealtimeBreakdownAsync($realtime_metric_id, $dimension = null, $timestamp = null, $filters = null, $order_by = null, $order_direction = null) { return $this->getRealtimeBreakdownAsyncWithHttpInfo($realtime_metric_id, $dimension, $timestamp, $filters, $order_by, $order_direction) ->then( function ($response) { return $response[0]; } ); } /** * Operation getRealtimeBreakdownAsyncWithHttpInfo * * Get Real-Time Breakdown * * @param string $realtime_metric_id ID of the Realtime Metric (required) * @param string $dimension Dimension the specified value belongs to (optional) * @param int $timestamp Timestamp to limit results by. This value must be provided as a unix timestamp. Defaults to the current unix timestamp. (optional) * @param string[] $filters Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` (optional) * @param string $order_by Value to order the results by (optional) * @param string $order_direction Sort order. (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getRealtimeBreakdownAsyncWithHttpInfo($realtime_metric_id, $dimension = null, $timestamp = null, $filters = null, $order_by = null, $order_direction = null) { $returnType = '\MuxPhp\Models\GetRealTimeBreakdownResponse'; $request = $this->getRealtimeBreakdownRequest($realtime_metric_id, $dimension, $timestamp, $filters, $order_by, $order_direction); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'getRealtimeBreakdown' * * @param string $realtime_metric_id ID of the Realtime Metric (required) * @param string $dimension Dimension the specified value belongs to (optional) * @param int $timestamp Timestamp to limit results by. This value must be provided as a unix timestamp. Defaults to the current unix timestamp. (optional) * @param string[] $filters Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` (optional) * @param string $order_by Value to order the results by (optional) * @param string $order_direction Sort order. (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function getRealtimeBreakdownRequest($realtime_metric_id, $dimension = null, $timestamp = null, $filters = null, $order_by = null, $order_direction = null) { // verify the required parameter 'realtime_metric_id' is set if ($realtime_metric_id === null || (is_array($realtime_metric_id) && count($realtime_metric_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $realtime_metric_id when calling getRealtimeBreakdown' ); } $resourcePath = '/data/v1/realtime/metrics/{REALTIME_METRIC_ID}/breakdown'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($dimension !== null) { if('form' === 'form' && is_array($dimension)) { foreach($dimension as $key => $value) { $queryParams[$key] = $value; } } else { $queryParams['dimension'] = $dimension; } } // query params if ($timestamp !== null) { if('form' === 'form' && is_array($timestamp)) { foreach($timestamp as $key => $value) { $queryParams[$key] = $value; } } else { $queryParams['timestamp'] = $timestamp; } } // query params if ($filters !== null) { if('form' === 'form' && is_array($filters)) { foreach($filters as $key => $value) { $queryParams[$key] = $value; } } else { $queryParams['filters[]'] = $filters; } } // query params if ($order_by !== null) { if('form' === 'form' && is_array($order_by)) { foreach($order_by as $key => $value) { $queryParams[$key] = $value; } } else { $queryParams['order_by'] = $order_by; } } // query params if ($order_direction !== null) { if('form' === 'form' && is_array($order_direction)) { foreach($order_direction as $key => $value) { $queryParams[$key] = $value; } } else { $queryParams['order_direction'] = $order_direction; } } // path params if ($realtime_metric_id !== null) { $resourcePath = str_replace( '{' . 'REALTIME_METRIC_ID' . '}', ObjectSerializer::toPathValue($realtime_metric_id), $resourcePath ); } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], [] ); } // for model (json/xml) if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation getRealtimeHistogramTimeseries * * Get Real-Time Histogram Timeseries * * @param string $realtime_histogram_metric_id ID of the Realtime Histogram Metric (required) * @param string[] $filters Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` (optional) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\GetRealTimeHistogramTimeseriesResponse */ public function getRealtimeHistogramTimeseries($realtime_histogram_metric_id, $filters = null) { list($response) = $this->getRealtimeHistogramTimeseriesWithHttpInfo($realtime_histogram_metric_id, $filters); return $response; } /** * Operation getRealtimeHistogramTimeseriesWithHttpInfo * * Get Real-Time Histogram Timeseries * * @param string $realtime_histogram_metric_id ID of the Realtime Histogram Metric (required) * @param string[] $filters Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` (optional) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\GetRealTimeHistogramTimeseriesResponse, HTTP status code, HTTP response headers (array of strings) */ public function getRealtimeHistogramTimeseriesWithHttpInfo($realtime_histogram_metric_id, $filters = null) { $request = $this->getRealtimeHistogramTimeseriesRequest($realtime_histogram_metric_id, $filters); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 200: if ('\MuxPhp\Models\GetRealTimeHistogramTimeseriesResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\GetRealTimeHistogramTimeseriesResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\GetRealTimeHistogramTimeseriesResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\GetRealTimeHistogramTimeseriesResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation getRealtimeHistogramTimeseriesAsync * * Get Real-Time Histogram Timeseries * * @param string $realtime_histogram_metric_id ID of the Realtime Histogram Metric (required) * @param string[] $filters Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getRealtimeHistogramTimeseriesAsync($realtime_histogram_metric_id, $filters = null) { return $this->getRealtimeHistogramTimeseriesAsyncWithHttpInfo($realtime_histogram_metric_id, $filters) ->then( function ($response) { return $response[0]; } ); } /** * Operation getRealtimeHistogramTimeseriesAsyncWithHttpInfo * * Get Real-Time Histogram Timeseries * * @param string $realtime_histogram_metric_id ID of the Realtime Histogram Metric (required) * @param string[] $filters Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getRealtimeHistogramTimeseriesAsyncWithHttpInfo($realtime_histogram_metric_id, $filters = null) { $returnType = '\MuxPhp\Models\GetRealTimeHistogramTimeseriesResponse'; $request = $this->getRealtimeHistogramTimeseriesRequest($realtime_histogram_metric_id, $filters); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'getRealtimeHistogramTimeseries' * * @param string $realtime_histogram_metric_id ID of the Realtime Histogram Metric (required) * @param string[] $filters Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function getRealtimeHistogramTimeseriesRequest($realtime_histogram_metric_id, $filters = null) { // verify the required parameter 'realtime_histogram_metric_id' is set if ($realtime_histogram_metric_id === null || (is_array($realtime_histogram_metric_id) && count($realtime_histogram_metric_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $realtime_histogram_metric_id when calling getRealtimeHistogramTimeseries' ); } $resourcePath = '/data/v1/realtime/metrics/{REALTIME_HISTOGRAM_METRIC_ID}/histogram-timeseries'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($filters !== null) { if('form' === 'form' && is_array($filters)) { foreach($filters as $key => $value) { $queryParams[$key] = $value; } } else { $queryParams['filters[]'] = $filters; } } // path params if ($realtime_histogram_metric_id !== null) { $resourcePath = str_replace( '{' . 'REALTIME_HISTOGRAM_METRIC_ID' . '}', ObjectSerializer::toPathValue($realtime_histogram_metric_id), $resourcePath ); } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], [] ); } // for model (json/xml) if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation getRealtimeTimeseries * * Get Real-Time Timeseries * * @param string $realtime_metric_id ID of the Realtime Metric (required) * @param string[] $filters Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` (optional) * @param int $timestamp Timestamp to use as the start of the timeseries data. This value must be provided as a unix timestamp. Defaults to 30 minutes ago. (optional) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\GetRealTimeTimeseriesResponse */ public function getRealtimeTimeseries($realtime_metric_id, $filters = null, $timestamp = null) { list($response) = $this->getRealtimeTimeseriesWithHttpInfo($realtime_metric_id, $filters, $timestamp); return $response; } /** * Operation getRealtimeTimeseriesWithHttpInfo * * Get Real-Time Timeseries * * @param string $realtime_metric_id ID of the Realtime Metric (required) * @param string[] $filters Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` (optional) * @param int $timestamp Timestamp to use as the start of the timeseries data. This value must be provided as a unix timestamp. Defaults to 30 minutes ago. (optional) * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\GetRealTimeTimeseriesResponse, HTTP status code, HTTP response headers (array of strings) */ public function getRealtimeTimeseriesWithHttpInfo($realtime_metric_id, $filters = null, $timestamp = null) { $request = $this->getRealtimeTimeseriesRequest($realtime_metric_id, $filters, $timestamp); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 200: if ('\MuxPhp\Models\GetRealTimeTimeseriesResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\GetRealTimeTimeseriesResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\GetRealTimeTimeseriesResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\GetRealTimeTimeseriesResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation getRealtimeTimeseriesAsync * * Get Real-Time Timeseries * * @param string $realtime_metric_id ID of the Realtime Metric (required) * @param string[] $filters Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` (optional) * @param int $timestamp Timestamp to use as the start of the timeseries data. This value must be provided as a unix timestamp. Defaults to 30 minutes ago. (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getRealtimeTimeseriesAsync($realtime_metric_id, $filters = null, $timestamp = null) { return $this->getRealtimeTimeseriesAsyncWithHttpInfo($realtime_metric_id, $filters, $timestamp) ->then( function ($response) { return $response[0]; } ); } /** * Operation getRealtimeTimeseriesAsyncWithHttpInfo * * Get Real-Time Timeseries * * @param string $realtime_metric_id ID of the Realtime Metric (required) * @param string[] $filters Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` (optional) * @param int $timestamp Timestamp to use as the start of the timeseries data. This value must be provided as a unix timestamp. Defaults to 30 minutes ago. (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function getRealtimeTimeseriesAsyncWithHttpInfo($realtime_metric_id, $filters = null, $timestamp = null) { $returnType = '\MuxPhp\Models\GetRealTimeTimeseriesResponse'; $request = $this->getRealtimeTimeseriesRequest($realtime_metric_id, $filters, $timestamp); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'getRealtimeTimeseries' * * @param string $realtime_metric_id ID of the Realtime Metric (required) * @param string[] $filters Limit the results to rows that match conditions from provided key:value pairs. Must be provided as an array query string parameter. To exclude rows that match a certain condition, prepend a `!` character to the dimension. Possible filter names are the same as returned by the List Monitoring Dimensions endpoint. Example: * `filters[]=operating_system:windows&filters[]=!country:US` (optional) * @param int $timestamp Timestamp to use as the start of the timeseries data. This value must be provided as a unix timestamp. Defaults to 30 minutes ago. (optional) * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function getRealtimeTimeseriesRequest($realtime_metric_id, $filters = null, $timestamp = null) { // verify the required parameter 'realtime_metric_id' is set if ($realtime_metric_id === null || (is_array($realtime_metric_id) && count($realtime_metric_id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $realtime_metric_id when calling getRealtimeTimeseries' ); } $resourcePath = '/data/v1/realtime/metrics/{REALTIME_METRIC_ID}/timeseries'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params if ($filters !== null) { if('form' === 'form' && is_array($filters)) { foreach($filters as $key => $value) { $queryParams[$key] = $value; } } else { $queryParams['filters[]'] = $filters; } } // query params if ($timestamp !== null) { if('form' === 'form' && is_array($timestamp)) { foreach($timestamp as $key => $value) { $queryParams[$key] = $value; } } else { $queryParams['timestamp'] = $timestamp; } } // path params if ($realtime_metric_id !== null) { $resourcePath = str_replace( '{' . 'REALTIME_METRIC_ID' . '}', ObjectSerializer::toPathValue($realtime_metric_id), $resourcePath ); } if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], [] ); } // for model (json/xml) if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation listRealtimeDimensions * * List Real-Time Dimensions * * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\ListRealTimeDimensionsResponse */ public function listRealtimeDimensions() { list($response) = $this->listRealtimeDimensionsWithHttpInfo(); return $response; } /** * Operation listRealtimeDimensionsWithHttpInfo * * List Real-Time Dimensions * * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\ListRealTimeDimensionsResponse, HTTP status code, HTTP response headers (array of strings) */ public function listRealtimeDimensionsWithHttpInfo() { $request = $this->listRealtimeDimensionsRequest(); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 200: if ('\MuxPhp\Models\ListRealTimeDimensionsResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\ListRealTimeDimensionsResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\ListRealTimeDimensionsResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\ListRealTimeDimensionsResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation listRealtimeDimensionsAsync * * List Real-Time Dimensions * * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function listRealtimeDimensionsAsync() { return $this->listRealtimeDimensionsAsyncWithHttpInfo() ->then( function ($response) { return $response[0]; } ); } /** * Operation listRealtimeDimensionsAsyncWithHttpInfo * * List Real-Time Dimensions * * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function listRealtimeDimensionsAsyncWithHttpInfo() { $returnType = '\MuxPhp\Models\ListRealTimeDimensionsResponse'; $request = $this->listRealtimeDimensionsRequest(); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'listRealtimeDimensions' * * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function listRealtimeDimensionsRequest() { $resourcePath = '/data/v1/realtime/dimensions'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], [] ); } // for model (json/xml) if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation listRealtimeMetrics * * List Real-Time Metrics * * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return \MuxPhp\Models\ListRealTimeMetricsResponse */ public function listRealtimeMetrics() { list($response) = $this->listRealtimeMetricsWithHttpInfo(); return $response; } /** * Operation listRealtimeMetricsWithHttpInfo * * List Real-Time Metrics * * * @throws \MuxPhp\ApiException on non-2xx response * @throws \InvalidArgumentException * @return array of \MuxPhp\Models\ListRealTimeMetricsResponse, HTTP status code, HTTP response headers (array of strings) */ public function listRealtimeMetricsWithHttpInfo() { $request = $this->listRealtimeMetricsRequest(); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } $statusCode = $response->getStatusCode(); if ($statusCode < 200 || $statusCode > 299) { throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $request->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } $responseBody = $response->getBody(); switch($statusCode) { case 200: if ('\MuxPhp\Models\ListRealTimeMetricsResponse' === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, '\MuxPhp\Models\ListRealTimeMetricsResponse', []), $response->getStatusCode(), $response->getHeaders() ]; } $returnType = '\MuxPhp\Models\ListRealTimeMetricsResponse'; $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\MuxPhp\Models\ListRealTimeMetricsResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); break; } throw $e; } } /** * Operation listRealtimeMetricsAsync * * List Real-Time Metrics * * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function listRealtimeMetricsAsync() { return $this->listRealtimeMetricsAsyncWithHttpInfo() ->then( function ($response) { return $response[0]; } ); } /** * Operation listRealtimeMetricsAsyncWithHttpInfo * * List Real-Time Metrics * * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function listRealtimeMetricsAsyncWithHttpInfo() { $returnType = '\MuxPhp\Models\ListRealTimeMetricsResponse'; $request = $this->listRealtimeMetricsRequest(); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { $responseBody = $response->getBody(); if ($returnType === '\SplFileObject') { $content = $responseBody; //stream goes to serializer } else { $content = (string) $responseBody; } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), $response->getBody() ); } ); } /** * Create request for operation 'listRealtimeMetrics' * * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function listRealtimeMetricsRequest() { $resourcePath = '/data/v1/realtime/metrics'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; if ($multipart) { $headers = $this->headerSelector->selectHeadersForMultipart( ['application/json'] ); } else { $headers = $this->headerSelector->selectHeaders( ['application/json'], [] ); } // for model (json/xml) if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif ($headers['Content-Type'] === 'application/json') { $httpBody = \GuzzleHttp\json_encode($formParams); } else { // for HTTP post (form) $httpBody = \GuzzleHttp\Psr7\build_query($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); // MUX: adds support for array params. // TODO: future upstream? $query = ObjectSerializer::buildBetterQuery($queryParams); return new Request( 'GET', $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Create http client option * * @throws \RuntimeException on file opening failure * @return array of http client options */ protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } return $options; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 0 |
proxy
|
phpinfo
|
Settings