diff --git a/src/Client/Api/EndpointsApi.php b/src/Client/Api/EndpointsApi.php index c80d17f..f72f036 100644 --- a/src/Client/Api/EndpointsApi.php +++ b/src/Client/Api/EndpointsApi.php @@ -90,6 +90,9 @@ class EndpointsApi 'getEndpoint' => [ 'application/json', ], + 'getEndpointPeriodFailureRates' => [ + 'application/json', + ], 'getEndpoints' => [ 'application/json', ], @@ -1838,6 +1841,365 @@ public function getEndpointRequest($project_id, $endpoint_id, string $contentTyp ); } + /** + * Operation getEndpointPeriodFailureRates + * + * Endpoint period failure rates + * + * @param string $project_id Project ID (required) + * @param string[]|null $endpoint_id Endpoint IDs (optional) + * @param string|null $start_date Start date (optional) + * @param string|null $end_date End date (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getEndpointPeriodFailureRates'] to see the possible values for this operation + * + * @throws \Convoy\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return \Convoy\Client\Model\GetEndpointPeriodFailureRates200Response|\Convoy\Client\Model\GetProjects400Response|\Convoy\Client\Model\GetProjects400Response|\Convoy\Client\Model\GetProjects400Response + */ + public function getEndpointPeriodFailureRates($project_id, $endpoint_id = null, $start_date = null, $end_date = null, string $contentType = self::contentTypes['getEndpointPeriodFailureRates'][0]) + { + list($response) = $this->getEndpointPeriodFailureRatesWithHttpInfo($project_id, $endpoint_id, $start_date, $end_date, $contentType); + return $response; + } + + /** + * Operation getEndpointPeriodFailureRatesWithHttpInfo + * + * Endpoint period failure rates + * + * @param string $project_id Project ID (required) + * @param string[]|null $endpoint_id Endpoint IDs (optional) + * @param string|null $start_date Start date (optional) + * @param string|null $end_date End date (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getEndpointPeriodFailureRates'] to see the possible values for this operation + * + * @throws \Convoy\Client\ApiException on non-2xx response or if the response body is not in the expected format + * @throws \InvalidArgumentException + * @return array of \Convoy\Client\Model\GetEndpointPeriodFailureRates200Response|\Convoy\Client\Model\GetProjects400Response|\Convoy\Client\Model\GetProjects400Response|\Convoy\Client\Model\GetProjects400Response, HTTP status code, HTTP response headers (array of strings) + */ + public function getEndpointPeriodFailureRatesWithHttpInfo($project_id, $endpoint_id = null, $start_date = null, $end_date = null, string $contentType = self::contentTypes['getEndpointPeriodFailureRates'][0]) + { + $request = $this->getEndpointPeriodFailureRatesRequest($project_id, $endpoint_id, $start_date, $end_date, $contentType); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } catch (ConnectException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + (int) $e->getCode(), + null, + null + ); + } + + $statusCode = $response->getStatusCode(); + + + switch($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\Convoy\Client\Model\GetEndpointPeriodFailureRates200Response', + $request, + $response, + ); + case 400: + return $this->handleResponseWithDataType( + '\Convoy\Client\Model\GetProjects400Response', + $request, + $response, + ); + case 401: + return $this->handleResponseWithDataType( + '\Convoy\Client\Model\GetProjects400Response', + $request, + $response, + ); + case 404: + return $this->handleResponseWithDataType( + '\Convoy\Client\Model\GetProjects400Response', + $request, + $response, + ); + } + + + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\Convoy\Client\Model\GetEndpointPeriodFailureRates200Response', + $request, + $response, + ); + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Convoy\Client\Model\GetEndpointPeriodFailureRates200Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 400: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Convoy\Client\Model\GetProjects400Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 401: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Convoy\Client\Model\GetProjects400Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + case 404: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Convoy\Client\Model\GetProjects400Response', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; + } + + + throw $e; + } + } + + /** + * Operation getEndpointPeriodFailureRatesAsync + * + * Endpoint period failure rates + * + * @param string $project_id Project ID (required) + * @param string[]|null $endpoint_id Endpoint IDs (optional) + * @param string|null $start_date Start date (optional) + * @param string|null $end_date End date (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getEndpointPeriodFailureRates'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getEndpointPeriodFailureRatesAsync($project_id, $endpoint_id = null, $start_date = null, $end_date = null, string $contentType = self::contentTypes['getEndpointPeriodFailureRates'][0]) + { + return $this->getEndpointPeriodFailureRatesAsyncWithHttpInfo($project_id, $endpoint_id, $start_date, $end_date, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getEndpointPeriodFailureRatesAsyncWithHttpInfo + * + * Endpoint period failure rates + * + * @param string $project_id Project ID (required) + * @param string[]|null $endpoint_id Endpoint IDs (optional) + * @param string|null $start_date Start date (optional) + * @param string|null $end_date End date (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getEndpointPeriodFailureRates'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getEndpointPeriodFailureRatesAsyncWithHttpInfo($project_id, $endpoint_id = null, $start_date = null, $end_date = null, string $contentType = self::contentTypes['getEndpointPeriodFailureRates'][0]) + { + $returnType = '\Convoy\Client\Model\GetEndpointPeriodFailureRates200Response'; + $request = $this->getEndpointPeriodFailureRatesRequest($project_id, $endpoint_id, $start_date, $end_date, $contentType); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + if ($returnType === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ($returnType !== 'string') { + $content = json_decode($content); + } + } + + 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(), + (string) $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'getEndpointPeriodFailureRates' + * + * @param string $project_id Project ID (required) + * @param string[]|null $endpoint_id Endpoint IDs (optional) + * @param string|null $start_date Start date (optional) + * @param string|null $end_date End date (optional) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getEndpointPeriodFailureRates'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getEndpointPeriodFailureRatesRequest($project_id, $endpoint_id = null, $start_date = null, $end_date = null, string $contentType = self::contentTypes['getEndpointPeriodFailureRates'][0]) + { + + // verify the required parameter 'project_id' is set + if ($project_id === null || (is_array($project_id) && count($project_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $project_id when calling getEndpointPeriodFailureRates' + ); + } + + + + + + $resourcePath = '/v1/projects/{projectID}/endpoints/period-failure-rates'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $endpoint_id, + 'endpointId', // param base name + 'array', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $start_date, + 'startDate', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + // query params + $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( + $end_date, + 'endDate', // param base name + 'string', // openApiType + 'form', // style + true, // explode + false // required + ) ?? []); + + + // path params + if ($project_id !== null) { + $resourcePath = str_replace( + '{projectID}', + ObjectSerializer::toPathValue($project_id), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // 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 (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the form parameters + $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); + } else { + // for HTTP post (form) + $httpBody = ObjectSerializer::buildQuery($formParams); + } + } + + // this endpoint requires Bearer authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $operationHost = $this->config->getHost(); + $query = ObjectSerializer::buildQuery($queryParams); + return new Request( + 'GET', + $operationHost . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + /** * Operation getEndpoints * diff --git a/src/Client/Model/GetEndpointPeriodFailureRates200Response.php b/src/Client/Model/GetEndpointPeriodFailureRates200Response.php new file mode 100644 index 0000000..b9f4419 --- /dev/null +++ b/src/Client/Model/GetEndpointPeriodFailureRates200Response.php @@ -0,0 +1,478 @@ + + */ +class GetEndpointPeriodFailureRates200Response implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'GetEndpointPeriodFailureRates_200_response'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'message' => 'string', + 'status' => 'bool', + 'data' => '\Convoy\Client\Model\ModelsEndpointPeriodFailureRate[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'message' => null, + 'status' => null, + 'data' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'message' => false, + 'status' => false, + 'data' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'message' => 'message', + 'status' => 'status', + 'data' => 'data' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'message' => 'setMessage', + 'status' => 'setStatus', + 'data' => 'setData' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'message' => 'getMessage', + 'status' => 'getStatus', + 'data' => 'getData' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('message', $data ?? [], null); + $this->setIfExists('status', $data ?? [], null); + $this->setIfExists('data', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message message + * + * @return self + */ + public function setMessage($message) + { + if (is_null($message)) { + throw new \InvalidArgumentException('non-nullable message cannot be null'); + } + $this->container['message'] = $message; + + return $this; + } + + /** + * Gets status + * + * @return bool|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param bool|null $status status + * + * @return self + */ + public function setStatus($status) + { + if (is_null($status)) { + throw new \InvalidArgumentException('non-nullable status cannot be null'); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets data + * + * @return \Convoy\Client\Model\ModelsEndpointPeriodFailureRate[]|null + */ + public function getData() + { + return $this->container['data']; + } + + /** + * Sets data + * + * @param \Convoy\Client\Model\ModelsEndpointPeriodFailureRate[]|null $data data + * + * @return self + */ + public function setData($data) + { + if (is_null($data)) { + throw new \InvalidArgumentException('non-nullable data cannot be null'); + } + $this->container['data'] = $data; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/src/Client/Model/ModelsEndpointPeriodFailureRate.php b/src/Client/Model/ModelsEndpointPeriodFailureRate.php new file mode 100644 index 0000000..ddf3955 --- /dev/null +++ b/src/Client/Model/ModelsEndpointPeriodFailureRate.php @@ -0,0 +1,546 @@ + + */ +class ModelsEndpointPeriodFailureRate implements ModelInterface, ArrayAccess, \JsonSerializable +{ + public const DISCRIMINATOR = null; + + /** + * The original name of the model. + * + * @var string + */ + protected static $openAPIModelName = 'models.EndpointPeriodFailureRate'; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPITypes = [ + 'failure_count' => 'int', + 'period_failure_rate' => 'float', + 'retry_count' => 'int', + 'success_count' => 'int', + 'uid' => 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ + protected static $openAPIFormats = [ + 'failure_count' => null, + 'period_failure_rate' => null, + 'retry_count' => null, + 'success_count' => null, + 'uid' => null + ]; + + /** + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ + protected static array $openAPINullables = [ + 'failure_count' => false, + 'period_failure_rate' => false, + 'retry_count' => false, + 'success_count' => false, + 'uid' => false + ]; + + /** + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ + protected array $openAPINullablesSetToNull = []; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of nullable properties + * + * @return array + */ + protected static function openAPINullables(): array + { + return self::$openAPINullables; + } + + /** + * Array of nullable field names deliberately set to null + * + * @return boolean[] + */ + private function getOpenAPINullablesSetToNull(): array + { + return $this->openAPINullablesSetToNull; + } + + /** + * Setter - Array of nullable field names deliberately set to null + * + * @param boolean[] $openAPINullablesSetToNull + */ + private function setOpenAPINullablesSetToNull(array $openAPINullablesSetToNull): void + { + $this->openAPINullablesSetToNull = $openAPINullablesSetToNull; + } + + /** + * Checks if a property is nullable + * + * @param string $property + * @return bool + */ + public static function isNullable(string $property): bool + { + return self::openAPINullables()[$property] ?? false; + } + + /** + * Checks if a nullable property is set to null. + * + * @param string $property + * @return bool + */ + public function isNullableSetToNull(string $property): bool + { + return in_array($property, $this->getOpenAPINullablesSetToNull(), true); + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'failure_count' => 'failure_count', + 'period_failure_rate' => 'period_failure_rate', + 'retry_count' => 'retry_count', + 'success_count' => 'success_count', + 'uid' => 'uid' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'failure_count' => 'setFailureCount', + 'period_failure_rate' => 'setPeriodFailureRate', + 'retry_count' => 'setRetryCount', + 'success_count' => 'setSuccessCount', + 'uid' => 'setUid' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'failure_count' => 'getFailureCount', + 'period_failure_rate' => 'getPeriodFailureRate', + 'retry_count' => 'getRetryCount', + 'success_count' => 'getSuccessCount', + 'uid' => 'getUid' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[]|null $data Associated array of property values + * initializing the model + */ + public function __construct(?array $data = null) + { + $this->setIfExists('failure_count', $data ?? [], null); + $this->setIfExists('period_failure_rate', $data ?? [], null); + $this->setIfExists('retry_count', $data ?? [], null); + $this->setIfExists('success_count', $data ?? [], null); + $this->setIfExists('uid', $data ?? [], null); + } + + /** + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ + private function setIfExists(string $variableName, array $fields, $defaultValue): void + { + if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { + $this->openAPINullablesSetToNull[] = $variableName; + } + + $this->container[$variableName] = $fields[$variableName] ?? $defaultValue; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets failure_count + * + * @return int|null + */ + public function getFailureCount() + { + return $this->container['failure_count']; + } + + /** + * Sets failure_count + * + * @param int|null $failure_count failure_count + * + * @return self + */ + public function setFailureCount($failure_count) + { + if (is_null($failure_count)) { + throw new \InvalidArgumentException('non-nullable failure_count cannot be null'); + } + $this->container['failure_count'] = $failure_count; + + return $this; + } + + /** + * Gets period_failure_rate + * + * @return float|null + */ + public function getPeriodFailureRate() + { + return $this->container['period_failure_rate']; + } + + /** + * Sets period_failure_rate + * + * @param float|null $period_failure_rate period_failure_rate + * + * @return self + */ + public function setPeriodFailureRate($period_failure_rate) + { + if (is_null($period_failure_rate)) { + throw new \InvalidArgumentException('non-nullable period_failure_rate cannot be null'); + } + $this->container['period_failure_rate'] = $period_failure_rate; + + return $this; + } + + /** + * Gets retry_count + * + * @return int|null + */ + public function getRetryCount() + { + return $this->container['retry_count']; + } + + /** + * Sets retry_count + * + * @param int|null $retry_count retry_count + * + * @return self + */ + public function setRetryCount($retry_count) + { + if (is_null($retry_count)) { + throw new \InvalidArgumentException('non-nullable retry_count cannot be null'); + } + $this->container['retry_count'] = $retry_count; + + return $this; + } + + /** + * Gets success_count + * + * @return int|null + */ + public function getSuccessCount() + { + return $this->container['success_count']; + } + + /** + * Sets success_count + * + * @param int|null $success_count success_count + * + * @return self + */ + public function setSuccessCount($success_count) + { + if (is_null($success_count)) { + throw new \InvalidArgumentException('non-nullable success_count cannot be null'); + } + $this->container['success_count'] = $success_count; + + return $this; + } + + /** + * Gets uid + * + * @return string|null + */ + public function getUid() + { + return $this->container['uid']; + } + + /** + * Sets uid + * + * @param string|null $uid uid + * + * @return self + */ + public function setUid($uid) + { + if (is_null($uid)) { + throw new \InvalidArgumentException('non-nullable uid cannot be null'); + } + $this->container['uid'] = $uid; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer|string $offset Offset + * + * @return boolean + */ + public function offsetExists(mixed $offset): bool + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer|string $offset Offset + * + * @return mixed|null + */ + #[\ReturnTypeWillChange] + public function offsetGet(mixed $offset) + { + return $this->container[$offset] ?? null; + } + + /** + * Sets value based on offset. + * + * @param int|null $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + public function offsetSet($offset, $value): void + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer|string $offset Offset + * + * @return void + */ + public function offsetUnset(mixed $offset): void + { + unset($this->container[$offset]); + } + + /** + * Serializes the object to a value that can be serialized natively by json_encode(). + * @link https://www.php.net/manual/en/jsonserializable.jsonserialize.php + * + * @return mixed Returns data which can be serialized by json_encode(), which is a value + * of any type other than a resource. + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return ObjectSerializer::sanitizeForSerialization($this); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + +