From 414893c688fd871983187d8457aef6dc755a4deb Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 28 May 2025 06:41:08 +0000 Subject: [PATCH 1/6] feat: Initial ArgoCD PHP Client Structure and Core Services This commit introduces the initial structure and core functionality for a new PHP client for the ArgoCD API, refactored from the KnpLabs GitHub API client. Key changes and accomplishments so far: 1. **Project Setup:** * Established new directory structure under `argocd-php-client/src/ArgoCD/`. * Initialized `composer.json` with PSR-4 autoloading and base dependencies. 2. **Core Client (`ArgoCD/Client.php`):** * Adapted from the GitHub client. * Handles ArgoCD server URL. * `authenticate()` method implemented to either: * Fetch a bearer token from `/api/v1/session` using username/password via `SessionService`. * Use a provided bearer token directly. * `api()` factory method for accessing service classes. 3. **HTTP Layer:** * `HttpClient/Builder.php` adapted for constructing the HTTP client. * `HttpClient/Plugin/Authentication.php` implemented for bearer token injection. * `HttpClient/Plugin/ArgoCdExceptionThrower.php` for basic error handling. * `Api/AbstractApi.php` provides base HTTP request methods. * `HttpClient/Message/ResponseMediator.php` for processing JSON responses. 4. **Exception Handling:** * Custom exception classes created in `ArgoCD/Exception/`. * `ArgoCdExceptionThrower` parses JSON error responses from ArgoCD. 5. **Models (`ArgoCD/Model/`):** * Initial set of PHP model classes generated based on ArgoCD OpenAPI definitions for session and account services (e.g., `AccountAccount`, `SessionSessionResponse`, `V1Time`). 6. **API Services (`ArgoCD/Api/`):** * `SessionService.php` implemented with `create` (login), `delete` (logout), and `getUserInfo` methods. * `AccountService.php` implemented with methods for account listing, password updates, and token management. * Placeholders for `ApplicationService.php`. This work lays the foundation for a comprehensive ArgoCD PHP client. Further development will involve implementing remaining API services and models, writing unit tests, and updating documentation. --- argocd-php-client/composer.json | 33 +++ .../src/ArgoCD/Api/AbstractApi.php | 211 ++++++++++++++++ .../src/ArgoCD/Api/AccountService.php | 124 ++++++++++ .../src/ArgoCD/Api/ApplicationService.php | 7 + .../src/ArgoCD/Api/SessionService.php | 62 +++++ argocd-php-client/src/ArgoCD/AuthMethod.php | 7 + argocd-php-client/src/ArgoCD/Client.php | 227 ++++++++++++++++++ .../Exception/BadMethodCallException.php | 4 + .../ArgoCD/Exception/ExceptionInterface.php | 4 + .../Exception/InvalidArgumentException.php | 4 + .../src/ArgoCD/Exception/RuntimeException.php | 4 + .../Exception/ValidationFailedException.php | 18 ++ .../src/ArgoCD/HttpClient/Builder.php | 176 ++++++++++++++ .../HttpClient/Message/ResponseMediator.php | 47 ++++ .../Plugin/ArgoCdExceptionThrower.php | 38 +++ .../HttpClient/Plugin/Authentication.php | 28 +++ .../src/ArgoCD/Model/AccountAccount.php | 55 +++++ .../src/ArgoCD/Model/AccountAccountsList.php | 39 +++ .../src/ArgoCD/Model/AccountCanIResponse.php | 28 +++ .../Model/AccountCreateTokenRequest.php | 82 +++++++ .../Model/AccountCreateTokenResponse.php | 17 ++ .../src/ArgoCD/Model/AccountEmptyResponse.php | 15 ++ .../src/ArgoCD/Model/AccountToken.php | 51 ++++ .../Model/AccountUpdatePasswordRequest.php | 64 +++++ .../Model/AccountUpdatePasswordResponse.php | 16 ++ .../src/ArgoCD/Model/RuntimeError.php | 42 ++++ .../Model/SessionGetUserInfoResponse.php | 44 ++++ .../Model/SessionSessionCreateRequest.php | 66 +++++ .../ArgoCD/Model/SessionSessionResponse.php | 17 ++ argocd-php-client/src/ArgoCD/Model/V1Time.php | 35 +++ 30 files changed, 1565 insertions(+) create mode 100644 argocd-php-client/composer.json create mode 100644 argocd-php-client/src/ArgoCD/Api/AbstractApi.php create mode 100644 argocd-php-client/src/ArgoCD/Api/AccountService.php create mode 100644 argocd-php-client/src/ArgoCD/Api/ApplicationService.php create mode 100644 argocd-php-client/src/ArgoCD/Api/SessionService.php create mode 100644 argocd-php-client/src/ArgoCD/AuthMethod.php create mode 100644 argocd-php-client/src/ArgoCD/Client.php create mode 100644 argocd-php-client/src/ArgoCD/Exception/BadMethodCallException.php create mode 100644 argocd-php-client/src/ArgoCD/Exception/ExceptionInterface.php create mode 100644 argocd-php-client/src/ArgoCD/Exception/InvalidArgumentException.php create mode 100644 argocd-php-client/src/ArgoCD/Exception/RuntimeException.php create mode 100644 argocd-php-client/src/ArgoCD/Exception/ValidationFailedException.php create mode 100644 argocd-php-client/src/ArgoCD/HttpClient/Builder.php create mode 100644 argocd-php-client/src/ArgoCD/HttpClient/Message/ResponseMediator.php create mode 100644 argocd-php-client/src/ArgoCD/HttpClient/Plugin/ArgoCdExceptionThrower.php create mode 100644 argocd-php-client/src/ArgoCD/HttpClient/Plugin/Authentication.php create mode 100644 argocd-php-client/src/ArgoCD/Model/AccountAccount.php create mode 100644 argocd-php-client/src/ArgoCD/Model/AccountAccountsList.php create mode 100644 argocd-php-client/src/ArgoCD/Model/AccountCanIResponse.php create mode 100644 argocd-php-client/src/ArgoCD/Model/AccountCreateTokenRequest.php create mode 100644 argocd-php-client/src/ArgoCD/Model/AccountCreateTokenResponse.php create mode 100644 argocd-php-client/src/ArgoCD/Model/AccountEmptyResponse.php create mode 100644 argocd-php-client/src/ArgoCD/Model/AccountToken.php create mode 100644 argocd-php-client/src/ArgoCD/Model/AccountUpdatePasswordRequest.php create mode 100644 argocd-php-client/src/ArgoCD/Model/AccountUpdatePasswordResponse.php create mode 100644 argocd-php-client/src/ArgoCD/Model/RuntimeError.php create mode 100644 argocd-php-client/src/ArgoCD/Model/SessionGetUserInfoResponse.php create mode 100644 argocd-php-client/src/ArgoCD/Model/SessionSessionCreateRequest.php create mode 100644 argocd-php-client/src/ArgoCD/Model/SessionSessionResponse.php create mode 100644 argocd-php-client/src/ArgoCD/Model/V1Time.php diff --git a/argocd-php-client/composer.json b/argocd-php-client/composer.json new file mode 100644 index 00000000000..30e4fdc157e --- /dev/null +++ b/argocd-php-client/composer.json @@ -0,0 +1,33 @@ +{ + "name": "your-vendor/argocd-php-client", + "description": "A PHP client for the ArgoCD API", + "type": "library", + "license": "MIT", + "authors": [ + { + "name": "Your Name", + "email": "your.email@example.com" + } + ], + "require": { + "php": ">=7.4 || ^8.0", + "php-http/client-common": "^2.3", + "php-http/discovery": "^1.12", + "psr/http-client-implementation": "^1.0", + "psr/http-factory-implementation": "^1.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "autoload": { + "psr-4": { + "ArgoCD\\": "src/ArgoCD/" + } + }, + "autoload-dev": { + "psr-4": { + "ArgoCD\\Tests\\": "tests/" + } + } +} diff --git a/argocd-php-client/src/ArgoCD/Api/AbstractApi.php b/argocd-php-client/src/ArgoCD/Api/AbstractApi.php new file mode 100644 index 00000000000..de44f1e687f --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Api/AbstractApi.php @@ -0,0 +1,211 @@ +client = $client; + } + + /** + * Get the client instance. + * + * @return Client + */ + protected function getClient(): Client + { + return $this->client; + } + + /** + * @return $this + */ + public function configure() + { + // Kept as a no-op or simple method returning $this + return $this; + } + + /** + * Send a GET request with query parameters. + * + * @param string $path Request path. + * @param array $parameters GET parameters. + * @param array $requestHeaders Request Headers. + * + * @return array|string + */ + protected function get(string $path, array $parameters = [], array $requestHeaders = []) + { + // Removed $perPage logic + // Removed 'ref' parameter logic as it's GitHub specific + + if (count($parameters) > 0) { + $path .= '?'.http_build_query($parameters, '', '&', PHP_QUERY_RFC3986); + } + + $response = $this->client->getHttpClient()->get($path, $requestHeaders); + + return ResponseMediator::getContent($response); + } + + /** + * Send a HEAD request with query parameters. + * + * @param string $path Request path. + * @param array $parameters HEAD parameters. + * @param array $requestHeaders Request headers. + * + * @return ResponseInterface + */ + protected function head(string $path, array $parameters = [], array $requestHeaders = []): ResponseInterface + { + // Removed 'ref' parameter logic + $queryString = ''; + if (count($parameters) > 0) { + $queryString = '?'.http_build_query($parameters, '', '&', PHP_QUERY_RFC3986); + } + return $this->client->getHttpClient()->head($path.$queryString, $requestHeaders); + } + + /** + * Send a POST request with JSON-encoded parameters. + * + * @param string $path Request path. + * @param array $parameters POST parameters to be JSON encoded. + * @param array $requestHeaders Request headers. + * + * @return array|string + */ + protected function post(string $path, array $parameters = [], array $requestHeaders = []) + { + return $this->postRaw( + $path, + $this->createJsonBody($parameters), + $requestHeaders + ); + } + + /** + * Send a POST request with raw data. + * + * @param string $path Request path. + * @param string|null $body Request body. + * @param array $requestHeaders Request headers. + * + * @return array|string + */ + protected function postRaw(string $path, $body, array $requestHeaders = []) + { + $response = $this->client->getHttpClient()->post( + $path, + $requestHeaders, + $body + ); + + return ResponseMediator::getContent($response); + } + + /** + * Send a PATCH request with JSON-encoded parameters. + * + * @param string $path Request path. + * @param array $parameters POST parameters to be JSON encoded. + * @param array $requestHeaders Request headers. + * + * @return array|string + */ + protected function patch(string $path, array $parameters = [], array $requestHeaders = []) + { + $response = $this->client->getHttpClient()->patch( + $path, + $requestHeaders, + $this->createJsonBody($parameters) + ); + + return ResponseMediator::getContent($response); + } + + /** + * Send a PUT request with JSON-encoded parameters. + * + * @param string $path Request path. + * @param array $parameters POST parameters to be JSON encoded. + * @param array $requestHeaders Request headers. + * + * @return array|string + */ + protected function put(string $path, array $parameters = [], array $requestHeaders = []) + { + $response = $this->client->getHttpClient()->put( + $path, + $requestHeaders, + $this->createJsonBody($parameters) + ); + + return ResponseMediator::getContent($response); + } + + /** + * Send a DELETE request with JSON-encoded parameters. + * + * @param string $path Request path. + * @param array $parameters POST parameters to be JSON encoded. + * @param array $requestHeaders Request headers. + * + * @return array|string + */ + protected function delete(string $path, array $parameters = [], array $requestHeaders = []) + { + // ArgoCD DELETE requests might not always have a body. + // If parameters are provided, assume they are for the body. + // If not, send null as the body. + $body = null; + if (count($parameters) > 0) { + $body = $this->createJsonBody($parameters); + } + + $response = $this->client->getHttpClient()->delete( + $path, + $requestHeaders, + $body + ); + + return ResponseMediator::getContent($response); + } + + /** + * Create a JSON encoded version of an array of parameters. + * + * @param array $parameters Request parameters + * + * @return string|null + */ + protected function createJsonBody(array $parameters): ?string + { + // Ensure empty array results in null, not "[]" for some ArgoCD endpoints if they expect no body. + // However, for POST/PUT/PATCH, an empty JSON object "{}" might be valid. + // The original behavior is to return null for empty arrays, which is generally fine. + return (count($parameters) === 0) ? null : json_encode($parameters, empty($parameters) ? JSON_FORCE_OBJECT : 0); + } +} diff --git a/argocd-php-client/src/ArgoCD/Api/AccountService.php b/argocd-php-client/src/ArgoCD/Api/AccountService.php new file mode 100644 index 00000000000..b48f83d3cba --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Api/AccountService.php @@ -0,0 +1,124 @@ +get('/api/v1/account'); + return new AccountAccountsList($responseArray); + } + + /** + * Corresponds to AccountService_CanI + * Checks if the current account has permission to perform an action. + * + * @param string $resource + * @param string $action + * @param string $subresource + * @return AccountCanIResponse + * @throws \ArgoCD\Exception\RuntimeException + */ + public function canI(string $resource, string $action, string $subresource): AccountCanIResponse + { + // The response for can-i is typically a raw string "yes" or "no". + // The AbstractApi::get method expects JSON. + // We need to handle this: either get() should allow raw responses, + // or this method needs to handle potential JSON decode errors if the response isn't JSON. + // For now, assuming get() returns the raw string if not JSON, + // and AccountCanIResponse constructor can handle it. + $response = $this->get(sprintf("/api/v1/account/can-i/%s/%s/%s", rawurlencode($resource), rawurlencode($action), rawurlencode($subresource))); + + // If $response is a string from get(), AccountCanIResponse constructor is designed to handle it. + // If $response is an array (e.g. {'value': 'yes'}), it also handles it. + return new AccountCanIResponse(is_array($response) ? $response : ['value' => $response]); + } + + /** + * Corresponds to AccountService_UpdatePassword + * Updates the password for the current account or a specified account. + * + * @param string $name The name of the account to update. If updating the current user's password, this might be the username. + * @param string $currentPassword The current password. + * @param string $newPassword The new password. + * @return AccountUpdatePasswordResponse + * @throws \ArgoCD\Exception\RuntimeException + */ + public function updatePassword(string $name, string $currentPassword, string $newPassword): AccountUpdatePasswordResponse + { + $requestModel = new AccountUpdatePasswordRequest(); + $requestModel->setName($name); // Name of the account being updated + $requestModel->setCurrentPassword($currentPassword); + $requestModel->setNewPassword($newPassword); + + $responseArray = $this->put('/api/v1/account/password', $requestModel->toArray()); + return new AccountUpdatePasswordResponse($responseArray ?: []); // Response might be empty + } + + /** + * Corresponds to AccountService_GetAccount + * Gets information about a specific account. + * + * @param string $name The name of the account. + * @return AccountAccount + * @throws \ArgoCD\Exception\RuntimeException + */ + public function getAccount(string $name): AccountAccount + { + $responseArray = $this->get(sprintf("/api/v1/account/%s", rawurlencode($name))); + return new AccountAccount($responseArray); + } + + /** + * Corresponds to AccountService_CreateToken + * Creates a new token for the specified account. + * + * @param string $accountName The name of the account. + * @param string $tokenId The desired ID/name for the token. + * @param string $tokenDescription A description for the token. + * @param string|null $expiresIn Duration string for token expiration (e.g., "30d", "24h", "0" for non-expiring). + * @return AccountCreateTokenResponse + * @throws \ArgoCD\Exception\RuntimeException + */ + public function createToken(string $accountName, string $tokenId, string $tokenDescription, ?string $expiresIn = "0"): AccountCreateTokenResponse + { + $requestModel = new AccountCreateTokenRequest(); + $requestModel->setId($tokenId); // This 'id' is the token's identifier + $requestModel->setName($tokenDescription); // This 'name' is the token's description + $requestModel->setExpiresIn($expiresIn); + + $responseArray = $this->post(sprintf("/api/v1/account/%s/token", rawurlencode($accountName)), $requestModel->toArray()); + return new AccountCreateTokenResponse($responseArray); + } + + /** + * Corresponds to AccountService_DeleteToken + * Deletes a token for the specified account. + * + * @param string $accountName The name of the account. + * @param string $tokenId The ID of the token to delete. + * @return AccountEmptyResponse + * @throws \ArgoCD\Exception\RuntimeException + */ + public function deleteToken(string $accountName, string $tokenId): AccountEmptyResponse + { + $responseArray = $this->delete(sprintf("/api/v1/account/%s/token/%s", rawurlencode($accountName), rawurlencode($tokenId))); + return new AccountEmptyResponse($responseArray ?: []); // Response is typically empty + } +} diff --git a/argocd-php-client/src/ArgoCD/Api/ApplicationService.php b/argocd-php-client/src/ArgoCD/Api/ApplicationService.php new file mode 100644 index 00000000000..1ca5658228b --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Api/ApplicationService.php @@ -0,0 +1,7 @@ +setUsername($username); + $requestModel->setPassword($password); + + $responseArray = $this->post('/api/v1/session', $requestModel->toArray()); + + return new SessionSessionResponse($responseArray); + } + + /** + * Corresponds to SessionService_Delete + * Deletes the current session. + * + * @return SessionSessionResponse + * @throws \ArgoCD\Exception\RuntimeException + */ + public function delete(): SessionSessionResponse + { + // The OpenAPI spec for delete /api/v1/session indicates a 200 response with sessionSessionResponse. + // This is unusual for a DELETE operation (typically 204 No Content or an empty body), + // but we will follow the spec. + $responseArray = $this->delete('/api/v1/session'); + + // If the response is truly empty (which is more typical for DELETE), + // instantiating SessionSessionResponse with an empty array will result in a model with a null token. + return new SessionSessionResponse($responseArray ?: []); + } + + /** + * Corresponds to SessionService_GetUserInfo + * Gets information about the current user. + * + * @return SessionGetUserInfoResponse + * @throws \ArgoCD\Exception\RuntimeException + */ + public function getUserInfo(): SessionGetUserInfoResponse + { + $responseArray = $this->get('/api/v1/session/userinfo'); + + return new SessionGetUserInfoResponse($responseArray); + } +} diff --git a/argocd-php-client/src/ArgoCD/AuthMethod.php b/argocd-php-client/src/ArgoCD/AuthMethod.php new file mode 100644 index 00000000000..dc2ceb0c38b --- /dev/null +++ b/argocd-php-client/src/ArgoCD/AuthMethod.php @@ -0,0 +1,7 @@ +responseHistory = new History(); + $this->httpClientBuilder = $builder = $httpClientBuilder ?? new Builder(); + + $builder->addPlugin(new ExceptionThrower()); + $builder->addPlugin(new Plugin\HistoryPlugin($this->responseHistory)); + $builder->addPlugin(new Plugin\RedirectPlugin()); + + if (null === $serverUrl) { + throw new InvalidArgumentException('Server URL is required to instantiate the ArgoCD client.'); + } + + $uri = Psr17FactoryDiscovery::findUriFactory()->createUri($serverUrl); + $builder->addPlugin(new Plugin\AddHostPlugin($uri)); + $builder->addPlugin(new Plugin\PathPrepend('/api/v1')); + + $builder->addPlugin(new Plugin\HeaderDefaultsPlugin([ + 'User-Agent' => 'argocd-php-client (https://github.com/your-vendor/argocd-php-client)', + 'Accept' => 'application/json', + ])); + } + + /** + * Create a ArgoCD\Client using a HTTP client. + * + * @param ClientInterface $httpClient + * @param string|null $serverUrl + * @return Client + */ + public static function createWithHttpClient(ClientInterface $httpClient, ?string $serverUrl = null): self + { + $builder = new Builder($httpClient); + // Allow serverUrl to be passed here for consistency, or ensure it's set later. + if ($serverUrl === null) { + // Or throw an exception if serverUrl is strictly required at this point + // For now, assuming it can be null and might be set via constructor or setServerUrl + } + return new self($serverUrl, $builder); + } + + /** + * @param string $name + * + * @throws InvalidArgumentException + * + * @return AbstractApi + */ + public function api($name): AbstractApi + { + switch (strtolower($name)) { + case 'session': + case 'sessionservice': + $api = new Api\SessionService($this); + break; + case 'application': + case 'applicationservice': + $api = new Api\ApplicationService($this); + break; + case 'account': + case 'accountservice': + $api = new Api\AccountService($this); + break; + default: + throw new InvalidArgumentException(sprintf('Undefined api instance called: "%s"', $name)); + } + + return $api; + } + + /** + * Authenticate a user for all next requests. + * + * @param string $usernameOrToken ArgoCD username or a pre-existing Bearer token + * @param string|null $password ArgoCD password (if username is provided) + * + * @throws InvalidArgumentException If username/password authentication fails or token is invalid. + * @throws \ArgoCD\Exception\RuntimeException For API errors. + * + * @return void + */ + public function authenticate(string $usernameOrToken, ?string $password = null): void + { + $this->getHttpClientBuilder()->removePlugin(Authentication::class); // Remove any existing auth plugin + + if ($password !== null) { + // Username/password authentication + $sessionService = new SessionService($this); + $sessionResponse = $sessionService->create($usernameOrToken, $password); + $this->token = $sessionResponse->getToken(); + + if (empty($this->token)) { + throw new InvalidArgumentException('Authentication failed: Could not retrieve token with the provided username and password.'); + } + } else { + // Direct token authentication + $this->token = $usernameOrToken; + } + + if (empty($this->token)) { + throw new InvalidArgumentException('Authentication failed: Token cannot be empty.'); + } + + $this->getHttpClientBuilder()->addPlugin(new Authentication($this->token, AuthMethod::BEARER_TOKEN)); + } + + /** + * Get the currently stored token. + * + * @return string|null + */ + public function getToken(): ?string + { + return $this->token; + } + + /** + * Sets the URL of your ArgoCD API server instance. + * + * @param string $serverUrl URL of the API in the form of http(s)://hostname or http(s)://hostname/api/v1 + * + * @return void + */ + public function setServerUrl(string $serverUrl): void + { + $builder = $this->getHttpClientBuilder(); + $builder->removePlugin(Plugin\AddHostPlugin::class); + $builder->removePlugin(Plugin\PathPrepend::class); + + $uri = Psr17FactoryDiscovery::findUriFactory()->createUri($serverUrl); + $builder->addPlugin(new Plugin\AddHostPlugin($uri)); + + if (strpos($serverUrl, '/api/v1') === false) { + $builder->addPlugin(new Plugin\PathPrepend('/api/v1')); + } + } + + /** + * @param string $name + * @param array $args + * + * @return AbstractApi + */ + public function __call($name, $args): AbstractApi + { + try { + return $this->api($name); + } catch (InvalidArgumentException $e) { + throw new BadMethodCallException(sprintf('Undefined method called: "%s"', $name)); + } + } + + /** + * @return null|ResponseInterface + */ + public function getLastResponse(): ?ResponseInterface + { + return $this->responseHistory->getLastResponse(); + } + + /** + * @return HttpMethodsClientInterface + */ + public function getHttpClient(): HttpMethodsClientInterface + { + return $this->getHttpClientBuilder()->getHttpClient(); + } + + /** + * @return Builder + */ + protected function getHttpClientBuilder(): Builder + { + return $this->httpClientBuilder; + } +} diff --git a/argocd-php-client/src/ArgoCD/Exception/BadMethodCallException.php b/argocd-php-client/src/ArgoCD/Exception/BadMethodCallException.php new file mode 100644 index 00000000000..1a34b298614 --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Exception/BadMethodCallException.php @@ -0,0 +1,4 @@ +errors = $errors; + } + + public function getErrors(): array + { + return $this->errors; + } +} diff --git a/argocd-php-client/src/ArgoCD/HttpClient/Builder.php b/argocd-php-client/src/ArgoCD/HttpClient/Builder.php new file mode 100644 index 00000000000..83e245018bf --- /dev/null +++ b/argocd-php-client/src/ArgoCD/HttpClient/Builder.php @@ -0,0 +1,176 @@ +httpClient = $httpClient ?? Psr18ClientDiscovery::find(); + $this->requestFactory = $requestFactory ?? Psr17FactoryDiscovery::findRequestFactory(); + $this->streamFactory = $streamFactory ?? Psr17FactoryDiscovery::findStreamFactory(); + } + + /** + * @return HttpMethodsClientInterface + */ + public function getHttpClient(): HttpMethodsClientInterface + { + if ($this->httpClientModified) { + $this->httpClientModified = false; + + $plugins = $this->plugins; + // Removed cache plugin logic + + $this->pluginClient = new HttpMethodsClient( + (new PluginClientFactory())->createClient($this->httpClient, $plugins), + $this->requestFactory, + $this->streamFactory + ); + } + + return $this->pluginClient; + } + + /** + * Add a new plugin to the end of the plugin chain. + * + * @param Plugin $plugin + * + * @return void + */ + public function addPlugin(Plugin $plugin): void + { + $this->plugins[] = $plugin; + $this->httpClientModified = true; + } + + /** + * Remove a plugin by its fully qualified class name (FQCN). + * + * @param string $fqcn + * + * @return void + */ + public function removePlugin(string $fqcn): void + { + foreach ($this->plugins as $idx => $plugin) { + if ($plugin instanceof $fqcn) { + unset($this->plugins[$idx]); + $this->httpClientModified = true; + } + } + } + + /** + * Clears used headers. + * + * @return void + */ + public function clearHeaders(): void + { + $this->headers = []; + + $this->removePlugin(Plugin\HeaderAppendPlugin::class); + // Ensure HeaderAppendPlugin is added only if there are headers to append. + // Or, rely on HeaderDefaultsPlugin in Client.php for default headers. + // For now, mimicking the original behavior of always adding it. + $this->addPlugin(new Plugin\HeaderAppendPlugin($this->headers)); + } + + /** + * @param array $headers + * + * @return void + */ + public function addHeaders(array $headers): void + { + $this->headers = array_merge($this->headers, $headers); + + $this->removePlugin(Plugin\HeaderAppendPlugin::class); + $this->addPlugin(new Plugin\HeaderAppendPlugin($this->headers)); + } + + /** + * @param string $header + * @param string $headerValue + * + * @return void + */ + public function addHeaderValue(string $header, string $headerValue): void + { + if (!isset($this->headers[$header])) { + $this->headers[$header] = $headerValue; + } else { + $this->headers[$header] = array_merge((array) $this->headers[$header], [$headerValue]); + } + + $this->removePlugin(Plugin\HeaderAppendPlugin::class); + $this->addPlugin(new Plugin\HeaderAppendPlugin($this->headers)); + } +} diff --git a/argocd-php-client/src/ArgoCD/HttpClient/Message/ResponseMediator.php b/argocd-php-client/src/ArgoCD/HttpClient/Message/ResponseMediator.php new file mode 100644 index 00000000000..37c6147ebb4 --- /dev/null +++ b/argocd-php-client/src/ArgoCD/HttpClient/Message/ResponseMediator.php @@ -0,0 +1,47 @@ +getBody()->__toString(); + // ArgoCD API primarily uses JSON. + if (strpos($response->getHeaderLine('Content-Type'), 'application/json') === 0) { + $content = json_decode($body, true); + if (JSON_ERROR_NONE === json_last_error()) { + return $content; + } + } + + return $body; // Return raw body if not JSON or if JSON decoding fails + } + + /** + * Get the value for a single header. + * (Kept as it might be useful, though ArgoCD pagination is typically cursor-based or not via Link headers) + * + * @param ResponseInterface $response + * @param string $name + * + * @return string|null + */ + public static function getHeader(ResponseInterface $response, string $name): ?string + { + $headers = $response->getHeader($name); + + return array_shift($headers); + } + + // Removed getPagination() and getApiLimit() as they are GitHub specific. + // ArgoCD error handling and rate limiting (if any) will be handled differently. +} diff --git a/argocd-php-client/src/ArgoCD/HttpClient/Plugin/ArgoCdExceptionThrower.php b/argocd-php-client/src/ArgoCD/HttpClient/Plugin/ArgoCdExceptionThrower.php new file mode 100644 index 00000000000..3f15abcfc27 --- /dev/null +++ b/argocd-php-client/src/ArgoCD/HttpClient/Plugin/ArgoCdExceptionThrower.php @@ -0,0 +1,38 @@ +then(function (ResponseInterface $response) { + if ($response->getStatusCode() < 400) { + return $response; + } + + $content = ResponseMediator::getContent($response); + + if (is_array($content) && isset($content['error'])) { + $errorMessage = $content['message'] ?? ($content['error'] ?? $response->getReasonPhrase()); + $errorCode = $content['code'] ?? $response->getStatusCode(); + + // Example: Check for a specific type of error if ArgoCD provides such details + // For instance, if a 400 error with a specific 'error' field means validation failed + if ($response->getStatusCode() == 400 && str_contains(strtolower($errorMessage), 'validation')) { + throw new ValidationFailedException('Validation Failed: ' . $errorMessage, $response->getStatusCode(), null, $content['details'] ?? []); + } + + throw new RuntimeException(sprintf('Error %s: %s', $errorCode, $errorMessage), $response->getStatusCode()); + } + + throw new RuntimeException(sprintf('HTTP error %d: %s', $response->getStatusCode(), $response->getReasonPhrase()), $response->getStatusCode()); + }); + } +} diff --git a/argocd-php-client/src/ArgoCD/HttpClient/Plugin/Authentication.php b/argocd-php-client/src/ArgoCD/HttpClient/Plugin/Authentication.php new file mode 100644 index 00000000000..5472f950473 --- /dev/null +++ b/argocd-php-client/src/ArgoCD/HttpClient/Plugin/Authentication.php @@ -0,0 +1,28 @@ +token = $token; + $this->authMethod = $method; + } + + public function handleRequest(\Psr\Http\Message\RequestInterface $request, callable $next, callable $first): \Http\Promise\Promise + { + if ($this->authMethod === AuthMethod::BEARER_TOKEN) { + $request = $request->withHeader('Authorization', 'Bearer ' . $this->token); + } + // Potentially add other auth methods here if ArgoCD supports them + + return $next($request); + } +} diff --git a/argocd-php-client/src/ArgoCD/Model/AccountAccount.php b/argocd-php-client/src/ArgoCD/Model/AccountAccount.php new file mode 100644 index 00000000000..cf035792435 --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Model/AccountAccount.php @@ -0,0 +1,55 @@ +capabilities = $data['capabilities']; + } + $this->enabled = isset($data['enabled']) ? (bool)$data['enabled'] : null; + $this->name = $data['name'] ?? null; + + if (isset($data['tokens']) && is_array($data['tokens'])) { + foreach ($data['tokens'] as $tokenData) { + if (is_array($tokenData)) { + $this->tokens[] = new AccountToken($tokenData); + } + } + } + } + + /** + * @return string[]|null + */ + public function getCapabilities(): ?array + { + return $this->capabilities; + } + + public function isEnabled(): ?bool + { + return $this->enabled; + } + + public function getName(): ?string + { + return $this->name; + } + + /** + * @return AccountToken[] + */ + public function getTokens(): array + { + return $this->tokens; + } +} diff --git a/argocd-php-client/src/ArgoCD/Model/AccountAccountsList.php b/argocd-php-client/src/ArgoCD/Model/AccountAccountsList.php new file mode 100644 index 00000000000..bca0a47f53f --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Model/AccountAccountsList.php @@ -0,0 +1,39 @@ +items[] = new AccountAccount($accountData); + } + } + } + // Initialize metadata if present, e.g.: + // if (isset($data['metadata'])) { + // $this->metadata = new V1ListMeta($data['metadata']); + // } + } + + /** + * @return AccountAccount[] + */ + public function getItems(): array + { + return $this->items; + } + + // Getter for metadata if added + // public function getMetadata(): ?V1ListMeta + // { + // return $this->metadata; + // } +} diff --git a/argocd-php-client/src/ArgoCD/Model/AccountCanIResponse.php b/argocd-php-client/src/ArgoCD/Model/AccountCanIResponse.php new file mode 100644 index 00000000000..52b96bb77f9 --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Model/AccountCanIResponse.php @@ -0,0 +1,28 @@ + 'the_string_response'] or the direct string. + if (isset($data['value'])) { + $this->value = (string)$data['value']; + } elseif (is_string($data)) { // Handle direct string response + $this->value = $data; + } else if (count($data) === 1 && is_string(current($data))) { // Handle if wrapped in an array with one string value + $this->value = current($data); + } + + } + + public function getValue(): ?string + { + return $this->value; + } +} diff --git a/argocd-php-client/src/ArgoCD/Model/AccountCreateTokenRequest.php b/argocd-php-client/src/ArgoCD/Model/AccountCreateTokenRequest.php new file mode 100644 index 00000000000..bde59a97eb0 --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Model/AccountCreateTokenRequest.php @@ -0,0 +1,82 @@ +expiresIn = $data['expiresIn'] ?? null; + $this->id = $data['id'] ?? null; + $this->name = $data['name'] ?? null; + } + + public function setExpiresIn(?string $expiresIn): self + { + $this->expiresIn = $expiresIn; + return $this; + } + + public function setId(string $id): self + { + $this->id = $id; + return $this; + } + + public function setName(string $name): self + { + $this->name = $name; + return $this; + } + + public function getExpiresIn(): ?string + { + return $this->expiresIn; + } + + public function getId(): ?string + { + return $this->id; + } + + public function getName(): ?string + { + return $this->name; + } + + public function toArray(): array + { + $payload = []; + // According to typical ArgoCD API usage for creating tokens, + // 'name' in the path is the account name. + // 'id' in the body is the token's identifier/name. + // 'expiresIn' in the body is the token's expiration duration. + // The 'name' field in the body for this request is often used as the token's description or friendly name. + // The OpenAPI spec has 'name' in the body, which is slightly ambiguous. + // Let's assume 'id' is the token's unique ID, and 'name' (body) is a display name. + // If 'name' from the constructor is meant for the account, it shouldn't be in this payload. + // The method signature for createToken in service will have $accountName for the path. + + if ($this->id !== null) { + // This 'id' in the request body is often used as the token's name or identifier. + // The API might also have a 'name' field for a description. + // The OpenAPI spec is: properties: { expiresIn, id, name } + // Let's assume 'id' is the desired token ID, and 'name' is its description. + $payload['id'] = $this->id; + } + if ($this->name !== null) { + // This 'name' field is for the token's display name/description. + $payload['name'] = $this->name; + } + if ($this->expiresIn !== null) { + $payload['expiresIn'] = $this->expiresIn; + } else { + // Default to non-expiring if not specified, or API might require it + $payload['expiresIn'] = "0"; + } + return $payload; + } +} diff --git a/argocd-php-client/src/ArgoCD/Model/AccountCreateTokenResponse.php b/argocd-php-client/src/ArgoCD/Model/AccountCreateTokenResponse.php new file mode 100644 index 00000000000..2dd368342cc --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Model/AccountCreateTokenResponse.php @@ -0,0 +1,17 @@ +token = $data['token'] ?? null; + } + + public function getToken(): ?string + { + return $this->token; + } +} diff --git a/argocd-php-client/src/ArgoCD/Model/AccountEmptyResponse.php b/argocd-php-client/src/ArgoCD/Model/AccountEmptyResponse.php new file mode 100644 index 00000000000..c871dbf8db9 --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Model/AccountEmptyResponse.php @@ -0,0 +1,15 @@ +expiresAt = $data['expiresAt'] ?? null; + $this->id = $data['id'] ?? null; + $this->issuedAt = $data['issuedAt'] ?? null; + } + + public function getExpiresAt(): ?string + { + return $this->expiresAt; + } + + public function getId(): ?string + { + return $this->id; + } + + public function getIssuedAt(): ?string + { + return $this->issuedAt; + } + + // Optional: Convert expiresAt to DateTimeImmutable + public function getExpiresAtDateTime(): ?\DateTimeImmutable + { + if ($this->expiresAt === null) { + return null; + } + $dateTime = new \DateTimeImmutable(); + return $dateTime->setTimestamp((int)$this->expiresAt); + } + + // Optional: Convert issuedAt to DateTimeImmutable + public function getIssuedAtDateTime(): ?\DateTimeImmutable + { + if ($this->issuedAt === null) { + return null; + } + $dateTime = new \DateTimeImmutable(); + return $dateTime->setTimestamp((int)$this->issuedAt); + } +} diff --git a/argocd-php-client/src/ArgoCD/Model/AccountUpdatePasswordRequest.php b/argocd-php-client/src/ArgoCD/Model/AccountUpdatePasswordRequest.php new file mode 100644 index 00000000000..4b01a32297c --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Model/AccountUpdatePasswordRequest.php @@ -0,0 +1,64 @@ +currentPassword = $data['currentPassword'] ?? null; + $this->name = $data['name'] ?? null; + $this->newPassword = $data['newPassword'] ?? null; + } + + public function setCurrentPassword(string $currentPassword): self + { + $this->currentPassword = $currentPassword; + return $this; + } + + public function setName(string $name): self + { + $this->name = $name; + return $this; + } + + public function setNewPassword(string $newPassword): self + { + $this->newPassword = $newPassword; + return $this; + } + + public function getCurrentPassword(): ?string + { + return $this->currentPassword; + } + + public function getName(): ?string + { + return $this->name; + } + + public function getNewPassword(): ?string + { + return $this->newPassword; + } + + public function toArray(): array + { + $payload = []; + if ($this->currentPassword !== null) { + $payload['currentPassword'] = $this->currentPassword; + } + if ($this->name !== null) { + $payload['name'] = $this->name; + } + if ($this->newPassword !== null) { + $payload['newPassword'] = $this->newPassword; + } + return $payload; + } +} diff --git a/argocd-php-client/src/ArgoCD/Model/AccountUpdatePasswordResponse.php b/argocd-php-client/src/ArgoCD/Model/AccountUpdatePasswordResponse.php new file mode 100644 index 00000000000..f3765e1166e --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Model/AccountUpdatePasswordResponse.php @@ -0,0 +1,16 @@ +code = isset($data['code']) ? (int)$data['code'] : null; + $this->error = $data['error'] ?? null; + $this->message = $data['message'] ?? null; + $this->details = $data['details'] ?? null; + } + + public function getCode(): ?int + { + return $this->code; + } + + public function getError(): ?string + { + return $this->error; + } + + public function getMessage(): ?string + { + return $this->message; + } + + public function getDetails(): ?array + { + return $this->details; + } +} diff --git a/argocd-php-client/src/ArgoCD/Model/SessionGetUserInfoResponse.php b/argocd-php-client/src/ArgoCD/Model/SessionGetUserInfoResponse.php new file mode 100644 index 00000000000..4e5cebaaef2 --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Model/SessionGetUserInfoResponse.php @@ -0,0 +1,44 @@ +groups = $data['groups']; + } + $this->iss = $data['iss'] ?? null; + $this->loggedIn = isset($data['loggedIn']) ? (bool)$data['loggedIn'] : null; + $this->username = $data['username'] ?? null; + } + + /** + * @return string[]|null + */ + public function getGroups(): ?array + { + return $this->groups; + } + + public function getIss(): ?string + { + return $this->iss; + } + + public function isLoggedIn(): ?bool + { + return $this->loggedIn; + } + + public function getUsername(): ?string + { + return $this->username; + } +} diff --git a/argocd-php-client/src/ArgoCD/Model/SessionSessionCreateRequest.php b/argocd-php-client/src/ArgoCD/Model/SessionSessionCreateRequest.php new file mode 100644 index 00000000000..9ca171dacea --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Model/SessionSessionCreateRequest.php @@ -0,0 +1,66 @@ +password = $data['password'] ?? null; + $this->token = $data['token'] ?? null; + $this->username = $data['username'] ?? null; + } + + public function getPassword(): ?string + { + return $this->password; + } + + public function getToken(): ?string + { + return $this->token; + } + + public function getUsername(): ?string + { + return $this->username; + } + + // It might be useful to have setters for a request object + // or a method to convert to array for the request body. + public function setPassword(string $password): self + { + $this->password = $password; + return $this; + } + + public function setToken(string $token): self + { + $this->token = $token; + return $this; + } + + public function setUsername(string $username): self + { + $this->username = $username; + return $this; + } + + public function toArray(): array + { + $payload = []; + if ($this->username !== null) { + $payload['username'] = $this->username; + } + if ($this->password !== null) { + $payload['password'] = $this->password; + } + if ($this->token !== null) { + $payload['token'] = $this->token; + } + return $payload; + } +} diff --git a/argocd-php-client/src/ArgoCD/Model/SessionSessionResponse.php b/argocd-php-client/src/ArgoCD/Model/SessionSessionResponse.php new file mode 100644 index 00000000000..146d6ab7328 --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Model/SessionSessionResponse.php @@ -0,0 +1,17 @@ +token = $data['token'] ?? null; + } + + public function getToken(): ?string + { + return $this->token; + } +} diff --git a/argocd-php-client/src/ArgoCD/Model/V1Time.php b/argocd-php-client/src/ArgoCD/Model/V1Time.php new file mode 100644 index 00000000000..a9d069325d3 --- /dev/null +++ b/argocd-php-client/src/ArgoCD/Model/V1Time.php @@ -0,0 +1,35 @@ +seconds = $data['seconds'] ?? null; + $this->nanos = isset($data['nanos']) ? (int)$data['nanos'] : null; + } + + public function getSeconds(): ?string + { + return $this->seconds; + } + + public function getNanos(): ?int + { + return $this->nanos; + } + + public function toDateTime(): ?\DateTimeImmutable + { + if ($this->seconds === null) { + return null; + } + // Assuming seconds is a string that can be cast to int for setTimestamp + $dateTime = new \DateTimeImmutable(); + return $dateTime->setTimestamp((int)$this->seconds); + // Note: Nanos are not easily representable in standard DateTime + } +} From 22d25731a25c10d416466c4ac410186e39c26e44 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 28 May 2025 07:08:40 +0000 Subject: [PATCH 2/6] feat: Initial ArgoCD PHP Client Foundation This commit establishes the foundational components for a PHP client for the ArgoCD API, refactored from the KnpLabs GitHub API client. Includes: - Core client structure (`Client.php`, `HttpClient/Builder.php`, `Api/AbstractApi.php`, `HttpClient/Message/ResponseMediator.php`). - Basic exception handling (`ArgoCD/Exception/` and `HttpClient/Plugin/ArgoCdExceptionThrower.php`). - Authentication mechanism via bearer tokens, with `HttpClient/Plugin/Authentication.php`. - Implemented `SessionService` for login/logout and user info. - Implemented `AccountService` for account and token management. - Initial data models for Session and Account services. - `AI.md` detailing the AI-assisted development process. - `reference/argocd_swagger.json` containing the ArgoCD OpenAPI spec. - Updated `README.md` for the ArgoCD client. I attempted to restructure the project to remove the 'argocd-php-client' sub-directory and update CI workflows for PHP 8.3+, but I encountered persistent errors related to file system access and state. These changes are therefore not included in this commit and will need to be revisited. --- AI.md | 43 + README.md | 180 +- argocd-php-client/composer.json | 33 - composer.json | 56 +- reference/argocd_swagger.json | 8094 +++++++++++++++++ .../src => src}/ArgoCD/Api/AbstractApi.php | 0 .../src => src}/ArgoCD/Api/AccountService.php | 0 .../ArgoCD/Api/ApplicationService.php | 0 .../src => src}/ArgoCD/Api/SessionService.php | 0 .../src => src}/ArgoCD/AuthMethod.php | 0 .../src => src}/ArgoCD/Client.php | 0 .../Exception/BadMethodCallException.php | 0 .../ArgoCD/Exception/ExceptionInterface.php | 0 .../Exception/InvalidArgumentException.php | 0 .../ArgoCD/Exception/RuntimeException.php | 0 .../Exception/ValidationFailedException.php | 0 .../src => src}/ArgoCD/HttpClient/Builder.php | 0 .../HttpClient/Message/ResponseMediator.php | 0 .../Plugin/ArgoCdExceptionThrower.php | 0 .../HttpClient/Plugin/Authentication.php | 0 .../ArgoCD/Model/AccountAccount.php | 0 .../ArgoCD/Model/AccountAccountsList.php | 0 .../ArgoCD/Model/AccountCanIResponse.php | 0 .../Model/AccountCreateTokenRequest.php | 0 .../Model/AccountCreateTokenResponse.php | 0 .../ArgoCD/Model/AccountEmptyResponse.php | 0 .../src => src}/ArgoCD/Model/AccountToken.php | 0 .../Model/AccountUpdatePasswordRequest.php | 0 .../Model/AccountUpdatePasswordResponse.php | 0 .../src => src}/ArgoCD/Model/RuntimeError.php | 0 .../Model/SessionGetUserInfoResponse.php | 0 .../Model/SessionSessionCreateRequest.php | 0 .../ArgoCD/Model/SessionSessionResponse.php | 0 .../src => src}/ArgoCD/Model/V1Time.php | 0 34 files changed, 8237 insertions(+), 169 deletions(-) create mode 100644 AI.md delete mode 100644 argocd-php-client/composer.json create mode 100644 reference/argocd_swagger.json rename {argocd-php-client/src => src}/ArgoCD/Api/AbstractApi.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Api/AccountService.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Api/ApplicationService.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Api/SessionService.php (100%) rename {argocd-php-client/src => src}/ArgoCD/AuthMethod.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Client.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Exception/BadMethodCallException.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Exception/ExceptionInterface.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Exception/InvalidArgumentException.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Exception/RuntimeException.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Exception/ValidationFailedException.php (100%) rename {argocd-php-client/src => src}/ArgoCD/HttpClient/Builder.php (100%) rename {argocd-php-client/src => src}/ArgoCD/HttpClient/Message/ResponseMediator.php (100%) rename {argocd-php-client/src => src}/ArgoCD/HttpClient/Plugin/ArgoCdExceptionThrower.php (100%) rename {argocd-php-client/src => src}/ArgoCD/HttpClient/Plugin/Authentication.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Model/AccountAccount.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Model/AccountAccountsList.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Model/AccountCanIResponse.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Model/AccountCreateTokenRequest.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Model/AccountCreateTokenResponse.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Model/AccountEmptyResponse.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Model/AccountToken.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Model/AccountUpdatePasswordRequest.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Model/AccountUpdatePasswordResponse.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Model/RuntimeError.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Model/SessionGetUserInfoResponse.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Model/SessionSessionCreateRequest.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Model/SessionSessionResponse.php (100%) rename {argocd-php-client/src => src}/ArgoCD/Model/V1Time.php (100%) diff --git a/AI.md b/AI.md new file mode 100644 index 00000000000..cf208121faa --- /dev/null +++ b/AI.md @@ -0,0 +1,43 @@ +# AI-Assisted Development Context: PHP ArgoCD API Client + +This document provides context on the development process of this PHP client for the ArgoCD API, which was significantly assisted by an AI agent named Jules. + +## Project Goal + +The primary goal of this project was to refactor an existing PHP client library originally designed for the GitHub API (KnpLabs/php-github-api) and adapt it to become a fully functional client for the ArgoCD REST API. + +## Development Process + +The development process involved a collaborative effort between a human developer and the AI agent, Jules. Key aspects of this process include: + +* **Initial Request:** The human developer provided an issue statement outlining the need to fork the GitHub library, study its structure, and then refactor it to implement ArgoCD's OpenAPI specification (`https://raw.githubusercontent.com/argoproj/argo-cd/master/assets/swagger.json`). +* **Codebase Analysis:** Jules explored the existing GitHub client's codebase using tools to list files and read their content to understand its architecture and patterns. +* **OpenAPI Analysis:** Jules fetched and analyzed the ArgoCD OpenAPI specification to understand its endpoints, data structures, and service organization. +* **Planning:** Based on the analysis, Jules created a detailed, multi-step plan to execute the refactoring. This plan was reviewed and approved by the human developer. +* **Iterative Implementation:** Jules executed the plan step-by-step by delegating specific, actionable tasks to a "Worker" agent. These tasks included: + * Creating new directory structures. + * Initializing `composer.json` and managing dependencies. + * Adapting core client classes (`Client.php`, `HttpClient/Builder.php`, `Api/AbstractApi.php`). + * Implementing exception handling. + * Generating PHP model classes based on OpenAPI definitions. + * Implementing API service classes (e.g., `SessionService.php`, `AccountService.php`) with methods corresponding to ArgoCD API operations. +* **Feedback Incorporation:** The human developer provided feedback at various stages (e.g., on directory structure, PHP version constraints), and Jules updated the plan and execution accordingly. + +## Current State + +As of the last AI interaction, the project has achieved the following: + +* **Core Infrastructure:** A foundational client structure is in place, including the main `Client` class, HTTP client builder, abstract API class, and basic exception handling. +* **Authentication:** The client can authenticate against an ArgoCD instance by exchanging username/password for a bearer token (via `SessionService`) or by using a pre-existing token. +* **Initial API Services:** + * `SessionService`: Implemented for login, logout, and user info. + * `AccountService`: Implemented for managing accounts and tokens. +* **Data Models:** PHP model classes corresponding to the implemented services' request/response structures have been created. +* **Project Configuration:** `composer.json` has been set up, and the project directory has been structured. The ArgoCD OpenAPI specification has been added to `reference/argocd_swagger.json`. + +Further development will involve implementing the remaining ArgoCD API services (like the extensive `ApplicationService`), adding comprehensive unit tests, and refining documentation. + +## Acknowledgements + +* The initial structure and patterns were derived from the excellent [KnpLabs/php-github-api](https://github.com/KnpLabs/php-github-api) library. +* The target API is [ArgoCD](https://argo-cd.readthedocs.io/en/stable/), and its OpenAPI specification was used as the blueprint for API implementation. diff --git a/README.md b/README.md index de79112b4f8..ef48968b6a0 100644 --- a/README.md +++ b/README.md @@ -1,81 +1,45 @@ -# PHP GitHub API +# PHP ArgoCD API Client -![Build Status](https://github.com/KnpLabs/php-github-api/actions/workflows/ci.yml/badge.svg) -[![StyleCI](https://styleci.io/repos/3948501/shield?style=flat)](https://styleci.io/repos/3948501) -[![Latest Stable Version](https://poser.pugx.org/knplabs/github-api/v/stable)](https://packagist.org/packages/knplabs/github-api) -[![Total Downloads](https://poser.pugx.org/knplabs/github-api/downloads)](https://packagist.org/packages/knplabs/github-api) -[![Monthly Downloads](https://poser.pugx.org/knplabs/github-api/d/monthly)](https://packagist.org/packages/knplabs/github-api) -[![Daily Downloads](https://poser.pugx.org/knplabs/github-api/d/daily)](https://packagist.org/packages/knplabs/github-api) +[![Build Status](https://github.com/your-vendor/argocd-php-client/actions/workflows/ci.yml/badge.svg)](https://github.com/your-vendor/argocd-php-client/actions/workflows/ci.yml) +[![Latest Stable Version](https://poser.pugx.org/your-vendor/argocd-php-client/v/stable)](https://packagist.org/packages/your-vendor/argocd-php-client) +[![Total Downloads](https://poser.pugx.org/your-vendor/argocd-php-client/downloads)](https://packagist.org/packages/your-vendor/argocd-php-client) -A simple Object Oriented wrapper for GitHub API, written with PHP. +A PHP client for interacting with the ArgoCD API. This library provides an object-oriented interface to the ArgoCD REST API. -Uses [GitHub API v3](http://developer.github.com/v3/) & supports [GitHub API v4](http://developer.github.com/v4). The object API (v3) is very similar to the RESTful API. +This client's structure is based on the [KnpLabs/php-github-api](https://github.com/KnpLabs/php-github-api) library. + +For more context on the AI-assisted development process of this library, please see [AI.md](AI.md). ## Features -* Light and fast thanks to lazy loading of API classes -* Extensively tested and documented +* Light and fast thanks to lazy loading of API classes. +* Object-oriented interface to the ArgoCD API. ## Requirements -* PHP >= 7.2 -* A [PSR-17 implementation](https://packagist.org/providers/psr/http-factory-implementation) -* A [PSR-18 implementation](https://packagist.org/providers/psr/http-client-implementation) +* PHP ^8.3 +* A [PSR-17 implementation](https://packagist.org/providers/psr/http-factory-implementation) (e.g., `nyholm/psr7`) +* A [PSR-18 implementation](https://packagist.org/providers/psr/http-client-implementation) (e.g., `symfony/http-client` or `guzzlehttp/guzzle`) ## Quick install Via [Composer](https://getcomposer.org). -This command will get you up and running quickly with a Guzzle HTTP client. - ```bash -composer require knplabs/github-api:^3.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0 +composer require your-vendor/argocd-php-client ``` -## Advanced install - -We are decoupled from any HTTP messaging client with help by [HTTPlug](https://httplug.io). - -### Using a different http client +You will also need to install implementations for PSR-17 (HTTP Factories) and PSR-18 (HTTP Client), for example: ```bash -composer require knplabs/github-api:^3.0 symfony/http-client nyholm/psr7 -``` - -To set up the Github client with this HTTP client - -```php -use Github\Client; -use Symfony\Component\HttpClient\HttplugClient; - -$client = Client::createWithHttpClient(new HttplugClient()); +composer require symfony/http-client nyholm/psr7 ``` - -Read more about [using different clients in our docs](doc/customize.md). - -## Framework integrations - -### Laravel - -To integrate this library in laravel [Graham Campbell](https://github.com/GrahamCampbell) created [graham-campbell/github](https://github.com/GrahamCampbell/Laravel-GitHub). See the [installation instructions](https://github.com/GrahamCampbell/Laravel-GitHub#installation) to get started in laravel. - -## Basic usage of `php-github-api` client - -```php -api('user')->repositories('ornicar'); +Or for Guzzle: +```bash +composer require guzzlehttp/guzzle php-http/guzzle7-adapter ``` -From `$client` object, you have access to all available GitHub api endpoints. - -## Cache usage - -This example uses the PSR6 cache pool [redis-adapter](https://github.com/php-cache/redis-adapter). See http://www.php-cache.com/ for alternatives. +## Basic Usage ```php connect('127.0.0.1', 6379); -// Create a PSR6 cache pool -$pool = new RedisCachePool($client); - -$client = new \Github\Client(); -$client->addCache($pool); - -// Do some request - -// Stop using cache -$client->removeCache(); +// 1. Instantiate the client with your ArgoCD server URL +// Ensure your ArgoCD server URL is correct and accessible. +// The client will automatically append /api/v1 if it's not present. +$client = new ArgoCD\Client('https://your-argocd-server.example.com'); + +// 2. Authenticate +// Option A: Using username and password (fetches a token via SessionService) +try { + $client->authenticate('your-username', 'your-password'); + echo "Successfully authenticated using username/password. Token: " . substr($client->getToken() ?? 'N/A', 0, 10) . "...\n"; +} catch (ArgoCD\Exception\RuntimeException $e) { + die('Authentication failed: ' . $e->getMessage() . "\n"); +} + +// Option B: Using a pre-existing token +// try { +// $client->authenticate('your-argocd-api-token'); +// echo "Successfully authenticated using pre-existing token.\n"; +// } catch (ArgoCD\Exception\InvalidArgumentException $e) { +// die('Authentication failed with token: ' . $e->getMessage() . "\n"); +// } + + +// 3. Access API services +try { + // Example: Get user info + $userInfo = $client->sessionService()->getUserInfo(); + echo "Logged in as: " . $userInfo->getUsername() . "\n"; + echo "Logged in status: " . ($userInfo->isLoggedIn() ? 'true' : 'false') . "\n"; + + // Example: List accounts (requires admin privileges typically) + // Note: Ensure the authenticated user has permissions for these operations. + // try { + // $accountsList = $client->accountService()->listAccounts(); + // echo "Listing accounts:\n"; + // if (count($accountsList->getItems()) > 0) { + // foreach ($accountsList->getItems() as $account) { + // echo " - Account Name: " . $account->getName() . ", Enabled: " . ($account->isEnabled() ? 'Yes' : 'No') . "\n"; + // } + // } else { + // echo "No accounts found or not enough permissions.\n"; + // } + // } catch (ArgoCD\Exception\RuntimeException $e) { + // echo "Could not list accounts: " . $e->getMessage() . "\n"; + // } + + +} catch (ArgoCD\Exception\RuntimeException $e) { + die('API Error: ' . $e->getMessage() . "\n"); +} + +// Example: Delete the session (logout) +// try { +// $client->sessionService()->delete(); +// echo "Successfully logged out.\n"; +// } catch (ArgoCD\Exception\RuntimeException $e) { +// die('Logout failed: ' . $e->getMessage() . "\n"); +// } + +?> ``` -Using cache, the client will get cached responses if resources haven't changed since last time, -**without** reaching the `X-Rate-Limit` [imposed by github](http://developer.github.com/v3/#rate-limiting). - - ## Documentation -See the [`doc` directory](doc/) for more detailed documentation. +Further documentation will be available as the library matures. For now, refer to the source code and the official [ArgoCD API documentation](https://cd.apps.argoproj.io/swagger-ui) (or the `reference/argocd_swagger.json` file in this repository). ## License -`php-github-api` is licensed under the MIT License - see the LICENSE file for details +This library is licensed under the MIT License - see the LICENSE file for details. ## Maintainers -Please read [this post](https://knplabs.com/en/blog/news-for-our-foss-projects-maintenance) first. - -This library is maintained by the following people (alphabetically sorted) : -- [@acrobat](https://github.com/acrobat) -- [@Nyholm](https://github.com/Nyholm) +This library is currently maintained by: +- [Your Name](https://github.com/your-vendor) (or your GitHub username) ## Contributors -- Thanks to [Thibault Duplessis aka. ornicar](https://github.com/ornicar) for his first version of this library. -- Thanks to [Joseph Bielawski aka. stloyd](https://github.com/stloyd) for his contributions and support. -- Thanks to [noloh](https://github.com/noloh) for his contribution on the Object API. -- Thanks to [bshaffer](https://github.com/bshaffer) for his contribution on the Repo API. -- Thanks to [Rolf van de Krol](https://github.com/rolfvandekrol) for his countless contributions. -- Thanks to [Nicolas Pastorino](https://github.com/jeanvoye) for his contribution on the Pull Request API. -- Thanks to [Edoardo Rivello](https://github.com/erivello) for his contribution on the Gists API. -- Thanks to [Miguel Piedrafita](https://github.com/m1guelpf) for his contribution to the v4 & Apps API. -- Thanks to [Emre DEGER](https://github.com/lexor) for his contribution to the Actions API. - -Thanks to GitHub for the high quality API and documentation. +* This project was significantly bootstrapped with the assistance of an AI agent. See [AI.md](AI.md) for more details. +* Structure and patterns inspired by [KnpLabs/php-github-api](https://github.com/KnpLabs/php-github-api). +* Thanks to the ArgoCD team for their excellent API and documentation. +``` diff --git a/argocd-php-client/composer.json b/argocd-php-client/composer.json deleted file mode 100644 index 30e4fdc157e..00000000000 --- a/argocd-php-client/composer.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "your-vendor/argocd-php-client", - "description": "A PHP client for the ArgoCD API", - "type": "library", - "license": "MIT", - "authors": [ - { - "name": "Your Name", - "email": "your.email@example.com" - } - ], - "require": { - "php": ">=7.4 || ^8.0", - "php-http/client-common": "^2.3", - "php-http/discovery": "^1.12", - "psr/http-client-implementation": "^1.0", - "psr/http-factory-implementation": "^1.0", - "psr/http-message": "^1.0 || ^2.0" - }, - "require-dev": { - "phpunit/phpunit": "^9.5" - }, - "autoload": { - "psr-4": { - "ArgoCD\\": "src/ArgoCD/" - } - }, - "autoload-dev": { - "psr-4": { - "ArgoCD\\Tests\\": "tests/" - } - } -} diff --git a/composer.json b/composer.json index da450bc019d..5b0c2cf9128 100644 --- a/composer.json +++ b/composer.json @@ -1,65 +1,33 @@ { - "name": "knplabs/github-api", + "name": "your-vendor/argocd-php-client", + "description": "A PHP client for the ArgoCD API", "type": "library", - "description": "GitHub API v3 client", - "homepage": "https://github.com/KnpLabs/php-github-api", - "keywords": ["github", "gh", "api", "gist"], "license": "MIT", "authors": [ { - "name": "KnpLabs Team", - "homepage": "http://knplabs.com" - }, - { - "name": "Thibault Duplessis", - "email": "thibault.duplessis@gmail.com", - "homepage": "http://ornicar.github.com" + "name": "Your Name", + "email": "your.email@example.com" } ], "require": { - "php": "^7.2.5 || ^8.0", - "ext-json": "*", - "php-http/cache-plugin": "^1.7.1|^2.0", + "php": "^8.3", "php-http/client-common": "^2.3", "php-http/discovery": "^1.12", - "php-http/httplug": "^2.2", - "php-http/multipart-stream-builder": "^1.1.2", - "psr/cache": "^1.0|^2.0|^3.0", "psr/http-client-implementation": "^1.0", "psr/http-factory-implementation": "^1.0", - "psr/http-message": "^1.0|^2.0", - "symfony/polyfill-php80": "^1.17", - "symfony/deprecation-contracts": "^2.2|^3.0" + "psr/http-message": "^1.0 || ^2.0" }, "require-dev": { - "symfony/cache": "^5.1.8", - "guzzlehttp/psr7": "^2.7", - "http-interop/http-factory-guzzle": "^1.0", - "guzzlehttp/guzzle": "^7.2", - "php-http/mock-client": "^1.4.1", - "phpstan/phpstan": "^0.12.57", - "phpstan/extension-installer": "^1.0.5", - "phpstan/phpstan-deprecation-rules": "^0.12.5", - "phpunit/phpunit": "^8.5 || ^9.4", - "symfony/phpunit-bridge": "^5.2" + "phpunit/phpunit": "^9.5" }, "autoload": { - "psr-4": { "Github\\": "lib/Github/" } - }, - "autoload-dev": { - "psr-4": { "Github\\Tests\\": "test/Github/Tests/"} - }, - "extra": { - "branch-alias": { - "dev-2.x": "2.20.x-dev", - "dev-master": "3.16-dev" + "psr-4": { + "ArgoCD\\": "src/ArgoCD/" } }, - "config": { - "allow-plugins": { - "phpstan/extension-installer": true, - "composer/package-versions-deprecated": true, - "php-http/discovery": true + "autoload-dev": { + "psr-4": { + "ArgoCD\\Tests\\": "tests/" } } } diff --git a/reference/argocd_swagger.json b/reference/argocd_swagger.json new file mode 100644 index 00000000000..e0cbba6447a --- /dev/null +++ b/reference/argocd_swagger.json @@ -0,0 +1,8094 @@ +{ + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "swagger": "2.0", + "info": { + "description": "Description of all APIs", + "title": "Consolidate Services", + "version": "version not set" + }, + "paths": { + "/api/v1/account": { + "get": { + "tags": [ + "AccountService" + ], + "summary": "ListAccounts returns the list of accounts", + "operationId": "AccountService_ListAccounts", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/accountAccountsList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/account/can-i/{resource}/{action}/{subresource}": { + "get": { + "tags": [ + "AccountService" + ], + "summary": "CanI checks if the current account has permission to perform an action", + "operationId": "AccountService_CanI", + "parameters": [ + { + "type": "string", + "name": "resource", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "action", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "subresource", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/accountCanIResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/account/password": { + "put": { + "tags": [ + "AccountService" + ], + "summary": "UpdatePassword updates an account's password to a new value", + "operationId": "AccountService_UpdatePassword", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/accountUpdatePasswordRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/accountUpdatePasswordResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/account/{name}": { + "get": { + "tags": [ + "AccountService" + ], + "summary": "GetAccount returns an account", + "operationId": "AccountService_GetAccount", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/accountAccount" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/account/{name}/token": { + "post": { + "tags": [ + "AccountService" + ], + "summary": "CreateToken creates a token", + "operationId": "AccountService_CreateToken", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/accountCreateTokenRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/accountCreateTokenResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/account/{name}/token/{id}": { + "delete": { + "tags": [ + "AccountService" + ], + "summary": "DeleteToken deletes a token", + "operationId": "AccountService_DeleteToken", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/accountEmptyResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "List returns list of applications", + "operationId": "ApplicationService_List", + "parameters": [ + { + "type": "string", + "description": "the application's name.", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "forces application reconciliation if set to 'hard'.", + "name": "refresh", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "the project names to restrict returned list applications.", + "name": "projects", + "in": "query" + }, + { + "type": "string", + "description": "when specified with a watch call, shows changes that occur after that particular version of a resource.", + "name": "resourceVersion", + "in": "query" + }, + { + "type": "string", + "description": "the selector to restrict returned list to applications only with matched labels.", + "name": "selector", + "in": "query" + }, + { + "type": "string", + "description": "the repoURL to restrict returned list applications.", + "name": "repo", + "in": "query" + }, + { + "type": "string", + "description": "the application's namespace.", + "name": "appNamespace", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "the project names to restrict returned list applications (legacy name for backwards-compatibility).", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1ApplicationList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "post": { + "tags": [ + "ApplicationService" + ], + "summary": "Create creates an application", + "operationId": "ApplicationService_Create", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1Application" + } + }, + { + "type": "boolean", + "name": "upsert", + "in": "query" + }, + { + "type": "boolean", + "name": "validate", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Application" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/manifestsWithFiles": { + "post": { + "tags": [ + "ApplicationService" + ], + "summary": "GetManifestsWithFiles returns application manifests using provided files to generate them", + "operationId": "ApplicationService_GetManifestsWithFiles", + "parameters": [ + { + "description": " (streaming inputs)", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/applicationApplicationManifestQueryWithFilesWrapper" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/repositoryManifestResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{application.metadata.name}": { + "put": { + "tags": [ + "ApplicationService" + ], + "summary": "Update updates an application", + "operationId": "ApplicationService_Update", + "parameters": [ + { + "type": "string", + "description": "Name must be unique within a namespace. Is required when creating resources, although\nsome resources may allow a client to request the generation of an appropriate name\nautomatically. Name is primarily intended for creation idempotence and configuration\ndefinition.\nCannot be updated.\nMore info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names\n+optional", + "name": "application.metadata.name", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1Application" + } + }, + { + "type": "boolean", + "name": "validate", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Application" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{applicationName}/managed-resources": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "ManagedResources returns list of managed resources", + "operationId": "ApplicationService_ManagedResources", + "parameters": [ + { + "type": "string", + "name": "applicationName", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "namespace", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "string", + "name": "version", + "in": "query" + }, + { + "type": "string", + "name": "group", + "in": "query" + }, + { + "type": "string", + "name": "kind", + "in": "query" + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/applicationManagedResourcesResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{applicationName}/resource-tree": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "ResourceTree returns resource tree", + "operationId": "ApplicationService_ResourceTree", + "parameters": [ + { + "type": "string", + "name": "applicationName", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "namespace", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "string", + "name": "version", + "in": "query" + }, + { + "type": "string", + "name": "group", + "in": "query" + }, + { + "type": "string", + "name": "kind", + "in": "query" + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1ApplicationTree" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "Get returns an application by name", + "operationId": "ApplicationService_Get", + "parameters": [ + { + "type": "string", + "description": "the application's name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "forces application reconciliation if set to 'hard'.", + "name": "refresh", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "the project names to restrict returned list applications.", + "name": "projects", + "in": "query" + }, + { + "type": "string", + "description": "when specified with a watch call, shows changes that occur after that particular version of a resource.", + "name": "resourceVersion", + "in": "query" + }, + { + "type": "string", + "description": "the selector to restrict returned list to applications only with matched labels.", + "name": "selector", + "in": "query" + }, + { + "type": "string", + "description": "the repoURL to restrict returned list applications.", + "name": "repo", + "in": "query" + }, + { + "type": "string", + "description": "the application's namespace.", + "name": "appNamespace", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "the project names to restrict returned list applications (legacy name for backwards-compatibility).", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Application" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "delete": { + "tags": [ + "ApplicationService" + ], + "summary": "Delete deletes an application", + "operationId": "ApplicationService_Delete", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "boolean", + "name": "cascade", + "in": "query" + }, + { + "type": "string", + "name": "propagationPolicy", + "in": "query" + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/applicationApplicationResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "patch": { + "tags": [ + "ApplicationService" + ], + "summary": "Patch patch an application", + "operationId": "ApplicationService_Patch", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/applicationApplicationPatchRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Application" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}/events": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "ListResourceEvents returns a list of event resources", + "operationId": "ApplicationService_ListResourceEvents", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "resourceNamespace", + "in": "query" + }, + { + "type": "string", + "name": "resourceName", + "in": "query" + }, + { + "type": "string", + "name": "resourceUID", + "in": "query" + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1EventList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}/links": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "ListLinks returns the list of all application deep links", + "operationId": "ApplicationService_ListLinks", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "namespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/applicationLinksResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}/logs": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "PodLogs returns stream of log entries for the specified pod. Pod", + "operationId": "ApplicationService_PodLogs2", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "namespace", + "in": "query" + }, + { + "type": "string", + "name": "podName", + "in": "query" + }, + { + "type": "string", + "name": "container", + "in": "query" + }, + { + "type": "string", + "format": "int64", + "name": "sinceSeconds", + "in": "query" + }, + { + "type": "string", + "format": "int64", + "description": "Represents seconds of UTC time since Unix epoch\n1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n9999-12-31T23:59:59Z inclusive.", + "name": "sinceTime.seconds", + "in": "query" + }, + { + "type": "integer", + "format": "int32", + "description": "Non-negative fractions of a second at nanosecond resolution. Negative\nsecond values with fractions must still have non-negative nanos values\nthat count forward in time. Must be from 0 to 999,999,999\ninclusive. This field may be limited in precision depending on context.", + "name": "sinceTime.nanos", + "in": "query" + }, + { + "type": "string", + "format": "int64", + "name": "tailLines", + "in": "query" + }, + { + "type": "boolean", + "name": "follow", + "in": "query" + }, + { + "type": "string", + "name": "untilTime", + "in": "query" + }, + { + "type": "string", + "name": "filter", + "in": "query" + }, + { + "type": "string", + "name": "kind", + "in": "query" + }, + { + "type": "string", + "name": "group", + "in": "query" + }, + { + "type": "string", + "name": "resourceName", + "in": "query" + }, + { + "type": "boolean", + "name": "previous", + "in": "query" + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + }, + { + "type": "boolean", + "name": "matchCase", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.(streaming responses)", + "schema": { + "type": "object", + "title": "Stream result of applicationLogEntry", + "properties": { + "error": { + "$ref": "#/definitions/runtimeStreamError" + }, + "result": { + "$ref": "#/definitions/applicationLogEntry" + } + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}/manifests": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "GetManifests returns application manifests", + "operationId": "ApplicationService_GetManifests", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "revision", + "in": "query" + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string", + "format": "int64" + }, + "collectionFormat": "multi", + "name": "sourcePositions", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "name": "revisions", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/repositoryManifestResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}/operation": { + "delete": { + "tags": [ + "ApplicationService" + ], + "summary": "TerminateOperation terminates the currently running operation", + "operationId": "ApplicationService_TerminateOperation", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/applicationOperationTerminateResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}/pods/{podName}/logs": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "PodLogs returns stream of log entries for the specified pod. Pod", + "operationId": "ApplicationService_PodLogs", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "podName", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "namespace", + "in": "query" + }, + { + "type": "string", + "name": "container", + "in": "query" + }, + { + "type": "string", + "format": "int64", + "name": "sinceSeconds", + "in": "query" + }, + { + "type": "string", + "format": "int64", + "description": "Represents seconds of UTC time since Unix epoch\n1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n9999-12-31T23:59:59Z inclusive.", + "name": "sinceTime.seconds", + "in": "query" + }, + { + "type": "integer", + "format": "int32", + "description": "Non-negative fractions of a second at nanosecond resolution. Negative\nsecond values with fractions must still have non-negative nanos values\nthat count forward in time. Must be from 0 to 999,999,999\ninclusive. This field may be limited in precision depending on context.", + "name": "sinceTime.nanos", + "in": "query" + }, + { + "type": "string", + "format": "int64", + "name": "tailLines", + "in": "query" + }, + { + "type": "boolean", + "name": "follow", + "in": "query" + }, + { + "type": "string", + "name": "untilTime", + "in": "query" + }, + { + "type": "string", + "name": "filter", + "in": "query" + }, + { + "type": "string", + "name": "kind", + "in": "query" + }, + { + "type": "string", + "name": "group", + "in": "query" + }, + { + "type": "string", + "name": "resourceName", + "in": "query" + }, + { + "type": "boolean", + "name": "previous", + "in": "query" + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + }, + { + "type": "boolean", + "name": "matchCase", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.(streaming responses)", + "schema": { + "type": "object", + "title": "Stream result of applicationLogEntry", + "properties": { + "error": { + "$ref": "#/definitions/runtimeStreamError" + }, + "result": { + "$ref": "#/definitions/applicationLogEntry" + } + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}/resource": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "GetResource returns single application resource", + "operationId": "ApplicationService_GetResource", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "namespace", + "in": "query" + }, + { + "type": "string", + "name": "resourceName", + "in": "query" + }, + { + "type": "string", + "name": "version", + "in": "query" + }, + { + "type": "string", + "name": "group", + "in": "query" + }, + { + "type": "string", + "name": "kind", + "in": "query" + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/applicationApplicationResourceResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "post": { + "tags": [ + "ApplicationService" + ], + "summary": "PatchResource patch single application resource", + "operationId": "ApplicationService_PatchResource", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + }, + { + "type": "string", + "name": "namespace", + "in": "query" + }, + { + "type": "string", + "name": "resourceName", + "in": "query" + }, + { + "type": "string", + "name": "version", + "in": "query" + }, + { + "type": "string", + "name": "group", + "in": "query" + }, + { + "type": "string", + "name": "kind", + "in": "query" + }, + { + "type": "string", + "name": "patchType", + "in": "query" + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/applicationApplicationResourceResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "delete": { + "tags": [ + "ApplicationService" + ], + "summary": "DeleteResource deletes a single application resource", + "operationId": "ApplicationService_DeleteResource", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "namespace", + "in": "query" + }, + { + "type": "string", + "name": "resourceName", + "in": "query" + }, + { + "type": "string", + "name": "version", + "in": "query" + }, + { + "type": "string", + "name": "group", + "in": "query" + }, + { + "type": "string", + "name": "kind", + "in": "query" + }, + { + "type": "boolean", + "name": "force", + "in": "query" + }, + { + "type": "boolean", + "name": "orphan", + "in": "query" + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/applicationApplicationResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}/resource/actions": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "ListResourceActions returns list of resource actions", + "operationId": "ApplicationService_ListResourceActions", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "namespace", + "in": "query" + }, + { + "type": "string", + "name": "resourceName", + "in": "query" + }, + { + "type": "string", + "name": "version", + "in": "query" + }, + { + "type": "string", + "name": "group", + "in": "query" + }, + { + "type": "string", + "name": "kind", + "in": "query" + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/applicationResourceActionsListResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "post": { + "tags": [ + "ApplicationService" + ], + "summary": "RunResourceAction run resource action", + "operationId": "ApplicationService_RunResourceAction", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/applicationResourceActionRunRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/applicationApplicationResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}/resource/links": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "ListResourceLinks returns the list of all resource deep links", + "operationId": "ApplicationService_ListResourceLinks", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "namespace", + "in": "query" + }, + { + "type": "string", + "name": "resourceName", + "in": "query" + }, + { + "type": "string", + "name": "version", + "in": "query" + }, + { + "type": "string", + "name": "group", + "in": "query" + }, + { + "type": "string", + "name": "kind", + "in": "query" + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/applicationLinksResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}/revisions/{revision}/chartdetails": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "Get the chart metadata (description, maintainers, home) for a specific revision of the application", + "operationId": "ApplicationService_RevisionChartDetails", + "parameters": [ + { + "type": "string", + "description": "the application's name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "the revision of the app", + "name": "revision", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "the application's namespace.", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + }, + { + "type": "integer", + "format": "int32", + "description": "source index (for multi source apps).", + "name": "sourceIndex", + "in": "query" + }, + { + "type": "integer", + "format": "int32", + "description": "versionId from historical data (for multi source apps).", + "name": "versionId", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1ChartDetails" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}/revisions/{revision}/metadata": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "Get the meta-data (author, date, tags, message) for a specific revision of the application", + "operationId": "ApplicationService_RevisionMetadata", + "parameters": [ + { + "type": "string", + "description": "the application's name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "the revision of the app", + "name": "revision", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "the application's namespace.", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + }, + { + "type": "integer", + "format": "int32", + "description": "source index (for multi source apps).", + "name": "sourceIndex", + "in": "query" + }, + { + "type": "integer", + "format": "int32", + "description": "versionId from historical data (for multi source apps).", + "name": "versionId", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1RevisionMetadata" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}/rollback": { + "post": { + "tags": [ + "ApplicationService" + ], + "summary": "Rollback syncs an application to its target state", + "operationId": "ApplicationService_Rollback", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/applicationApplicationRollbackRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Application" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}/spec": { + "put": { + "tags": [ + "ApplicationService" + ], + "summary": "UpdateSpec updates an application spec", + "operationId": "ApplicationService_UpdateSpec", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1ApplicationSpec" + } + }, + { + "type": "boolean", + "name": "validate", + "in": "query" + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1ApplicationSpec" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}/sync": { + "post": { + "tags": [ + "ApplicationService" + ], + "summary": "Sync syncs an application to its target state", + "operationId": "ApplicationService_Sync", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/applicationApplicationSyncRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Application" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applications/{name}/syncwindows": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "Get returns sync windows of the application", + "operationId": "ApplicationService_GetApplicationSyncWindows", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/applicationApplicationSyncWindowsResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applicationsets": { + "get": { + "tags": [ + "ApplicationSetService" + ], + "summary": "List returns list of applicationset", + "operationId": "ApplicationSetService_List", + "parameters": [ + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "the project names to restrict returned list applicationsets.", + "name": "projects", + "in": "query" + }, + { + "type": "string", + "description": "the selector to restrict returned list to applications only with matched labels.", + "name": "selector", + "in": "query" + }, + { + "type": "string", + "description": "The application set namespace. Default empty is argocd control plane namespace.", + "name": "appsetNamespace", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1ApplicationSetList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "post": { + "tags": [ + "ApplicationSetService" + ], + "summary": "Create creates an applicationset", + "operationId": "ApplicationSetService_Create", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1ApplicationSet" + } + }, + { + "type": "boolean", + "name": "upsert", + "in": "query" + }, + { + "type": "boolean", + "name": "dryRun", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1ApplicationSet" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applicationsets/generate": { + "post": { + "tags": [ + "ApplicationSetService" + ], + "summary": "Generate generates", + "operationId": "ApplicationSetService_Generate", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/applicationsetApplicationSetGenerateRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/applicationsetApplicationSetGenerateResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applicationsets/{name}": { + "get": { + "tags": [ + "ApplicationSetService" + ], + "summary": "Get returns an applicationset by name", + "operationId": "ApplicationSetService_Get", + "parameters": [ + { + "type": "string", + "description": "the applicationsets's name", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The application set namespace. Default empty is argocd control plane namespace.", + "name": "appsetNamespace", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1ApplicationSet" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "delete": { + "tags": [ + "ApplicationSetService" + ], + "summary": "Delete deletes an application set", + "operationId": "ApplicationSetService_Delete", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The application set namespace. Default empty is argocd control plane namespace.", + "name": "appsetNamespace", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/applicationsetApplicationSetResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/applicationsets/{name}/resource-tree": { + "get": { + "tags": [ + "ApplicationSetService" + ], + "summary": "ResourceTree returns resource tree", + "operationId": "ApplicationSetService_ResourceTree", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "The application set namespace. Default empty is argocd control plane namespace.", + "name": "appsetNamespace", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1ApplicationSetTree" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/certificates": { + "get": { + "tags": [ + "CertificateService" + ], + "summary": "List all available repository certificates", + "operationId": "CertificateService_ListCertificates", + "parameters": [ + { + "type": "string", + "description": "A file-glob pattern (not regular expression) the host name has to match.", + "name": "hostNamePattern", + "in": "query" + }, + { + "type": "string", + "description": "The type of the certificate to match (ssh or https).", + "name": "certType", + "in": "query" + }, + { + "type": "string", + "description": "The sub type of the certificate to match (protocol dependent, usually only used for ssh certs).", + "name": "certSubType", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1RepositoryCertificateList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "post": { + "tags": [ + "CertificateService" + ], + "summary": "Creates repository certificates on the server", + "operationId": "CertificateService_CreateCertificate", + "parameters": [ + { + "description": "List of certificates to be created", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1RepositoryCertificateList" + } + }, + { + "type": "boolean", + "description": "Whether to upsert already existing certificates.", + "name": "upsert", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1RepositoryCertificateList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "delete": { + "tags": [ + "CertificateService" + ], + "summary": "Delete the certificates that match the RepositoryCertificateQuery", + "operationId": "CertificateService_DeleteCertificate", + "parameters": [ + { + "type": "string", + "description": "A file-glob pattern (not regular expression) the host name has to match.", + "name": "hostNamePattern", + "in": "query" + }, + { + "type": "string", + "description": "The type of the certificate to match (ssh or https).", + "name": "certType", + "in": "query" + }, + { + "type": "string", + "description": "The sub type of the certificate to match (protocol dependent, usually only used for ssh certs).", + "name": "certSubType", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1RepositoryCertificateList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/clusters": { + "get": { + "tags": [ + "ClusterService" + ], + "summary": "List returns list of clusters", + "operationId": "ClusterService_List", + "parameters": [ + { + "type": "string", + "name": "server", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "type is the type of the specified cluster identifier ( \"server\" - default, \"name\" ).", + "name": "id.type", + "in": "query" + }, + { + "type": "string", + "description": "value holds the cluster server URL or cluster name.", + "name": "id.value", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1ClusterList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "post": { + "tags": [ + "ClusterService" + ], + "summary": "Create creates a cluster", + "operationId": "ClusterService_Create", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1Cluster" + } + }, + { + "type": "boolean", + "name": "upsert", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Cluster" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/clusters/{id.value}": { + "get": { + "tags": [ + "ClusterService" + ], + "summary": "Get returns a cluster by server address", + "operationId": "ClusterService_Get", + "parameters": [ + { + "type": "string", + "description": "value holds the cluster server URL or cluster name", + "name": "id.value", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "server", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "type is the type of the specified cluster identifier ( \"server\" - default, \"name\" ).", + "name": "id.type", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Cluster" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "put": { + "tags": [ + "ClusterService" + ], + "summary": "Update updates a cluster", + "operationId": "ClusterService_Update", + "parameters": [ + { + "type": "string", + "description": "value holds the cluster server URL or cluster name", + "name": "id.value", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1Cluster" + } + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "name": "updatedFields", + "in": "query" + }, + { + "type": "string", + "description": "type is the type of the specified cluster identifier ( \"server\" - default, \"name\" ).", + "name": "id.type", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Cluster" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "delete": { + "tags": [ + "ClusterService" + ], + "summary": "Delete deletes a cluster", + "operationId": "ClusterService_Delete", + "parameters": [ + { + "type": "string", + "description": "value holds the cluster server URL or cluster name", + "name": "id.value", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "server", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "type is the type of the specified cluster identifier ( \"server\" - default, \"name\" ).", + "name": "id.type", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/clusterClusterResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/clusters/{id.value}/invalidate-cache": { + "post": { + "tags": [ + "ClusterService" + ], + "summary": "InvalidateCache invalidates cluster cache", + "operationId": "ClusterService_InvalidateCache", + "parameters": [ + { + "type": "string", + "description": "value holds the cluster server URL or cluster name", + "name": "id.value", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Cluster" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/clusters/{id.value}/rotate-auth": { + "post": { + "tags": [ + "ClusterService" + ], + "summary": "RotateAuth rotates the bearer token used for a cluster", + "operationId": "ClusterService_RotateAuth", + "parameters": [ + { + "type": "string", + "description": "value holds the cluster server URL or cluster name", + "name": "id.value", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/clusterClusterResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/gpgkeys": { + "get": { + "tags": [ + "GPGKeyService" + ], + "summary": "List all available repository certificates", + "operationId": "GPGKeyService_List", + "parameters": [ + { + "type": "string", + "description": "The GPG key ID to query for.", + "name": "keyID", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1GnuPGPublicKeyList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "post": { + "tags": [ + "GPGKeyService" + ], + "summary": "Create one or more GPG public keys in the server's configuration", + "operationId": "GPGKeyService_Create", + "parameters": [ + { + "description": "Raw key data of the GPG key(s) to create", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1GnuPGPublicKey" + } + }, + { + "type": "boolean", + "description": "Whether to upsert already existing public keys.", + "name": "upsert", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/gpgkeyGnuPGPublicKeyCreateResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "delete": { + "tags": [ + "GPGKeyService" + ], + "summary": "Delete specified GPG public key from the server's configuration", + "operationId": "GPGKeyService_Delete", + "parameters": [ + { + "type": "string", + "description": "The GPG key ID to query for.", + "name": "keyID", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/gpgkeyGnuPGPublicKeyResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/gpgkeys/{keyID}": { + "get": { + "tags": [ + "GPGKeyService" + ], + "summary": "Get information about specified GPG public key from the server", + "operationId": "GPGKeyService_Get", + "parameters": [ + { + "type": "string", + "description": "The GPG key ID to query for", + "name": "keyID", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1GnuPGPublicKey" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/notifications/services": { + "get": { + "tags": [ + "NotificationService" + ], + "summary": "List returns list of services", + "operationId": "NotificationService_ListServices", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/notificationServiceList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/notifications/templates": { + "get": { + "tags": [ + "NotificationService" + ], + "summary": "List returns list of templates", + "operationId": "NotificationService_ListTemplates", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/notificationTemplateList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/notifications/triggers": { + "get": { + "tags": [ + "NotificationService" + ], + "summary": "List returns list of triggers", + "operationId": "NotificationService_ListTriggers", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/notificationTriggerList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/projects": { + "get": { + "tags": [ + "ProjectService" + ], + "summary": "List returns list of projects", + "operationId": "ProjectService_List", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1AppProjectList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "post": { + "tags": [ + "ProjectService" + ], + "summary": "Create a new project", + "operationId": "ProjectService_Create", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/projectProjectCreateRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1AppProject" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/projects/{name}": { + "get": { + "tags": [ + "ProjectService" + ], + "summary": "Get returns a project by name", + "operationId": "ProjectService_Get", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1AppProject" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "delete": { + "tags": [ + "ProjectService" + ], + "summary": "Delete deletes a project", + "operationId": "ProjectService_Delete", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/projectEmptyResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/projects/{name}/detailed": { + "get": { + "tags": [ + "ProjectService" + ], + "summary": "GetDetailedProject returns a project that include project, global project and scoped resources by name", + "operationId": "ProjectService_GetDetailedProject", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/projectDetailedProjectsResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/projects/{name}/events": { + "get": { + "tags": [ + "ProjectService" + ], + "summary": "ListEvents returns a list of project events", + "operationId": "ProjectService_ListEvents", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1EventList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/projects/{name}/globalprojects": { + "get": { + "tags": [ + "ProjectService" + ], + "summary": "Get returns a virtual project by name", + "operationId": "ProjectService_GetGlobalProjects", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/projectGlobalProjectsResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/projects/{name}/links": { + "get": { + "tags": [ + "ProjectService" + ], + "summary": "ListLinks returns all deep links for the particular project", + "operationId": "ProjectService_ListLinks", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/applicationLinksResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/projects/{name}/syncwindows": { + "get": { + "tags": [ + "ProjectService" + ], + "summary": "GetSchedulesState returns true if there are any active sync syncWindows", + "operationId": "ProjectService_GetSyncWindowsState", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/projectSyncWindowsResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/projects/{project.metadata.name}": { + "put": { + "tags": [ + "ProjectService" + ], + "summary": "Update updates a project", + "operationId": "ProjectService_Update", + "parameters": [ + { + "type": "string", + "description": "Name must be unique within a namespace. Is required when creating resources, although\nsome resources may allow a client to request the generation of an appropriate name\nautomatically. Name is primarily intended for creation idempotence and configuration\ndefinition.\nCannot be updated.\nMore info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names\n+optional", + "name": "project.metadata.name", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/projectProjectUpdateRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1AppProject" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/projects/{project}/roles/{role}/token": { + "post": { + "tags": [ + "ProjectService" + ], + "summary": "Create a new project token", + "operationId": "ProjectService_CreateToken", + "parameters": [ + { + "type": "string", + "name": "project", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "role", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/projectProjectTokenCreateRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/projectProjectTokenResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/projects/{project}/roles/{role}/token/{iat}": { + "delete": { + "tags": [ + "ProjectService" + ], + "summary": "Delete a new project token", + "operationId": "ProjectService_DeleteToken", + "parameters": [ + { + "type": "string", + "name": "project", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "role", + "in": "path", + "required": true + }, + { + "type": "string", + "format": "int64", + "name": "iat", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/projectEmptyResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/repocreds": { + "get": { + "tags": [ + "RepoCredsService" + ], + "summary": "ListRepositoryCredentials gets a list of all configured repository credential sets", + "operationId": "RepoCredsService_ListRepositoryCredentials", + "parameters": [ + { + "type": "string", + "description": "Repo URL for query.", + "name": "url", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1RepoCredsList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "post": { + "tags": [ + "RepoCredsService" + ], + "summary": "CreateRepositoryCredentials creates a new repository credential set", + "operationId": "RepoCredsService_CreateRepositoryCredentials", + "parameters": [ + { + "description": "Repository definition", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1RepoCreds" + } + }, + { + "type": "boolean", + "description": "Whether to create in upsert mode.", + "name": "upsert", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1RepoCreds" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/repocreds/{creds.url}": { + "put": { + "tags": [ + "RepoCredsService" + ], + "summary": "UpdateRepositoryCredentials updates a repository credential set", + "operationId": "RepoCredsService_UpdateRepositoryCredentials", + "parameters": [ + { + "type": "string", + "description": "URL is the URL to which these credentials match", + "name": "creds.url", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1RepoCreds" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1RepoCreds" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/repocreds/{url}": { + "delete": { + "tags": [ + "RepoCredsService" + ], + "summary": "DeleteRepositoryCredentials deletes a repository credential set from the configuration", + "operationId": "RepoCredsService_DeleteRepositoryCredentials", + "parameters": [ + { + "type": "string", + "name": "url", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/repocredsRepoCredsResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/repositories": { + "get": { + "tags": [ + "RepositoryService" + ], + "summary": "ListRepositories gets a list of all configured repositories", + "operationId": "RepositoryService_ListRepositories", + "parameters": [ + { + "type": "string", + "description": "Repo URL for query.", + "name": "repo", + "in": "query" + }, + { + "type": "boolean", + "description": "Whether to force a cache refresh on repo's connection state.", + "name": "forceRefresh", + "in": "query" + }, + { + "type": "string", + "description": "App project for query.", + "name": "appProject", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1RepositoryList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "post": { + "tags": [ + "RepositoryService" + ], + "summary": "CreateRepository creates a new repository configuration", + "operationId": "RepositoryService_CreateRepository", + "parameters": [ + { + "description": "Repository definition", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1Repository" + } + }, + { + "type": "boolean", + "description": "Whether to create in upsert mode.", + "name": "upsert", + "in": "query" + }, + { + "type": "boolean", + "description": "Whether to operate on credential set instead of repository.", + "name": "credsOnly", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Repository" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/repositories/{repo.repo}": { + "put": { + "tags": [ + "RepositoryService" + ], + "summary": "UpdateRepository updates a repository configuration", + "operationId": "RepositoryService_UpdateRepository", + "parameters": [ + { + "type": "string", + "description": "Repo contains the URL to the remote repository", + "name": "repo.repo", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1Repository" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Repository" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/repositories/{repo}": { + "get": { + "tags": [ + "RepositoryService" + ], + "summary": "Get returns a repository or its credentials", + "operationId": "RepositoryService_Get", + "parameters": [ + { + "type": "string", + "description": "Repo URL for query", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Whether to force a cache refresh on repo's connection state.", + "name": "forceRefresh", + "in": "query" + }, + { + "type": "string", + "description": "App project for query.", + "name": "appProject", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Repository" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "delete": { + "tags": [ + "RepositoryService" + ], + "summary": "DeleteRepository deletes a repository from the configuration", + "operationId": "RepositoryService_DeleteRepository", + "parameters": [ + { + "type": "string", + "description": "Repo URL for query", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Whether to force a cache refresh on repo's connection state.", + "name": "forceRefresh", + "in": "query" + }, + { + "type": "string", + "description": "App project for query.", + "name": "appProject", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/repositoryRepoResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/repositories/{repo}/apps": { + "get": { + "tags": [ + "RepositoryService" + ], + "summary": "ListApps returns list of apps in the repo", + "operationId": "RepositoryService_ListApps", + "parameters": [ + { + "type": "string", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "revision", + "in": "query" + }, + { + "type": "string", + "name": "appName", + "in": "query" + }, + { + "type": "string", + "name": "appProject", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/repositoryRepoAppsResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/repositories/{repo}/helmcharts": { + "get": { + "tags": [ + "RepositoryService" + ], + "summary": "GetHelmCharts returns list of helm charts in the specified repository", + "operationId": "RepositoryService_GetHelmCharts", + "parameters": [ + { + "type": "string", + "description": "Repo URL for query", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Whether to force a cache refresh on repo's connection state.", + "name": "forceRefresh", + "in": "query" + }, + { + "type": "string", + "description": "App project for query.", + "name": "appProject", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/repositoryHelmChartsResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/repositories/{repo}/refs": { + "get": { + "tags": [ + "RepositoryService" + ], + "operationId": "RepositoryService_ListRefs", + "parameters": [ + { + "type": "string", + "description": "Repo URL for query", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Whether to force a cache refresh on repo's connection state.", + "name": "forceRefresh", + "in": "query" + }, + { + "type": "string", + "description": "App project for query.", + "name": "appProject", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/repositoryRefs" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/repositories/{repo}/validate": { + "post": { + "tags": [ + "RepositoryService" + ], + "summary": "ValidateAccess validates access to a repository with given parameters", + "operationId": "RepositoryService_ValidateAccess", + "parameters": [ + { + "type": "string", + "description": "The URL to the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "description": "The URL to the repo", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + }, + { + "type": "string", + "description": "Username for accessing repo.", + "name": "username", + "in": "query" + }, + { + "type": "string", + "description": "Password for accessing repo.", + "name": "password", + "in": "query" + }, + { + "type": "string", + "description": "Private key data for accessing SSH repository.", + "name": "sshPrivateKey", + "in": "query" + }, + { + "type": "boolean", + "description": "Whether to skip certificate or host key validation.", + "name": "insecure", + "in": "query" + }, + { + "type": "string", + "description": "TLS client cert data for accessing HTTPS repository.", + "name": "tlsClientCertData", + "in": "query" + }, + { + "type": "string", + "description": "TLS client cert key for accessing HTTPS repository.", + "name": "tlsClientCertKey", + "in": "query" + }, + { + "type": "string", + "description": "The type of the repo.", + "name": "type", + "in": "query" + }, + { + "type": "string", + "description": "The name of the repo.", + "name": "name", + "in": "query" + }, + { + "type": "boolean", + "description": "Whether helm-oci support should be enabled for this repo.", + "name": "enableOci", + "in": "query" + }, + { + "type": "string", + "description": "Github App Private Key PEM data.", + "name": "githubAppPrivateKey", + "in": "query" + }, + { + "type": "string", + "format": "int64", + "description": "Github App ID of the app used to access the repo.", + "name": "githubAppID", + "in": "query" + }, + { + "type": "string", + "format": "int64", + "description": "Github App Installation ID of the installed GitHub App.", + "name": "githubAppInstallationID", + "in": "query" + }, + { + "type": "string", + "description": "Github App Enterprise base url if empty will default to https://api.github.com.", + "name": "githubAppEnterpriseBaseUrl", + "in": "query" + }, + { + "type": "string", + "description": "HTTP/HTTPS proxy to access the repository.", + "name": "proxy", + "in": "query" + }, + { + "type": "string", + "description": "Reference between project and repository that allow you automatically to be added as item inside SourceRepos project entity.", + "name": "project", + "in": "query" + }, + { + "type": "string", + "description": "Google Cloud Platform service account key.", + "name": "gcpServiceAccountKey", + "in": "query" + }, + { + "type": "boolean", + "description": "Whether to force HTTP basic auth.", + "name": "forceHttpBasicAuth", + "in": "query" + }, + { + "type": "boolean", + "description": "Whether to use azure workload identity for authentication.", + "name": "useAzureWorkloadIdentity", + "in": "query" + }, + { + "type": "string", + "description": "BearerToken contains the bearer token used for Git auth at the repo server.", + "name": "bearerToken", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/repositoryRepoResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/repositories/{source.repoURL}/appdetails": { + "post": { + "tags": [ + "RepositoryService" + ], + "summary": "GetAppDetails returns application details by given path", + "operationId": "RepositoryService_GetAppDetails", + "parameters": [ + { + "type": "string", + "description": "RepoURL is the URL to the repository (Git or Helm) that contains the application manifests", + "name": "source.repoURL", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/repositoryRepoAppDetailsQuery" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/repositoryRepoAppDetailsResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/session": { + "post": { + "tags": [ + "SessionService" + ], + "summary": "Create a new JWT for authentication and set a cookie if using HTTP", + "operationId": "SessionService_Create", + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/sessionSessionCreateRequest" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/sessionSessionResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "delete": { + "tags": [ + "SessionService" + ], + "summary": "Delete an existing JWT cookie if using HTTP", + "operationId": "SessionService_Delete", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/sessionSessionResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/session/userinfo": { + "get": { + "tags": [ + "SessionService" + ], + "summary": "Get the current user's info", + "operationId": "SessionService_GetUserInfo", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/sessionGetUserInfoResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/settings": { + "get": { + "tags": [ + "SettingsService" + ], + "summary": "Get returns Argo CD settings", + "operationId": "SettingsService_Get", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/clusterSettings" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/settings/plugins": { + "get": { + "tags": [ + "SettingsService" + ], + "summary": "Get returns Argo CD plugins", + "operationId": "SettingsService_GetPlugins", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/clusterSettingsPluginsResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/stream/applications": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "Watch returns stream of application change events", + "operationId": "ApplicationService_Watch", + "parameters": [ + { + "type": "string", + "description": "the application's name.", + "name": "name", + "in": "query" + }, + { + "type": "string", + "description": "forces application reconciliation if set to 'hard'.", + "name": "refresh", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "the project names to restrict returned list applications.", + "name": "projects", + "in": "query" + }, + { + "type": "string", + "description": "when specified with a watch call, shows changes that occur after that particular version of a resource.", + "name": "resourceVersion", + "in": "query" + }, + { + "type": "string", + "description": "the selector to restrict returned list to applications only with matched labels.", + "name": "selector", + "in": "query" + }, + { + "type": "string", + "description": "the repoURL to restrict returned list applications.", + "name": "repo", + "in": "query" + }, + { + "type": "string", + "description": "the application's namespace.", + "name": "appNamespace", + "in": "query" + }, + { + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "multi", + "description": "the project names to restrict returned list applications (legacy name for backwards-compatibility).", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.(streaming responses)", + "schema": { + "type": "object", + "title": "Stream result of v1alpha1ApplicationWatchEvent", + "properties": { + "error": { + "$ref": "#/definitions/runtimeStreamError" + }, + "result": { + "$ref": "#/definitions/v1alpha1ApplicationWatchEvent" + } + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/stream/applications/{applicationName}/resource-tree": { + "get": { + "tags": [ + "ApplicationService" + ], + "summary": "Watch returns stream of application resource tree", + "operationId": "ApplicationService_WatchResourceTree", + "parameters": [ + { + "type": "string", + "name": "applicationName", + "in": "path", + "required": true + }, + { + "type": "string", + "name": "namespace", + "in": "query" + }, + { + "type": "string", + "name": "name", + "in": "query" + }, + { + "type": "string", + "name": "version", + "in": "query" + }, + { + "type": "string", + "name": "group", + "in": "query" + }, + { + "type": "string", + "name": "kind", + "in": "query" + }, + { + "type": "string", + "name": "appNamespace", + "in": "query" + }, + { + "type": "string", + "name": "project", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.(streaming responses)", + "schema": { + "type": "object", + "title": "Stream result of v1alpha1ApplicationTree", + "properties": { + "error": { + "$ref": "#/definitions/runtimeStreamError" + }, + "result": { + "$ref": "#/definitions/v1alpha1ApplicationTree" + } + } + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/write-repocreds": { + "get": { + "tags": [ + "RepoCredsService" + ], + "summary": "ListWriteRepositoryCredentials gets a list of all configured repository credential sets that have write access", + "operationId": "RepoCredsService_ListWriteRepositoryCredentials", + "parameters": [ + { + "type": "string", + "description": "Repo URL for query.", + "name": "url", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1RepoCredsList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "post": { + "tags": [ + "RepoCredsService" + ], + "summary": "CreateWriteRepositoryCredentials creates a new repository credential set with write access", + "operationId": "RepoCredsService_CreateWriteRepositoryCredentials", + "parameters": [ + { + "description": "Repository definition", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1RepoCreds" + } + }, + { + "type": "boolean", + "description": "Whether to create in upsert mode.", + "name": "upsert", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1RepoCreds" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/write-repocreds/{creds.url}": { + "put": { + "tags": [ + "RepoCredsService" + ], + "summary": "UpdateWriteRepositoryCredentials updates a repository credential set with write access", + "operationId": "RepoCredsService_UpdateWriteRepositoryCredentials", + "parameters": [ + { + "type": "string", + "description": "URL is the URL to which these credentials match", + "name": "creds.url", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1RepoCreds" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1RepoCreds" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/write-repocreds/{url}": { + "delete": { + "tags": [ + "RepoCredsService" + ], + "summary": "DeleteWriteRepositoryCredentials deletes a repository credential set with write access from the configuration", + "operationId": "RepoCredsService_DeleteWriteRepositoryCredentials", + "parameters": [ + { + "type": "string", + "name": "url", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/repocredsRepoCredsResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/write-repositories": { + "get": { + "tags": [ + "RepositoryService" + ], + "summary": "ListWriteRepositories gets a list of all configured write repositories", + "operationId": "RepositoryService_ListWriteRepositories", + "parameters": [ + { + "type": "string", + "description": "Repo URL for query.", + "name": "repo", + "in": "query" + }, + { + "type": "boolean", + "description": "Whether to force a cache refresh on repo's connection state.", + "name": "forceRefresh", + "in": "query" + }, + { + "type": "string", + "description": "App project for query.", + "name": "appProject", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1RepositoryList" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "post": { + "tags": [ + "RepositoryService" + ], + "summary": "CreateWriteRepository creates a new write repository configuration", + "operationId": "RepositoryService_CreateWriteRepository", + "parameters": [ + { + "description": "Repository definition", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1Repository" + } + }, + { + "type": "boolean", + "description": "Whether to create in upsert mode.", + "name": "upsert", + "in": "query" + }, + { + "type": "boolean", + "description": "Whether to operate on credential set instead of repository.", + "name": "credsOnly", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Repository" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/write-repositories/{repo.repo}": { + "put": { + "tags": [ + "RepositoryService" + ], + "summary": "UpdateWriteRepository updates a write repository configuration", + "operationId": "RepositoryService_UpdateWriteRepository", + "parameters": [ + { + "type": "string", + "description": "Repo contains the URL to the remote repository", + "name": "repo.repo", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1alpha1Repository" + } + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Repository" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/write-repositories/{repo}": { + "get": { + "tags": [ + "RepositoryService" + ], + "summary": "GetWrite returns a repository or its write credentials", + "operationId": "RepositoryService_GetWrite", + "parameters": [ + { + "type": "string", + "description": "Repo URL for query", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Whether to force a cache refresh on repo's connection state.", + "name": "forceRefresh", + "in": "query" + }, + { + "type": "string", + "description": "App project for query.", + "name": "appProject", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/v1alpha1Repository" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + }, + "delete": { + "tags": [ + "RepositoryService" + ], + "summary": "DeleteWriteRepository deletes a write repository from the configuration", + "operationId": "RepositoryService_DeleteWriteRepository", + "parameters": [ + { + "type": "string", + "description": "Repo URL for query", + "name": "repo", + "in": "path", + "required": true + }, + { + "type": "boolean", + "description": "Whether to force a cache refresh on repo's connection state.", + "name": "forceRefresh", + "in": "query" + }, + { + "type": "string", + "description": "App project for query.", + "name": "appProject", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/repositoryRepoResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/v1/write-repositories/{repo}/validate": { + "post": { + "tags": [ + "RepositoryService" + ], + "summary": "ValidateWriteAccess validates write access to a repository with given parameters", + "operationId": "RepositoryService_ValidateWriteAccess", + "parameters": [ + { + "type": "string", + "description": "The URL to the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "description": "The URL to the repo", + "name": "body", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + }, + { + "type": "string", + "description": "Username for accessing repo.", + "name": "username", + "in": "query" + }, + { + "type": "string", + "description": "Password for accessing repo.", + "name": "password", + "in": "query" + }, + { + "type": "string", + "description": "Private key data for accessing SSH repository.", + "name": "sshPrivateKey", + "in": "query" + }, + { + "type": "boolean", + "description": "Whether to skip certificate or host key validation.", + "name": "insecure", + "in": "query" + }, + { + "type": "string", + "description": "TLS client cert data for accessing HTTPS repository.", + "name": "tlsClientCertData", + "in": "query" + }, + { + "type": "string", + "description": "TLS client cert key for accessing HTTPS repository.", + "name": "tlsClientCertKey", + "in": "query" + }, + { + "type": "string", + "description": "The type of the repo.", + "name": "type", + "in": "query" + }, + { + "type": "string", + "description": "The name of the repo.", + "name": "name", + "in": "query" + }, + { + "type": "boolean", + "description": "Whether helm-oci support should be enabled for this repo.", + "name": "enableOci", + "in": "query" + }, + { + "type": "string", + "description": "Github App Private Key PEM data.", + "name": "githubAppPrivateKey", + "in": "query" + }, + { + "type": "string", + "format": "int64", + "description": "Github App ID of the app used to access the repo.", + "name": "githubAppID", + "in": "query" + }, + { + "type": "string", + "format": "int64", + "description": "Github App Installation ID of the installed GitHub App.", + "name": "githubAppInstallationID", + "in": "query" + }, + { + "type": "string", + "description": "Github App Enterprise base url if empty will default to https://api.github.com.", + "name": "githubAppEnterpriseBaseUrl", + "in": "query" + }, + { + "type": "string", + "description": "HTTP/HTTPS proxy to access the repository.", + "name": "proxy", + "in": "query" + }, + { + "type": "string", + "description": "Reference between project and repository that allow you automatically to be added as item inside SourceRepos project entity.", + "name": "project", + "in": "query" + }, + { + "type": "string", + "description": "Google Cloud Platform service account key.", + "name": "gcpServiceAccountKey", + "in": "query" + }, + { + "type": "boolean", + "description": "Whether to force HTTP basic auth.", + "name": "forceHttpBasicAuth", + "in": "query" + }, + { + "type": "boolean", + "description": "Whether to use azure workload identity for authentication.", + "name": "useAzureWorkloadIdentity", + "in": "query" + }, + { + "type": "string", + "description": "BearerToken contains the bearer token used for Git auth at the repo server.", + "name": "bearerToken", + "in": "query" + } + ], + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/repositoryRepoResponse" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + }, + "/api/version": { + "get": { + "tags": [ + "VersionService" + ], + "summary": "Version returns version information of the API server", + "operationId": "VersionService_Version", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/versionVersionMessage" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/runtimeError" + } + } + } + } + } + }, + "definitions": { + "accountAccount": { + "type": "object", + "properties": { + "capabilities": { + "type": "array", + "items": { + "type": "string" + } + }, + "enabled": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "tokens": { + "type": "array", + "items": { + "$ref": "#/definitions/accountToken" + } + } + } + }, + "accountAccountsList": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/accountAccount" + } + } + } + }, + "accountCanIResponse": { + "type": "object", + "properties": { + "value": { + "type": "string" + } + } + }, + "accountCreateTokenRequest": { + "type": "object", + "properties": { + "expiresIn": { + "type": "integer", + "format": "int64", + "title": "expiresIn represents a duration in seconds" + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "accountCreateTokenResponse": { + "type": "object", + "properties": { + "token": { + "type": "string" + } + } + }, + "accountEmptyResponse": { + "type": "object" + }, + "accountToken": { + "type": "object", + "properties": { + "expiresAt": { + "type": "integer", + "format": "int64" + }, + "id": { + "type": "string" + }, + "issuedAt": { + "type": "integer", + "format": "int64" + } + } + }, + "accountUpdatePasswordRequest": { + "type": "object", + "properties": { + "currentPassword": { + "type": "string" + }, + "name": { + "type": "string" + }, + "newPassword": { + "type": "string" + } + } + }, + "accountUpdatePasswordResponse": { + "type": "object" + }, + "applicationApplicationManifestQueryWithFiles": { + "type": "object", + "properties": { + "appNamespace": { + "type": "string" + }, + "checksum": { + "type": "string" + }, + "name": { + "type": "string" + }, + "project": { + "type": "string" + } + } + }, + "applicationApplicationManifestQueryWithFilesWrapper": { + "type": "object", + "properties": { + "chunk": { + "$ref": "#/definitions/applicationFileChunk" + }, + "query": { + "$ref": "#/definitions/applicationApplicationManifestQueryWithFiles" + } + } + }, + "applicationApplicationPatchRequest": { + "type": "object", + "title": "ApplicationPatchRequest is a request to patch an application", + "properties": { + "appNamespace": { + "type": "string" + }, + "name": { + "type": "string" + }, + "patch": { + "type": "string" + }, + "patchType": { + "type": "string" + }, + "project": { + "type": "string" + } + } + }, + "applicationApplicationResourceResponse": { + "type": "object", + "properties": { + "manifest": { + "type": "string" + } + } + }, + "applicationApplicationResponse": { + "type": "object" + }, + "applicationApplicationRollbackRequest": { + "type": "object", + "properties": { + "appNamespace": { + "type": "string" + }, + "dryRun": { + "type": "boolean" + }, + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "project": { + "type": "string" + }, + "prune": { + "type": "boolean" + } + } + }, + "applicationApplicationSyncRequest": { + "type": "object", + "title": "ApplicationSyncRequest is a request to apply the config state to live state", + "properties": { + "appNamespace": { + "type": "string" + }, + "dryRun": { + "type": "boolean" + }, + "infos": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1Info" + } + }, + "manifests": { + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "type": "string" + }, + "project": { + "type": "string" + }, + "prune": { + "type": "boolean" + }, + "resources": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1SyncOperationResource" + } + }, + "retryStrategy": { + "$ref": "#/definitions/v1alpha1RetryStrategy" + }, + "revision": { + "type": "string" + }, + "revisions": { + "type": "array", + "items": { + "type": "string" + } + }, + "sourcePositions": { + "type": "array", + "items": { + "type": "string", + "format": "int64" + } + }, + "strategy": { + "$ref": "#/definitions/v1alpha1SyncStrategy" + }, + "syncOptions": { + "$ref": "#/definitions/applicationSyncOptions" + } + } + }, + "applicationApplicationSyncWindow": { + "type": "object", + "properties": { + "duration": { + "type": "string" + }, + "kind": { + "type": "string" + }, + "manualSync": { + "type": "boolean" + }, + "schedule": { + "type": "string" + } + } + }, + "applicationApplicationSyncWindowsResponse": { + "type": "object", + "properties": { + "activeWindows": { + "type": "array", + "items": { + "$ref": "#/definitions/applicationApplicationSyncWindow" + } + }, + "assignedWindows": { + "type": "array", + "items": { + "$ref": "#/definitions/applicationApplicationSyncWindow" + } + }, + "canSync": { + "type": "boolean" + } + } + }, + "applicationFileChunk": { + "type": "object", + "properties": { + "chunk": { + "type": "string", + "format": "byte" + } + } + }, + "applicationLinkInfo": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "iconClass": { + "type": "string" + }, + "title": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, + "applicationLinksResponse": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/applicationLinkInfo" + } + } + } + }, + "applicationLogEntry": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "last": { + "type": "boolean" + }, + "podName": { + "type": "string" + }, + "timeStamp": { + "$ref": "#/definitions/v1Time" + }, + "timeStampStr": { + "type": "string" + } + } + }, + "applicationManagedResourcesResponse": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1ResourceDiff" + } + } + } + }, + "applicationOperationTerminateResponse": { + "type": "object" + }, + "applicationResourceActionParameters": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "string" + } + } + }, + "applicationResourceActionRunRequest": { + "type": "object", + "properties": { + "action": { + "type": "string" + }, + "appNamespace": { + "type": "string" + }, + "group": { + "type": "string" + }, + "kind": { + "type": "string" + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + }, + "project": { + "type": "string" + }, + "resourceActionParameters": { + "type": "array", + "items": { + "$ref": "#/definitions/applicationResourceActionParameters" + } + }, + "resourceName": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "applicationResourceActionsListResponse": { + "type": "object", + "properties": { + "actions": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1ResourceAction" + } + } + } + }, + "applicationSyncOptions": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "applicationsetApplicationSetGenerateRequest": { + "type": "object", + "title": "ApplicationSetGetQuery is a query for applicationset resources", + "properties": { + "applicationSet": { + "$ref": "#/definitions/v1alpha1ApplicationSet" + } + } + }, + "applicationsetApplicationSetGenerateResponse": { + "type": "object", + "title": "ApplicationSetGenerateResponse is a response for applicationset generate request", + "properties": { + "applications": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1Application" + } + } + } + }, + "applicationsetApplicationSetResponse": { + "type": "object", + "properties": { + "applicationset": { + "$ref": "#/definitions/v1alpha1ApplicationSet" + }, + "project": { + "type": "string" + } + } + }, + "applicationv1alpha1EnvEntry": { + "type": "object", + "title": "EnvEntry represents an entry in the application's environment", + "properties": { + "name": { + "type": "string", + "title": "Name is the name of the variable, usually expressed in uppercase" + }, + "value": { + "type": "string", + "title": "Value is the value of the variable" + } + } + }, + "applicationv1alpha1ResourceStatus": { + "description": "ResourceStatus holds the current synchronization and health status of a Kubernetes resource.", + "type": "object", + "properties": { + "group": { + "description": "Group represents the API group of the resource (e.g., \"apps\" for Deployments).", + "type": "string" + }, + "health": { + "$ref": "#/definitions/v1alpha1HealthStatus" + }, + "hook": { + "description": "Hook is true if the resource is used as a lifecycle hook in an Argo CD application.", + "type": "boolean" + }, + "kind": { + "description": "Kind specifies the type of the resource (e.g., \"Deployment\", \"Service\").", + "type": "string" + }, + "name": { + "description": "Name is the unique name of the resource within the namespace.", + "type": "string" + }, + "namespace": { + "description": "Namespace defines the Kubernetes namespace where the resource is located.", + "type": "string" + }, + "requiresDeletionConfirmation": { + "description": "RequiresDeletionConfirmation is true if the resource requires explicit user confirmation before deletion.", + "type": "boolean" + }, + "requiresPruning": { + "description": "RequiresPruning is true if the resource needs to be pruned (deleted) as part of synchronization.", + "type": "boolean" + }, + "status": { + "description": "Status represents the synchronization state of the resource (e.g., Synced, OutOfSync).", + "type": "string" + }, + "syncWave": { + "description": "SyncWave determines the order in which resources are applied during a sync operation.\nLower values are applied first.", + "type": "integer", + "format": "int64" + }, + "version": { + "description": "Version indicates the API version of the resource (e.g., \"v1\", \"v1beta1\").", + "type": "string" + } + } + }, + "clusterClusterID": { + "type": "object", + "title": "ClusterID holds a cluster server URL or cluster name", + "properties": { + "type": { + "type": "string", + "title": "type is the type of the specified cluster identifier ( \"server\" - default, \"name\" )" + }, + "value": { + "type": "string", + "title": "value holds the cluster server URL or cluster name" + } + } + }, + "clusterClusterResponse": { + "type": "object" + }, + "clusterConnector": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "clusterDexConfig": { + "type": "object", + "properties": { + "connectors": { + "type": "array", + "items": { + "$ref": "#/definitions/clusterConnector" + } + } + } + }, + "clusterGoogleAnalyticsConfig": { + "type": "object", + "properties": { + "anonymizeUsers": { + "type": "boolean" + }, + "trackingID": { + "type": "string" + } + } + }, + "clusterHelp": { + "type": "object", + "title": "Help settings", + "properties": { + "binaryUrls": { + "type": "object", + "title": "the URLs for downloading argocd binaries", + "additionalProperties": { + "type": "string" + } + }, + "chatText": { + "type": "string", + "title": "the text for getting chat help, defaults to \"Chat now!\"" + }, + "chatUrl": { + "type": "string", + "title": "the URL for getting chat help, this will typically be your Slack channel for support" + } + } + }, + "clusterOIDCConfig": { + "type": "object", + "properties": { + "cliClientID": { + "type": "string" + }, + "clientID": { + "type": "string" + }, + "enablePKCEAuthentication": { + "type": "boolean" + }, + "idTokenClaims": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/oidcClaim" + } + }, + "issuer": { + "type": "string" + }, + "name": { + "type": "string" + }, + "scopes": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "clusterPlugin": { + "type": "object", + "title": "Plugin settings", + "properties": { + "name": { + "type": "string", + "title": "the name of the plugin, e.g. \"kasane\"" + } + } + }, + "clusterSettings": { + "type": "object", + "properties": { + "additionalUrls": { + "type": "array", + "items": { + "type": "string" + } + }, + "appLabelKey": { + "type": "string" + }, + "appsInAnyNamespaceEnabled": { + "type": "boolean" + }, + "configManagementPlugins": { + "description": "Deprecated: use sidecar plugins instead.", + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1ConfigManagementPlugin" + } + }, + "controllerNamespace": { + "type": "string" + }, + "dexConfig": { + "$ref": "#/definitions/clusterDexConfig" + }, + "execEnabled": { + "type": "boolean" + }, + "googleAnalytics": { + "$ref": "#/definitions/clusterGoogleAnalyticsConfig" + }, + "help": { + "$ref": "#/definitions/clusterHelp" + }, + "hydratorEnabled": { + "type": "boolean" + }, + "impersonationEnabled": { + "type": "boolean" + }, + "installationID": { + "type": "string" + }, + "kustomizeOptions": { + "$ref": "#/definitions/v1alpha1KustomizeOptions" + }, + "kustomizeVersions": { + "type": "array", + "items": { + "type": "string" + } + }, + "oidcConfig": { + "$ref": "#/definitions/clusterOIDCConfig" + }, + "passwordPattern": { + "type": "string" + }, + "plugins": { + "type": "array", + "items": { + "$ref": "#/definitions/clusterPlugin" + } + }, + "resourceOverrides": { + "type": "object", + "additionalProperties": { + "$ref": "#/definitions/v1alpha1ResourceOverride" + } + }, + "statusBadgeEnabled": { + "type": "boolean" + }, + "statusBadgeRootUrl": { + "type": "string" + }, + "trackingMethod": { + "type": "string" + }, + "uiBannerContent": { + "type": "string" + }, + "uiBannerPermanent": { + "type": "boolean" + }, + "uiBannerPosition": { + "type": "string" + }, + "uiBannerURL": { + "type": "string" + }, + "uiCssURL": { + "type": "string" + }, + "url": { + "type": "string" + }, + "userLoginsDisabled": { + "type": "boolean" + } + } + }, + "clusterSettingsPluginsResponse": { + "type": "object", + "properties": { + "plugins": { + "type": "array", + "items": { + "$ref": "#/definitions/clusterPlugin" + } + } + } + }, + "gpgkeyGnuPGPublicKeyCreateResponse": { + "type": "object", + "title": "Response to a public key creation request", + "properties": { + "created": { + "$ref": "#/definitions/v1alpha1GnuPGPublicKeyList" + }, + "skipped": { + "type": "array", + "title": "List of key IDs that haven been skipped because they already exist on the server", + "items": { + "type": "string" + } + } + } + }, + "gpgkeyGnuPGPublicKeyResponse": { + "type": "object", + "title": "Generic (empty) response for GPG public key CRUD requests" + }, + "intstrIntOrString": { + "description": "+protobuf=true\n+protobuf.options.(gogoproto.goproto_stringer)=false\n+k8s:openapi-gen=true", + "type": "object", + "title": "IntOrString is a type that can hold an int32 or a string. When used in\nJSON or YAML marshalling and unmarshalling, it produces or consumes the\ninner type. This allows you to have, for example, a JSON field that can\naccept a name or number.\nTODO: Rename to Int32OrString", + "properties": { + "intVal": { + "type": "integer", + "format": "int32" + }, + "strVal": { + "type": "string" + }, + "type": { + "type": "integer", + "format": "int64" + } + } + }, + "notificationService": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + } + }, + "notificationServiceList": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/notificationService" + } + } + } + }, + "notificationTemplate": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + } + }, + "notificationTemplateList": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/notificationTemplate" + } + } + } + }, + "notificationTrigger": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + } + }, + "notificationTriggerList": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/notificationTrigger" + } + } + } + }, + "oidcClaim": { + "type": "object", + "properties": { + "essential": { + "type": "boolean" + }, + "value": { + "type": "string" + }, + "values": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "projectDetailedProjectsResponse": { + "type": "object", + "properties": { + "clusters": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1Cluster" + } + }, + "globalProjects": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1AppProject" + } + }, + "project": { + "$ref": "#/definitions/v1alpha1AppProject" + }, + "repositories": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1Repository" + } + } + } + }, + "projectEmptyResponse": { + "type": "object" + }, + "projectGlobalProjectsResponse": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1AppProject" + } + } + } + }, + "projectProjectCreateRequest": { + "description": "ProjectCreateRequest defines project creation parameters.", + "type": "object", + "properties": { + "project": { + "$ref": "#/definitions/v1alpha1AppProject" + }, + "upsert": { + "type": "boolean" + } + } + }, + "projectProjectTokenCreateRequest": { + "description": "ProjectTokenCreateRequest defines project token creation parameters.", + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "expiresIn": { + "type": "integer", + "format": "int64", + "title": "expiresIn represents a duration in seconds" + }, + "id": { + "type": "string" + }, + "project": { + "type": "string" + }, + "role": { + "type": "string" + } + } + }, + "projectProjectTokenResponse": { + "description": "ProjectTokenResponse wraps the created token or returns an empty string if deleted.", + "type": "object", + "properties": { + "token": { + "type": "string" + } + } + }, + "projectProjectUpdateRequest": { + "type": "object", + "properties": { + "project": { + "$ref": "#/definitions/v1alpha1AppProject" + } + } + }, + "projectSyncWindowsResponse": { + "type": "object", + "properties": { + "windows": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1SyncWindow" + } + } + } + }, + "protobufAny": { + "type": "object", + "properties": { + "type_url": { + "type": "string" + }, + "value": { + "type": "string", + "format": "byte" + } + } + }, + "repocredsRepoCredsResponse": { + "type": "object", + "title": "RepoCredsResponse is a response to most repository credentials requests" + }, + "repositoryAppInfo": { + "type": "object", + "title": "AppInfo contains application type and app file path", + "properties": { + "path": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "repositoryDirectoryAppSpec": { + "type": "object", + "title": "DirectoryAppSpec contains directory" + }, + "repositoryHelmAppSpec": { + "type": "object", + "title": "HelmAppSpec contains helm app name in source repo", + "properties": { + "fileParameters": { + "type": "array", + "title": "helm file parameters", + "items": { + "$ref": "#/definitions/v1alpha1HelmFileParameter" + } + }, + "name": { + "type": "string" + }, + "parameters": { + "type": "array", + "title": "the output of `helm inspect values`", + "items": { + "$ref": "#/definitions/v1alpha1HelmParameter" + } + }, + "valueFiles": { + "type": "array", + "items": { + "type": "string" + } + }, + "values": { + "type": "string", + "title": "the contents of values.yaml" + } + } + }, + "repositoryHelmChart": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "versions": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "repositoryHelmChartsResponse": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/repositoryHelmChart" + } + } + } + }, + "repositoryKustomizeAppSpec": { + "type": "object", + "title": "KustomizeAppSpec contains kustomize images", + "properties": { + "images": { + "description": "images is a list of available images.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "repositoryManifestResponse": { + "type": "object", + "properties": { + "commands": { + "type": "array", + "title": "Commands is the list of commands used to hydrate the manifests", + "items": { + "type": "string" + } + }, + "manifests": { + "type": "array", + "items": { + "type": "string" + } + }, + "namespace": { + "type": "string" + }, + "revision": { + "type": "string", + "title": "resolved revision" + }, + "server": { + "type": "string" + }, + "sourceType": { + "type": "string" + }, + "verifyResult": { + "type": "string", + "title": "Raw response of git verify-commit operation (always the empty string for Helm)" + } + } + }, + "repositoryParameterAnnouncement": { + "type": "object", + "properties": { + "array": { + "description": "array is the default value of the parameter if the parameter is an array.", + "type": "array", + "items": { + "type": "string" + } + }, + "collectionType": { + "description": "collectionType is the type of value this parameter holds - either a single value (a string) or a collection\n(array or map). If collectionType is set, only the field with that type will be used. If collectionType is not\nset, `string` is the default. If collectionType is set to an invalid value, a validation error is thrown.", + "type": "string" + }, + "itemType": { + "description": "itemType determines the primitive data type represented by the parameter. Parameters are always encoded as\nstrings, but this field lets them be interpreted as other primitive types.", + "type": "string" + }, + "map": { + "description": "map is the default value of the parameter if the parameter is a map.", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "name": { + "description": "name is the name identifying a parameter.", + "type": "string" + }, + "required": { + "description": "required defines if this given parameter is mandatory.", + "type": "boolean" + }, + "string": { + "description": "string is the default value of the parameter if the parameter is a string.", + "type": "string" + }, + "title": { + "description": "title is a human-readable text of the parameter name.", + "type": "string" + }, + "tooltip": { + "description": "tooltip is a human-readable description of the parameter.", + "type": "string" + } + } + }, + "repositoryPluginAppSpec": { + "type": "object", + "title": "PluginAppSpec contains details about a plugin-type Application", + "properties": { + "parametersAnnouncement": { + "type": "array", + "items": { + "$ref": "#/definitions/repositoryParameterAnnouncement" + } + } + } + }, + "repositoryRefs": { + "type": "object", + "title": "A subset of the repository's named refs", + "properties": { + "branches": { + "type": "array", + "items": { + "type": "string" + } + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "repositoryRepoAppDetailsQuery": { + "type": "object", + "title": "RepoAppDetailsQuery contains query information for app details request", + "properties": { + "appName": { + "type": "string" + }, + "appProject": { + "type": "string" + }, + "source": { + "$ref": "#/definitions/v1alpha1ApplicationSource" + }, + "sourceIndex": { + "type": "integer", + "format": "int32", + "title": "source index (for multi source apps)" + }, + "versionId": { + "type": "integer", + "format": "int32", + "title": "versionId from historical data (for multi source apps)" + } + } + }, + "repositoryRepoAppDetailsResponse": { + "type": "object", + "title": "RepoAppDetailsResponse application details", + "properties": { + "directory": { + "$ref": "#/definitions/repositoryDirectoryAppSpec" + }, + "helm": { + "$ref": "#/definitions/repositoryHelmAppSpec" + }, + "kustomize": { + "$ref": "#/definitions/repositoryKustomizeAppSpec" + }, + "plugin": { + "$ref": "#/definitions/repositoryPluginAppSpec" + }, + "type": { + "type": "string" + } + } + }, + "repositoryRepoAppsResponse": { + "type": "object", + "title": "RepoAppsResponse contains applications of specified repository", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/repositoryAppInfo" + } + } + } + }, + "repositoryRepoResponse": { + "type": "object" + }, + "runtimeError": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/protobufAny" + } + }, + "error": { + "type": "string" + }, + "message": { + "type": "string" + } + } + }, + "runtimeRawExtension": { + "description": "RawExtension is used to hold extensions in external versions.\n\nTo use this, make a field which has RawExtension as its type in your external, versioned\nstruct, and Object in your internal struct. You also need to register your\nvarious plugin types.\n\n// Internal package:\n\n\ttype MyAPIObject struct {\n\t\truntime.TypeMeta `json:\",inline\"`\n\t\tMyPlugin runtime.Object `json:\"myPlugin\"`\n\t}\n\n\ttype PluginA struct {\n\t\tAOption string `json:\"aOption\"`\n\t}\n\n// External package:\n\n\ttype MyAPIObject struct {\n\t\truntime.TypeMeta `json:\",inline\"`\n\t\tMyPlugin runtime.RawExtension `json:\"myPlugin\"`\n\t}\n\n\ttype PluginA struct {\n\t\tAOption string `json:\"aOption\"`\n\t}\n\n// On the wire, the JSON will look something like this:\n\n\t{\n\t\t\"kind\":\"MyAPIObject\",\n\t\t\"apiVersion\":\"v1\",\n\t\t\"myPlugin\": {\n\t\t\t\"kind\":\"PluginA\",\n\t\t\t\"aOption\":\"foo\",\n\t\t},\n\t}\n\nSo what happens? Decode first uses json or yaml to unmarshal the serialized data into\nyour external MyAPIObject. That causes the raw JSON to be stored, but not unpacked.\nThe next step is to copy (using pkg/conversion) into the internal struct. The runtime\npackage's DefaultScheme has conversion functions installed which will unpack the\nJSON stored in RawExtension, turning it into the correct object type, and storing it\nin the Object. (TODO: In the case where the object is of an unknown type, a\nruntime.Unknown object will be created and stored.)\n\n+k8s:deepcopy-gen=true\n+protobuf=true\n+k8s:openapi-gen=true", + "type": "object", + "properties": { + "raw": { + "description": "Raw is the underlying serialization of this object.\n\nTODO: Determine how to detect ContentType and ContentEncoding of 'Raw' data.", + "type": "string", + "format": "byte" + } + } + }, + "runtimeStreamError": { + "type": "object", + "properties": { + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/protobufAny" + } + }, + "grpc_code": { + "type": "integer", + "format": "int32" + }, + "http_code": { + "type": "integer", + "format": "int32" + }, + "http_status": { + "type": "string" + }, + "message": { + "type": "string" + } + } + }, + "sessionGetUserInfoResponse": { + "type": "object", + "title": "The current user's userInfo info", + "properties": { + "groups": { + "type": "array", + "items": { + "type": "string" + } + }, + "iss": { + "type": "string" + }, + "loggedIn": { + "type": "boolean" + }, + "username": { + "type": "string" + } + } + }, + "sessionSessionCreateRequest": { + "description": "SessionCreateRequest is for logging in.", + "type": "object", + "properties": { + "password": { + "type": "string" + }, + "token": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, + "sessionSessionResponse": { + "description": "SessionResponse wraps the created token or returns an empty string if deleted.", + "type": "object", + "properties": { + "token": { + "type": "string" + } + } + }, + "v1Event": { + "description": "Event is a report of an event somewhere in the cluster. Events\nhave a limited retention time and triggers and messages may evolve\nwith time. Event consumers should not rely on the timing of an event\nwith a given Reason reflecting a consistent underlying trigger, or the\ncontinued existence of events with that Reason. Events should be\ntreated as informative, best-effort, supplemental data.", + "type": "object", + "properties": { + "action": { + "type": "string", + "title": "What action was taken/failed regarding to the Regarding object.\n+optional" + }, + "count": { + "type": "integer", + "format": "int32", + "title": "The number of times this event has occurred.\n+optional" + }, + "eventTime": { + "$ref": "#/definitions/v1MicroTime" + }, + "firstTimestamp": { + "$ref": "#/definitions/v1Time" + }, + "involvedObject": { + "$ref": "#/definitions/v1ObjectReference" + }, + "lastTimestamp": { + "$ref": "#/definitions/v1Time" + }, + "message": { + "type": "string", + "title": "A human-readable description of the status of this operation.\nTODO: decide on maximum length.\n+optional" + }, + "metadata": { + "$ref": "#/definitions/v1ObjectMeta" + }, + "reason": { + "type": "string", + "title": "This should be a short, machine understandable string that gives the reason\nfor the transition into the object's current status.\nTODO: provide exact specification for format.\n+optional" + }, + "related": { + "$ref": "#/definitions/v1ObjectReference" + }, + "reportingComponent": { + "type": "string", + "title": "Name of the controller that emitted this Event, e.g. `kubernetes.io/kubelet`.\n+optional" + }, + "reportingInstance": { + "type": "string", + "title": "ID of the controller instance, e.g. `kubelet-xyzf`.\n+optional" + }, + "series": { + "$ref": "#/definitions/v1EventSeries" + }, + "source": { + "$ref": "#/definitions/v1EventSource" + }, + "type": { + "type": "string", + "title": "Type of this event (Normal, Warning), new types could be added in the future\n+optional" + } + } + }, + "v1EventList": { + "description": "EventList is a list of events.", + "type": "object", + "properties": { + "items": { + "type": "array", + "title": "List of events", + "items": { + "$ref": "#/definitions/v1Event" + } + }, + "metadata": { + "$ref": "#/definitions/v1ListMeta" + } + } + }, + "v1EventSeries": { + "description": "EventSeries contain information on series of events, i.e. thing that was/is happening\ncontinuously for some time.", + "type": "object", + "properties": { + "count": { + "type": "integer", + "format": "int32", + "title": "Number of occurrences in this series up to the last heartbeat time" + }, + "lastObservedTime": { + "$ref": "#/definitions/v1MicroTime" + } + } + }, + "v1EventSource": { + "description": "EventSource contains information for an event.", + "type": "object", + "properties": { + "component": { + "type": "string", + "title": "Component from which the event is generated.\n+optional" + }, + "host": { + "type": "string", + "title": "Node name on which the event is generated.\n+optional" + } + } + }, + "v1FieldsV1": { + "description": "FieldsV1 stores a set of fields in a data structure like a Trie, in JSON format.\n\nEach key is either a '.' representing the field itself, and will always map to an empty set,\nor a string representing a sub-field or item. The string will follow one of these four formats:\n'f:', where is the name of a field in a struct, or key in a map\n'v:', where is the exact json formatted value of a list item\n'i:', where is position of a item in a list\n'k:', where is a map of a list item's key fields to their unique values\nIf a key maps to an empty Fields value, the field that key represents is part of the set.\n\nThe exact format is defined in sigs.k8s.io/structured-merge-diff\n+protobuf.options.(gogoproto.goproto_stringer)=false", + "type": "object", + "properties": { + "Raw": { + "description": "Raw is the underlying serialization of this object.", + "type": "string", + "format": "byte" + } + } + }, + "v1GroupKind": { + "description": "+protobuf.options.(gogoproto.goproto_stringer)=false", + "type": "object", + "title": "GroupKind specifies a Group and a Kind, but does not force a version. This is useful for identifying\nconcepts during lookup stages without having partially valid types", + "properties": { + "group": { + "type": "string" + }, + "kind": { + "type": "string" + } + } + }, + "v1JSON": { + "description": "JSON represents any valid JSON value.\nThese types are supported: bool, int64, float64, string, []interface{}, map[string]interface{} and nil.", + "type": "object", + "properties": { + "raw": { + "type": "string", + "format": "byte" + } + } + }, + "v1LabelSelector": { + "type": "object", + "title": "A label selector is a label query over a set of resources. The result of matchLabels and\nmatchExpressions are ANDed. An empty label selector matches all objects. A null\nlabel selector matches no objects.\n+structType=atomic", + "properties": { + "matchExpressions": { + "type": "array", + "title": "matchExpressions is a list of label selector requirements. The requirements are ANDed.\n+optional\n+listType=atomic", + "items": { + "$ref": "#/definitions/v1LabelSelectorRequirement" + } + }, + "matchLabels": { + "type": "object", + "title": "matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels\nmap is equivalent to an element of matchExpressions, whose key field is \"key\", the\noperator is \"In\", and the values array contains only \"value\". The requirements are ANDed.\n+optional", + "additionalProperties": { + "type": "string" + } + } + } + }, + "v1LabelSelectorRequirement": { + "description": "A label selector requirement is a selector that contains values, a key, and an operator that\nrelates the key and values.", + "type": "object", + "properties": { + "key": { + "description": "key is the label key that the selector applies to.", + "type": "string" + }, + "operator": { + "description": "operator represents a key's relationship to a set of values.\nValid operators are In, NotIn, Exists and DoesNotExist.", + "type": "string" + }, + "values": { + "type": "array", + "title": "values is an array of string values. If the operator is In or NotIn,\nthe values array must be non-empty. If the operator is Exists or DoesNotExist,\nthe values array must be empty. This array is replaced during a strategic\nmerge patch.\n+optional\n+listType=atomic", + "items": { + "type": "string" + } + } + } + }, + "v1ListMeta": { + "description": "ListMeta describes metadata that synthetic resources must have, including lists and\nvarious status objects. A resource may have only one of {ObjectMeta, ListMeta}.", + "type": "object", + "properties": { + "continue": { + "description": "continue may be set if the user set a limit on the number of items returned, and indicates that\nthe server has more data available. The value is opaque and may be used to issue another request\nto the endpoint that served this list to retrieve the next set of available objects. Continuing a\nconsistent list may not be possible if the server configuration has changed or more than a few\nminutes have passed. The resourceVersion field returned when using this continue value will be\nidentical to the value in the first response, unless you have received this token from an error\nmessage.", + "type": "string" + }, + "remainingItemCount": { + "type": "integer", + "format": "int64", + "title": "remainingItemCount is the number of subsequent items in the list which are not included in this\nlist response. If the list request contained label or field selectors, then the number of\nremaining items is unknown and the field will be left unset and omitted during serialization.\nIf the list is complete (either because it is not chunking or because this is the last chunk),\nthen there are no more remaining items and this field will be left unset and omitted during\nserialization.\nServers older than v1.15 do not set this field.\nThe intended use of the remainingItemCount is *estimating* the size of a collection. Clients\nshould not rely on the remainingItemCount to be set or to be exact.\n+optional" + }, + "resourceVersion": { + "type": "string", + "title": "String that identifies the server's internal version of this object that\ncan be used by clients to determine when objects have changed.\nValue must be treated as opaque by clients and passed unmodified back to the server.\nPopulated by the system.\nRead-only.\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency\n+optional" + }, + "selfLink": { + "type": "string", + "title": "Deprecated: selfLink is a legacy read-only field that is no longer populated by the system.\n+optional" + } + } + }, + "v1LoadBalancerIngress": { + "description": "LoadBalancerIngress represents the status of a load-balancer ingress point:\ntraffic intended for the service should be sent to an ingress point.", + "type": "object", + "properties": { + "hostname": { + "type": "string", + "title": "Hostname is set for load-balancer ingress points that are DNS based\n(typically AWS load-balancers)\n+optional" + }, + "ip": { + "type": "string", + "title": "IP is set for load-balancer ingress points that are IP based\n(typically GCE or OpenStack load-balancers)\n+optional" + }, + "ipMode": { + "type": "string", + "title": "IPMode specifies how the load-balancer IP behaves, and may only be specified when the ip field is specified.\nSetting this to \"VIP\" indicates that traffic is delivered to the node with\nthe destination set to the load-balancer's IP and port.\nSetting this to \"Proxy\" indicates that traffic is delivered to the node or pod with\nthe destination set to the node's IP and node port or the pod's IP and port.\nService implementations may use this information to adjust traffic routing.\n+optional" + }, + "ports": { + "type": "array", + "title": "Ports is a list of records of service ports\nIf used, every port defined in the service should have an entry in it\n+listType=atomic\n+optional", + "items": { + "$ref": "#/definitions/v1PortStatus" + } + } + } + }, + "v1ManagedFieldsEntry": { + "description": "ManagedFieldsEntry is a workflow-id, a FieldSet and the group version of the resource\nthat the fieldset applies to.", + "type": "object", + "properties": { + "apiVersion": { + "description": "APIVersion defines the version of this resource that this field set\napplies to. The format is \"group/version\" just like the top-level\nAPIVersion field. It is necessary to track the version of a field\nset because it cannot be automatically converted.", + "type": "string" + }, + "fieldsType": { + "type": "string", + "title": "FieldsType is the discriminator for the different fields format and version.\nThere is currently only one possible value: \"FieldsV1\"" + }, + "fieldsV1": { + "$ref": "#/definitions/v1FieldsV1" + }, + "manager": { + "description": "Manager is an identifier of the workflow managing these fields.", + "type": "string" + }, + "operation": { + "description": "Operation is the type of operation which lead to this ManagedFieldsEntry being created.\nThe only valid values for this field are 'Apply' and 'Update'.", + "type": "string" + }, + "subresource": { + "description": "Subresource is the name of the subresource used to update that object, or\nempty string if the object was updated through the main resource. The\nvalue of this field is used to distinguish between managers, even if they\nshare the same name. For example, a status update will be distinct from a\nregular update using the same manager name.\nNote that the APIVersion field is not related to the Subresource field and\nit always corresponds to the version of the main resource.", + "type": "string" + }, + "time": { + "$ref": "#/definitions/v1Time" + } + } + }, + "v1MicroTime": { + "description": "MicroTime is version of Time with microsecond level precision.\n\n+protobuf.options.marshal=false\n+protobuf.as=Timestamp\n+protobuf.options.(gogoproto.goproto_stringer)=false", + "type": "object", + "properties": { + "nanos": { + "description": "Non-negative fractions of a second at nanosecond resolution. Negative\nsecond values with fractions must still have non-negative nanos values\nthat count forward in time. Must be from 0 to 999,999,999\ninclusive. This field may be limited in precision depending on context.", + "type": "integer", + "format": "int32" + }, + "seconds": { + "description": "Represents seconds of UTC time since Unix epoch\n1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n9999-12-31T23:59:59Z inclusive.", + "type": "integer", + "format": "int64" + } + } + }, + "v1NodeSystemInfo": { + "description": "NodeSystemInfo is a set of ids/uuids to uniquely identify the node.", + "type": "object", + "properties": { + "architecture": { + "type": "string", + "title": "The Architecture reported by the node" + }, + "bootID": { + "description": "Boot ID reported by the node.", + "type": "string" + }, + "containerRuntimeVersion": { + "description": "ContainerRuntime Version reported by the node through runtime remote API (e.g. containerd://1.4.2).", + "type": "string" + }, + "kernelVersion": { + "description": "Kernel Version reported by the node from 'uname -r' (e.g. 3.16.0-0.bpo.4-amd64).", + "type": "string" + }, + "kubeProxyVersion": { + "description": "Deprecated: KubeProxy Version reported by the node.", + "type": "string" + }, + "kubeletVersion": { + "description": "Kubelet Version reported by the node.", + "type": "string" + }, + "machineID": { + "type": "string", + "title": "MachineID reported by the node. For unique machine identification\nin the cluster this field is preferred. Learn more from man(5)\nmachine-id: http://man7.org/linux/man-pages/man5/machine-id.5.html" + }, + "operatingSystem": { + "type": "string", + "title": "The Operating System reported by the node" + }, + "osImage": { + "description": "OS Image reported by the node from /etc/os-release (e.g. Debian GNU/Linux 7 (wheezy)).", + "type": "string" + }, + "systemUUID": { + "type": "string", + "title": "SystemUUID reported by the node. For unique machine identification\nMachineID is preferred. This field is specific to Red Hat hosts\nhttps://access.redhat.com/documentation/en-us/red_hat_subscription_management/1/html/rhsm/uuid" + } + } + }, + "v1ObjectMeta": { + "description": "ObjectMeta is metadata that all persisted resources must have, which includes all objects\nusers must create.", + "type": "object", + "properties": { + "annotations": { + "type": "object", + "title": "Annotations is an unstructured key value map stored with a resource that may be\nset by external tools to store and retrieve arbitrary metadata. They are not\nqueryable and should be preserved when modifying objects.\nMore info: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations\n+optional", + "additionalProperties": { + "type": "string" + } + }, + "creationTimestamp": { + "$ref": "#/definitions/v1Time" + }, + "deletionGracePeriodSeconds": { + "type": "integer", + "format": "int64", + "title": "Number of seconds allowed for this object to gracefully terminate before\nit will be removed from the system. Only set when deletionTimestamp is also set.\nMay only be shortened.\nRead-only.\n+optional" + }, + "deletionTimestamp": { + "$ref": "#/definitions/v1Time" + }, + "finalizers": { + "type": "array", + "title": "Must be empty before the object is deleted from the registry. Each entry\nis an identifier for the responsible component that will remove the entry\nfrom the list. If the deletionTimestamp of the object is non-nil, entries\nin this list can only be removed.\nFinalizers may be processed and removed in any order. Order is NOT enforced\nbecause it introduces significant risk of stuck finalizers.\nfinalizers is a shared field, any actor with permission can reorder it.\nIf the finalizer list is processed in order, then this can lead to a situation\nin which the component responsible for the first finalizer in the list is\nwaiting for a signal (field value, external system, or other) produced by a\ncomponent responsible for a finalizer later in the list, resulting in a deadlock.\nWithout enforced ordering finalizers are free to order amongst themselves and\nare not vulnerable to ordering changes in the list.\n+optional\n+patchStrategy=merge\n+listType=set", + "items": { + "type": "string" + } + }, + "generateName": { + "description": "GenerateName is an optional prefix, used by the server, to generate a unique\nname ONLY IF the Name field has not been provided.\nIf this field is used, the name returned to the client will be different\nthan the name passed. This value will also be combined with a unique suffix.\nThe provided value has the same validation rules as the Name field,\nand may be truncated by the length of the suffix required to make the value\nunique on the server.\n\nIf this field is specified and the generated name exists, the server will return a 409.\n\nApplied only if Name is not specified.\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency\n+optional", + "type": "string" + }, + "generation": { + "type": "integer", + "format": "int64", + "title": "A sequence number representing a specific generation of the desired state.\nPopulated by the system. Read-only.\n+optional" + }, + "labels": { + "type": "object", + "title": "Map of string keys and values that can be used to organize and categorize\n(scope and select) objects. May match selectors of replication controllers\nand services.\nMore info: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels\n+optional", + "additionalProperties": { + "type": "string" + } + }, + "managedFields": { + "description": "ManagedFields maps workflow-id and version to the set of fields\nthat are managed by that workflow. This is mostly for internal\nhousekeeping, and users typically shouldn't need to set or\nunderstand this field. A workflow can be the user's name, a\ncontroller's name, or the name of a specific apply path like\n\"ci-cd\". The set of fields is always in the version that the\nworkflow used when modifying the object.\n\n+optional\n+listType=atomic", + "type": "array", + "items": { + "$ref": "#/definitions/v1ManagedFieldsEntry" + } + }, + "name": { + "type": "string", + "title": "Name must be unique within a namespace. Is required when creating resources, although\nsome resources may allow a client to request the generation of an appropriate name\nautomatically. Name is primarily intended for creation idempotence and configuration\ndefinition.\nCannot be updated.\nMore info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names\n+optional" + }, + "namespace": { + "description": "Namespace defines the space within which each name must be unique. An empty namespace is\nequivalent to the \"default\" namespace, but \"default\" is the canonical representation.\nNot all objects are required to be scoped to a namespace - the value of this field for\nthose objects will be empty.\n\nMust be a DNS_LABEL.\nCannot be updated.\nMore info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces\n+optional", + "type": "string" + }, + "ownerReferences": { + "type": "array", + "title": "List of objects depended by this object. If ALL objects in the list have\nbeen deleted, this object will be garbage collected. If this object is managed by a controller,\nthen an entry in this list will point to this controller, with the controller field set to true.\nThere cannot be more than one managing controller.\n+optional\n+patchMergeKey=uid\n+patchStrategy=merge\n+listType=map\n+listMapKey=uid", + "items": { + "$ref": "#/definitions/v1OwnerReference" + } + }, + "resourceVersion": { + "description": "An opaque value that represents the internal version of this object that can\nbe used by clients to determine when objects have changed. May be used for optimistic\nconcurrency, change detection, and the watch operation on a resource or set of resources.\nClients must treat these values as opaque and passed unmodified back to the server.\nThey may only be valid for a particular resource or set of resources.\n\nPopulated by the system.\nRead-only.\nValue must be treated as opaque by clients and .\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency\n+optional", + "type": "string" + }, + "selfLink": { + "type": "string", + "title": "Deprecated: selfLink is a legacy read-only field that is no longer populated by the system.\n+optional" + }, + "uid": { + "description": "UID is the unique in time and space value for this object. It is typically generated by\nthe server on successful creation of a resource and is not allowed to change on PUT\noperations.\n\nPopulated by the system.\nRead-only.\nMore info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids\n+optional", + "type": "string" + } + } + }, + "v1ObjectReference": { + "description": "ObjectReference contains enough information to let you inspect or modify the referred object.\n---\nNew uses of this type are discouraged because of difficulty describing its usage when embedded in APIs.\n 1. Ignored fields. It includes many fields which are not generally honored. For instance, ResourceVersion and FieldPath are both very rarely valid in actual usage.\n 2. Invalid usage help. It is impossible to add specific help for individual usage. In most embedded usages, there are particular\n restrictions like, \"must refer only to types A and B\" or \"UID not honored\" or \"name must be restricted\".\n Those cannot be well described when embedded.\n 3. Inconsistent validation. Because the usages are different, the validation rules are different by usage, which makes it hard for users to predict what will happen.\n 4. The fields are both imprecise and overly precise. Kind is not a precise mapping to a URL. This can produce ambiguity\n during interpretation and require a REST mapping. In most cases, the dependency is on the group,resource tuple\n and the version of the actual struct is irrelevant.\n 5. We cannot easily change it. Because this type is embedded in many locations, updates to this type\n will affect numerous schemas. Don't make new APIs embed an underspecified API type they do not control.\n\nInstead of using this type, create a locally provided and used type that is well-focused on your reference.\nFor example, ServiceReferences for admission registration: https://github.com/kubernetes/api/blob/release-1.17/admissionregistration/v1/types.go#L533 .\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object\n+structType=atomic", + "type": "object", + "properties": { + "apiVersion": { + "type": "string", + "title": "API version of the referent.\n+optional" + }, + "fieldPath": { + "type": "string", + "title": "If referring to a piece of an object instead of an entire object, this string\nshould contain a valid JSON/Go field access statement, such as desiredState.manifest.containers[2].\nFor example, if the object reference is to a container within a pod, this would take on a value like:\n\"spec.containers{name}\" (where \"name\" refers to the name of the container that triggered\nthe event) or if no container name is specified \"spec.containers[2]\" (container with\nindex 2 in this pod). This syntax is chosen only to have some well-defined way of\nreferencing a part of an object.\nTODO: this design is not final and this field is subject to change in the future.\n+optional" + }, + "kind": { + "type": "string", + "title": "Kind of the referent.\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds\n+optional" + }, + "name": { + "type": "string", + "title": "Name of the referent.\nMore info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names\n+optional" + }, + "namespace": { + "type": "string", + "title": "Namespace of the referent.\nMore info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/\n+optional" + }, + "resourceVersion": { + "type": "string", + "title": "Specific resourceVersion to which this reference is made, if any.\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency\n+optional" + }, + "uid": { + "type": "string", + "title": "UID of the referent.\nMore info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#uids\n+optional" + } + } + }, + "v1OwnerReference": { + "type": "object", + "title": "OwnerReference contains enough information to let you identify an owning\nobject. An owning object must be in the same namespace as the dependent, or\nbe cluster-scoped, so there is no namespace field.\n+structType=atomic", + "properties": { + "apiVersion": { + "description": "API version of the referent.", + "type": "string" + }, + "blockOwnerDeletion": { + "type": "boolean", + "title": "If true, AND if the owner has the \"foregroundDeletion\" finalizer, then\nthe owner cannot be deleted from the key-value store until this\nreference is removed.\nSee https://kubernetes.io/docs/concepts/architecture/garbage-collection/#foreground-deletion\nfor how the garbage collector interacts with this field and enforces the foreground deletion.\nDefaults to false.\nTo set this field, a user needs \"delete\" permission of the owner,\notherwise 422 (Unprocessable Entity) will be returned.\n+optional" + }, + "controller": { + "type": "boolean", + "title": "If true, this reference points to the managing controller.\n+optional" + }, + "kind": { + "type": "string", + "title": "Kind of the referent.\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds" + }, + "name": { + "type": "string", + "title": "Name of the referent.\nMore info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#names" + }, + "uid": { + "type": "string", + "title": "UID of the referent.\nMore info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names#uids" + } + } + }, + "v1PortStatus": { + "type": "object", + "title": "PortStatus represents the error condition of a service port", + "properties": { + "error": { + "type": "string", + "title": "Error is to record the problem with the service port\nThe format of the error shall comply with the following rules:\n- built-in error values shall be specified in this file and those shall use\n CamelCase names\n- cloud provider specific error values must have names that comply with the\n format foo.example.com/CamelCase.\n---\nThe regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)\n+optional\n+kubebuilder:validation:Required\n+kubebuilder:validation:Pattern=`^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$`\n+kubebuilder:validation:MaxLength=316" + }, + "port": { + "type": "integer", + "format": "int32", + "title": "Port is the port number of the service port of which status is recorded here" + }, + "protocol": { + "type": "string", + "title": "Protocol is the protocol of the service port of which status is recorded here\nThe supported values are: \"TCP\", \"UDP\", \"SCTP\"" + } + } + }, + "v1Time": { + "description": "Time is a wrapper around time.Time which supports correct\nmarshaling to YAML and JSON. Wrappers are provided for many\nof the factory methods that the time package offers.\n\n+protobuf.options.marshal=false\n+protobuf.as=Timestamp\n+protobuf.options.(gogoproto.goproto_stringer)=false", + "type": "string", + "format": "date-time" + }, + "v1alpha1AWSAuthConfig": { + "type": "object", + "title": "AWSAuthConfig is an AWS IAM authentication configuration", + "properties": { + "clusterName": { + "type": "string", + "title": "ClusterName contains AWS cluster name" + }, + "profile": { + "description": "Profile contains optional role ARN. If set then AWS IAM Authenticator uses the profile to perform cluster operations instead of the default AWS credential provider chain.", + "type": "string" + }, + "roleARN": { + "description": "RoleARN contains optional role ARN. If set then AWS IAM Authenticator assume a role to perform cluster operations instead of the default AWS credential provider chain.", + "type": "string" + } + } + }, + "v1alpha1AppHealthStatus": { + "type": "object", + "title": "AppHealthStatus contains information about the currently observed health state of an application", + "properties": { + "lastTransitionTime": { + "$ref": "#/definitions/v1Time" + }, + "message": { + "description": "Deprecated: this field is not used and will be removed in a future release.", + "type": "string", + "title": "Message is a human-readable informational message describing the health status" + }, + "status": { + "type": "string", + "title": "Status holds the status code of the application" + } + } + }, + "v1alpha1AppProject": { + "type": "object", + "title": "AppProject provides a logical grouping of applications, providing controls for:\n* where the apps may deploy to (cluster whitelist)\n* what may be deployed (repository whitelist, resource whitelist/blacklist)\n* who can access these applications (roles, OIDC group claims bindings)\n* and what they can do (RBAC policies)\n* automation access to these roles (JWT tokens)\n+genclient\n+genclient:noStatus\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object\n+kubebuilder:resource:path=appprojects,shortName=appproj;appprojs", + "properties": { + "metadata": { + "$ref": "#/definitions/v1ObjectMeta" + }, + "spec": { + "$ref": "#/definitions/v1alpha1AppProjectSpec" + }, + "status": { + "$ref": "#/definitions/v1alpha1AppProjectStatus" + } + } + }, + "v1alpha1AppProjectList": { + "type": "object", + "title": "AppProjectList is list of AppProject resources\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1AppProject" + } + }, + "metadata": { + "$ref": "#/definitions/v1ListMeta" + } + } + }, + "v1alpha1AppProjectSpec": { + "type": "object", + "title": "AppProjectSpec is the specification of an AppProject", + "properties": { + "clusterResourceBlacklist": { + "type": "array", + "title": "ClusterResourceBlacklist contains list of blacklisted cluster level resources", + "items": { + "$ref": "#/definitions/v1GroupKind" + } + }, + "clusterResourceWhitelist": { + "type": "array", + "title": "ClusterResourceWhitelist contains list of whitelisted cluster level resources", + "items": { + "$ref": "#/definitions/v1GroupKind" + } + }, + "description": { + "type": "string", + "title": "Description contains optional project description\n+kubebuilder:validation:MaxLength=255" + }, + "destinationServiceAccounts": { + "description": "DestinationServiceAccounts holds information about the service accounts to be impersonated for the application sync operation for each destination.", + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1ApplicationDestinationServiceAccount" + } + }, + "destinations": { + "type": "array", + "title": "Destinations contains list of destinations available for deployment", + "items": { + "$ref": "#/definitions/v1alpha1ApplicationDestination" + } + }, + "namespaceResourceBlacklist": { + "type": "array", + "title": "NamespaceResourceBlacklist contains list of blacklisted namespace level resources", + "items": { + "$ref": "#/definitions/v1GroupKind" + } + }, + "namespaceResourceWhitelist": { + "type": "array", + "title": "NamespaceResourceWhitelist contains list of whitelisted namespace level resources", + "items": { + "$ref": "#/definitions/v1GroupKind" + } + }, + "orphanedResources": { + "$ref": "#/definitions/v1alpha1OrphanedResourcesMonitorSettings" + }, + "permitOnlyProjectScopedClusters": { + "type": "boolean", + "title": "PermitOnlyProjectScopedClusters determines whether destinations can only reference clusters which are project-scoped" + }, + "roles": { + "type": "array", + "title": "Roles are user defined RBAC roles associated with this project", + "items": { + "$ref": "#/definitions/v1alpha1ProjectRole" + } + }, + "signatureKeys": { + "type": "array", + "title": "SignatureKeys contains a list of PGP key IDs that commits in Git must be signed with in order to be allowed for sync", + "items": { + "$ref": "#/definitions/v1alpha1SignatureKey" + } + }, + "sourceNamespaces": { + "type": "array", + "title": "SourceNamespaces defines the namespaces application resources are allowed to be created in", + "items": { + "type": "string" + } + }, + "sourceRepos": { + "type": "array", + "title": "SourceRepos contains list of repository URLs which can be used for deployment", + "items": { + "type": "string" + } + }, + "syncWindows": { + "type": "array", + "title": "SyncWindows controls when syncs can be run for apps in this project", + "items": { + "$ref": "#/definitions/v1alpha1SyncWindow" + } + } + } + }, + "v1alpha1AppProjectStatus": { + "type": "object", + "title": "AppProjectStatus contains status information for AppProject CRs", + "properties": { + "jwtTokensByRole": { + "type": "object", + "title": "JWTTokensByRole contains a list of JWT tokens issued for a given role", + "additionalProperties": { + "$ref": "#/definitions/v1alpha1JWTTokens" + } + } + } + }, + "v1alpha1Application": { + "type": "object", + "title": "Application is a definition of Application resource.\n+genclient\n+genclient:noStatus\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object\n+kubebuilder:resource:path=applications,shortName=app;apps\n+kubebuilder:printcolumn:name=\"Sync Status\",type=string,JSONPath=`.status.sync.status`\n+kubebuilder:printcolumn:name=\"Health Status\",type=string,JSONPath=`.status.health.status`\n+kubebuilder:printcolumn:name=\"Revision\",type=string,JSONPath=`.status.sync.revision`,priority=10\n+kubebuilder:printcolumn:name=\"Project\",type=string,JSONPath=`.spec.project`,priority=10", + "properties": { + "metadata": { + "$ref": "#/definitions/v1ObjectMeta" + }, + "operation": { + "$ref": "#/definitions/v1alpha1Operation" + }, + "spec": { + "$ref": "#/definitions/v1alpha1ApplicationSpec" + }, + "status": { + "$ref": "#/definitions/v1alpha1ApplicationStatus" + } + } + }, + "v1alpha1ApplicationCondition": { + "type": "object", + "title": "ApplicationCondition contains details about an application condition, which is usually an error or warning", + "properties": { + "lastTransitionTime": { + "$ref": "#/definitions/v1Time" + }, + "message": { + "type": "string", + "title": "Message contains human-readable message indicating details about condition" + }, + "type": { + "type": "string", + "title": "Type is an application condition type" + } + } + }, + "v1alpha1ApplicationDestination": { + "type": "object", + "title": "ApplicationDestination holds information about the application's destination", + "properties": { + "name": { + "description": "Name is an alternate way of specifying the target cluster by its symbolic name. This must be set if Server is not set.", + "type": "string" + }, + "namespace": { + "type": "string", + "title": "Namespace specifies the target namespace for the application's resources.\nThe namespace will only be set for namespace-scoped resources that have not set a value for .metadata.namespace" + }, + "server": { + "description": "Server specifies the URL of the target cluster's Kubernetes control plane API. This must be set if Name is not set.", + "type": "string" + } + } + }, + "v1alpha1ApplicationDestinationServiceAccount": { + "description": "ApplicationDestinationServiceAccount holds information about the service account to be impersonated for the application sync operation.", + "type": "object", + "properties": { + "defaultServiceAccount": { + "type": "string", + "title": "DefaultServiceAccount to be used for impersonation during the sync operation" + }, + "namespace": { + "description": "Namespace specifies the target namespace for the application's resources.", + "type": "string" + }, + "server": { + "description": "Server specifies the URL of the target cluster's Kubernetes control plane API.", + "type": "string" + } + } + }, + "v1alpha1ApplicationList": { + "type": "object", + "title": "ApplicationList is list of Application resources\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1Application" + } + }, + "metadata": { + "$ref": "#/definitions/v1ListMeta" + } + } + }, + "v1alpha1ApplicationMatchExpression": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "operator": { + "type": "string" + }, + "values": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "v1alpha1ApplicationPreservedFields": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "string" + } + }, + "labels": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "v1alpha1ApplicationSet": { + "type": "object", + "title": "ApplicationSet is a set of Application resources\n+genclient\n+genclient:noStatus\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object\n+kubebuilder:resource:path=applicationsets,shortName=appset;appsets\n+kubebuilder:subresource:status", + "properties": { + "metadata": { + "$ref": "#/definitions/v1ObjectMeta" + }, + "spec": { + "$ref": "#/definitions/v1alpha1ApplicationSetSpec" + }, + "status": { + "$ref": "#/definitions/v1alpha1ApplicationSetStatus" + } + } + }, + "v1alpha1ApplicationSetApplicationStatus": { + "type": "object", + "title": "ApplicationSetApplicationStatus contains details about each Application managed by the ApplicationSet", + "properties": { + "application": { + "type": "string", + "title": "Application contains the name of the Application resource" + }, + "lastTransitionTime": { + "$ref": "#/definitions/v1Time" + }, + "message": { + "type": "string", + "title": "Message contains human-readable message indicating details about the status" + }, + "status": { + "type": "string", + "title": "Status contains the AppSet's perceived status of the managed Application resource: (Waiting, Pending, Progressing, Healthy)" + }, + "step": { + "type": "string", + "title": "Step tracks which step this Application should be updated in" + }, + "targetrevisions": { + "description": "TargetRevision tracks the desired revisions the Application should be synced to.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "v1alpha1ApplicationSetCondition": { + "type": "object", + "title": "ApplicationSetCondition contains details about an applicationset condition, which is usually an error or warning", + "properties": { + "lastTransitionTime": { + "$ref": "#/definitions/v1Time" + }, + "message": { + "type": "string", + "title": "Message contains human-readable message indicating details about condition" + }, + "reason": { + "type": "string", + "title": "Single word camelcase representing the reason for the status eg ErrorOccurred" + }, + "status": { + "type": "string", + "title": "True/False/Unknown" + }, + "type": { + "type": "string", + "title": "Type is an applicationset condition type" + } + } + }, + "v1alpha1ApplicationSetGenerator": { + "description": "ApplicationSetGenerator represents a generator at the top level of an ApplicationSet.", + "type": "object", + "properties": { + "clusterDecisionResource": { + "$ref": "#/definitions/v1alpha1DuckTypeGenerator" + }, + "clusters": { + "$ref": "#/definitions/v1alpha1ClusterGenerator" + }, + "git": { + "$ref": "#/definitions/v1alpha1GitGenerator" + }, + "list": { + "$ref": "#/definitions/v1alpha1ListGenerator" + }, + "matrix": { + "$ref": "#/definitions/v1alpha1MatrixGenerator" + }, + "merge": { + "$ref": "#/definitions/v1alpha1MergeGenerator" + }, + "plugin": { + "$ref": "#/definitions/v1alpha1PluginGenerator" + }, + "pullRequest": { + "$ref": "#/definitions/v1alpha1PullRequestGenerator" + }, + "scmProvider": { + "$ref": "#/definitions/v1alpha1SCMProviderGenerator" + }, + "selector": { + "$ref": "#/definitions/v1LabelSelector" + } + } + }, + "v1alpha1ApplicationSetList": { + "type": "object", + "title": "ApplicationSetList contains a list of ApplicationSet\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object\n+kubebuilder:object:root=true", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1ApplicationSet" + } + }, + "metadata": { + "$ref": "#/definitions/v1ListMeta" + } + } + }, + "v1alpha1ApplicationSetNestedGenerator": { + "description": "ApplicationSetNestedGenerator represents a generator nested within a combination-type generator (MatrixGenerator or\nMergeGenerator).", + "type": "object", + "properties": { + "clusterDecisionResource": { + "$ref": "#/definitions/v1alpha1DuckTypeGenerator" + }, + "clusters": { + "$ref": "#/definitions/v1alpha1ClusterGenerator" + }, + "git": { + "$ref": "#/definitions/v1alpha1GitGenerator" + }, + "list": { + "$ref": "#/definitions/v1alpha1ListGenerator" + }, + "matrix": { + "$ref": "#/definitions/v1JSON" + }, + "merge": { + "$ref": "#/definitions/v1JSON" + }, + "plugin": { + "$ref": "#/definitions/v1alpha1PluginGenerator" + }, + "pullRequest": { + "$ref": "#/definitions/v1alpha1PullRequestGenerator" + }, + "scmProvider": { + "$ref": "#/definitions/v1alpha1SCMProviderGenerator" + }, + "selector": { + "$ref": "#/definitions/v1LabelSelector" + } + } + }, + "v1alpha1ApplicationSetResourceIgnoreDifferences": { + "description": "ApplicationSetResourceIgnoreDifferences configures how the ApplicationSet controller will ignore differences in live\napplications when applying changes from generated applications.", + "type": "object", + "properties": { + "jqPathExpressions": { + "description": "JQPathExpressions is a list of JQ path expressions to fields to ignore differences for.", + "type": "array", + "items": { + "type": "string" + } + }, + "jsonPointers": { + "description": "JSONPointers is a list of JSON pointers to fields to ignore differences for.", + "type": "array", + "items": { + "type": "string" + } + }, + "name": { + "description": "Name is the name of the application to ignore differences for. If not specified, the rule applies to all applications.", + "type": "string" + } + } + }, + "v1alpha1ApplicationSetRolloutStep": { + "type": "object", + "properties": { + "matchExpressions": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1ApplicationMatchExpression" + } + }, + "maxUpdate": { + "$ref": "#/definitions/intstrIntOrString" + } + } + }, + "v1alpha1ApplicationSetRolloutStrategy": { + "type": "object", + "properties": { + "steps": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1ApplicationSetRolloutStep" + } + } + } + }, + "v1alpha1ApplicationSetSpec": { + "description": "ApplicationSetSpec represents a class of application set state.", + "type": "object", + "properties": { + "applyNestedSelectors": { + "description": "ApplyNestedSelectors enables selectors defined within the generators of two level-nested matrix or merge generators\nDeprecated: This field is ignored, and the behavior is always enabled. The field will be removed in a future\nversion of the ApplicationSet CRD.", + "type": "boolean" + }, + "generators": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1ApplicationSetGenerator" + } + }, + "goTemplate": { + "type": "boolean" + }, + "goTemplateOptions": { + "type": "array", + "items": { + "type": "string" + } + }, + "ignoreApplicationDifferences": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1ApplicationSetResourceIgnoreDifferences" + } + }, + "preservedFields": { + "$ref": "#/definitions/v1alpha1ApplicationPreservedFields" + }, + "strategy": { + "$ref": "#/definitions/v1alpha1ApplicationSetStrategy" + }, + "syncPolicy": { + "$ref": "#/definitions/v1alpha1ApplicationSetSyncPolicy" + }, + "template": { + "$ref": "#/definitions/v1alpha1ApplicationSetTemplate" + }, + "templatePatch": { + "type": "string" + } + } + }, + "v1alpha1ApplicationSetStatus": { + "type": "object", + "title": "ApplicationSetStatus defines the observed state of ApplicationSet", + "properties": { + "applicationStatus": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1ApplicationSetApplicationStatus" + } + }, + "conditions": { + "type": "array", + "title": "INSERT ADDITIONAL STATUS FIELD - define observed state of cluster\nImportant: Run \"make\" to regenerate code after modifying this file", + "items": { + "$ref": "#/definitions/v1alpha1ApplicationSetCondition" + } + }, + "resources": { + "description": "Resources is a list of Applications resources managed by this application set.", + "type": "array", + "items": { + "$ref": "#/definitions/applicationv1alpha1ResourceStatus" + } + } + } + }, + "v1alpha1ApplicationSetStrategy": { + "description": "ApplicationSetStrategy configures how generated Applications are updated in sequence.", + "type": "object", + "properties": { + "rollingSync": { + "$ref": "#/definitions/v1alpha1ApplicationSetRolloutStrategy" + }, + "type": { + "type": "string" + } + } + }, + "v1alpha1ApplicationSetSyncPolicy": { + "description": "ApplicationSetSyncPolicy configures how generated Applications will relate to their\nApplicationSet.", + "type": "object", + "properties": { + "applicationsSync": { + "type": "string", + "title": "ApplicationsSync represents the policy applied on the generated applications. Possible values are create-only, create-update, create-delete, sync\n+kubebuilder:validation:Optional\n+kubebuilder:validation:Enum=create-only;create-update;create-delete;sync" + }, + "preserveResourcesOnDeletion": { + "description": "PreserveResourcesOnDeletion will preserve resources on deletion. If PreserveResourcesOnDeletion is set to true, these Applications will not be deleted.", + "type": "boolean" + } + } + }, + "v1alpha1ApplicationSetTemplate": { + "type": "object", + "title": "ApplicationSetTemplate represents argocd ApplicationSpec", + "properties": { + "metadata": { + "$ref": "#/definitions/v1alpha1ApplicationSetTemplateMeta" + }, + "spec": { + "$ref": "#/definitions/v1alpha1ApplicationSpec" + } + } + }, + "v1alpha1ApplicationSetTemplateMeta": { + "type": "object", + "title": "ApplicationSetTemplateMeta represents the Argo CD application fields that may\nbe used for Applications generated from the ApplicationSet (based on metav1.ObjectMeta)", + "properties": { + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "finalizers": { + "type": "array", + "items": { + "type": "string" + } + }, + "labels": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "name": { + "type": "string" + }, + "namespace": { + "type": "string" + } + } + }, + "v1alpha1ApplicationSetTree": { + "type": "object", + "title": "ApplicationSetTree holds nodes which belongs to the application\nUsed to build a tree of an ApplicationSet and its children", + "properties": { + "nodes": { + "type": "array", + "title": "Nodes contains list of nodes which are directly managed by the applicationset", + "items": { + "$ref": "#/definitions/v1alpha1ResourceNode" + } + } + } + }, + "v1alpha1ApplicationSource": { + "type": "object", + "title": "ApplicationSource contains all required information about the source of an application", + "properties": { + "chart": { + "description": "Chart is a Helm chart name, and must be specified for applications sourced from a Helm repo.", + "type": "string" + }, + "directory": { + "$ref": "#/definitions/v1alpha1ApplicationSourceDirectory" + }, + "helm": { + "$ref": "#/definitions/v1alpha1ApplicationSourceHelm" + }, + "kustomize": { + "$ref": "#/definitions/v1alpha1ApplicationSourceKustomize" + }, + "name": { + "description": "Name is used to refer to a source and is displayed in the UI. It is used in multi-source Applications.", + "type": "string" + }, + "path": { + "description": "Path is a directory path within the Git repository, and is only valid for applications sourced from Git.", + "type": "string" + }, + "plugin": { + "$ref": "#/definitions/v1alpha1ApplicationSourcePlugin" + }, + "ref": { + "description": "Ref is reference to another source within sources field. This field will not be used if used with a `source` tag.", + "type": "string" + }, + "repoURL": { + "type": "string", + "title": "RepoURL is the URL to the repository (Git or Helm) that contains the application manifests" + }, + "targetRevision": { + "description": "TargetRevision defines the revision of the source to sync the application to.\nIn case of Git, this can be commit, tag, or branch. If omitted, will equal to HEAD.\nIn case of Helm, this is a semver tag for the Chart's version.", + "type": "string" + } + } + }, + "v1alpha1ApplicationSourceDirectory": { + "type": "object", + "title": "ApplicationSourceDirectory holds options for applications of type plain YAML or Jsonnet", + "properties": { + "exclude": { + "type": "string", + "title": "Exclude contains a glob pattern to match paths against that should be explicitly excluded from being used during manifest generation" + }, + "include": { + "type": "string", + "title": "Include contains a glob pattern to match paths against that should be explicitly included during manifest generation" + }, + "jsonnet": { + "$ref": "#/definitions/v1alpha1ApplicationSourceJsonnet" + }, + "recurse": { + "type": "boolean", + "title": "Recurse specifies whether to scan a directory recursively for manifests" + } + } + }, + "v1alpha1ApplicationSourceHelm": { + "type": "object", + "title": "ApplicationSourceHelm holds helm specific options", + "properties": { + "apiVersions": { + "description": "APIVersions specifies the Kubernetes resource API versions to pass to Helm when templating manifests. By default,\nArgo CD uses the API versions of the target cluster. The format is [group/]version/kind.", + "type": "array", + "items": { + "type": "string" + } + }, + "fileParameters": { + "type": "array", + "title": "FileParameters are file parameters to the helm template", + "items": { + "$ref": "#/definitions/v1alpha1HelmFileParameter" + } + }, + "ignoreMissingValueFiles": { + "type": "boolean", + "title": "IgnoreMissingValueFiles prevents helm template from failing when valueFiles do not exist locally by not appending them to helm template --values" + }, + "kubeVersion": { + "description": "KubeVersion specifies the Kubernetes API version to pass to Helm when templating manifests. By default, Argo CD\nuses the Kubernetes version of the target cluster.", + "type": "string" + }, + "namespace": { + "description": "Namespace is an optional namespace to template with. If left empty, defaults to the app's destination namespace.", + "type": "string" + }, + "parameters": { + "type": "array", + "title": "Parameters is a list of Helm parameters which are passed to the helm template command upon manifest generation", + "items": { + "$ref": "#/definitions/v1alpha1HelmParameter" + } + }, + "passCredentials": { + "type": "boolean", + "title": "PassCredentials pass credentials to all domains (Helm's --pass-credentials)" + }, + "releaseName": { + "type": "string", + "title": "ReleaseName is the Helm release name to use. If omitted it will use the application name" + }, + "skipCrds": { + "type": "boolean", + "title": "SkipCrds skips custom resource definition installation step (Helm's --skip-crds)" + }, + "skipSchemaValidation": { + "type": "boolean", + "title": "SkipSchemaValidation skips JSON schema validation (Helm's --skip-schema-validation)" + }, + "skipTests": { + "description": "SkipTests skips test manifest installation step (Helm's --skip-tests).", + "type": "boolean" + }, + "valueFiles": { + "type": "array", + "title": "ValuesFiles is a list of Helm value files to use when generating a template", + "items": { + "type": "string" + } + }, + "values": { + "type": "string", + "title": "Values specifies Helm values to be passed to helm template, typically defined as a block. ValuesObject takes precedence over Values, so use one or the other.\n+patchStrategy=replace" + }, + "valuesObject": { + "$ref": "#/definitions/runtimeRawExtension" + }, + "version": { + "type": "string", + "title": "Version is the Helm version to use for templating (\"3\")" + } + } + }, + "v1alpha1ApplicationSourceJsonnet": { + "type": "object", + "title": "ApplicationSourceJsonnet holds options specific to applications of type Jsonnet", + "properties": { + "extVars": { + "type": "array", + "title": "ExtVars is a list of Jsonnet External Variables", + "items": { + "$ref": "#/definitions/v1alpha1JsonnetVar" + } + }, + "libs": { + "type": "array", + "title": "Additional library search dirs", + "items": { + "type": "string" + } + }, + "tlas": { + "type": "array", + "title": "TLAS is a list of Jsonnet Top-level Arguments", + "items": { + "$ref": "#/definitions/v1alpha1JsonnetVar" + } + } + } + }, + "v1alpha1ApplicationSourceKustomize": { + "type": "object", + "title": "ApplicationSourceKustomize holds options specific to an Application source specific to Kustomize", + "properties": { + "apiVersions": { + "description": "APIVersions specifies the Kubernetes resource API versions to pass to Helm when templating manifests. By default,\nArgo CD uses the API versions of the target cluster. The format is [group/]version/kind.", + "type": "array", + "items": { + "type": "string" + } + }, + "commonAnnotations": { + "type": "object", + "title": "CommonAnnotations is a list of additional annotations to add to rendered manifests", + "additionalProperties": { + "type": "string" + } + }, + "commonAnnotationsEnvsubst": { + "type": "boolean", + "title": "CommonAnnotationsEnvsubst specifies whether to apply env variables substitution for annotation values" + }, + "commonLabels": { + "type": "object", + "title": "CommonLabels is a list of additional labels to add to rendered manifests", + "additionalProperties": { + "type": "string" + } + }, + "components": { + "type": "array", + "title": "Components specifies a list of kustomize components to add to the kustomization before building", + "items": { + "type": "string" + } + }, + "forceCommonAnnotations": { + "type": "boolean", + "title": "ForceCommonAnnotations specifies whether to force applying common annotations to resources for Kustomize apps" + }, + "forceCommonLabels": { + "type": "boolean", + "title": "ForceCommonLabels specifies whether to force applying common labels to resources for Kustomize apps" + }, + "ignoreMissingComponents": { + "type": "boolean", + "title": "IgnoreMissingComponents prevents kustomize from failing when components do not exist locally by not appending them to kustomization file" + }, + "images": { + "type": "array", + "title": "Images is a list of Kustomize image override specifications", + "items": { + "type": "string" + } + }, + "kubeVersion": { + "description": "KubeVersion specifies the Kubernetes API version to pass to Helm when templating manifests. By default, Argo CD\nuses the Kubernetes version of the target cluster.", + "type": "string" + }, + "labelIncludeTemplates": { + "type": "boolean", + "title": "LabelIncludeTemplates specifies whether to apply common labels to resource templates or not" + }, + "labelWithoutSelector": { + "type": "boolean", + "title": "LabelWithoutSelector specifies whether to apply common labels to resource selectors or not" + }, + "namePrefix": { + "type": "string", + "title": "NamePrefix is a prefix appended to resources for Kustomize apps" + }, + "nameSuffix": { + "type": "string", + "title": "NameSuffix is a suffix appended to resources for Kustomize apps" + }, + "namespace": { + "type": "string", + "title": "Namespace sets the namespace that Kustomize adds to all resources" + }, + "patches": { + "type": "array", + "title": "Patches is a list of Kustomize patches", + "items": { + "$ref": "#/definitions/v1alpha1KustomizePatch" + } + }, + "replicas": { + "type": "array", + "title": "Replicas is a list of Kustomize Replicas override specifications", + "items": { + "$ref": "#/definitions/v1alpha1KustomizeReplica" + } + }, + "version": { + "type": "string", + "title": "Version controls which version of Kustomize to use for rendering manifests" + } + } + }, + "v1alpha1ApplicationSourcePlugin": { + "type": "object", + "title": "ApplicationSourcePlugin holds options specific to config management plugins", + "properties": { + "env": { + "type": "array", + "items": { + "$ref": "#/definitions/applicationv1alpha1EnvEntry" + } + }, + "name": { + "type": "string" + }, + "parameters": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1ApplicationSourcePluginParameter" + } + } + } + }, + "v1alpha1ApplicationSourcePluginParameter": { + "type": "object", + "properties": { + "array": { + "description": "Array is the value of an array type parameter.", + "type": "array", + "items": { + "type": "string" + } + }, + "map": { + "description": "Map is the value of a map type parameter.", + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "name": { + "description": "Name is the name identifying a parameter.", + "type": "string" + }, + "string": { + "description": "String_ is the value of a string type parameter.", + "type": "string" + } + } + }, + "v1alpha1ApplicationSpec": { + "description": "ApplicationSpec represents desired application state. Contains link to repository with application definition and additional parameters link definition revision.", + "type": "object", + "properties": { + "destination": { + "$ref": "#/definitions/v1alpha1ApplicationDestination" + }, + "ignoreDifferences": { + "type": "array", + "title": "IgnoreDifferences is a list of resources and their fields which should be ignored during comparison", + "items": { + "$ref": "#/definitions/v1alpha1ResourceIgnoreDifferences" + } + }, + "info": { + "type": "array", + "title": "Info contains a list of information (URLs, email addresses, and plain text) that relates to the application", + "items": { + "$ref": "#/definitions/v1alpha1Info" + } + }, + "project": { + "description": "Project is a reference to the project this application belongs to.\nThe empty string means that application belongs to the 'default' project.", + "type": "string" + }, + "revisionHistoryLimit": { + "description": "RevisionHistoryLimit limits the number of items kept in the application's revision history, which is used for informational purposes as well as for rollbacks to previous versions.\nThis should only be changed in exceptional circumstances.\nSetting to zero will store no history. This will reduce storage used.\nIncreasing will increase the space used to store the history, so we do not recommend increasing it.\nDefault is 10.", + "type": "integer", + "format": "int64" + }, + "source": { + "$ref": "#/definitions/v1alpha1ApplicationSource" + }, + "sourceHydrator": { + "$ref": "#/definitions/v1alpha1SourceHydrator" + }, + "sources": { + "type": "array", + "title": "Sources is a reference to the location of the application's manifests or chart", + "items": { + "$ref": "#/definitions/v1alpha1ApplicationSource" + } + }, + "syncPolicy": { + "$ref": "#/definitions/v1alpha1SyncPolicy" + } + } + }, + "v1alpha1ApplicationStatus": { + "type": "object", + "title": "ApplicationStatus contains status information for the application", + "properties": { + "conditions": { + "type": "array", + "title": "Conditions is a list of currently observed application conditions", + "items": { + "$ref": "#/definitions/v1alpha1ApplicationCondition" + } + }, + "controllerNamespace": { + "type": "string", + "title": "ControllerNamespace indicates the namespace in which the application controller is located" + }, + "health": { + "$ref": "#/definitions/v1alpha1AppHealthStatus" + }, + "history": { + "type": "array", + "title": "History contains information about the application's sync history", + "items": { + "$ref": "#/definitions/v1alpha1RevisionHistory" + } + }, + "observedAt": { + "$ref": "#/definitions/v1Time" + }, + "operationState": { + "$ref": "#/definitions/v1alpha1OperationState" + }, + "reconciledAt": { + "$ref": "#/definitions/v1Time" + }, + "resourceHealthSource": { + "type": "string", + "title": "ResourceHealthSource indicates where the resource health status is stored: inline if not set or appTree" + }, + "resources": { + "type": "array", + "title": "Resources is a list of Kubernetes resources managed by this application", + "items": { + "$ref": "#/definitions/applicationv1alpha1ResourceStatus" + } + }, + "sourceHydrator": { + "$ref": "#/definitions/v1alpha1SourceHydratorStatus" + }, + "sourceType": { + "type": "string", + "title": "SourceType specifies the type of this application" + }, + "sourceTypes": { + "type": "array", + "title": "SourceTypes specifies the type of the sources included in the application", + "items": { + "type": "string" + } + }, + "summary": { + "$ref": "#/definitions/v1alpha1ApplicationSummary" + }, + "sync": { + "$ref": "#/definitions/v1alpha1SyncStatus" + } + } + }, + "v1alpha1ApplicationSummary": { + "type": "object", + "title": "ApplicationSummary contains information about URLs and container images used by an application", + "properties": { + "externalURLs": { + "description": "ExternalURLs holds all external URLs of application child resources.", + "type": "array", + "items": { + "type": "string" + } + }, + "images": { + "description": "Images holds all images of application child resources.", + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "v1alpha1ApplicationTree": { + "description": "ApplicationTree represents the hierarchical structure of resources associated with an Argo CD application.", + "type": "object", + "properties": { + "hosts": { + "description": "Hosts provides a list of Kubernetes nodes that are running pods related to the application.", + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1HostInfo" + } + }, + "nodes": { + "description": "Nodes contains a list of resources that are either directly managed by the application\nor are children of directly managed resources.", + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1ResourceNode" + } + }, + "orphanedNodes": { + "description": "OrphanedNodes contains resources that exist in the same namespace as the application\nbut are not managed by it. This list is populated only if orphaned resource tracking\nis enabled in the application's project settings.", + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1ResourceNode" + } + }, + "shardsCount": { + "description": "ShardsCount represents the total number of shards the application tree is split into.\nThis is used to distribute resource processing across multiple shards.", + "type": "integer", + "format": "int64" + } + } + }, + "v1alpha1ApplicationWatchEvent": { + "description": "ApplicationWatchEvent contains information about application change.", + "type": "object", + "properties": { + "application": { + "$ref": "#/definitions/v1alpha1Application" + }, + "type": { + "type": "string" + } + } + }, + "v1alpha1Backoff": { + "type": "object", + "title": "Backoff is the backoff strategy to use on subsequent retries for failing syncs", + "properties": { + "duration": { + "type": "string", + "title": "Duration is the amount to back off. Default unit is seconds, but could also be a duration (e.g. \"2m\", \"1h\")" + }, + "factor": { + "type": "integer", + "format": "int64", + "title": "Factor is a factor to multiply the base duration after each failed retry" + }, + "maxDuration": { + "type": "string", + "title": "MaxDuration is the maximum amount of time allowed for the backoff strategy" + } + } + }, + "v1alpha1BasicAuthBitbucketServer": { + "description": "BasicAuthBitbucketServer defines the username/(password or personal access token) for Basic auth.", + "type": "object", + "properties": { + "passwordRef": { + "$ref": "#/definitions/v1alpha1SecretRef" + }, + "username": { + "type": "string", + "title": "Username for Basic auth" + } + } + }, + "v1alpha1BearerTokenBitbucket": { + "description": "BearerTokenBitbucket defines the Bearer token for BitBucket AppToken auth.", + "type": "object", + "properties": { + "tokenRef": { + "$ref": "#/definitions/v1alpha1SecretRef" + } + } + }, + "v1alpha1BearerTokenBitbucketCloud": { + "description": "BearerTokenBitbucketCloud defines the Bearer token for BitBucket AppToken auth.", + "type": "object", + "properties": { + "tokenRef": { + "$ref": "#/definitions/v1alpha1SecretRef" + } + } + }, + "v1alpha1ChartDetails": { + "type": "object", + "title": "ChartDetails contains helm chart metadata for a specific version", + "properties": { + "description": { + "type": "string" + }, + "home": { + "type": "string", + "title": "The URL of this projects home page, e.g. \"http://example.com\"" + }, + "maintainers": { + "type": "array", + "title": "List of maintainer details, name and email, e.g. [\"John Doe \"]", + "items": { + "type": "string" + } + } + } + }, + "v1alpha1Cluster": { + "type": "object", + "title": "Cluster is the definition of a cluster resource", + "properties": { + "annotations": { + "type": "object", + "title": "Annotations for cluster secret metadata", + "additionalProperties": { + "type": "string" + } + }, + "clusterResources": { + "description": "Indicates if cluster level resources should be managed. This setting is used only if cluster is connected in a namespaced mode.", + "type": "boolean" + }, + "config": { + "$ref": "#/definitions/v1alpha1ClusterConfig" + }, + "connectionState": { + "$ref": "#/definitions/v1alpha1ConnectionState" + }, + "info": { + "$ref": "#/definitions/v1alpha1ClusterInfo" + }, + "labels": { + "type": "object", + "title": "Labels for cluster secret metadata", + "additionalProperties": { + "type": "string" + } + }, + "name": { + "type": "string", + "title": "Name of the cluster. If omitted, will use the server address" + }, + "namespaces": { + "description": "Holds list of namespaces which are accessible in that cluster. Cluster level resources will be ignored if namespace list is not empty.", + "type": "array", + "items": { + "type": "string" + } + }, + "project": { + "type": "string", + "title": "Reference between project and cluster that allow you automatically to be added as item inside Destinations project entity" + }, + "refreshRequestedAt": { + "$ref": "#/definitions/v1Time" + }, + "server": { + "type": "string", + "title": "Server is the API server URL of the Kubernetes cluster" + }, + "serverVersion": { + "type": "string", + "title": "Deprecated: use Info.ServerVersion field instead.\nThe server version" + }, + "shard": { + "description": "Shard contains optional shard number. Calculated on the fly by the application controller if not specified.", + "type": "integer", + "format": "int64" + } + } + }, + "v1alpha1ClusterCacheInfo": { + "type": "object", + "title": "ClusterCacheInfo contains information about the cluster cache", + "properties": { + "apisCount": { + "type": "integer", + "format": "int64", + "title": "APIsCount holds number of observed Kubernetes API count" + }, + "lastCacheSyncTime": { + "$ref": "#/definitions/v1Time" + }, + "resourcesCount": { + "type": "integer", + "format": "int64", + "title": "ResourcesCount holds number of observed Kubernetes resources" + } + } + }, + "v1alpha1ClusterConfig": { + "description": "ClusterConfig is the configuration attributes. This structure is subset of the go-client\nrest.Config with annotations added for marshalling.", + "type": "object", + "properties": { + "awsAuthConfig": { + "$ref": "#/definitions/v1alpha1AWSAuthConfig" + }, + "bearerToken": { + "description": "Server requires Bearer authentication. This client will not attempt to use\nrefresh tokens for an OAuth2 flow.\nTODO: demonstrate an OAuth2 compatible client.", + "type": "string" + }, + "disableCompression": { + "description": "DisableCompression bypasses automatic GZip compression requests to the server.", + "type": "boolean" + }, + "execProviderConfig": { + "$ref": "#/definitions/v1alpha1ExecProviderConfig" + }, + "password": { + "type": "string" + }, + "proxyUrl": { + "type": "string", + "title": "ProxyURL is the URL to the proxy to be used for all requests send to the server" + }, + "tlsClientConfig": { + "$ref": "#/definitions/v1alpha1TLSClientConfig" + }, + "username": { + "type": "string", + "title": "Server requires Basic authentication" + } + } + }, + "v1alpha1ClusterGenerator": { + "description": "ClusterGenerator defines a generator to match against clusters registered with ArgoCD.", + "type": "object", + "properties": { + "flatList": { + "type": "boolean", + "title": "returns the clusters a single 'clusters' value in the template" + }, + "selector": { + "$ref": "#/definitions/v1LabelSelector" + }, + "template": { + "$ref": "#/definitions/v1alpha1ApplicationSetTemplate" + }, + "values": { + "type": "object", + "title": "Values contains key/value pairs which are passed directly as parameters to the template", + "additionalProperties": { + "type": "string" + } + } + } + }, + "v1alpha1ClusterInfo": { + "type": "object", + "title": "ClusterInfo contains information about the cluster", + "properties": { + "apiVersions": { + "type": "array", + "title": "APIVersions contains list of API versions supported by the cluster", + "items": { + "type": "string" + } + }, + "applicationsCount": { + "type": "integer", + "format": "int64", + "title": "ApplicationsCount is the number of applications managed by Argo CD on the cluster" + }, + "cacheInfo": { + "$ref": "#/definitions/v1alpha1ClusterCacheInfo" + }, + "connectionState": { + "$ref": "#/definitions/v1alpha1ConnectionState" + }, + "serverVersion": { + "type": "string", + "title": "ServerVersion contains information about the Kubernetes version of the cluster" + } + } + }, + "v1alpha1ClusterList": { + "description": "ClusterList is a collection of Clusters.", + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1Cluster" + } + }, + "metadata": { + "$ref": "#/definitions/v1ListMeta" + } + } + }, + "v1alpha1Command": { + "type": "object", + "title": "Command holds binary path and arguments list", + "properties": { + "args": { + "type": "array", + "items": { + "type": "string" + } + }, + "command": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "v1alpha1ComparedTo": { + "type": "object", + "title": "ComparedTo contains application source and target which was used for resources comparison", + "properties": { + "destination": { + "$ref": "#/definitions/v1alpha1ApplicationDestination" + }, + "ignoreDifferences": { + "type": "array", + "title": "IgnoreDifferences is a reference to the application's ignored differences used for comparison", + "items": { + "$ref": "#/definitions/v1alpha1ResourceIgnoreDifferences" + } + }, + "source": { + "$ref": "#/definitions/v1alpha1ApplicationSource" + }, + "sources": { + "type": "array", + "title": "Sources is a reference to the application's multiple sources used for comparison", + "items": { + "$ref": "#/definitions/v1alpha1ApplicationSource" + } + } + } + }, + "v1alpha1ConfigManagementPlugin": { + "type": "object", + "title": "ConfigManagementPlugin contains config management plugin configuration", + "properties": { + "generate": { + "$ref": "#/definitions/v1alpha1Command" + }, + "init": { + "$ref": "#/definitions/v1alpha1Command" + }, + "lockRepo": { + "type": "boolean" + }, + "name": { + "type": "string" + } + } + }, + "v1alpha1ConfigMapKeyRef": { + "description": "Utility struct for a reference to a configmap key.", + "type": "object", + "properties": { + "configMapName": { + "type": "string" + }, + "key": { + "type": "string" + } + } + }, + "v1alpha1ConnectionState": { + "type": "object", + "title": "ConnectionState contains information about remote resource connection state, currently used for clusters and repositories", + "properties": { + "attemptedAt": { + "$ref": "#/definitions/v1Time" + }, + "message": { + "type": "string", + "title": "Message contains human readable information about the connection status" + }, + "status": { + "type": "string", + "title": "Status contains the current status indicator for the connection" + } + } + }, + "v1alpha1DrySource": { + "description": "DrySource specifies a location for dry \"don't repeat yourself\" manifest source information.", + "type": "object", + "properties": { + "path": { + "type": "string", + "title": "Path is a directory path within the Git repository where the manifests are located" + }, + "repoURL": { + "type": "string", + "title": "RepoURL is the URL to the git repository that contains the application manifests" + }, + "targetRevision": { + "type": "string", + "title": "TargetRevision defines the revision of the source to hydrate" + } + } + }, + "v1alpha1DuckTypeGenerator": { + "description": "DuckType defines a generator to match against clusters registered with ArgoCD.", + "type": "object", + "properties": { + "configMapRef": { + "type": "string", + "title": "ConfigMapRef is a ConfigMap with the duck type definitions needed to retrieve the data\n this includes apiVersion(group/version), kind, matchKey and validation settings\nName is the resource name of the kind, group and version, defined in the ConfigMapRef\nRequeueAfterSeconds is how long before the duckType will be rechecked for a change" + }, + "labelSelector": { + "$ref": "#/definitions/v1LabelSelector" + }, + "name": { + "type": "string" + }, + "requeueAfterSeconds": { + "type": "integer", + "format": "int64" + }, + "template": { + "$ref": "#/definitions/v1alpha1ApplicationSetTemplate" + }, + "values": { + "type": "object", + "title": "Values contains key/value pairs which are passed directly as parameters to the template", + "additionalProperties": { + "type": "string" + } + } + } + }, + "v1alpha1ExecProviderConfig": { + "type": "object", + "title": "ExecProviderConfig is config used to call an external command to perform cluster authentication\nSee: https://godoc.org/k8s.io/client-go/tools/clientcmd/api#ExecConfig", + "properties": { + "apiVersion": { + "type": "string", + "title": "Preferred input version of the ExecInfo" + }, + "args": { + "type": "array", + "title": "Arguments to pass to the command when executing it", + "items": { + "type": "string" + } + }, + "command": { + "type": "string", + "title": "Command to execute" + }, + "env": { + "type": "object", + "title": "Env defines additional environment variables to expose to the process", + "additionalProperties": { + "type": "string" + } + }, + "installHint": { + "type": "string", + "title": "This text is shown to the user when the executable doesn't seem to be present" + } + } + }, + "v1alpha1GitDirectoryGeneratorItem": { + "type": "object", + "properties": { + "exclude": { + "type": "boolean" + }, + "path": { + "type": "string" + } + } + }, + "v1alpha1GitFileGeneratorItem": { + "type": "object", + "properties": { + "exclude": { + "type": "boolean" + }, + "path": { + "type": "string" + } + } + }, + "v1alpha1GitGenerator": { + "type": "object", + "properties": { + "directories": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1GitDirectoryGeneratorItem" + } + }, + "files": { + "type": "array", + "items": { + "$ref": "#/definitions/v1alpha1GitFileGeneratorItem" + } + }, + "pathParamPrefix": { + "type": "string" + }, + "repoURL": { + "type": "string" + }, + "requeueAfterSeconds": { + "type": "integer", + "format": "int64" diff --git a/argocd-php-client/src/ArgoCD/Api/AbstractApi.php b/src/ArgoCD/Api/AbstractApi.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Api/AbstractApi.php rename to src/ArgoCD/Api/AbstractApi.php diff --git a/argocd-php-client/src/ArgoCD/Api/AccountService.php b/src/ArgoCD/Api/AccountService.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Api/AccountService.php rename to src/ArgoCD/Api/AccountService.php diff --git a/argocd-php-client/src/ArgoCD/Api/ApplicationService.php b/src/ArgoCD/Api/ApplicationService.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Api/ApplicationService.php rename to src/ArgoCD/Api/ApplicationService.php diff --git a/argocd-php-client/src/ArgoCD/Api/SessionService.php b/src/ArgoCD/Api/SessionService.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Api/SessionService.php rename to src/ArgoCD/Api/SessionService.php diff --git a/argocd-php-client/src/ArgoCD/AuthMethod.php b/src/ArgoCD/AuthMethod.php similarity index 100% rename from argocd-php-client/src/ArgoCD/AuthMethod.php rename to src/ArgoCD/AuthMethod.php diff --git a/argocd-php-client/src/ArgoCD/Client.php b/src/ArgoCD/Client.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Client.php rename to src/ArgoCD/Client.php diff --git a/argocd-php-client/src/ArgoCD/Exception/BadMethodCallException.php b/src/ArgoCD/Exception/BadMethodCallException.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Exception/BadMethodCallException.php rename to src/ArgoCD/Exception/BadMethodCallException.php diff --git a/argocd-php-client/src/ArgoCD/Exception/ExceptionInterface.php b/src/ArgoCD/Exception/ExceptionInterface.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Exception/ExceptionInterface.php rename to src/ArgoCD/Exception/ExceptionInterface.php diff --git a/argocd-php-client/src/ArgoCD/Exception/InvalidArgumentException.php b/src/ArgoCD/Exception/InvalidArgumentException.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Exception/InvalidArgumentException.php rename to src/ArgoCD/Exception/InvalidArgumentException.php diff --git a/argocd-php-client/src/ArgoCD/Exception/RuntimeException.php b/src/ArgoCD/Exception/RuntimeException.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Exception/RuntimeException.php rename to src/ArgoCD/Exception/RuntimeException.php diff --git a/argocd-php-client/src/ArgoCD/Exception/ValidationFailedException.php b/src/ArgoCD/Exception/ValidationFailedException.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Exception/ValidationFailedException.php rename to src/ArgoCD/Exception/ValidationFailedException.php diff --git a/argocd-php-client/src/ArgoCD/HttpClient/Builder.php b/src/ArgoCD/HttpClient/Builder.php similarity index 100% rename from argocd-php-client/src/ArgoCD/HttpClient/Builder.php rename to src/ArgoCD/HttpClient/Builder.php diff --git a/argocd-php-client/src/ArgoCD/HttpClient/Message/ResponseMediator.php b/src/ArgoCD/HttpClient/Message/ResponseMediator.php similarity index 100% rename from argocd-php-client/src/ArgoCD/HttpClient/Message/ResponseMediator.php rename to src/ArgoCD/HttpClient/Message/ResponseMediator.php diff --git a/argocd-php-client/src/ArgoCD/HttpClient/Plugin/ArgoCdExceptionThrower.php b/src/ArgoCD/HttpClient/Plugin/ArgoCdExceptionThrower.php similarity index 100% rename from argocd-php-client/src/ArgoCD/HttpClient/Plugin/ArgoCdExceptionThrower.php rename to src/ArgoCD/HttpClient/Plugin/ArgoCdExceptionThrower.php diff --git a/argocd-php-client/src/ArgoCD/HttpClient/Plugin/Authentication.php b/src/ArgoCD/HttpClient/Plugin/Authentication.php similarity index 100% rename from argocd-php-client/src/ArgoCD/HttpClient/Plugin/Authentication.php rename to src/ArgoCD/HttpClient/Plugin/Authentication.php diff --git a/argocd-php-client/src/ArgoCD/Model/AccountAccount.php b/src/ArgoCD/Model/AccountAccount.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Model/AccountAccount.php rename to src/ArgoCD/Model/AccountAccount.php diff --git a/argocd-php-client/src/ArgoCD/Model/AccountAccountsList.php b/src/ArgoCD/Model/AccountAccountsList.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Model/AccountAccountsList.php rename to src/ArgoCD/Model/AccountAccountsList.php diff --git a/argocd-php-client/src/ArgoCD/Model/AccountCanIResponse.php b/src/ArgoCD/Model/AccountCanIResponse.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Model/AccountCanIResponse.php rename to src/ArgoCD/Model/AccountCanIResponse.php diff --git a/argocd-php-client/src/ArgoCD/Model/AccountCreateTokenRequest.php b/src/ArgoCD/Model/AccountCreateTokenRequest.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Model/AccountCreateTokenRequest.php rename to src/ArgoCD/Model/AccountCreateTokenRequest.php diff --git a/argocd-php-client/src/ArgoCD/Model/AccountCreateTokenResponse.php b/src/ArgoCD/Model/AccountCreateTokenResponse.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Model/AccountCreateTokenResponse.php rename to src/ArgoCD/Model/AccountCreateTokenResponse.php diff --git a/argocd-php-client/src/ArgoCD/Model/AccountEmptyResponse.php b/src/ArgoCD/Model/AccountEmptyResponse.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Model/AccountEmptyResponse.php rename to src/ArgoCD/Model/AccountEmptyResponse.php diff --git a/argocd-php-client/src/ArgoCD/Model/AccountToken.php b/src/ArgoCD/Model/AccountToken.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Model/AccountToken.php rename to src/ArgoCD/Model/AccountToken.php diff --git a/argocd-php-client/src/ArgoCD/Model/AccountUpdatePasswordRequest.php b/src/ArgoCD/Model/AccountUpdatePasswordRequest.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Model/AccountUpdatePasswordRequest.php rename to src/ArgoCD/Model/AccountUpdatePasswordRequest.php diff --git a/argocd-php-client/src/ArgoCD/Model/AccountUpdatePasswordResponse.php b/src/ArgoCD/Model/AccountUpdatePasswordResponse.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Model/AccountUpdatePasswordResponse.php rename to src/ArgoCD/Model/AccountUpdatePasswordResponse.php diff --git a/argocd-php-client/src/ArgoCD/Model/RuntimeError.php b/src/ArgoCD/Model/RuntimeError.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Model/RuntimeError.php rename to src/ArgoCD/Model/RuntimeError.php diff --git a/argocd-php-client/src/ArgoCD/Model/SessionGetUserInfoResponse.php b/src/ArgoCD/Model/SessionGetUserInfoResponse.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Model/SessionGetUserInfoResponse.php rename to src/ArgoCD/Model/SessionGetUserInfoResponse.php diff --git a/argocd-php-client/src/ArgoCD/Model/SessionSessionCreateRequest.php b/src/ArgoCD/Model/SessionSessionCreateRequest.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Model/SessionSessionCreateRequest.php rename to src/ArgoCD/Model/SessionSessionCreateRequest.php diff --git a/argocd-php-client/src/ArgoCD/Model/SessionSessionResponse.php b/src/ArgoCD/Model/SessionSessionResponse.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Model/SessionSessionResponse.php rename to src/ArgoCD/Model/SessionSessionResponse.php diff --git a/argocd-php-client/src/ArgoCD/Model/V1Time.php b/src/ArgoCD/Model/V1Time.php similarity index 100% rename from argocd-php-client/src/ArgoCD/Model/V1Time.php rename to src/ArgoCD/Model/V1Time.php From 1663ec0e26c4b89a9f830efc14a1c77e4d642057 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 28 May 2025 07:26:47 +0000 Subject: [PATCH 3/6] chore: Attempted styling and CI updates, blocked by tooling This session aimed to apply styling patches and update GitHub Actions CI workflows to PHP 8.3+. - Styling patches were attempted, and a majority of files were processed. However, persistent errors prevented me from successfully patching a few specific model files (`src/ArgoCD/Model/RuntimeError.php`, `src/ArgoCD/Model/SessionSessionCreateRequest.php`), making it unsafe to commit the partially applied styling. These changes have been omitted to maintain consistency. - My attempts to update `.github/workflows/ci.yml` and `.github/workflows/backwards-compatibility.yml` also failed due to similar persistent errors, indicating potential issues with file system access or state tracking, especially after project restructuring operations. No functional code changes from the previous submission (`feat/argocd-client-foundation`) are included in this commit. The purpose of this commit is to document the attempted work and highlight the issues that prevented completion of the planned tasks. Further investigation into the stability of my environment is recommended before proceeding with these changes. From bd2b53e809f92f4a33eee0709611ec1bf77cb5de Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Wed, 28 May 2025 11:29:21 +0200 Subject: [PATCH 4/6] WIP --- .idea/.gitignore | 8 + .idea/inspectionProfiles/Project_Default.xml | 6 + .idea/modules.xml | 8 + .idea/php-github-api.iml | 73 ++ .idea/php.xml | 96 ++ .idea/vcs.xml | 6 + AI.md | 23 +- CHANGELOG-3.X.md | 231 ----- CHANGELOG.md | 438 --------- UPGRADE-3.0.md | 21 - UPGRADE-4.0.md | 11 - composer.json | 30 +- {src => lib}/ArgoCD/Api/AbstractApi.php | 2 +- {src => lib}/ArgoCD/Api/AccountService.php | 0 .../ArgoCD/Api/ApplicationService.php | 0 {src => lib}/ArgoCD/Api/SessionService.php | 0 {src => lib}/ArgoCD/AuthMethod.php | 0 {src => lib}/ArgoCD/Client.php | 13 +- .../Exception/BadMethodCallException.php | 0 .../ArgoCD/Exception/ExceptionInterface.php | 0 .../Exception/InvalidArgumentException.php | 0 .../ArgoCD/Exception/RuntimeException.php | 0 .../Exception/ValidationFailedException.php | 0 {src => lib}/ArgoCD/HttpClient/Builder.php | 0 .../HttpClient/Message/ResponseMediator.php | 0 .../Plugin/ArgoCDExceptionThrower.php | 6 +- .../HttpClient/Plugin/Authentication.php | 0 .../HttpClient/Plugin/History.php | 2 +- .../HttpClient/Plugin/PathPrepend.php | 2 +- {src => lib}/ArgoCD/Model/AccountAccount.php | 0 .../ArgoCD/Model/AccountAccountsList.php | 0 .../ArgoCD/Model/AccountCanIResponse.php | 0 .../Model/AccountCreateTokenRequest.php | 0 .../Model/AccountCreateTokenResponse.php | 0 .../ArgoCD/Model/AccountEmptyResponse.php | 0 {src => lib}/ArgoCD/Model/AccountToken.php | 0 .../Model/AccountUpdatePasswordRequest.php | 0 .../Model/AccountUpdatePasswordResponse.php | 0 {src => lib}/ArgoCD/Model/RuntimeError.php | 0 .../Model/SessionGetUserInfoResponse.php | 0 .../Model/SessionSessionCreateRequest.php | 0 .../ArgoCD/Model/SessionSessionResponse.php | 0 {src => lib}/ArgoCD/Model/V1Time.php | 0 lib/Github/Api/AbstractApi.php | 224 ----- lib/Github/Api/AcceptHeaderTrait.php | 66 -- lib/Github/Api/App/Hook.php | 76 -- lib/Github/Api/Apps.php | 215 ----- lib/Github/Api/Authorizations.php | 65 -- lib/Github/Api/Copilot/Usage.php | 34 - lib/Github/Api/CurrentUser.php | 193 ---- lib/Github/Api/CurrentUser/Emails.php | 94 -- lib/Github/Api/CurrentUser/Followers.php | 71 -- lib/Github/Api/CurrentUser/Memberships.php | 48 - lib/Github/Api/CurrentUser/Notifications.php | 145 --- lib/Github/Api/CurrentUser/PublicKeys.php | 74 -- lib/Github/Api/CurrentUser/Starring.php | 97 -- lib/Github/Api/CurrentUser/Watchers.php | 76 -- lib/Github/Api/Deployment.php | 151 --- lib/Github/Api/Deployment/Environments.php | 90 -- lib/Github/Api/Deployment/Policies.php | 97 -- lib/Github/Api/Enterprise.php | 60 -- lib/Github/Api/Enterprise/License.php | 20 - .../Api/Enterprise/ManagementConsole.php | 77 -- lib/Github/Api/Enterprise/SecretScanning.php | 21 - lib/Github/Api/Enterprise/Stats.php | 128 --- lib/Github/Api/Enterprise/UserAdmin.php | 36 - lib/Github/Api/Environment/Secrets.php | 80 -- lib/Github/Api/Environment/Variables.php | 81 -- lib/Github/Api/Gist/Comments.php | 101 -- lib/Github/Api/Gists.php | 182 ---- lib/Github/Api/GitData.php | 59 -- lib/Github/Api/GitData/Blobs.php | 68 -- lib/Github/Api/GitData/Commits.php | 48 - lib/Github/Api/GitData/References.php | 156 --- lib/Github/Api/GitData/Tags.php | 65 -- lib/Github/Api/GitData/Trees.php | 64 -- lib/Github/Api/GraphQL.php | 48 - lib/Github/Api/Issue.php | 241 ----- lib/Github/Api/Issue/Assignees.php | 91 -- lib/Github/Api/Issue/Comments.php | 133 --- lib/Github/Api/Issue/Events.php | 54 -- lib/Github/Api/Issue/Labels.php | 192 ---- lib/Github/Api/Issue/Milestones.php | 139 --- lib/Github/Api/Issue/Timeline.php | 34 - lib/Github/Api/Markdown.php | 49 - lib/Github/Api/Meta.php | 23 - .../Api/Miscellaneous/CodeOfConduct.php | 44 - lib/Github/Api/Miscellaneous/Emojis.php | 20 - lib/Github/Api/Miscellaneous/Gitignore.php | 34 - lib/Github/Api/Miscellaneous/Licenses.php | 34 - lib/Github/Api/Notification.php | 91 -- lib/Github/Api/Organization.php | 167 ---- .../Api/Organization/Actions/Secrets.php | 144 --- .../Actions/SelfHostedRunners.php | 59 -- .../Api/Organization/Actions/Variables.php | 131 --- lib/Github/Api/Organization/Hooks.php | 111 --- lib/Github/Api/Organization/Members.php | 75 -- .../Api/Organization/OrganizationRoles.php | 61 -- .../Api/Organization/OutsideCollaborators.php | 52 - lib/Github/Api/Organization/Projects.php | 23 - .../Api/Organization/SecretScanning.php | 19 - lib/Github/Api/Organization/Teams.php | 128 --- lib/Github/Api/Project/AbstractProjectApi.php | 45 - lib/Github/Api/Project/Cards.php | 60 -- lib/Github/Api/Project/Columns.php | 73 -- lib/Github/Api/PullRequest.php | 207 ---- lib/Github/Api/PullRequest/Comments.php | 153 --- lib/Github/Api/PullRequest/Review.php | 211 ---- lib/Github/Api/PullRequest/ReviewRequest.php | 72 -- lib/Github/Api/RateLimit.php | 70 -- .../Api/RateLimit/RateLimitResource.php | 73 -- lib/Github/Api/Repo.php | 909 ------------------ .../Api/Repository/Actions/Artifacts.php | 82 -- lib/Github/Api/Repository/Actions/Secrets.php | 95 -- .../Repository/Actions/SelfHostedRunners.php | 65 -- .../Api/Repository/Actions/Variables.php | 81 -- .../Api/Repository/Actions/WorkflowJobs.php | 54 -- .../Api/Repository/Actions/WorkflowRuns.php | 155 --- .../Api/Repository/Actions/Workflows.php | 82 -- lib/Github/Api/Repository/Assets.php | 123 --- .../Api/Repository/Checks/CheckRuns.php | 96 -- .../Api/Repository/Checks/CheckSuites.php | 74 -- lib/Github/Api/Repository/Collaborators.php | 84 -- lib/Github/Api/Repository/Comments.php | 75 -- lib/Github/Api/Repository/Commits.php | 38 - lib/Github/Api/Repository/Contents.php | 319 ------ lib/Github/Api/Repository/DeployKeys.php | 49 - lib/Github/Api/Repository/Downloads.php | 60 -- lib/Github/Api/Repository/Forks.php | 27 - lib/Github/Api/Repository/Hooks.php | 57 -- lib/Github/Api/Repository/Labels.php | 43 - lib/Github/Api/Repository/Pages.php | 60 -- lib/Github/Api/Repository/Projects.php | 23 - lib/Github/Api/Repository/Protection.php | 440 --------- lib/Github/Api/Repository/Releases.php | 141 --- lib/Github/Api/Repository/SecretScanning.php | 64 -- lib/Github/Api/Repository/Stargazers.php | 40 - lib/Github/Api/Repository/Statuses.php | 63 -- lib/Github/Api/Repository/Traffic.php | 67 -- lib/Github/Api/Search.php | 130 --- lib/Github/Api/User.php | 259 ----- lib/Github/Api/User/Migration.php | 83 -- lib/Github/AuthMethod.php | 30 - lib/Github/Client.php | 435 --------- .../Exception/ApiLimitExceedException.php | 46 - .../Exception/BadMethodCallException.php | 10 - lib/Github/Exception/ErrorException.php | 10 - lib/Github/Exception/ExceptionInterface.php | 9 - .../Exception/InvalidArgumentException.php | 10 - .../Exception/MissingArgumentException.php | 25 - lib/Github/Exception/RuntimeException.php | 10 - lib/Github/Exception/SsoRequiredException.php | 31 - ...oFactorAuthenticationRequiredException.php | 30 - .../Exception/ValidationFailedException.php | 12 - lib/Github/HttpClient/Builder.php | 214 ----- .../HttpClient/Message/ResponseMediator.php | 90 -- .../HttpClient/Plugin/Authentication.php | 71 -- .../Plugin/GithubExceptionThrower.php | 174 ---- lib/Github/ResultPager.php | 216 ----- lib/Github/ResultPagerInterface.php | 104 -- phpunit.xml.dist | 6 +- .../Tests/Api/Organization/TeamsTest.php | 8 +- .../Tests/Api/OrganizationTest.php | 12 +- .../{Github => ArgoCD}/Tests/Api/TestCase.php | 4 +- test/{Github => ArgoCD}/Tests/ClientTest.php | 24 +- .../Tests/HttpClient/BuilderTest.php | 8 +- .../Message/ResponseMediatorTest.php | 22 +- .../HttpClient/Plugin/AuthenticationTest.php | 6 +- .../Plugin/GithubExceptionThrowerTest.php | 30 +- .../HttpClient/Plugin/PathPrependTest.php | 4 +- .../Tests/Integration/TestCase.php | 8 +- .../Tests/Integration/UserTest.php | 4 +- test/Github/Tests/Api/AbstractApiTest.php | 239 ----- test/Github/Tests/Api/App/HookTest.php | 109 --- test/Github/Tests/Api/AppTest.php | 187 ---- test/Github/Tests/Api/Copilot/UsageTest.php | 78 -- .../Tests/Api/CurrentUser/DeployKeysTest.php | 112 --- .../Tests/Api/CurrentUser/EmailsTest.php | 139 --- .../Tests/Api/CurrentUser/FollowersTest.php | 77 -- .../Tests/Api/CurrentUser/MembershipsTest.php | 96 -- .../Tests/Api/CurrentUser/StarringTest.php | 77 -- .../Tests/Api/CurrentUser/WatchersTest.php | 77 -- test/Github/Tests/Api/CurrentUserTest.php | 170 ---- .../Tests/Api/Deployment/EnvironmentsTest.php | 73 -- .../Tests/Api/Deployment/PoliciesTest.php | 91 -- test/Github/Tests/Api/DeploymentTest.php | 148 --- .../Tests/Api/Enterprise/LicenseTest.php | 39 - .../Api/Enterprise/ManagementConsoleTest.php | 117 --- .../Api/Enterprise/SecretScanningTest.php | 41 - .../Github/Tests/Api/Enterprise/StatsTest.php | 94 -- .../Tests/Api/Enterprise/UserAdminTest.php | 47 - test/Github/Tests/Api/EnterpriseTest.php | 54 -- .../Tests/Api/Environment/SecretsTest.php | 116 --- .../Tests/Api/Environment/VariablesTest.php | 118 --- test/Github/Tests/Api/Gist/CommentsTest.php | 97 -- test/Github/Tests/Api/GistsTest.php | 266 ----- test/Github/Tests/Api/GitData/BlobsTest.php | 93 -- test/Github/Tests/Api/GitData/CommitsTest.php | 95 -- .../Tests/Api/GitData/ReferencesTest.php | 208 ---- test/Github/Tests/Api/GitData/TagsTest.php | 263 ----- test/Github/Tests/Api/GitData/TreesTest.php | 213 ---- test/Github/Tests/Api/GitDataTest.php | 64 -- test/Github/Tests/Api/GraphQLTest.php | 58 -- test/Github/Tests/Api/Issue/AssigneesTest.php | 108 --- test/Github/Tests/Api/Issue/CommentsTest.php | 147 --- test/Github/Tests/Api/Issue/EventsTest.php | 64 -- test/Github/Tests/Api/Issue/LabelsTest.php | 229 ----- .../Github/Tests/Api/Issue/MilestonesTest.php | 229 ----- test/Github/Tests/Api/Issue/TimelineTest.php | 35 - test/Github/Tests/Api/IssueTest.php | 246 ----- test/Github/Tests/Api/MetaTest.php | 37 - .../Api/Miscellaneous/CodeOfConductTest.php | 54 -- .../Tests/Api/Miscellaneous/EmojisTest.php | 36 - .../Tests/Api/Miscellaneous/GitignoreTest.php | 60 -- .../Tests/Api/Miscellaneous/LicensesTest.php | 54 -- .../Tests/Api/Miscellaneous/MarkdownTest.php | 97 -- test/Github/Tests/Api/NotificationTest.php | 153 --- .../Api/Organization/Actions/SecretsTest.php | 219 ----- .../Actions/SelfHostedRunnersTest.php | 115 --- .../Organization/Actions/VariablesTest.php | 198 ---- .../Tests/Api/Organization/HooksTest.php | 160 --- .../Tests/Api/Organization/MembersTest.php | 144 --- .../Organization/OrganizationRolesTest.php | 187 ---- .../Organization/OutsideCollaboratorsTest.php | 66 -- .../Tests/Api/Organization/ProjectsTest.php | 65 -- .../Api/Organization/SecretScanningTest.php | 41 - test/Github/Tests/Api/Project/CardsTest.php | 131 --- test/Github/Tests/Api/Project/ColumnsTest.php | 171 ---- .../Github/Tests/Api/Project/ProjectsTest.php | 76 -- .../Tests/Api/PullRequest/CommentsTest.php | 495 ---------- .../Api/PullRequest/ReviewRequestTest.php | 65 -- .../Tests/Api/PullRequest/ReviewTest.php | 455 --------- test/Github/Tests/Api/PullRequestTest.php | 402 -------- test/Github/Tests/Api/RateLimitTest.php | 90 -- test/Github/Tests/Api/RepoTest.php | 789 --------------- .../Api/Repository/Actions/ArtifactsTest.php | 96 -- .../Api/Repository/Actions/SecretsTest.php | 136 --- .../Actions/SelfHostedRunnersTest.php | 115 --- .../Api/Repository/Actions/VariablesTest.php | 119 --- .../Repository/Actions/WorkflowJobsTest.php | 57 -- .../Repository/Actions/WorkflowRunsTest.php | 223 ----- .../Api/Repository/Actions/WorkflowsTest.php | 116 --- .../Tests/Api/Repository/AssetsTest.php | 129 --- .../Api/Repository/Checks/CheckRunsTest.php | 123 --- .../Api/Repository/Checks/CheckSuitsTest.php | 93 -- .../Api/Repository/CollaboratorsTest.php | 96 -- .../Tests/Api/Repository/CommentsTest.php | 160 --- .../Tests/Api/Repository/CommitsTest.php | 84 -- .../Tests/Api/Repository/ContentsTest.php | 347 ------- .../Tests/Api/Repository/DeployKeysTest.php | 167 ---- .../Tests/Api/Repository/DownloadsTest.php | 64 -- .../Github/Tests/Api/Repository/ForksTest.php | 65 -- .../Github/Tests/Api/Repository/HooksTest.php | 160 --- .../Tests/Api/Repository/LabelsTest.php | 129 --- .../Github/Tests/Api/Repository/PagesTest.php | 150 --- .../Tests/Api/Repository/ProjectsTest.php | 65 -- .../Tests/Api/Repository/ProtectionTest.php | 444 --------- .../Tests/Api/Repository/ReleasesTest.php | 183 ---- .../Api/Repository/SecretScanningTest.php | 132 --- .../Tests/Api/Repository/StargazersTest.php | 49 - .../Tests/Api/Repository/StatusesTest.php | 98 -- .../Tests/Api/Repository/TrafficTest.php | 80 -- .../fixtures/ContentsDownloadFixture.php | 6 - .../ContentsDownloadSpacedFixture.php | 6 - test/Github/Tests/Api/SearchTest.php | 269 ------ test/Github/Tests/Api/User/MigrationTest.php | 186 ---- test/Github/Tests/Api/UserTest.php | 261 ----- test/Github/Tests/Functional/CacheTest.php | 71 -- test/Github/Tests/Integration/CommitTest.php | 65 -- test/Github/Tests/Integration/GistTest.php | 71 -- .../Tests/Integration/IssueCommentTest.php | 109 --- .../Github/Tests/Integration/MarkdownTest.php | 32 - .../Tests/Integration/RateLimitTest.php | 35 - .../Tests/Integration/RepoCommentTest.php | 128 --- test/Github/Tests/Integration/RepoTest.php | 107 --- .../Tests/Integration/ResultPagerTest.php | 38 - test/Github/Tests/Mock/PaginatedResponse.php | 50 - test/Github/Tests/ResultPagerTest.php | 304 ------ 278 files changed, 300 insertions(+), 26992 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/php-github-api.iml create mode 100644 .idea/php.xml create mode 100644 .idea/vcs.xml delete mode 100644 CHANGELOG-3.X.md delete mode 100644 CHANGELOG.md delete mode 100644 UPGRADE-3.0.md delete mode 100644 UPGRADE-4.0.md rename {src => lib}/ArgoCD/Api/AbstractApi.php (99%) rename {src => lib}/ArgoCD/Api/AccountService.php (100%) rename {src => lib}/ArgoCD/Api/ApplicationService.php (100%) rename {src => lib}/ArgoCD/Api/SessionService.php (100%) rename {src => lib}/ArgoCD/AuthMethod.php (100%) rename {src => lib}/ArgoCD/Client.php (96%) rename {src => lib}/ArgoCD/Exception/BadMethodCallException.php (100%) rename {src => lib}/ArgoCD/Exception/ExceptionInterface.php (100%) rename {src => lib}/ArgoCD/Exception/InvalidArgumentException.php (100%) rename {src => lib}/ArgoCD/Exception/RuntimeException.php (100%) rename {src => lib}/ArgoCD/Exception/ValidationFailedException.php (100%) rename {src => lib}/ArgoCD/HttpClient/Builder.php (100%) rename {src => lib}/ArgoCD/HttpClient/Message/ResponseMediator.php (100%) rename src/ArgoCD/HttpClient/Plugin/ArgoCdExceptionThrower.php => lib/ArgoCD/HttpClient/Plugin/ArgoCDExceptionThrower.php (95%) rename {src => lib}/ArgoCD/HttpClient/Plugin/Authentication.php (100%) rename lib/{Github => ArgoCD}/HttpClient/Plugin/History.php (96%) rename lib/{Github => ArgoCD}/HttpClient/Plugin/PathPrepend.php (96%) rename {src => lib}/ArgoCD/Model/AccountAccount.php (100%) rename {src => lib}/ArgoCD/Model/AccountAccountsList.php (100%) rename {src => lib}/ArgoCD/Model/AccountCanIResponse.php (100%) rename {src => lib}/ArgoCD/Model/AccountCreateTokenRequest.php (100%) rename {src => lib}/ArgoCD/Model/AccountCreateTokenResponse.php (100%) rename {src => lib}/ArgoCD/Model/AccountEmptyResponse.php (100%) rename {src => lib}/ArgoCD/Model/AccountToken.php (100%) rename {src => lib}/ArgoCD/Model/AccountUpdatePasswordRequest.php (100%) rename {src => lib}/ArgoCD/Model/AccountUpdatePasswordResponse.php (100%) rename {src => lib}/ArgoCD/Model/RuntimeError.php (100%) rename {src => lib}/ArgoCD/Model/SessionGetUserInfoResponse.php (100%) rename {src => lib}/ArgoCD/Model/SessionSessionCreateRequest.php (100%) rename {src => lib}/ArgoCD/Model/SessionSessionResponse.php (100%) rename {src => lib}/ArgoCD/Model/V1Time.php (100%) delete mode 100644 lib/Github/Api/AbstractApi.php delete mode 100644 lib/Github/Api/AcceptHeaderTrait.php delete mode 100644 lib/Github/Api/App/Hook.php delete mode 100644 lib/Github/Api/Apps.php delete mode 100644 lib/Github/Api/Authorizations.php delete mode 100644 lib/Github/Api/Copilot/Usage.php delete mode 100644 lib/Github/Api/CurrentUser.php delete mode 100644 lib/Github/Api/CurrentUser/Emails.php delete mode 100644 lib/Github/Api/CurrentUser/Followers.php delete mode 100644 lib/Github/Api/CurrentUser/Memberships.php delete mode 100644 lib/Github/Api/CurrentUser/Notifications.php delete mode 100644 lib/Github/Api/CurrentUser/PublicKeys.php delete mode 100644 lib/Github/Api/CurrentUser/Starring.php delete mode 100644 lib/Github/Api/CurrentUser/Watchers.php delete mode 100644 lib/Github/Api/Deployment.php delete mode 100644 lib/Github/Api/Deployment/Environments.php delete mode 100644 lib/Github/Api/Deployment/Policies.php delete mode 100644 lib/Github/Api/Enterprise.php delete mode 100644 lib/Github/Api/Enterprise/License.php delete mode 100644 lib/Github/Api/Enterprise/ManagementConsole.php delete mode 100644 lib/Github/Api/Enterprise/SecretScanning.php delete mode 100644 lib/Github/Api/Enterprise/Stats.php delete mode 100644 lib/Github/Api/Enterprise/UserAdmin.php delete mode 100644 lib/Github/Api/Environment/Secrets.php delete mode 100644 lib/Github/Api/Environment/Variables.php delete mode 100644 lib/Github/Api/Gist/Comments.php delete mode 100644 lib/Github/Api/Gists.php delete mode 100644 lib/Github/Api/GitData.php delete mode 100644 lib/Github/Api/GitData/Blobs.php delete mode 100644 lib/Github/Api/GitData/Commits.php delete mode 100644 lib/Github/Api/GitData/References.php delete mode 100644 lib/Github/Api/GitData/Tags.php delete mode 100644 lib/Github/Api/GitData/Trees.php delete mode 100644 lib/Github/Api/GraphQL.php delete mode 100644 lib/Github/Api/Issue.php delete mode 100644 lib/Github/Api/Issue/Assignees.php delete mode 100644 lib/Github/Api/Issue/Comments.php delete mode 100644 lib/Github/Api/Issue/Events.php delete mode 100644 lib/Github/Api/Issue/Labels.php delete mode 100644 lib/Github/Api/Issue/Milestones.php delete mode 100644 lib/Github/Api/Issue/Timeline.php delete mode 100644 lib/Github/Api/Markdown.php delete mode 100644 lib/Github/Api/Meta.php delete mode 100644 lib/Github/Api/Miscellaneous/CodeOfConduct.php delete mode 100644 lib/Github/Api/Miscellaneous/Emojis.php delete mode 100644 lib/Github/Api/Miscellaneous/Gitignore.php delete mode 100644 lib/Github/Api/Miscellaneous/Licenses.php delete mode 100644 lib/Github/Api/Notification.php delete mode 100644 lib/Github/Api/Organization.php delete mode 100644 lib/Github/Api/Organization/Actions/Secrets.php delete mode 100644 lib/Github/Api/Organization/Actions/SelfHostedRunners.php delete mode 100644 lib/Github/Api/Organization/Actions/Variables.php delete mode 100644 lib/Github/Api/Organization/Hooks.php delete mode 100644 lib/Github/Api/Organization/Members.php delete mode 100644 lib/Github/Api/Organization/OrganizationRoles.php delete mode 100644 lib/Github/Api/Organization/OutsideCollaborators.php delete mode 100644 lib/Github/Api/Organization/Projects.php delete mode 100644 lib/Github/Api/Organization/SecretScanning.php delete mode 100644 lib/Github/Api/Organization/Teams.php delete mode 100644 lib/Github/Api/Project/AbstractProjectApi.php delete mode 100644 lib/Github/Api/Project/Cards.php delete mode 100644 lib/Github/Api/Project/Columns.php delete mode 100644 lib/Github/Api/PullRequest.php delete mode 100644 lib/Github/Api/PullRequest/Comments.php delete mode 100644 lib/Github/Api/PullRequest/Review.php delete mode 100644 lib/Github/Api/PullRequest/ReviewRequest.php delete mode 100644 lib/Github/Api/RateLimit.php delete mode 100644 lib/Github/Api/RateLimit/RateLimitResource.php delete mode 100644 lib/Github/Api/Repo.php delete mode 100644 lib/Github/Api/Repository/Actions/Artifacts.php delete mode 100644 lib/Github/Api/Repository/Actions/Secrets.php delete mode 100644 lib/Github/Api/Repository/Actions/SelfHostedRunners.php delete mode 100644 lib/Github/Api/Repository/Actions/Variables.php delete mode 100644 lib/Github/Api/Repository/Actions/WorkflowJobs.php delete mode 100644 lib/Github/Api/Repository/Actions/WorkflowRuns.php delete mode 100644 lib/Github/Api/Repository/Actions/Workflows.php delete mode 100644 lib/Github/Api/Repository/Assets.php delete mode 100644 lib/Github/Api/Repository/Checks/CheckRuns.php delete mode 100644 lib/Github/Api/Repository/Checks/CheckSuites.php delete mode 100644 lib/Github/Api/Repository/Collaborators.php delete mode 100644 lib/Github/Api/Repository/Comments.php delete mode 100644 lib/Github/Api/Repository/Commits.php delete mode 100644 lib/Github/Api/Repository/Contents.php delete mode 100644 lib/Github/Api/Repository/DeployKeys.php delete mode 100644 lib/Github/Api/Repository/Downloads.php delete mode 100644 lib/Github/Api/Repository/Forks.php delete mode 100644 lib/Github/Api/Repository/Hooks.php delete mode 100644 lib/Github/Api/Repository/Labels.php delete mode 100644 lib/Github/Api/Repository/Pages.php delete mode 100644 lib/Github/Api/Repository/Projects.php delete mode 100644 lib/Github/Api/Repository/Protection.php delete mode 100644 lib/Github/Api/Repository/Releases.php delete mode 100644 lib/Github/Api/Repository/SecretScanning.php delete mode 100644 lib/Github/Api/Repository/Stargazers.php delete mode 100644 lib/Github/Api/Repository/Statuses.php delete mode 100644 lib/Github/Api/Repository/Traffic.php delete mode 100644 lib/Github/Api/Search.php delete mode 100644 lib/Github/Api/User.php delete mode 100644 lib/Github/Api/User/Migration.php delete mode 100644 lib/Github/AuthMethod.php delete mode 100644 lib/Github/Client.php delete mode 100644 lib/Github/Exception/ApiLimitExceedException.php delete mode 100644 lib/Github/Exception/BadMethodCallException.php delete mode 100644 lib/Github/Exception/ErrorException.php delete mode 100644 lib/Github/Exception/ExceptionInterface.php delete mode 100644 lib/Github/Exception/InvalidArgumentException.php delete mode 100644 lib/Github/Exception/MissingArgumentException.php delete mode 100644 lib/Github/Exception/RuntimeException.php delete mode 100644 lib/Github/Exception/SsoRequiredException.php delete mode 100644 lib/Github/Exception/TwoFactorAuthenticationRequiredException.php delete mode 100644 lib/Github/Exception/ValidationFailedException.php delete mode 100644 lib/Github/HttpClient/Builder.php delete mode 100644 lib/Github/HttpClient/Message/ResponseMediator.php delete mode 100644 lib/Github/HttpClient/Plugin/Authentication.php delete mode 100644 lib/Github/HttpClient/Plugin/GithubExceptionThrower.php delete mode 100644 lib/Github/ResultPager.php delete mode 100644 lib/Github/ResultPagerInterface.php rename test/{Github => ArgoCD}/Tests/Api/Organization/TeamsTest.php (98%) rename test/{Github => ArgoCD}/Tests/Api/OrganizationTest.php (88%) rename test/{Github => ArgoCD}/Tests/Api/TestCase.php (96%) rename test/{Github => ArgoCD}/Tests/ClientTest.php (94%) rename test/{Github => ArgoCD}/Tests/HttpClient/BuilderTest.php (89%) rename test/{Github => ArgoCD}/Tests/HttpClient/Message/ResponseMediatorTest.php (68%) rename test/{Github => ArgoCD}/Tests/HttpClient/Plugin/AuthenticationTest.php (93%) rename test/{Github => ArgoCD}/Tests/HttpClient/Plugin/GithubExceptionThrowerTest.php (91%) rename test/{Github => ArgoCD}/Tests/HttpClient/Plugin/PathPrependTest.php (92%) rename test/{Github => ArgoCD}/Tests/Integration/TestCase.php (85%) rename test/{Github => ArgoCD}/Tests/Integration/UserTest.php (98%) delete mode 100644 test/Github/Tests/Api/AbstractApiTest.php delete mode 100644 test/Github/Tests/Api/App/HookTest.php delete mode 100644 test/Github/Tests/Api/AppTest.php delete mode 100644 test/Github/Tests/Api/Copilot/UsageTest.php delete mode 100644 test/Github/Tests/Api/CurrentUser/DeployKeysTest.php delete mode 100644 test/Github/Tests/Api/CurrentUser/EmailsTest.php delete mode 100644 test/Github/Tests/Api/CurrentUser/FollowersTest.php delete mode 100644 test/Github/Tests/Api/CurrentUser/MembershipsTest.php delete mode 100644 test/Github/Tests/Api/CurrentUser/StarringTest.php delete mode 100644 test/Github/Tests/Api/CurrentUser/WatchersTest.php delete mode 100644 test/Github/Tests/Api/CurrentUserTest.php delete mode 100644 test/Github/Tests/Api/Deployment/EnvironmentsTest.php delete mode 100644 test/Github/Tests/Api/Deployment/PoliciesTest.php delete mode 100644 test/Github/Tests/Api/DeploymentTest.php delete mode 100644 test/Github/Tests/Api/Enterprise/LicenseTest.php delete mode 100644 test/Github/Tests/Api/Enterprise/ManagementConsoleTest.php delete mode 100644 test/Github/Tests/Api/Enterprise/SecretScanningTest.php delete mode 100644 test/Github/Tests/Api/Enterprise/StatsTest.php delete mode 100644 test/Github/Tests/Api/Enterprise/UserAdminTest.php delete mode 100644 test/Github/Tests/Api/EnterpriseTest.php delete mode 100644 test/Github/Tests/Api/Environment/SecretsTest.php delete mode 100644 test/Github/Tests/Api/Environment/VariablesTest.php delete mode 100644 test/Github/Tests/Api/Gist/CommentsTest.php delete mode 100644 test/Github/Tests/Api/GistsTest.php delete mode 100644 test/Github/Tests/Api/GitData/BlobsTest.php delete mode 100644 test/Github/Tests/Api/GitData/CommitsTest.php delete mode 100644 test/Github/Tests/Api/GitData/ReferencesTest.php delete mode 100644 test/Github/Tests/Api/GitData/TagsTest.php delete mode 100644 test/Github/Tests/Api/GitData/TreesTest.php delete mode 100644 test/Github/Tests/Api/GitDataTest.php delete mode 100644 test/Github/Tests/Api/GraphQLTest.php delete mode 100644 test/Github/Tests/Api/Issue/AssigneesTest.php delete mode 100644 test/Github/Tests/Api/Issue/CommentsTest.php delete mode 100644 test/Github/Tests/Api/Issue/EventsTest.php delete mode 100644 test/Github/Tests/Api/Issue/LabelsTest.php delete mode 100644 test/Github/Tests/Api/Issue/MilestonesTest.php delete mode 100644 test/Github/Tests/Api/Issue/TimelineTest.php delete mode 100644 test/Github/Tests/Api/IssueTest.php delete mode 100644 test/Github/Tests/Api/MetaTest.php delete mode 100644 test/Github/Tests/Api/Miscellaneous/CodeOfConductTest.php delete mode 100644 test/Github/Tests/Api/Miscellaneous/EmojisTest.php delete mode 100644 test/Github/Tests/Api/Miscellaneous/GitignoreTest.php delete mode 100644 test/Github/Tests/Api/Miscellaneous/LicensesTest.php delete mode 100644 test/Github/Tests/Api/Miscellaneous/MarkdownTest.php delete mode 100644 test/Github/Tests/Api/NotificationTest.php delete mode 100644 test/Github/Tests/Api/Organization/Actions/SecretsTest.php delete mode 100644 test/Github/Tests/Api/Organization/Actions/SelfHostedRunnersTest.php delete mode 100644 test/Github/Tests/Api/Organization/Actions/VariablesTest.php delete mode 100644 test/Github/Tests/Api/Organization/HooksTest.php delete mode 100644 test/Github/Tests/Api/Organization/MembersTest.php delete mode 100644 test/Github/Tests/Api/Organization/OrganizationRolesTest.php delete mode 100644 test/Github/Tests/Api/Organization/OutsideCollaboratorsTest.php delete mode 100644 test/Github/Tests/Api/Organization/ProjectsTest.php delete mode 100644 test/Github/Tests/Api/Organization/SecretScanningTest.php delete mode 100644 test/Github/Tests/Api/Project/CardsTest.php delete mode 100644 test/Github/Tests/Api/Project/ColumnsTest.php delete mode 100644 test/Github/Tests/Api/Project/ProjectsTest.php delete mode 100644 test/Github/Tests/Api/PullRequest/CommentsTest.php delete mode 100644 test/Github/Tests/Api/PullRequest/ReviewRequestTest.php delete mode 100644 test/Github/Tests/Api/PullRequest/ReviewTest.php delete mode 100644 test/Github/Tests/Api/PullRequestTest.php delete mode 100644 test/Github/Tests/Api/RateLimitTest.php delete mode 100644 test/Github/Tests/Api/RepoTest.php delete mode 100644 test/Github/Tests/Api/Repository/Actions/ArtifactsTest.php delete mode 100644 test/Github/Tests/Api/Repository/Actions/SecretsTest.php delete mode 100644 test/Github/Tests/Api/Repository/Actions/SelfHostedRunnersTest.php delete mode 100644 test/Github/Tests/Api/Repository/Actions/VariablesTest.php delete mode 100644 test/Github/Tests/Api/Repository/Actions/WorkflowJobsTest.php delete mode 100644 test/Github/Tests/Api/Repository/Actions/WorkflowRunsTest.php delete mode 100644 test/Github/Tests/Api/Repository/Actions/WorkflowsTest.php delete mode 100644 test/Github/Tests/Api/Repository/AssetsTest.php delete mode 100644 test/Github/Tests/Api/Repository/Checks/CheckRunsTest.php delete mode 100644 test/Github/Tests/Api/Repository/Checks/CheckSuitsTest.php delete mode 100644 test/Github/Tests/Api/Repository/CollaboratorsTest.php delete mode 100644 test/Github/Tests/Api/Repository/CommentsTest.php delete mode 100644 test/Github/Tests/Api/Repository/CommitsTest.php delete mode 100644 test/Github/Tests/Api/Repository/ContentsTest.php delete mode 100644 test/Github/Tests/Api/Repository/DeployKeysTest.php delete mode 100644 test/Github/Tests/Api/Repository/DownloadsTest.php delete mode 100644 test/Github/Tests/Api/Repository/ForksTest.php delete mode 100644 test/Github/Tests/Api/Repository/HooksTest.php delete mode 100644 test/Github/Tests/Api/Repository/LabelsTest.php delete mode 100644 test/Github/Tests/Api/Repository/PagesTest.php delete mode 100644 test/Github/Tests/Api/Repository/ProjectsTest.php delete mode 100644 test/Github/Tests/Api/Repository/ProtectionTest.php delete mode 100644 test/Github/Tests/Api/Repository/ReleasesTest.php delete mode 100644 test/Github/Tests/Api/Repository/SecretScanningTest.php delete mode 100644 test/Github/Tests/Api/Repository/StargazersTest.php delete mode 100644 test/Github/Tests/Api/Repository/StatusesTest.php delete mode 100644 test/Github/Tests/Api/Repository/TrafficTest.php delete mode 100644 test/Github/Tests/Api/Repository/fixtures/ContentsDownloadFixture.php delete mode 100644 test/Github/Tests/Api/Repository/fixtures/ContentsDownloadSpacedFixture.php delete mode 100644 test/Github/Tests/Api/SearchTest.php delete mode 100644 test/Github/Tests/Api/User/MigrationTest.php delete mode 100644 test/Github/Tests/Api/UserTest.php delete mode 100644 test/Github/Tests/Functional/CacheTest.php delete mode 100644 test/Github/Tests/Integration/CommitTest.php delete mode 100644 test/Github/Tests/Integration/GistTest.php delete mode 100644 test/Github/Tests/Integration/IssueCommentTest.php delete mode 100644 test/Github/Tests/Integration/MarkdownTest.php delete mode 100644 test/Github/Tests/Integration/RateLimitTest.php delete mode 100644 test/Github/Tests/Integration/RepoCommentTest.php delete mode 100644 test/Github/Tests/Integration/RepoTest.php delete mode 100644 test/Github/Tests/Integration/ResultPagerTest.php delete mode 100644 test/Github/Tests/Mock/PaginatedResponse.php delete mode 100644 test/Github/Tests/ResultPagerTest.php diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000000..13566b81b01 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000000..576d84cdb98 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000000..1eac27627bd --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php-github-api.iml b/.idea/php-github-api.iml new file mode 100644 index 00000000000..2fa1b046a65 --- /dev/null +++ b/.idea/php-github-api.iml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 00000000000..a17a3e1775f --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000000..35eb1ddfbbc --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/AI.md b/AI.md index cf208121faa..9f394d3e4d4 100644 --- a/AI.md +++ b/AI.md @@ -16,28 +16,15 @@ The development process involved a collaborative effort between a human develope * **Planning:** Based on the analysis, Jules created a detailed, multi-step plan to execute the refactoring. This plan was reviewed and approved by the human developer. * **Iterative Implementation:** Jules executed the plan step-by-step by delegating specific, actionable tasks to a "Worker" agent. These tasks included: * Creating new directory structures. - * Initializing `composer.json` and managing dependencies. - * Adapting core client classes (`Client.php`, `HttpClient/Builder.php`, `Api/AbstractApi.php`). + * Adapting core classes that are derived from the fork, to work with the constraints of ArgoCD. * Implementing exception handling. - * Generating PHP model classes based on OpenAPI definitions. - * Implementing API service classes (e.g., `SessionService.php`, `AccountService.php`) with methods corresponding to ArgoCD API operations. + * Implementing API classes (e.g., `Sessions.php`, `Accounts.php`) with methods corresponding to ArgoCD API operations. + * Interaction with these methods should be like [KnpLabs/php-github-api](https://github.com/KnpLabs/php-github-api). + * Any other validation is done through the parameter resolver like in [KnpLabs/php-github-api](https://github.com/KnpLabs/php-github-api). * **Feedback Incorporation:** The human developer provided feedback at various stages (e.g., on directory structure, PHP version constraints), and Jules updated the plan and execution accordingly. -## Current State - -As of the last AI interaction, the project has achieved the following: - -* **Core Infrastructure:** A foundational client structure is in place, including the main `Client` class, HTTP client builder, abstract API class, and basic exception handling. -* **Authentication:** The client can authenticate against an ArgoCD instance by exchanging username/password for a bearer token (via `SessionService`) or by using a pre-existing token. -* **Initial API Services:** - * `SessionService`: Implemented for login, logout, and user info. - * `AccountService`: Implemented for managing accounts and tokens. -* **Data Models:** PHP model classes corresponding to the implemented services' request/response structures have been created. -* **Project Configuration:** `composer.json` has been set up, and the project directory has been structured. The ArgoCD OpenAPI specification has been added to `reference/argocd_swagger.json`. - -Further development will involve implementing the remaining ArgoCD API services (like the extensive `ApplicationService`), adding comprehensive unit tests, and refining documentation. - ## Acknowledgements * The initial structure and patterns were derived from the excellent [KnpLabs/php-github-api](https://github.com/KnpLabs/php-github-api) library. * The target API is [ArgoCD](https://argo-cd.readthedocs.io/en/stable/), and its OpenAPI specification was used as the blueprint for API implementation. + * You can find the OpenAPI spec in `reference/argocd_swagger.json`. diff --git a/CHANGELOG-3.X.md b/CHANGELOG-3.X.md deleted file mode 100644 index f26bcc96430..00000000000 --- a/CHANGELOG-3.X.md +++ /dev/null @@ -1,231 +0,0 @@ -# Changelog - -## 3.16.0 - -### Added -- Add API to rerequest a check run ([Spea](https://github.com/Spea)) [#1141](https://github.com/KnpLabs/php-github-api/issues/1141) -- List pull requests associated with a commit ([lmjhs](https://github.com/lmjhs)) [#1146](https://github.com/KnpLabs/php-github-api/issues/1146) - -## 3.15.0 - -### Added -- Fix implicit nullable types to avoid PHP 8.4 warnings ([eiriksm](https://github.com/eiriksm), [acrobat](https://github.com/acrobat)) [#1144](https://github.com/KnpLabs/php-github-api/issues/1144) -- Add API endpoints to interact with organization roles ([glaubinix](https://github.com/glaubinix)) [#1143](https://github.com/KnpLabs/php-github-api/issues/1143) -- Copilot Usage Endpoints ([anthony-webart](https://github.com/anthony-webart)) [#1142](https://github.com/KnpLabs/php-github-api/issues/1142) -- Fix type error in ResultPager::fetch ([nunoplopes](https://github.com/nunoplopes)) [#1132](https://github.com/KnpLabs/php-github-api/issues/1132) - -## 3.14.1 - -### Fixed -- Handle case of GitHub returning 204 No Content in some scenarios ([tomcorbett](https://github.com/tomcorbett)) [#1135](https://github.com/KnpLabs/php-github-api/issues/1135) - -## 3.14.0 - -### Added -- Allow php-http/cache-plugin v2 ([GrahamCampbell](https://github.com/GrahamCampbell)) [#1134](https://github.com/KnpLabs/php-github-api/issues/1134) - -## 3.13.0 - -### Added -- Test against php 8.3 ([sergiy-petrov](https://github.com/sergiy-petrov)) [#1124](https://github.com/KnpLabs/php-github-api/issues/1124) -- feat: Secret Scanning Alerts ([haridarshan](https://github.com/haridarshan)) [#1114](https://github.com/KnpLabs/php-github-api/issues/1114) -- feat: User Migration ([haridarshan](https://github.com/haridarshan)) [#1115](https://github.com/KnpLabs/php-github-api/issues/1115) - -### Changed -- General chores ([acrobat](https://github.com/acrobat)) [#1125](https://github.com/KnpLabs/php-github-api/issues/1125) - -### Fixed -- Fix detection of secondary rate limit ([mathieudz](https://github.com/mathieudz)) [#1126](https://github.com/KnpLabs/php-github-api/issues/1126) - -## 3.12.0 - -### Added -- feat: Support for Organization Runners ([haridarshan](https://github.com/haridarshan), [renovate](https://github.com/renovate)[[bot](https://github.com/bot)]) [#1101](https://github.com/KnpLabs/php-github-api/issues/1101) -- allow psr/http-message v2 ([LordSimal](https://github.com/LordSimal)) [#1122](https://github.com/KnpLabs/php-github-api/issues/1122) - -### Changed -- Fixed branch alias ([GrahamCampbell](https://github.com/GrahamCampbell)) [#1109](https://github.com/KnpLabs/php-github-api/issues/1109) - -## 3.11.0 - -### Added -- Added environment variables & secrets ([Froxz](https://github.com/Froxz)) [#1104](https://github.com/KnpLabs/php-github-api/issues/1104) -- Added Org & Repository variables ([Froxz](https://github.com/Froxz)) [#1106](https://github.com/KnpLabs/php-github-api/issues/1106) -- Deployment branch policies ([Froxz](https://github.com/Froxz)) [#1108](https://github.com/KnpLabs/php-github-api/issues/1108) - -### Changed -- Test on PHP 8.2 ([GrahamCampbell](https://github.com/GrahamCampbell)) [#1105](https://github.com/KnpLabs/php-github-api/issues/1105) - -### Fixed -- Bugfix creating env ([Froxz](https://github.com/Froxz)) [#1107](https://github.com/KnpLabs/php-github-api/issues/1107) - -## 3.10.0 - -### Added -- Add vulnerability alerts endpoints ([andreia](https://github.com/andreia)) [#1096](https://github.com/KnpLabs/php-github-api/issues/1096) -- Added environments ([Froxz](https://github.com/Froxz)) [#1103](https://github.com/KnpLabs/php-github-api/issues/1103) - -### Changed -- Create authorization removed from docs ([rafasashi](https://github.com/rafasashi)) [#1090](https://github.com/KnpLabs/php-github-api/issues/1090) -- Setup dependabot for github action workflows ([acrobat](https://github.com/acrobat)) [#1098](https://github.com/KnpLabs/php-github-api/issues/1098) -- Bump actions/checkout from 2 to 3 ([dependabot](https://github.com/dependabot)[[bot](https://github.com/bot)]) [#1099](https://github.com/KnpLabs/php-github-api/issues/1099) -- Bump ramsey/composer-install from 1 to 2 ([dependabot](https://github.com/dependabot)[[bot](https://github.com/bot)]) [#1100](https://github.com/KnpLabs/php-github-api/issues/1100) - -## 3.9.0 - -### Added -- Add the ability to download raw file, needed when size > 1MB ([genintho](https://github.com/genintho)) [#1075](https://github.com/KnpLabs/php-github-api/issues/1075) -- Feat: Support new Team Repositories Endpoint ([iBotPeaches](https://github.com/iBotPeaches)) [#1082](https://github.com/KnpLabs/php-github-api/issues/1082) -- App: add hook endpoints ([glaubinix](https://github.com/glaubinix)) [#1086](https://github.com/KnpLabs/php-github-api/issues/1086) -- Add sync a fork branch with the upstream repository ([DAGpro](https://github.com/DAGpro)) [#1084](https://github.com/KnpLabs/php-github-api/issues/1084) - -### Changed -- Fix return types in phpdoc for `Assignees` and `ReviewRequest` ([rob006](https://github.com/rob006)) [#1078](https://github.com/KnpLabs/php-github-api/issues/1078) -- Fixed several typos and grammar errors ([AndrewDawes](https://github.com/AndrewDawes)) [#1088](https://github.com/KnpLabs/php-github-api/issues/1088) - -## 3.8.0 - -### Added -- API rate limit error status can be 403 ([matthewnessworthy](https://github.com/matthewnessworthy)) [#1072](https://github.com/KnpLabs/php-github-api/issues/1072) -- Add method to use generate release notes endpoint ([GuySartorelli](https://github.com/GuySartorelli)) [#1074](https://github.com/KnpLabs/php-github-api/issues/1074) -- Fix typehint for repository dispatch method ([cweagans](https://github.com/cweagans)) [#1066](https://github.com/KnpLabs/php-github-api/issues/1066) - -### Changed -- Update security.md ([secalith-code](https://github.com/secalith-code)) [#1076](https://github.com/KnpLabs/php-github-api/issues/1076) - -### Fixed -- dont require encoding ([gemal](https://github.com/gemal)) [#1071](https://github.com/KnpLabs/php-github-api/issues/1071) - -## 3.7.0 - -### Added -- added phpdocs ([staabm](https://github.com/staabm)) [#1068](https://github.com/KnpLabs/php-github-api/issues/1068) -- added missing magic method phpdocs for deployments ([staabm](https://github.com/staabm)) [#1069](https://github.com/KnpLabs/php-github-api/issues/1069) -- Fix issue https://github.com/KnpLabs/php-github-api/issues/1061 ([mruell](https://github.com/mruell)) [#1062](https://github.com/KnpLabs/php-github-api/issues/1062) - -### Changed -- Updates ReviewRequest Create method to return type Array ([ejntaylor](https://github.com/ejntaylor)) [#1060](https://github.com/KnpLabs/php-github-api/issues/1060) - -## 3.6.0 - -### Added -- Include optional params parameter for Commits compare method ([mountiny](https://github.com/mountiny)) [#1053](https://github.com/KnpLabs/php-github-api/issues/1053) - -### Changed -- Update incorrect documentation ([pheeque1](https://github.com/pheeque1)) [#1058](https://github.com/KnpLabs/php-github-api/issues/1058) - -### Fixed -- fix(Apps): use /orgs/ORG/installation ([ellisio](https://github.com/ellisio)) [#1056](https://github.com/KnpLabs/php-github-api/issues/1056) - -## 3.5.1 - -### Fixed -- Boolean private needed to create private repo! ([mruell](https://github.com/mruell)) [#1051](https://github.com/KnpLabs/php-github-api/issues/1051) - -## 3.5.0 - -### Added -- added support for psr\cache 3.0 ([rconfig](https://github.com/rconfig)) [#1046](https://github.com/KnpLabs/php-github-api/issues/1046) -- Symfony: allow deprecation-contracts version 3 ([glaubinix](https://github.com/glaubinix)) [#1049](https://github.com/KnpLabs/php-github-api/issues/1049) - -### Changed -- Fix internal doc link ([staudenmeir](https://github.com/staudenmeir)) [#1044](https://github.com/KnpLabs/php-github-api/issues/1044) - -### Fixed -- Fix Client URL Prepending For GraphQL Endpoint on Enterprise ([asher-goldberg](https://github.com/asher-goldberg), [acrobat](https://github.com/acrobat)) [#1048](https://github.com/KnpLabs/php-github-api/issues/1048) - -## 3.4.0 - -### Added -- Add create a repository using a template endpoint ([martinbean](https://github.com/martinbean)) [#994](https://github.com/KnpLabs/php-github-api/issues/994) -- Allow fetching repo readme for a specific ref ([bery](https://github.com/bery)) [#1019](https://github.com/KnpLabs/php-github-api/issues/1019) -- allow assigning role to organisation members ([luceos](https://github.com/luceos)) [#1018](https://github.com/KnpLabs/php-github-api/issues/1018) -- Branch lists . ( ? query per_page) ([pitonic](https://github.com/pitonic)) [#1020](https://github.com/KnpLabs/php-github-api/issues/1020) -- Php8.1 support ([acrobat](https://github.com/acrobat)) [#1025](https://github.com/KnpLabs/php-github-api/issues/1025) -- Allow psr/cache 2.0 as well as 1.0 ([johnnoel](https://github.com/johnnoel)) [#1029](https://github.com/KnpLabs/php-github-api/issues/1029) -- adding code_with_match (#1024) ([QuentinRa](https://github.com/QuentinRa)) [#1031](https://github.com/KnpLabs/php-github-api/issues/1031) -- Added dir parameter for Repo readme ([AlexandrePavy](https://github.com/AlexandrePavy)) [#1032](https://github.com/KnpLabs/php-github-api/issues/1032) -- refs #955: deprecate Client::AUTH_* constants and replace them with AuthMethod::AUTH_* const ([ipalo](https://github.com/ipalo)) [#1036](https://github.com/KnpLabs/php-github-api/issues/1036) -- feat: Add `visibility` option to repo create ([gerdemann](https://github.com/gerdemann)) [#1038](https://github.com/KnpLabs/php-github-api/issues/1038) -- Feature get authenticated app ([kdaniel95](https://github.com/kdaniel95)) [#1041](https://github.com/KnpLabs/php-github-api/issues/1041) - -### Changed -- Fix up typos ([dereuromark](https://github.com/dereuromark)) [#1011](https://github.com/KnpLabs/php-github-api/issues/1011) -- Update integration authentication documentation for usage with lcobucci/jwt ^4 ([glaubinix](https://github.com/glaubinix)) [#1017](https://github.com/KnpLabs/php-github-api/issues/1017) -- Update result_pager.md ([tomsowerby](https://github.com/tomsowerby)) [#1023](https://github.com/KnpLabs/php-github-api/issues/1023) -- fix(doc): links to doc in CurrentUser class ([Nek-](https://github.com/Nek-)) [#1026](https://github.com/KnpLabs/php-github-api/issues/1026) -- Fix incorrect phpdoc ([gemal](https://github.com/gemal)) [#1034](https://github.com/KnpLabs/php-github-api/issues/1034) - -### Fixed -- Add accept header for creating repo from template ([davidpeach](https://github.com/davidpeach)) [#1030](https://github.com/KnpLabs/php-github-api/issues/1030) - -## 3.3.0 - -### Added -- Allow costume accept headers for GraphQL Endpoint. ([Necmttn](https://github.com/Necmttn)) [#1001](https://github.com/KnpLabs/php-github-api/issues/1001) -- Add endpoint for approve workflow run ([Nyholm](https://github.com/Nyholm)) [#1006](https://github.com/KnpLabs/php-github-api/issues/1006) - -### Changed -- Update readme and add example for different http client usage ([acrobat](https://github.com/acrobat)) [#1002](https://github.com/KnpLabs/php-github-api/issues/1002) -- Bumped branch alias after new feature merged ([GrahamCampbell](https://github.com/GrahamCampbell)) [#1004](https://github.com/KnpLabs/php-github-api/issues/1004) -- Add comment on AbstractApi::$perPage() ([Nyholm](https://github.com/Nyholm)) [#1007](https://github.com/KnpLabs/php-github-api/issues/1007) - -### Fixed -- Fix publicKey ([Yurunsoft](https://github.com/Yurunsoft)) [#1005](https://github.com/KnpLabs/php-github-api/issues/1005) - -## 3.2.0 - -### Added -- Deprecate ResultPager::postFetch method ([acrobat](https://github.com/acrobat)) [#986](https://github.com/KnpLabs/php-github-api/issues/986) -- Add deprecations to the PR review methods to allow cleanup ([acrobat](https://github.com/acrobat)) [#984](https://github.com/KnpLabs/php-github-api/issues/984) -- Allow binary content downloads of assets ([acrobat](https://github.com/acrobat)) [#990](https://github.com/KnpLabs/php-github-api/issues/990) -- Deployments: added missing 'delete deployment' endpoint ([clxmstaab](https://github.com/clxmstaab)) [#991](https://github.com/KnpLabs/php-github-api/issues/991) -- Events list per authenticated user for all repos ([richard015ar](https://github.com/richard015ar)) [#1000](https://github.com/KnpLabs/php-github-api/issues/1000) - -### Changed -- Fixed branch alias ([GrahamCampbell](https://github.com/GrahamCampbell)) [#975](https://github.com/KnpLabs/php-github-api/issues/975) -- fix typo ([staabm](https://github.com/staabm)) [#977](https://github.com/KnpLabs/php-github-api/issues/977) -- Improved bc check ([acrobat](https://github.com/acrobat)) [#982](https://github.com/KnpLabs/php-github-api/issues/982) -- Correctly link to github actions docs and fix backlinks ([acrobat](https://github.com/acrobat)) [#983](https://github.com/KnpLabs/php-github-api/issues/983) -- Add missing repo hooks documentation ([acrobat](https://github.com/acrobat)) [#987](https://github.com/KnpLabs/php-github-api/issues/987) -- Fix incorrect public key documentation ([acrobat](https://github.com/acrobat)) [#988](https://github.com/KnpLabs/php-github-api/issues/988) -- Fixed incorrect parameters in apps docs ([acrobat](https://github.com/acrobat)) [#989](https://github.com/KnpLabs/php-github-api/issues/989) -- phpdoc: fix typo ([clxmstaab](https://github.com/clxmstaab)) [#993](https://github.com/KnpLabs/php-github-api/issues/993) -- Fix upmerged usage of deprecated phpunit assert ([acrobat](https://github.com/acrobat)) [#995](https://github.com/KnpLabs/php-github-api/issues/995) -- Fix typo ([romainneutron](https://github.com/romainneutron)) [#997](https://github.com/KnpLabs/php-github-api/issues/997) - -### Fixed -- Deployments: use proper media-type for in_progress/queued, inactive state ([staabm](https://github.com/staabm)) [#979](https://github.com/KnpLabs/php-github-api/issues/979) -- [952] doc - Specify lcobucci/jwt version, fix deprecation ([amacrobert-meq](https://github.com/amacrobert-meq), [acrobat](https://github.com/acrobat)) [#953](https://github.com/KnpLabs/php-github-api/issues/953) -- Replace deprecated organization team repository add/remove urls ([acrobat](https://github.com/acrobat)) [#985](https://github.com/KnpLabs/php-github-api/issues/985) -- fixed php warning in GithubExceptionThrower ([clxmstaab](https://github.com/clxmstaab), [acrobat](https://github.com/acrobat)) [#992](https://github.com/KnpLabs/php-github-api/issues/992) - -## 3.1.0 - -### Added -- Add workflow dispatch and allow workflow names. ([fodinabor](https://github.com/fodinabor)) [#969](https://github.com/KnpLabs/php-github-api/issues/969) - -### Changed -- Re-enable roave bc check for 3.x ([acrobat](https://github.com/acrobat)) [#958](https://github.com/KnpLabs/php-github-api/issues/958) -- Cleanup 3.0.0 changelog ([acrobat](https://github.com/acrobat)) [#957](https://github.com/KnpLabs/php-github-api/issues/957) -- Update new GitHub doc links in repo. ([fodinabor](https://github.com/fodinabor)) [#974](https://github.com/KnpLabs/php-github-api/issues/974) - -### Fixed -- Add accept header for the checks API ([Agares](https://github.com/Agares)) [#968](https://github.com/KnpLabs/php-github-api/issues/968) -- ExceptionThrower: adjust rate limit detection ([glaubinix](https://github.com/glaubinix)) [#959](https://github.com/KnpLabs/php-github-api/issues/959) - -## 3.0.0 - -### Added -- Switch to PSR18 client implementation and bump httplug minimum version to ^2.0 ([GrahamCampbell](https://github.com/GrahamCampbell)) [#885](https://github.com/KnpLabs/php-github-api/issues/885) -- Switch to PSR-17 and remove deprecated code ([GrahamCampbell](https://github.com/GrahamCampbell)) [#888](https://github.com/KnpLabs/php-github-api/issues/888) -- Allow PHP8 ([acrobat](https://github.com/acrobat)) [#934](https://github.com/KnpLabs/php-github-api/issues/934) -- [3.x] Make PHP 7.2.5 the minimum version ([GrahamCampbell](https://github.com/GrahamCampbell)) [#942](https://github.com/KnpLabs/php-github-api/issues/942) -- [3.x] Re-worked pagination to not mutate the api classes ([GrahamCampbell](https://github.com/GrahamCampbell)) [#907](https://github.com/KnpLabs/php-github-api/issues/907) & ([acrobat](https://github.com/acrobat)) [#956](https://github.com/KnpLabs/php-github-api/issues/956) -- Prepare 3.0 release and remove remaining deprecated code ([acrobat](https://github.com/acrobat)) [#948](https://github.com/KnpLabs/php-github-api/issues/948) - -### Changed -- Remove BC check on 3.x ([GrahamCampbell](https://github.com/GrahamCampbell)) [#900](https://github.com/KnpLabs/php-github-api/issues/900) -- [3.x] Fix the HTTP methods client ([GrahamCampbell](https://github.com/GrahamCampbell)) [#910](https://github.com/KnpLabs/php-github-api/issues/910) -- fix typo ([michielkempen](https://github.com/michielkempen)) [#920](https://github.com/KnpLabs/php-github-api/issues/920) -- [3.x] Added some additional scalar types and return types ([GrahamCampbell](https://github.com/GrahamCampbell)) [#949](https://github.com/KnpLabs/php-github-api/issues/949) diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 47980eff62f..00000000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,438 +0,0 @@ -# Changelog - -## 2.20.0 - -### Added -- Deployments: added missing 'delete deployment' endpoint ([clxmstaab](https://github.com/clxmstaab)) [#991](https://github.com/KnpLabs/php-github-api/issues/991) - -### Changed -- phpdoc: fix typo ([clxmstaab](https://github.com/clxmstaab)) [#993](https://github.com/KnpLabs/php-github-api/issues/993) - -### Fixed -- fixed php warning in GithubExceptionThrower ([clxmstaab](https://github.com/clxmstaab), [acrobat](https://github.com/acrobat)) [#992](https://github.com/KnpLabs/php-github-api/issues/992) - -## 2.19.2 - -### Changed -- Improved bc check ([acrobat](https://github.com/acrobat)) [#982](https://github.com/KnpLabs/php-github-api/issues/982) -- Correctly link to github actions docs and fix backlinks ([acrobat](https://github.com/acrobat)) [#983](https://github.com/KnpLabs/php-github-api/issues/983) -- Add missing repo hooks documentation ([acrobat](https://github.com/acrobat)) [#987](https://github.com/KnpLabs/php-github-api/issues/987) -- Fix incorrect public key documentation ([acrobat](https://github.com/acrobat)) [#988](https://github.com/KnpLabs/php-github-api/issues/988) -- Fixed incorrect parameters in apps docs ([acrobat](https://github.com/acrobat)) [#989](https://github.com/KnpLabs/php-github-api/issues/989) - -### Fixed -- Deployments: use proper media-type for in_progress/queued, inactive state ([staabm](https://github.com/staabm)) [#979](https://github.com/KnpLabs/php-github-api/issues/979) -- backported #979 into 2.x ([staabm](https://github.com/staabm)) [#981](https://github.com/KnpLabs/php-github-api/issues/981) -- [952] doc - Specify lcobucci/jwt version, fix deprecation ([amacrobert-meq](https://github.com/amacrobert-meq), [acrobat](https://github.com/acrobat)) [#953](https://github.com/KnpLabs/php-github-api/issues/953) -- Replace deprecated organization team repository add/remove urls ([acrobat](https://github.com/acrobat)) [#985](https://github.com/KnpLabs/php-github-api/issues/985) - -## 2.19.1 - -### Fixed -- ExceptionThrower: adjust rate limit detection ([glaubinix](https://github.com/glaubinix)) [#959](https://github.com/KnpLabs/php-github-api/issues/959) - -## 2.19.0 - -### Added -- Mark some classes as final ([acrobat](https://github.com/acrobat)) [#954](https://github.com/KnpLabs/php-github-api/issues/954) - -## 2.18.0 - -### Added -- Add parameters to PullRequest commits method ([seanmtaylor](https://github.com/seanmtaylor)) [#938](https://github.com/KnpLabs/php-github-api/issues/938) -- Actions (#872) ([lexor](https://github.com/lexor)) [#939](https://github.com/KnpLabs/php-github-api/issues/939) -- automated security endpoints (#868) ([lexor](https://github.com/lexor)) [#944](https://github.com/KnpLabs/php-github-api/issues/944) - -### Changed -- Update apps.md ([clarkeash](https://github.com/clarkeash)) [#936](https://github.com/KnpLabs/php-github-api/issues/936) - -### Fixed -- Throw exception for graphql errors ([acrobat](https://github.com/acrobat)) [#941](https://github.com/KnpLabs/php-github-api/issues/941) - -## 2.17.0 - -### Added - -- Improve checks api implementation ([acrobat](https://github.com/acrobat)) [#932](https://github.com/KnpLabs/php-github-api/issues/932) - -### Changed -- Missing auth method in list of omitted passwords. ([tobyS](https://github.com/tobyS)) [#933](https://github.com/KnpLabs/php-github-api/issues/933) -- Improve github actions setup ([acrobat](https://github.com/acrobat)) [#935](https://github.com/KnpLabs/php-github-api/issues/935) - -## 2.16.0 - -### Added -- Add support for SSO errors coming from the API ([eiriksm](https://github.com/eiriksm)) [#913](https://github.com/KnpLabs/php-github-api/issues/913) -- Add OutsideCollaborators api ([Matth--](https://github.com/Matth--)) [#925](https://github.com/KnpLabs/php-github-api/issues/925) -- Add support for creating a repo dispatch event ([Nyholm](https://github.com/Nyholm)) [#931](https://github.com/KnpLabs/php-github-api/issues/931) - -### Changed -- Fix: Wrong PHPDoc description ([OskarStark](https://github.com/OskarStark)) [#922](https://github.com/KnpLabs/php-github-api/issues/922) -- Adding GitHub authentication to GraphQL documentation ([legionth](https://github.com/legionth)) [#927](https://github.com/KnpLabs/php-github-api/issues/927) - -### Fixed -- Use RFC3986 for building URI query strings ([GrahamCampbell](https://github.com/GrahamCampbell)) [#908](https://github.com/KnpLabs/php-github-api/issues/908) -- Fix call to test a webhook method ([morrislaptop](https://github.com/morrislaptop)) [#915](https://github.com/KnpLabs/php-github-api/issues/915) - -## 2.15.0 - -### Added -- Prepare deprecation of authentication methods ([acrobat](https://github.com/acrobat)) [#870](https://github.com/KnpLabs/php-github-api/issues/870) -- Add Support For GitData Reference Matching Methods ([nickpoulos](https://github.com/nickpoulos)) [#875](https://github.com/KnpLabs/php-github-api/issues/875) -- Make invalid request error more clear ([acrobat](https://github.com/acrobat)) [#880](https://github.com/KnpLabs/php-github-api/issues/880) -- Show user by ID ([genintho](https://github.com/genintho)) [#894](https://github.com/KnpLabs/php-github-api/issues/894) -- add additional check run methods ([bobeagan](https://github.com/bobeagan), [acrobat](https://github.com/acrobat)) [#865](https://github.com/KnpLabs/php-github-api/issues/865) - -### Changed -- Added phpstan ([clxkoders](https://github.com/clxkoders)) [#871](https://github.com/KnpLabs/php-github-api/issues/871) -- Increase phpstan to level 4 ([acrobat](https://github.com/acrobat)) [#874](https://github.com/KnpLabs/php-github-api/issues/874) -- [Documentation] Add Missing Children to Pull Request Index ([jimlind](https://github.com/jimlind)) [#877](https://github.com/KnpLabs/php-github-api/issues/877) -- [Documentation] Include links to Pull Request Children on Pull Request Doc. ([jimlind](https://github.com/jimlind)) [#878](https://github.com/KnpLabs/php-github-api/issues/878) -- Fix typo in /lib/Github/Api/RateLimit.php ([yoonper](https://github.com/yoonper)) [#886](https://github.com/KnpLabs/php-github-api/issues/886) -- Don't use deprecated auth in examples ([GrahamCampbell](https://github.com/GrahamCampbell)) [#892](https://github.com/KnpLabs/php-github-api/issues/892) -- Removed shadow-cat ([GrahamCampbell](https://github.com/GrahamCampbell)) [#893](https://github.com/KnpLabs/php-github-api/issues/893) -- Don't urlencode integer values ([acrobat](https://github.com/acrobat)) [#895](https://github.com/KnpLabs/php-github-api/issues/895) -- phpstan level 6 fixes ([acrobat](https://github.com/acrobat), [GrahamCampbell](https://github.com/GrahamCampbell)) [#897](https://github.com/KnpLabs/php-github-api/issues/897) - -### Fixed -- fix: use new media type for branch protections ([iBotPeaches](https://github.com/iBotPeaches)) [#881](https://github.com/KnpLabs/php-github-api/issues/881) -- Added missing 'machine-man-preview' accept headers ([vovayatsyuk](https://github.com/vovayatsyuk)) [#883](https://github.com/KnpLabs/php-github-api/issues/883) -- Fix broken roave/bc-check test ([acrobat](https://github.com/acrobat)) [#890](https://github.com/KnpLabs/php-github-api/issues/890) -- Fixed incorrect MissingArgumentException parent constructor values ([acrobat](https://github.com/acrobat)) [#896](https://github.com/KnpLabs/php-github-api/issues/896) -- Added AUTH_ACCESS_TOKEN to allowed methods ([GrahamCampbell](https://github.com/GrahamCampbell)) [#899](https://github.com/KnpLabs/php-github-api/issues/899) - -## 2.14.0 - -### Added -- Replace deprecated Organization\Teams api calls ([lolos](https://github.com/lolos)) [#860](https://github.com/KnpLabs/php-github-api/issues/860) -- Add sort and direction for fetching organizations repos ([pgrimaud](https://github.com/pgrimaud)) [#863](https://github.com/KnpLabs/php-github-api/issues/863) -- Added parameters to Repo/milestones() method ([dereuromark](https://github.com/dereuromark)) [#856](https://github.com/KnpLabs/php-github-api/issues/856) - -### Fixed - -- Remove incorrect MissingArgumentException in Labels api ([bobeagan](https://github.com/bobeagan)) [#861](https://github.com/KnpLabs/php-github-api/issues/861) - -### Changed -- Fix typos in test/Github/Tests/Api/RepoTest.php ([pgrimaud](https://github.com/pgrimaud)) [#862](https://github.com/KnpLabs/php-github-api/issues/862) -- further detail on ResultPager parameters ([sepiariver](https://github.com/sepiariver)) [#843](https://github.com/KnpLabs/php-github-api/issues/843) -- fix phpdoc in labels api ([staabm](https://github.com/staabm)) [#854](https://github.com/KnpLabs/php-github-api/issues/854) -- fix api link in Issue\Labels::add() phpdoc ([staabm](https://github.com/staabm)) [#853](https://github.com/KnpLabs/php-github-api/issues/853) - -## 2.13.0 - -### Added - -- Support the new authorizations API -- Repo community profile API endpoint -- Support for draft PRs -- Missing Apps endpoints -- Test against php 7.4 - -### Changed - -- Allow create & remove to set and remove requests for teams - -## 2.12.1 - -### Fixed - -- Fixed bug in handling of validation errors -- Updated docs to not use deprected string parameter in issue assignee call - -## 2.12.0 - -### Added - -- Support for HTTPlug 2.0 and PSR-18 -- Add support for GitHub Checks -- Add support for GitHub Pages -- Add support to update a Pull Request Review -- Add support to get specific revision of a gist -- Added a 4th argument `$parameters` to `PullRequest::files()` -- Added `Accept` headers to Github Apps - -### Removed - -- Active support for HHVM -- Support for PHP <7.1 - -### Changed - -- Allow tags to be created without the `Tagger` object -- When updating DeployKeys we will first remove existing then add a new DeployKey - -### Fixed - -- In `Trees` we should check if `array_key_exists('sha', $tree)` instead of `isset` to avoid issues with `null`. (#822) - -### Deprecated - -- Passing an integer (`$page`) as 4th arugment in `Comments::all()` is deprecated. It should be an array. - -## 2.11.0 - -### Added - -- Support for Miscellaneous Licenses (#744) -- Structured Limit objects for rate limiting API (#733) -- Support for getting star creation timestamps in activity/starring endpoint (#729) - -### Fixed - -- Added missing has_projects parameter to repo create (#752) -- Proper type hinting for magic methods (#758) -- Allow symlink to files to be downloaded (#751) - -### Changed - -- Fix of PHP version in readme (#747) -- Fix documentation to get release for a tag (#755) -- Declare all used properties in RateLimitResource class (#762) -- Set correct property and return types (#764) -- Fixed install docs broken after 2.0 release of httplug lib (#767) - -## 2.10.1 - -### Fixed - -- Convert the assignee parameter to array to avoid getting a 422 error on github (#738) -- Fix GraphQL test warnings when they do not assert anything (#735) - -### Changed - -- Check for BC breaks during the travis build (#734) - -## 2.10.0 - -### Added - -- Support for "before" parameter on Notification API (#724) - -### Changed - -- Allow unspecified `event` when creating review (#723) - -### Fixed - -- Adjust: installationn access token endpoint (#731) -- Fixed "get single label" example and add correct example for getting issue's labels (#732) -- Add comment about `Key` constructor argument (#722) - -## 2.9.0 - -### Added - -- API endpoint `Github\Api\Repo::transfer()` -- API endpoint `Github\Api\Notification::markThreadRead()` -- API endpoint `Github\Api\Search::topics()` - -### Fixed - -- Make sure to always reset the "per page" in `Github\ResultPager::fetchAll()`. - -## 2.8.0 - -### Added - -- Allow our HTTP plugins to show up in the Symfony web profiler page. (#687) -- Repository documentation to current user (#671) -- Add collaborator permission call (#678) -- Add missing parameters for User/CurrentUser Repositories (#684) -- Pimp the readme with badge poser (#686) - -### Fixed - -- Typo in assignee documentation -- Missing use statement in security example -- Fixed phpdoc typo (#695) -- Replace use of deprecated api to the correct one in the security docs (#697) - -### Changed - -- Updated requirements in readme (#689) - -## 2.7.0 - -### Added - -- Phpunit 6 compatibility -- `Github\Api\AbstractApi::setPage()` to allow you to set the page on all endpoints. -- Support for query parameters and request headers on `Github\Api\User::following` and `Github\Api\User::followers` -- API endpoint `Github\Api\CurrentUser\Emails::allPublic()` -- API endpoint `Github\Api\Search::commits()` -- API endpoint `Github\Api\Miscellaneous\CodeOfConduct` -- API endpoint `Github\Api\Repo::topics()` -- API endpoint `Github\Api\Repo::replaceTopics()` - -### Fixed - -- Fixed bug in `PathPrepend` plugin where "api/vX" could be duplicated. - -### Changed - -- Improved documentation and doc blocks - -### Removed - -- Dropped support for php 5.5 - -### Deprecated - -The following endpoints were deprecated by Github and are also deprecated in the client: - -- `Github\Api\Repo::find()` -- `Github\Api\User::find()` -- `Github\Api\Issue::find()` - -## 2.6.0 - -### Added - -- Support for graphql api [variables](https://developer.github.com/v4/guides/forming-calls/#working-with-variables) (#612) -- Added missing branch protection methods (#616) -- Helper function `fromFile ` to get GraphQL queries from a file (#628) -- Extra parameter `params` to collaborators api calls (#623) -- Documentation for GitData API (#613) - -### Fixed -- Remove `body` as a required parameter when creating an issue (#624) -- Minor fixes in example code (#617) - -## 2.5.0 - -### Added - -- Stable support for graphql api (V4) (#593) -- Stable support for apps (previously integrations) (#592) -- `Repo::events()` - -### Fixed - -- Incorrect link in repository search docs (#594) -- Added the required parameter `$message` on `Review::dismiss`. - -## 2.4.0 - -### Added - -- `Integrations::configure` to allow accessing early access program endpoints. -- Add support for pagination and parameters in the pull request comments -- Add the ability to fetch user installations (`CurrentUser::installations`) -- Allow getting repo info by id (`Repo::showById`) -- Allow fetching repositories for a specific installation and user (`CurrentUser::repositoriesByInstallation`) - -### Changed - -- `PullRequest\Review` and `PullRequest\ReviewRequest` is now part of the official API. No need to call `configure`. - -## 2.3.0 - -### Fixed - -- Issue where we serve the wrong cached response. We vary on authorization header now. - -### Added - -- `PullRequest::status` -- Throw InvalidArgumentException on `PullRequest::merge` when wrong merge method is used. -- Added `Protection::configure` - -### Changed - -- First argument to `Integrations::listRepositories()` is now optional. -- Moved tests from "functional" to "integration" - -## 2.2.0 - -### Added - -- API support for Pull Request Review Requests. -- API support for Traffic. -- API support for issue Assignees. -- API support for Miscellaneous Gitignore and Emojis. -- Added endpoints for issue lock, unlock and issue label show. -- Added more parameters to `User::starred`. -- Fluid interface by allowing `configure()` to return `$this`. -- `configure()` support for issues API. - -### Fixed - -- Cache issue where some requests are not cached -- Issue with `User::all()` creates a query with double question marks. - -## 2.1.0 - -### Added - -- Add support for retrieving a single notification info using his ID -- Add a function to get user organizations -- Added GraphQL support -- Add page variable to organization repo list (Organization::repositories()) -- Add support for pull request review. -- Add support for adding branch protection. - -### Fixed - -- Bug with double slashes when using enterprise URL. -- Bug when headers not being passed to request (#529) - -## 2.0.0 - -### Added - -- Support for JWT authentication -- API for Organization\Members -- API for Integrations -- API for Repo\Cards -- API for Repo\Columns -- API for Repo\Projects -- API for User\MyRepositories -- Methods in Repo API for frequency and participation - -### Changed - -- `ApiLimitExceedException::__construct` has a new second parameter for the remaining API calls. -- First parameter of `Github\Client` has changed type from `\Http\Client\HttpClient` to -`Github\HttpClient\Builder`. A factory class was also added. To upgrade you need to change: - -```php -// Old way does not work: -$github = new Github\Client($httpClient); - -// New way will work: -$github = new Github\Client(new Github\HttpClient\Builder($httpClient)); -$github = Github\Client::createWithHttpClient($httpClient); -``` -- Renamed the currentuser `DeployKeys` api class to `PublicKeys` to reflect to github api name. - -## 2.0.0-rc4 - -### Added - -- HTTPlug to decouple from Guzzle -- `Github\Client::getLastResponse` was added -- Support for PSR-6 cache -- `Github\Client::addPlugin` and `Github\Client::removePlugin` -- `Github\Client::getApiVersion` -- `Github\Client::removeCache` - -### Changed - -- Uses of `Github\HttpClient\HttpClientInterface` is replaced by `Http\Client\HttpClient` ie the constructor of `Github\Client`. -- We use PSR-7's representation of HTTP message instead of `Guzzle\Http\Message\Response` and `Guzzle\Http\Message\Request`. -- `Github\Client::addHeaders` was added instead of `Github\Client::setHeaders` -- Signature of `Github\Client::useCache` has changed. First argument must be a `CacheItemPoolInterface` -- We use PSR-4 instead of PSR-0 - -### Removed - -- Support for PHP 5.3 and 5.4 -- `Github/HttpClient/HttpClientInterface` was removed -- `Github/HttpClient/HttpClient` was removed -- All classes in `Github/HttpClient/HttpClient/Listener/*` were removed -- `Github/HttpClient/CachedHttpClient` was removed -- All classes in `Github/HttpClient/Cache/*` were removed - -## 1.7.1 - -No change log before this version diff --git a/UPGRADE-3.0.md b/UPGRADE-3.0.md deleted file mode 100644 index 738343d6c37..00000000000 --- a/UPGRADE-3.0.md +++ /dev/null @@ -1,21 +0,0 @@ -## UPGRADE from 2.x to 3.0 - -### General - -* The `php-http/httplug` dependency requires is bumped to minimum ^2.1. -* A client implementing `psr/http-client-implementation` is required. - To upgrade your application (default install) switch from guzzle 6 to guzzle 7 (or replace `php-http/guzzle6-adapter` with any `psr/http-client-implementation`), see the install instructions in the [README file](README.md) -* All previous deprecated code in version 2 is removed. -* The following classes are now final - * `Github\HttpClient\Message\ResponseMediator` - * `Github\HttpClient\Plugin\Authentication` - * `Github\HttpClient\Plugin\GithubExceptionThrower` - * `Github\HttpClient\Plugin\History` - * `Github\HttpClient\Plugin\PathPrepend` - -### Authentication methods - -* `Github\Client::AUTH_URL_TOKEN` use `Github\Client::AUTH_ACCESS_TOKEN` instead. -* `Github\Client::AUTH_URL_CLIENT_ID` use `Github\Client::AUTH_CLIENT_ID` instead. -* `Github\Client::AUTH_HTTP_TOKEN` use `Github\Client::AUTH_ACCESS_TOKEN` instead. -* `Github\Client::AUTH_HTTP_PASSWORD` use `Github\Client::AUTH_ACCESS_TOKEN` instead. diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md deleted file mode 100644 index 6ede78deb51..00000000000 --- a/UPGRADE-4.0.md +++ /dev/null @@ -1,11 +0,0 @@ -## UPGRADE from 3.x to 4.0 - -### ResultPager - -* `\Github\ResultPagerInterface::postFetch` is deprecated, and the method will be removed from the ResultPager interface/class. - -### Authentication methods - -* `Github\Client::AUTH_CLIENT_ID` is deprecated, use `Github\AuthMethod::CLIENT_ID` instead. -* `Github\Client::AUTH_ACCESS_TOKEN` is deprecated, use `Github\AuthMethod::ACCESS_TOKEN` instead. -* `Github\Client::AUTH_JWT` is deprecated, use `Github\AuthMethod::JWT` instead. diff --git a/composer.json b/composer.json index 5b0c2cf9128..20e850a169f 100644 --- a/composer.json +++ b/composer.json @@ -11,23 +11,45 @@ ], "require": { "php": "^8.3", + "ext-json": "*", + "php-http/cache-plugin": "^1.7.1|^2.0", "php-http/client-common": "^2.3", "php-http/discovery": "^1.12", + "php-http/httplug": "^2.2", + "php-http/multipart-stream-builder": "^1.1.2", + "psr/cache": "^1.0|^2.0|^3.0", "psr/http-client-implementation": "^1.0", "psr/http-factory-implementation": "^1.0", - "psr/http-message": "^1.0 || ^2.0" + "psr/http-message": "^1.0|^2.0", + "symfony/polyfill-php80": "^1.17", + "symfony/deprecation-contracts": "^2.2|^3.0" }, "require-dev": { - "phpunit/phpunit": "^9.5" + "symfony/cache": "^5.1.8", + "guzzlehttp/psr7": "^2.7", + "http-interop/http-factory-guzzle": "^1.0", + "guzzlehttp/guzzle": "^7.2", + "php-http/mock-client": "^1.4.1", + "phpstan/phpstan": "^0.12.57", + "phpstan/extension-installer": "^1.0.5", + "phpstan/phpstan-deprecation-rules": "^0.12.5", + "phpunit/phpunit": "^8.5 || ^9.4", + "symfony/phpunit-bridge": "^5.2" }, "autoload": { "psr-4": { - "ArgoCD\\": "src/ArgoCD/" + "ArgoCD\\": "lib/ArgoCD/" } }, "autoload-dev": { "psr-4": { - "ArgoCD\\Tests\\": "tests/" + "ArgoCD\\Tests\\": "test/ArgoCD/Tests/" + } + }, + "config": { + "allow-plugins": { + "php-http/discovery": true, + "phpstan/extension-installer": true } } } diff --git a/src/ArgoCD/Api/AbstractApi.php b/lib/ArgoCD/Api/AbstractApi.php similarity index 99% rename from src/ArgoCD/Api/AbstractApi.php rename to lib/ArgoCD/Api/AbstractApi.php index de44f1e687f..90ea2836290 100644 --- a/src/ArgoCD/Api/AbstractApi.php +++ b/lib/ArgoCD/Api/AbstractApi.php @@ -184,7 +184,7 @@ protected function delete(string $path, array $parameters = [], array $requestHe if (count($parameters) > 0) { $body = $this->createJsonBody($parameters); } - + $response = $this->client->getHttpClient()->delete( $path, $requestHeaders, diff --git a/src/ArgoCD/Api/AccountService.php b/lib/ArgoCD/Api/AccountService.php similarity index 100% rename from src/ArgoCD/Api/AccountService.php rename to lib/ArgoCD/Api/AccountService.php diff --git a/src/ArgoCD/Api/ApplicationService.php b/lib/ArgoCD/Api/ApplicationService.php similarity index 100% rename from src/ArgoCD/Api/ApplicationService.php rename to lib/ArgoCD/Api/ApplicationService.php diff --git a/src/ArgoCD/Api/SessionService.php b/lib/ArgoCD/Api/SessionService.php similarity index 100% rename from src/ArgoCD/Api/SessionService.php rename to lib/ArgoCD/Api/SessionService.php diff --git a/src/ArgoCD/AuthMethod.php b/lib/ArgoCD/AuthMethod.php similarity index 100% rename from src/ArgoCD/AuthMethod.php rename to lib/ArgoCD/AuthMethod.php diff --git a/src/ArgoCD/Client.php b/lib/ArgoCD/Client.php similarity index 96% rename from src/ArgoCD/Client.php rename to lib/ArgoCD/Client.php index 5777e401eaa..853e950e1e6 100644 --- a/src/ArgoCD/Client.php +++ b/lib/ArgoCD/Client.php @@ -7,6 +7,7 @@ use ArgoCD\Exception\BadMethodCallException; use ArgoCD\Exception\InvalidArgumentException; use ArgoCD\HttpClient\Builder; +use ArgoCD\HttpClient\Plugin\ArgoCDExceptionThrower; use ArgoCD\HttpClient\Plugin\Authentication; use ArgoCD\HttpClient\Plugin\ExceptionThrower; use Http\Client\Common\HttpMethodsClientInterface; @@ -54,7 +55,7 @@ public function __construct(?string $serverUrl = null, ?Builder $httpClientBuild $this->responseHistory = new History(); $this->httpClientBuilder = $builder = $httpClientBuilder ?? new Builder(); - $builder->addPlugin(new ExceptionThrower()); + $builder->addPlugin(new ArgoCDExceptionThrower()); $builder->addPlugin(new Plugin\HistoryPlugin($this->responseHistory)); $builder->addPlugin(new Plugin\RedirectPlugin()); @@ -64,7 +65,7 @@ public function __construct(?string $serverUrl = null, ?Builder $httpClientBuild $uri = Psr17FactoryDiscovery::findUriFactory()->createUri($serverUrl); $builder->addPlugin(new Plugin\AddHostPlugin($uri)); - $builder->addPlugin(new Plugin\PathPrepend('/api/v1')); + $builder->addPlugin(new Plugin\PathPrepend('/api/v1')); $builder->addPlugin(new Plugin\HeaderDefaultsPlugin([ 'User-Agent' => 'argocd-php-client (https://github.com/your-vendor/argocd-php-client)', @@ -87,7 +88,7 @@ public static function createWithHttpClient(ClientInterface $httpClient, ?string // Or throw an exception if serverUrl is strictly required at this point // For now, assuming it can be null and might be set via constructor or setServerUrl } - return new self($serverUrl, $builder); + return new self($serverUrl, $builder); } /** @@ -154,7 +155,7 @@ public function authenticate(string $usernameOrToken, ?string $password = null): $this->getHttpClientBuilder()->addPlugin(new Authentication($this->token, AuthMethod::BEARER_TOKEN)); } - + /** * Get the currently stored token. * @@ -176,11 +177,11 @@ public function setServerUrl(string $serverUrl): void { $builder = $this->getHttpClientBuilder(); $builder->removePlugin(Plugin\AddHostPlugin::class); - $builder->removePlugin(Plugin\PathPrepend::class); + $builder->removePlugin(Plugin\PathPrepend::class); $uri = Psr17FactoryDiscovery::findUriFactory()->createUri($serverUrl); $builder->addPlugin(new Plugin\AddHostPlugin($uri)); - + if (strpos($serverUrl, '/api/v1') === false) { $builder->addPlugin(new Plugin\PathPrepend('/api/v1')); } diff --git a/src/ArgoCD/Exception/BadMethodCallException.php b/lib/ArgoCD/Exception/BadMethodCallException.php similarity index 100% rename from src/ArgoCD/Exception/BadMethodCallException.php rename to lib/ArgoCD/Exception/BadMethodCallException.php diff --git a/src/ArgoCD/Exception/ExceptionInterface.php b/lib/ArgoCD/Exception/ExceptionInterface.php similarity index 100% rename from src/ArgoCD/Exception/ExceptionInterface.php rename to lib/ArgoCD/Exception/ExceptionInterface.php diff --git a/src/ArgoCD/Exception/InvalidArgumentException.php b/lib/ArgoCD/Exception/InvalidArgumentException.php similarity index 100% rename from src/ArgoCD/Exception/InvalidArgumentException.php rename to lib/ArgoCD/Exception/InvalidArgumentException.php diff --git a/src/ArgoCD/Exception/RuntimeException.php b/lib/ArgoCD/Exception/RuntimeException.php similarity index 100% rename from src/ArgoCD/Exception/RuntimeException.php rename to lib/ArgoCD/Exception/RuntimeException.php diff --git a/src/ArgoCD/Exception/ValidationFailedException.php b/lib/ArgoCD/Exception/ValidationFailedException.php similarity index 100% rename from src/ArgoCD/Exception/ValidationFailedException.php rename to lib/ArgoCD/Exception/ValidationFailedException.php diff --git a/src/ArgoCD/HttpClient/Builder.php b/lib/ArgoCD/HttpClient/Builder.php similarity index 100% rename from src/ArgoCD/HttpClient/Builder.php rename to lib/ArgoCD/HttpClient/Builder.php diff --git a/src/ArgoCD/HttpClient/Message/ResponseMediator.php b/lib/ArgoCD/HttpClient/Message/ResponseMediator.php similarity index 100% rename from src/ArgoCD/HttpClient/Message/ResponseMediator.php rename to lib/ArgoCD/HttpClient/Message/ResponseMediator.php diff --git a/src/ArgoCD/HttpClient/Plugin/ArgoCdExceptionThrower.php b/lib/ArgoCD/HttpClient/Plugin/ArgoCDExceptionThrower.php similarity index 95% rename from src/ArgoCD/HttpClient/Plugin/ArgoCdExceptionThrower.php rename to lib/ArgoCD/HttpClient/Plugin/ArgoCDExceptionThrower.php index 3f15abcfc27..21548a24b78 100644 --- a/src/ArgoCD/HttpClient/Plugin/ArgoCdExceptionThrower.php +++ b/lib/ArgoCD/HttpClient/Plugin/ArgoCDExceptionThrower.php @@ -8,7 +8,7 @@ use ArgoCD\Exception\ValidationFailedException; // Example use ArgoCD\HttpClient\Message\ResponseMediator; -class ArgoCdExceptionThrower implements Plugin +class ArgoCDExceptionThrower implements Plugin { public function handleRequest(RequestInterface $request, callable $next, callable $first): \Http\Promise\Promise { @@ -22,13 +22,13 @@ public function handleRequest(RequestInterface $request, callable $next, callabl if (is_array($content) && isset($content['error'])) { $errorMessage = $content['message'] ?? ($content['error'] ?? $response->getReasonPhrase()); $errorCode = $content['code'] ?? $response->getStatusCode(); - + // Example: Check for a specific type of error if ArgoCD provides such details // For instance, if a 400 error with a specific 'error' field means validation failed if ($response->getStatusCode() == 400 && str_contains(strtolower($errorMessage), 'validation')) { throw new ValidationFailedException('Validation Failed: ' . $errorMessage, $response->getStatusCode(), null, $content['details'] ?? []); } - + throw new RuntimeException(sprintf('Error %s: %s', $errorCode, $errorMessage), $response->getStatusCode()); } diff --git a/src/ArgoCD/HttpClient/Plugin/Authentication.php b/lib/ArgoCD/HttpClient/Plugin/Authentication.php similarity index 100% rename from src/ArgoCD/HttpClient/Plugin/Authentication.php rename to lib/ArgoCD/HttpClient/Plugin/Authentication.php diff --git a/lib/Github/HttpClient/Plugin/History.php b/lib/ArgoCD/HttpClient/Plugin/History.php similarity index 96% rename from lib/Github/HttpClient/Plugin/History.php rename to lib/ArgoCD/HttpClient/Plugin/History.php index 341c288a6ea..3fd75d417fa 100644 --- a/lib/Github/HttpClient/Plugin/History.php +++ b/lib/ArgoCD/HttpClient/Plugin/History.php @@ -1,6 +1,6 @@ - * @author Graham Campbell - */ -abstract class AbstractApi -{ - /** - * The client instance. - * - * @var Client - */ - private $client; - - /** - * The per page parameter. It is used by the ResultPager. - * - * @var int|null - */ - private $perPage; - - /** - * Create a new API instance. - * - * @param Client $client - * - * @return void - */ - public function __construct(Client $client) - { - $this->client = $client; - } - - /** - * Get the client instance. - * - * @return Client - */ - protected function getClient(): Client - { - return $this->client; - } - - /** - * Get the API version. - * - * @return string - */ - protected function getApiVersion(): string - { - return $this->client->getApiVersion(); - } - - /** - * @return $this - */ - public function configure() - { - return $this; - } - - /** - * Send a GET request with query parameters. - * - * @param string $path Request path. - * @param array $parameters GET parameters. - * @param array $requestHeaders Request Headers. - * - * @return array|string - */ - protected function get(string $path, array $parameters = [], array $requestHeaders = []) - { - if (null !== $this->perPage && !isset($parameters['per_page'])) { - $parameters['per_page'] = $this->perPage; - } - - if (array_key_exists('ref', $parameters) && null === $parameters['ref']) { - unset($parameters['ref']); - } - - if (count($parameters) > 0) { - $path .= '?'.http_build_query($parameters, '', '&', PHP_QUERY_RFC3986); - } - - $response = $this->client->getHttpClient()->get($path, $requestHeaders); - - return ResponseMediator::getContent($response); - } - - /** - * Send a HEAD request with query parameters. - * - * @param string $path Request path. - * @param array $parameters HEAD parameters. - * @param array $requestHeaders Request headers. - * - * @return ResponseInterface - */ - protected function head(string $path, array $parameters = [], array $requestHeaders = []): ResponseInterface - { - if (array_key_exists('ref', $parameters) && null === $parameters['ref']) { - unset($parameters['ref']); - } - - return $this->client->getHttpClient()->head($path.'?'.http_build_query($parameters, '', '&', PHP_QUERY_RFC3986), $requestHeaders); - } - - /** - * Send a POST request with JSON-encoded parameters. - * - * @param string $path Request path. - * @param array $parameters POST parameters to be JSON encoded. - * @param array $requestHeaders Request headers. - * - * @return array|string - */ - protected function post(string $path, array $parameters = [], array $requestHeaders = []) - { - return $this->postRaw( - $path, - $this->createJsonBody($parameters), - $requestHeaders - ); - } - - /** - * Send a POST request with raw data. - * - * @param string $path Request path. - * @param string $body Request body. - * @param array $requestHeaders Request headers. - * - * @return array|string - */ - protected function postRaw(string $path, $body, array $requestHeaders = []) - { - $response = $this->client->getHttpClient()->post( - $path, - $requestHeaders, - $body - ); - - return ResponseMediator::getContent($response); - } - - /** - * Send a PATCH request with JSON-encoded parameters. - * - * @param string $path Request path. - * @param array $parameters POST parameters to be JSON encoded. - * @param array $requestHeaders Request headers. - * - * @return array|string - */ - protected function patch(string $path, array $parameters = [], array $requestHeaders = []) - { - $response = $this->client->getHttpClient()->patch( - $path, - $requestHeaders, - $this->createJsonBody($parameters) - ); - - return ResponseMediator::getContent($response); - } - - /** - * Send a PUT request with JSON-encoded parameters. - * - * @param string $path Request path. - * @param array $parameters POST parameters to be JSON encoded. - * @param array $requestHeaders Request headers. - * - * @return array|string - */ - protected function put(string $path, array $parameters = [], array $requestHeaders = []) - { - $response = $this->client->getHttpClient()->put( - $path, - $requestHeaders, - $this->createJsonBody($parameters) - ); - - return ResponseMediator::getContent($response); - } - - /** - * Send a DELETE request with JSON-encoded parameters. - * - * @param string $path Request path. - * @param array $parameters POST parameters to be JSON encoded. - * @param array $requestHeaders Request headers. - * - * @return array|string - */ - protected function delete(string $path, array $parameters = [], array $requestHeaders = []) - { - $response = $this->client->getHttpClient()->delete( - $path, - $requestHeaders, - $this->createJsonBody($parameters) - ); - - return ResponseMediator::getContent($response); - } - - /** - * Create a JSON encoded version of an array of parameters. - * - * @param array $parameters Request parameters - * - * @return string|null - */ - protected function createJsonBody(array $parameters): ?string - { - return (count($parameters) === 0) ? null : json_encode($parameters, empty($parameters) ? JSON_FORCE_OBJECT : 0); - } -} diff --git a/lib/Github/Api/AcceptHeaderTrait.php b/lib/Github/Api/AcceptHeaderTrait.php deleted file mode 100644 index 6a990a56144..00000000000 --- a/lib/Github/Api/AcceptHeaderTrait.php +++ /dev/null @@ -1,66 +0,0 @@ - - */ -trait AcceptHeaderTrait -{ - /** @var string */ - protected $acceptHeaderValue; - - protected function get(string $path, array $parameters = [], array $requestHeaders = []) - { - return parent::get($path, $parameters, $this->mergeHeaders($requestHeaders)); - } - - protected function head(string $path, array $parameters = [], array $requestHeaders = []): ResponseInterface - { - return parent::head($path, $parameters, $this->mergeHeaders($requestHeaders)); - } - - protected function post(string $path, array $parameters = [], array $requestHeaders = []) - { - return parent::post($path, $parameters, $this->mergeHeaders($requestHeaders)); - } - - protected function postRaw(string $path, $body, array $requestHeaders = []) - { - return parent::postRaw($path, $body, $this->mergeHeaders($requestHeaders)); - } - - protected function patch(string $path, array $parameters = [], array $requestHeaders = []) - { - return parent::patch($path, $parameters, $this->mergeHeaders($requestHeaders)); - } - - protected function put(string $path, array $parameters = [], array $requestHeaders = []) - { - return parent::put($path, $parameters, $this->mergeHeaders($requestHeaders)); - } - - protected function delete(string $path, array $parameters = [], array $requestHeaders = []) - { - return parent::delete($path, $parameters, $this->mergeHeaders($requestHeaders)); - } - - /** - * Append a new accept header on all requests. - * - * @return array - */ - private function mergeHeaders(array $headers = []): array - { - $default = []; - if ($this->acceptHeaderValue) { - $default = ['Accept' => $this->acceptHeaderValue]; - } - - return array_merge($default, $headers); - } -} diff --git a/lib/Github/Api/App/Hook.php b/lib/Github/Api/App/Hook.php deleted file mode 100644 index e7475dce740..00000000000 --- a/lib/Github/Api/App/Hook.php +++ /dev/null @@ -1,76 +0,0 @@ -get('/app/hook/config'); - } - - /** - * Update the hook configuration of an app. - * - * @link https://docs.github.com/en/rest/apps/webhooks#update-a-webhook-configuration-for-an-app - * - * @param array $params - * - * @return array - */ - public function updateConfig(array $params) - { - return $this->patch('/app/hook/config', $params); - } - - /** - * List deliveries for an app webhook. - * - * @link https://docs.github.com/en/rest/apps/webhooks#list-deliveries-for-an-app-webhook - * - * @return array - */ - public function deliveries() - { - return $this->get('/app/hook/deliveries'); - } - - /** - * Get a delivery for an app webhook. - * - * @link https://docs.github.com/en/rest/apps/webhooks#get-a-delivery-for-an-app-webhook - * - * @param int $delivery - * - * @return array - */ - public function delivery($delivery) - { - return $this->get('/app/hook/deliveries/'.$delivery); - } - - /** - * Redeliver a delivery for an app webhook. - * - * @link https://docs.github.com/en/rest/apps/webhooks#redeliver-a-delivery-for-an-app-webhook - * - * @param int $delivery - * - * @return array - */ - public function redeliver($delivery) - { - return $this->post('/app/hook/deliveries/'.$delivery.'/attempts'); - } -} diff --git a/lib/Github/Api/Apps.php b/lib/Github/Api/Apps.php deleted file mode 100644 index 15e1dfdcd4a..00000000000 --- a/lib/Github/Api/Apps.php +++ /dev/null @@ -1,215 +0,0 @@ - - */ -class Apps extends AbstractApi -{ - use AcceptHeaderTrait; - - private function configurePreviewHeader() - { - $this->acceptHeaderValue = 'application/vnd.github.machine-man-preview+json'; - } - - /** - * Create an access token for an installation. - * - * @param int $installationId An integration installation id - * @param int $userId An optional user id on behalf of whom the - * token will be requested - * - * @link https://developer.github.com/v3/apps/#create-a-new-installation-token - * - * @return array token and token metadata - */ - public function createInstallationToken($installationId, $userId = null) - { - $parameters = []; - if ($userId) { - $parameters['user_id'] = $userId; - } - - $this->configurePreviewHeader(); - - return $this->post('/app/installations/'.$installationId.'/access_tokens', $parameters); - } - - /** - * Find all installations for the authenticated application. - * - * @link https://developer.github.com/v3/apps/#find-installations - * - * @return array - */ - public function findInstallations() - { - $this->configurePreviewHeader(); - - return $this->get('/app/installations'); - } - - /** - * Get an installation of the application. - * - * @link https://developer.github.com/v3/apps/#get-an-installation - * - * @param int $installationId An integration installation id - * - * @return array - */ - public function getInstallation($installationId) - { - $this->configurePreviewHeader(); - - return $this->get('/app/installations/'.$installationId); - } - - /** - * Get an installation of the application for an organization. - * - * @link https://developer.github.com/v3/apps/#get-an-organization-installation - * - * @param string $org An organization - * - * @return array - */ - public function getInstallationForOrganization($org) - { - $this->configurePreviewHeader(); - - return $this->get('/orgs/'.rawurldecode($org).'/installation'); - } - - /** - * Get an installation of the application for a repository. - * - * @link https://developer.github.com/v3/apps/#get-a-repository-installation - * - * @param string $owner the owner of a repository - * @param string $repo the name of the repository - * - * @return array - */ - public function getInstallationForRepo($owner, $repo) - { - $this->configurePreviewHeader(); - - return $this->get('/repos/'.rawurldecode($owner).'/'.rawurldecode($repo).'/installation'); - } - - /** - * Get an installation of the application for a user. - * - * @link https://developer.github.com/v3/apps/#get-a-user-installation - * - * @param string $username - * - * @return array - */ - public function getInstallationForUser($username) - { - $this->configurePreviewHeader(); - - return $this->get('/users/'.rawurldecode($username).'/installation'); - } - - /** - * Delete an installation of the application. - * - * @link https://developer.github.com/v3/apps/#delete-an-installation - * - * @param int $installationId An integration installation id - */ - public function removeInstallation($installationId) - { - $this->configurePreviewHeader(); - - $this->delete('/app/installations/'.$installationId); - } - - /** - * List repositories that are accessible to the authenticated installation. - * - * @link https://developer.github.com/v3/apps/installations/#list-repositories - * - * @param int $userId - * - * @return array - */ - public function listRepositories($userId = null) - { - $parameters = []; - if ($userId) { - $parameters['user_id'] = $userId; - } - - $this->configurePreviewHeader(); - - return $this->get('/installation/repositories', $parameters); - } - - /** - * Add a single repository to an installation. - * - * @link https://developer.github.com/v3/apps/installations/#add-repository-to-installation - * - * @param int $installationId - * @param int $repositoryId - * - * @return array - */ - public function addRepository($installationId, $repositoryId) - { - $this->configurePreviewHeader(); - - return $this->put('/installations/'.$installationId.'/repositories/'.$repositoryId); - } - - /** - * Remove a single repository from an installation. - * - * @link https://developer.github.com/v3/apps/installations/#remove-repository-from-installation - * - * @param int $installationId - * @param int $repositoryId - * - * @return array - */ - public function removeRepository($installationId, $repositoryId) - { - $this->configurePreviewHeader(); - - return $this->delete('/installations/'.$installationId.'/repositories/'.$repositoryId); - } - - /** - * Get the currently authenticated app. - * - * @link https://docs.github.com/en/rest/reference/apps#get-the-authenticated-app - * - * @return array - */ - public function getAuthenticatedApp() - { - return $this->get('/app'); - } - - /** - * Manage the hook of an app. - * - * @link https://docs.github.com/en/rest/apps/webhooks - * - * @return Hook - */ - public function hook() - { - return new Hook($this->getClient()); - } -} diff --git a/lib/Github/Api/Authorizations.php b/lib/Github/Api/Authorizations.php deleted file mode 100644 index 6032c7fadb2..00000000000 --- a/lib/Github/Api/Authorizations.php +++ /dev/null @@ -1,65 +0,0 @@ - - */ -class Authorizations extends AbstractApi -{ - /** - * Check an application token. - * - * @param string $clientId - * @param string|null $token - * - * @return array - */ - public function checkToken($clientId, $token = null) - { - return $this->post('/applications/'.rawurlencode($clientId).'/token', $token ? ['access_token' => $token] : []); - } - - /** - * Reset an application token. - * - * @param string $clientId - * @param string|null $token - * - * @return array - */ - public function resetToken($clientId, $token = null) - { - return $this->patch('/applications/'.rawurlencode($clientId).'/token', $token ? ['access_token' => $token] : []); - } - - /** - * Revoke an application token. - * - * @param string $clientId - * @param string|null $token - * - * @return void - */ - public function deleteToken($clientId, $token = null) - { - $this->delete('/applications/'.rawurlencode($clientId).'/token', $token ? ['access_token' => $token] : []); - } - - /** - * Revoke an application authorization. - * - * @param string $clientId - * @param string|null $token - * - * @return void - */ - public function deleteGrant($clientId, $token = null) - { - $this->delete('/applications/'.rawurlencode($clientId).'/grant', $token ? ['access_token' => $token] : []); - } -} diff --git a/lib/Github/Api/Copilot/Usage.php b/lib/Github/Api/Copilot/Usage.php deleted file mode 100644 index 0110a58bb40..00000000000 --- a/lib/Github/Api/Copilot/Usage.php +++ /dev/null @@ -1,34 +0,0 @@ -get('/orgs/'.rawurlencode($organization).'/copilot/usage', $params); - } - - public function orgTeamUsageSummary(string $organization, string $teamSlug, array $params = []): array - { - return $this->get( - '/orgs/'.rawurlencode($organization).'/team/'.rawurlencode($teamSlug).'/copilot/usage', - $params - ); - } - - public function enterpriseUsageSummary(string $enterprise, array $params = []): array - { - return $this->get('/enterprises/'.rawurlencode($enterprise).'/copilot/usage', $params); - } - - public function enterpriseTeamUsageSummary(string $enterprise, string $teamSlug, array $params = []): array - { - return $this->get( - '/enterprises/'.rawurlencode($enterprise).'/team/'.rawurlencode($teamSlug).'/copilot/usage', - $params - ); - } -} diff --git a/lib/Github/Api/CurrentUser.php b/lib/Github/Api/CurrentUser.php deleted file mode 100644 index b5cbc89a376..00000000000 --- a/lib/Github/Api/CurrentUser.php +++ /dev/null @@ -1,193 +0,0 @@ - - * @author Felipe Valtl de Mello - */ -class CurrentUser extends AbstractApi -{ - use AcceptHeaderTrait; - - public function show() - { - return $this->get('/user'); - } - - public function update(array $params) - { - return $this->patch('/user', $params); - } - - /** - * @return Emails - */ - public function emails() - { - return new Emails($this->getClient()); - } - - /** - * @return Followers - */ - public function follow() - { - return new Followers($this->getClient()); - } - - public function followers($page = 1) - { - return $this->get('/user/followers', [ - 'page' => $page, - ]); - } - - /** - * @link https://docs.github.com/en/rest/reference/issues#list-user-account-issues-assigned-to-the-authenticated-user - * - * @param array $params - * @param bool $includeOrgIssues - * - * @return array - */ - public function issues(array $params = [], $includeOrgIssues = true) - { - return $this->get($includeOrgIssues ? '/issues' : '/user/issues', array_merge(['page' => 1], $params)); - } - - /** - * @return PublicKeys - */ - public function keys() - { - return new PublicKeys($this->getClient()); - } - - /** - * @return Notifications - */ - public function notifications() - { - return new Notifications($this->getClient()); - } - - /** - * @return Memberships - */ - public function memberships() - { - return new Memberships($this->getClient()); - } - - /** - * @link https://docs.github.com/en/rest/reference/orgs#list-organizations-for-the-authenticated-user - * - * @return array - */ - public function organizations() - { - return $this->get('/user/orgs'); - } - - /** - * @link https://developer.github.com/v3/orgs/teams/#list-user-teams - * - * @return array - */ - public function teams() - { - return $this->get('/user/teams'); - } - - /** - * @link https://docs.github.com/en/rest/reference/repos#list-repositories-for-the-authenticated-user - * - * @param string $type role in the repository - * @param string $sort sort by - * @param string $direction direction of sort, asc or desc - * @param string $visibility visibility of repository - * @param string $affiliation relationship to repository - * - * @return array - */ - public function repositories($type = 'owner', $sort = 'full_name', $direction = 'asc', $visibility = null, $affiliation = null) - { - $params = [ - 'type' => $type, - 'sort' => $sort, - 'direction' => $direction, - ]; - - if (null !== $visibility) { - unset($params['type']); - $params['visibility'] = $visibility; - } - - if (null !== $affiliation) { - unset($params['type']); - $params['affiliation'] = $affiliation; - } - - return $this->get('/user/repos', $params); - } - - /** - * @return Watchers - */ - public function watchers() - { - return new Watchers($this->getClient()); - } - - /** - * @return Starring - */ - public function starring() - { - return new Starring($this->getClient()); - } - - /** - * @link https://docs.github.com/en/rest/reference/activity#list-repositories-watched-by-the-authenticated-user - */ - public function subscriptions() - { - return $this->get('/user/subscriptions'); - } - - /** - * @link https://docs.github.com/en/rest/reference/apps#list-app-installations-accessible-to-the-user-access-token - * - * @param array $params - */ - public function installations(array $params = []) - { - $this->acceptHeaderValue = 'application/vnd.github.machine-man-preview+json'; - - return $this->get('/user/installations', array_merge(['page' => 1], $params)); - } - - /** - * @link https://developer.github.com/v3/apps/installations/#list-repositories-accessible-to-the-user-access-token - * - * @param string $installationId the ID of the Installation - * @param array $params - */ - public function repositoriesByInstallation($installationId, array $params = []) - { - $this->acceptHeaderValue = 'application/vnd.github.machine-man-preview+json'; - - return $this->get(sprintf('/user/installations/%s/repositories', $installationId), array_merge(['page' => 1], $params)); - } -} diff --git a/lib/Github/Api/CurrentUser/Emails.php b/lib/Github/Api/CurrentUser/Emails.php deleted file mode 100644 index 23f2ab2402d..00000000000 --- a/lib/Github/Api/CurrentUser/Emails.php +++ /dev/null @@ -1,94 +0,0 @@ - - */ -class Emails extends AbstractApi -{ - /** - * List emails for the authenticated user. - * - * @link http://developer.github.com/v3/users/emails/ - * - * @return array - */ - public function all() - { - return $this->get('/user/emails'); - } - - /** - * List public email addresses for a user. - * - * @link https://developer.github.com/v3/users/emails/#list-public-email-addresses-for-a-user - * - * @return array - */ - public function allPublic() - { - return $this->get('/user/public_emails'); - } - - /** - * Adds one or more email for the authenticated user. - * - * @link http://developer.github.com/v3/users/emails/ - * - * @param string|array $emails - * - * @throws \Github\Exception\InvalidArgumentException - * - * @return array - */ - public function add($emails) - { - if (is_string($emails)) { - $emails = [$emails]; - } elseif (0 === count($emails)) { - throw new InvalidArgumentException('The user emails parameter should be a single email or an array of emails'); - } - - return $this->post('/user/emails', $emails); - } - - /** - * Removes one or more email for the authenticated user. - * - * @link http://developer.github.com/v3/users/emails/ - * - * @param string|array $emails - * - * @throws \Github\Exception\InvalidArgumentException - * - * @return array - */ - public function remove($emails) - { - if (is_string($emails)) { - $emails = [$emails]; - } elseif (0 === count($emails)) { - throw new InvalidArgumentException('The user emails parameter should be a single email or an array of emails'); - } - - return $this->delete('/user/emails', $emails); - } - - /** - * Toggle primary email visibility. - * - * @link https://developer.github.com/v3/users/emails/#toggle-primary-email-visibility - * - * @return array - */ - public function toggleVisibility() - { - return $this->patch('/user/email/visibility'); - } -} diff --git a/lib/Github/Api/CurrentUser/Followers.php b/lib/Github/Api/CurrentUser/Followers.php deleted file mode 100644 index 52a712ca99e..00000000000 --- a/lib/Github/Api/CurrentUser/Followers.php +++ /dev/null @@ -1,71 +0,0 @@ - - */ -class Followers extends AbstractApi -{ - /** - * List followed users by the authenticated user. - * - * @link http://developer.github.com/v3/repos/followers/ - * - * @param int $page - * - * @return array - */ - public function all($page = 1) - { - return $this->get('/user/following', [ - 'page' => $page, - ]); - } - - /** - * Check that the authenticated user follows a user. - * - * @link http://developer.github.com/v3/repos/followers/ - * - * @param string $username the username to follow - * - * @return array - */ - public function check($username) - { - return $this->get('/user/following/'.rawurlencode($username)); - } - - /** - * Make the authenticated user follow a user. - * - * @link http://developer.github.com/v3/repos/followers/ - * - * @param string $username the username to follow - * - * @return array - */ - public function follow($username) - { - return $this->put('/user/following/'.rawurlencode($username)); - } - - /** - * Make the authenticated user un-follow a user. - * - * @link http://developer.github.com/v3/repos/followers/ - * - * @param string $username the username to un-follow - * - * @return array - */ - public function unfollow($username) - { - return $this->delete('/user/following/'.rawurlencode($username)); - } -} diff --git a/lib/Github/Api/CurrentUser/Memberships.php b/lib/Github/Api/CurrentUser/Memberships.php deleted file mode 100644 index da727397407..00000000000 --- a/lib/Github/Api/CurrentUser/Memberships.php +++ /dev/null @@ -1,48 +0,0 @@ -get('/user/memberships/orgs'); - } - - /** - * Get your organization membership. - * - * @link https://developer.github.com/v3/orgs/members/#get-your-organization-membership - * - * @param string $organization - * - * @return array - */ - public function organization($organization) - { - return $this->get('/user/memberships/orgs/'.rawurlencode($organization)); - } - - /** - * Edit your organization membership. - * - * @link https://developer.github.com/v3/orgs/members/#edit-your-organization-membership - * - * @param string $organization - * - * @return array - */ - public function edit($organization) - { - return $this->patch('/user/memberships/orgs/'.rawurlencode($organization), ['state' => 'active']); - } -} diff --git a/lib/Github/Api/CurrentUser/Notifications.php b/lib/Github/Api/CurrentUser/Notifications.php deleted file mode 100644 index 9f3f2ce7bac..00000000000 --- a/lib/Github/Api/CurrentUser/Notifications.php +++ /dev/null @@ -1,145 +0,0 @@ - - */ -class Notifications extends AbstractApi -{ - /** - * List all notifications for the authenticated user. - * - * @link http://developer.github.com/v3/activity/notifications/#list-your-notifications - * - * @param array $params - * - * @return array - */ - public function all(array $params = []) - { - return $this->get('/notifications', $params); - } - - /** - * List all notifications for the authenticated user in selected repository. - * - * @link http://developer.github.com/v3/activity/notifications/#list-your-notifications-in-a-repository - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * @param array $params - * - * @return array - */ - public function allInRepository($username, $repository, array $params = []) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/notifications', $params); - } - - /** - * Mark all notifications as read. - * - * @link http://developer.github.com/v3/activity/notifications/#mark-as-read - * - * @param array $params - * - * @return array - */ - public function markAsReadAll(array $params = []) - { - return $this->put('/notifications', $params); - } - - /** - * Mark all notifications for a repository as read. - * - * @link http://developer.github.com/v3/activity/notifications/#mark-notifications-as-read-in-a-repository - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * @param array $params - * - * @return array - */ - public function markAsReadInRepository($username, $repository, array $params = []) - { - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/notifications', $params); - } - - /** - * Mark a notification as read. - * - * @link http://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read - * - * @param int $id the notification number - * @param array $params - * - * @return array - */ - public function markAsRead($id, array $params) - { - return $this->patch('/notifications/threads/'.$id, $params); - } - - /** - * Show a notification. - * - * @link http://developer.github.com/v3/activity/notifications/#view-a-single-thread - * - * @param int $id the notification number - * - * @return array - */ - public function show($id) - { - return $this->get('/notifications/threads/'.$id); - } - - /** - * Show a subscription. - * - * @link http://developer.github.com/v3/activity/notifications/#get-a-thread-subscription - * - * @param int $id the notification number - * - * @return array - */ - public function showSubscription($id) - { - return $this->get('/notifications/threads/'.$id.'/subscription'); - } - - /** - * Create a subscription. - * - * @link http://developer.github.com/v3/activity/notifications/#set-a-thread-subscription - * - * @param int $id the notification number - * @param array $params - * - * @return array - */ - public function createSubscription($id, array $params) - { - return $this->put('/notifications/threads/'.$id.'/subscription', $params); - } - - /** - * Delete a subscription. - * - * @link http://developer.github.com/v3/activity/notifications/#delete-a-thread-subscription - * - * @param int $id the notification number - * - * @return array - */ - public function removeSubscription($id) - { - return $this->delete('/notifications/threads/'.$id.'/subscription'); - } -} diff --git a/lib/Github/Api/CurrentUser/PublicKeys.php b/lib/Github/Api/CurrentUser/PublicKeys.php deleted file mode 100644 index cb24dec9ace..00000000000 --- a/lib/Github/Api/CurrentUser/PublicKeys.php +++ /dev/null @@ -1,74 +0,0 @@ - - */ -class PublicKeys extends AbstractApi -{ - /** - * List deploy keys for the authenticated user. - * - * @link https://developer.github.com/v3/users/keys/ - * - * @return array - */ - public function all() - { - return $this->get('/user/keys'); - } - - /** - * Shows deploy key for the authenticated user. - * - * @link https://developer.github.com/v3/users/keys/ - * - * @param int $id - * - * @return array - */ - public function show($id) - { - return $this->get('/user/keys/'.$id); - } - - /** - * Adds deploy key for the authenticated user. - * - * @link https://developer.github.com/v3/users/keys/ - * - * @param array $params - * - * @throws \Github\Exception\MissingArgumentException - * - * @return array - */ - public function create(array $params) - { - if (!isset($params['title'], $params['key'])) { - throw new MissingArgumentException(['title', 'key']); - } - - return $this->post('/user/keys', $params); - } - - /** - * Removes deploy key for the authenticated user. - * - * @link https://developer.github.com/v3/users/keys/ - * - * @param int $id - * - * @return array - */ - public function remove($id) - { - return $this->delete('/user/keys/'.$id); - } -} diff --git a/lib/Github/Api/CurrentUser/Starring.php b/lib/Github/Api/CurrentUser/Starring.php deleted file mode 100644 index ee2c50233e3..00000000000 --- a/lib/Github/Api/CurrentUser/Starring.php +++ /dev/null @@ -1,97 +0,0 @@ - - */ -class Starring extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * Configure the body type. - * - * @see https://developer.github.com/v3/activity/starring/#list-stargazers - * - * @param string $bodyType - * - * @return $this - */ - public function configure($bodyType = null) - { - if ('star' === $bodyType) { - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.star+json', $this->getApiVersion()); - } - - return $this; - } - - /** - * List repositories starred by the authenticated user. - * - * @link https://developer.github.com/v3/activity/starring/ - * - * @param int $page - * @param int $perPage - * - * @return array - */ - public function all($page = 1, $perPage = 30) - { - return $this->get('/user/starred', [ - 'page' => $page, - 'per_page' => $perPage, - ]); - } - - /** - * Check that the authenticated user starres a repository. - * - * @link https://developer.github.com/v3/activity/starring/ - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * - * @return array - */ - public function check($username, $repository) - { - return $this->get('/user/starred/'.rawurlencode($username).'/'.rawurlencode($repository)); - } - - /** - * Make the authenticated user star a repository. - * - * @link https://developer.github.com/v3/activity/starring/ - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * - * @return array - */ - public function star($username, $repository) - { - return $this->put('/user/starred/'.rawurlencode($username).'/'.rawurlencode($repository)); - } - - /** - * Make the authenticated user unstar a repository. - * - * @link https://developer.github.com/v3/activity/starring - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * - * @return array - */ - public function unstar($username, $repository) - { - return $this->delete('/user/starred/'.rawurlencode($username).'/'.rawurlencode($repository)); - } -} diff --git a/lib/Github/Api/CurrentUser/Watchers.php b/lib/Github/Api/CurrentUser/Watchers.php deleted file mode 100644 index 79c04b5df36..00000000000 --- a/lib/Github/Api/CurrentUser/Watchers.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * @revised Felipe Valtl de Mello - */ -class Watchers extends AbstractApi -{ - /** - * List repositories watched by the authenticated user. - * - * @link https://developer.github.com/v3/activity/watching/ - * - * @param int $page - * - * @return array - */ - public function all($page = 1) - { - return $this->get('/user/subscriptions', [ - 'page' => $page, - ]); - } - - /** - * Check that the authenticated user watches a repository. - * - * @link https://developer.github.com/v3/activity/watching/ - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * - * @return array - */ - public function check($username, $repository) - { - return $this->get('/user/subscriptions/'.rawurlencode($username).'/'.rawurlencode($repository)); - } - - /** - * Make the authenticated user watch a repository. - * - * @link https://developer.github.com/v3/activity/watching/ - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * - * @return array - */ - public function watch($username, $repository) - { - return $this->put('/user/subscriptions/'.rawurlencode($username).'/'.rawurlencode($repository)); - } - - /** - * Make the authenticated user unwatch a repository. - * - * @link https://developer.github.com/v3/activity/watching/ - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * - * @return array - */ - public function unwatch($username, $repository) - { - return $this->delete('/user/subscriptions/'.rawurlencode($username).'/'.rawurlencode($repository)); - } -} diff --git a/lib/Github/Api/Deployment.php b/lib/Github/Api/Deployment.php deleted file mode 100644 index de5b0cb0eb9..00000000000 --- a/lib/Github/Api/Deployment.php +++ /dev/null @@ -1,151 +0,0 @@ -get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments', $params); - } - - /** - * Get a deployment in selected repository. - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * @param int $id the id of the deployment - * - * @return array - */ - public function show($username, $repository, $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id); - } - - /** - * Create a new deployment for the given username and repo. - * - * @link https://developer.github.com/v3/repos/deployments/#create-a-deployment - * - * Important: Once a deployment is created, it cannot be updated. Changes are indicated by creating new statuses. - * @see updateStatus - * - * @param string $username the username - * @param string $repository the repository - * @param array $params the new deployment data - * - * @throws MissingArgumentException - * - * @return array information about the deployment - */ - public function create($username, $repository, array $params) - { - if (!isset($params['ref'])) { - throw new MissingArgumentException(['ref']); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments', $params); - } - - /** - * Delete a deployment for the given username and repo. - * - * @link https://docs.github.com/en/rest/reference/repos#delete-a-deployment - * - * Important: Deployments can only be deleted when in inactive state - * @see updateStatus - * - * @return mixed null on success, array on error with 'message' - */ - public function remove(string $username, string $repository, int $id) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id); - } - - /** - * Updates a deployment by creating a new status update. - * - * @link https://developer.github.com/v3/repos/deployments/#create-a-deployment-status - * - * @param string $username the username - * @param string $repository the repository - * @param int $id the deployment number - * @param array $params The information about the deployment update. - * Must include a "state" field of pending, success, error, or failure. - * May also be given a target_url and description, see link for more details. - * - * @throws MissingArgumentException - * - * @return array information about the deployment - */ - public function updateStatus($username, $repository, $id, array $params) - { - if (!isset($params['state'])) { - throw new MissingArgumentException(['state']); - } - - // adjust media-type per github docs - // https://docs.github.com/en/rest/reference/repos#create-a-deployment-status - if ($params['state'] === 'inactive') { - $this->acceptHeaderValue = 'application/vnd.github.ant-man-preview+json'; - } - if ($params['state'] === 'in_progress' || $params['state'] === 'queued') { - $this->acceptHeaderValue = 'application/vnd.github.flash-preview+json'; - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id.'/statuses', $params); - } - - /** - * Gets all of the status updates tied to a given deployment. - * - * @param string $username the username - * @param string $repository the repository - * @param int $id the deployment identifier - * - * @return array the deployment statuses - */ - public function getStatuses($username, $repository, $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/deployments/'.$id.'/statuses'); - } - - /** - * @return Environments - */ - public function environments() - { - return new Environments($this->getClient()); - } - - /** - * @return Policies - */ - public function policies() - { - return new Policies($this->getClient()); - } -} diff --git a/lib/Github/Api/Deployment/Environments.php b/lib/Github/Api/Deployment/Environments.php deleted file mode 100644 index 191ec498eab..00000000000 --- a/lib/Github/Api/Deployment/Environments.php +++ /dev/null @@ -1,90 +0,0 @@ -get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments', $params); - } - - /** - * Get a environment in selected repository. - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * @param string $name the name of the environment - * - * @return array - */ - public function show($username, $repository, $name) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($name)); - } - - /** - * Create or update a environment for the given username and repo. - * - * @link https://docs.github.com/en/rest/deployments/environments?apiVersion=2022-11-28#create-or-update-an-environment - * - * @param string $username the username - * @param string $repository the repository - * @param string $name the name of the environment - * @param array $params the new environment data - * - * @return array information about the environment - */ - public function createOrUpdate($username, $repository, $name, array $params = []) - { - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($name), $params); - } - - /** - * Delete a environment for the given username and repo. - * - * @link https://docs.github.com/en/rest/deployments/environments?apiVersion=2022-11-28#delete-an-environment - * - * @return mixed null on success, array on error with 'message' - */ - public function remove(string $username, string $repository, string $name) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($name)); - } - - /** - * @link https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#about-secrets-in-github-actions - */ - public function secrets(): Secrets - { - return new Secrets($this->getClient()); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#about-variables-in-github-actions - */ - public function variables(): Variables - { - return new Variables($this->getClient()); - } -} diff --git a/lib/Github/Api/Deployment/Policies.php b/lib/Github/Api/Deployment/Policies.php deleted file mode 100644 index e2d8fb59680..00000000000 --- a/lib/Github/Api/Deployment/Policies.php +++ /dev/null @@ -1,97 +0,0 @@ -get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($environment).'/deployment-branch-policies', $params); - } - - /** - * Get a deployment branch policy. - * - * @link https://docs.github.com/en/rest/deployments/branch-policies?apiVersion=2022-11-28#get-a-deployment-branch-policy - * - * @param string $username the username of the user who owns the repository - * @param string $repository the name of the repository - * @param string $environment the name of the environment. - * @param int $id the unique identifier of the branch policy. - * - * @return array - */ - public function show(string $username, string $repository, string $environment, int $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($environment).'/deployment-branch-policies/'.$id); - } - - /** - * Creates a deployment branch policy for an environment. - * - * @link https://docs.github.com/en/rest/deployments/branch-policies?apiVersion=2022-11-28#create-a-deployment-branch-policy - * - * @param string $username the username of the user who owns the repository - * @param string $repository the name of the repository - * @param string $environment the name of the environment. - * - * @return array information about the deployment branch policy - */ - public function create(string $username, string $repository, string $environment, array $params) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($environment).'/deployment-branch-policies', $params); - } - - /** - * Updates a deployment branch policy for an environment. - * - * @link https://docs.github.com/en/rest/deployments/branch-policies?apiVersion=2022-11-28#update-a-deployment-branch-policy - * - * @param string $username the username of the user who owns the repository - * @param string $repository the name of the repository - * @param string $environment the name of the environment. - * @param int $id the unique identifier of the branch policy. - * - * @return array information about the deployment branch policy - */ - public function update(string $username, string $repository, string $environment, int $id, array $params) - { - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($environment).'/deployment-branch-policies/'.$id, $params); - } - - /** - * Delete a deployment branch policy. - * - * @link https://docs.github.com/en/rest/deployments/branch-policies?apiVersion=2022-11-28#delete-a-deployment-branch-policy - * - * @param string $username the username of the user who owns the repository - * @param string $repository the name of the repository - * @param string $environment the name of the environment. - * @param int $id the unique identifier of the branch policy. - * - * @return mixed null on success, array on error with 'message' - */ - public function remove(string $username, string $repository, string $environment, int $id) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/environments/'.rawurlencode($environment).'/deployment-branch-policies/'.$id); - } -} diff --git a/lib/Github/Api/Enterprise.php b/lib/Github/Api/Enterprise.php deleted file mode 100644 index 62abaff577e..00000000000 --- a/lib/Github/Api/Enterprise.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @author Guillermo A. Fisher - */ -class Enterprise extends AbstractApi -{ - /** - * @return Stats - */ - public function stats() - { - return new Stats($this->getClient()); - } - - /** - * @return License - */ - public function license() - { - return new License($this->getClient()); - } - - /** - * @return ManagementConsole - */ - public function console() - { - return new ManagementConsole($this->getClient()); - } - - /** - * @return UserAdmin - */ - public function userAdmin() - { - return new UserAdmin($this->getClient()); - } - - /** - * @return SecretScanning - */ - public function secretScanning(): SecretScanning - { - return new SecretScanning($this->getClient()); - } -} diff --git a/lib/Github/Api/Enterprise/License.php b/lib/Github/Api/Enterprise/License.php deleted file mode 100644 index 67e1c2a96ea..00000000000 --- a/lib/Github/Api/Enterprise/License.php +++ /dev/null @@ -1,20 +0,0 @@ -get('/enterprise/settings/license'); - } -} diff --git a/lib/Github/Api/Enterprise/ManagementConsole.php b/lib/Github/Api/Enterprise/ManagementConsole.php deleted file mode 100644 index f11c47643eb..00000000000 --- a/lib/Github/Api/Enterprise/ManagementConsole.php +++ /dev/null @@ -1,77 +0,0 @@ -getWithLicenseHash('/setup/api/configcheck', $hash); - } - - /** - * Retrieves your installation’s settings. - * - * @link https://developer.github.com/v3/enterprise/management_console/#retrieve-settings - * - * @param string $hash md5 hash of your license - * - * @return array array of settings - */ - public function settings($hash) - { - return $this->getWithLicenseHash('/setup/api/settings', $hash); - } - - /** - * Checks your installation’s maintenance status. - * - * @link https://developer.github.com/v3/enterprise/management_console/#check-maintenance-status - * - * @param string $hash md5 hash of your license - * - * @return array array of maintenance status information - */ - public function maintenance($hash) - { - return $this->getWithLicenseHash('/setup/api/maintenance', $hash); - } - - /** - * Retrieves your installation’s authorized SSH keys. - * - * @link https://developer.github.com/v3/enterprise/management_console/#retrieve-authorized-ssh-keys - * - * @param string $hash md5 hash of your license - * - * @return array array of authorized keys - */ - public function keys($hash) - { - return $this->getWithLicenseHash('/setup/api/settings/authorized-keys', $hash); - } - - /** - * Sends an authenticated GET request. - * - * @param string $uri the request URI - * @param string $hash md5 hash of your license - * - * @return array|string - */ - protected function getWithLicenseHash($uri, $hash) - { - return $this->get($uri, ['license_md5' => rawurlencode($hash)]); - } -} diff --git a/lib/Github/Api/Enterprise/SecretScanning.php b/lib/Github/Api/Enterprise/SecretScanning.php deleted file mode 100644 index 5d92c1d8a47..00000000000 --- a/lib/Github/Api/Enterprise/SecretScanning.php +++ /dev/null @@ -1,21 +0,0 @@ -get('/enterprises/'.rawurlencode($enterprise).'/secret-scanning/alerts', $params); - } -} diff --git a/lib/Github/Api/Enterprise/Stats.php b/lib/Github/Api/Enterprise/Stats.php deleted file mode 100644 index 78ba42565e9..00000000000 --- a/lib/Github/Api/Enterprise/Stats.php +++ /dev/null @@ -1,128 +0,0 @@ -show('issues'); - } - - /** - * Returns the number of active and inactive hooks. - * - * @return array array with totals of active and inactive hooks - */ - public function hooks() - { - return $this->show('hooks'); - } - - /** - * Returns the number of open and closed milestones. - * - * @return array array with totals of open and closed milestones - */ - public function milestones() - { - return $this->show('milestones'); - } - - /** - * Returns the number of organizations, teams, team members, and disabled organizations. - * - * @return array array with totals of organizations, teams, team members, and disabled organizations - */ - public function orgs() - { - return $this->show('orgs'); - } - - /** - * Returns the number of comments on issues, pull requests, commits, and gists. - * - * @return array array with totals of comments on issues, pull requests, commits, and gists - */ - public function comments() - { - return $this->show('comments'); - } - - /** - * Returns the number of GitHub Pages sites. - * - * @return array array with totals of GitHub Pages sites - */ - public function pages() - { - return $this->show('pages'); - } - - /** - * Returns the number of suspended and admin users. - * - * @return array array with totals of suspended and admin users - */ - public function users() - { - return $this->show('users'); - } - - /** - * Returns the number of private and public gists. - * - * @return array array with totals of private and public gists - */ - public function gists() - { - return $this->show('gists'); - } - - /** - * Returns the number of merged, mergeable, and unmergeable pull requests. - * - * @return array array with totals of merged, mergeable, and unmergeable pull requests - */ - public function pulls() - { - return $this->show('pulls'); - } - - /** - * Returns the number of organization-owned repositories, root repositories, forks, pushed commits, and wikis. - * - * @return array array with totals of organization-owned repositories, root repositories, forks, pushed commits, and wikis - */ - public function repos() - { - return $this->show('repos'); - } - - /** - * Returns all of the statistics. - * - * @return array array with all of the statistics - */ - public function all() - { - return $this->show('all'); - } - - /** - * @param string $type The type of statistics to show - * - * @return array - */ - public function show($type) - { - return $this->get('/enterprise/stats/'.rawurlencode($type)); - } -} diff --git a/lib/Github/Api/Enterprise/UserAdmin.php b/lib/Github/Api/Enterprise/UserAdmin.php deleted file mode 100644 index 0cd55a38c53..00000000000 --- a/lib/Github/Api/Enterprise/UserAdmin.php +++ /dev/null @@ -1,36 +0,0 @@ -put('/users/'.rawurldecode($username).'/suspended', ['Content-Length' => 0]); - } - - /** - * Unsuspend a user. - * - * @link https://developer.github.com/v3/users/administration/#unsuspend-a-user - * - * @param string $username - * - * @return array - */ - public function unsuspend($username) - { - return $this->delete('/users/'.rawurldecode($username).'/suspended'); - } -} diff --git a/lib/Github/Api/Environment/Secrets.php b/lib/Github/Api/Environment/Secrets.php deleted file mode 100644 index cef84c34958..00000000000 --- a/lib/Github/Api/Environment/Secrets.php +++ /dev/null @@ -1,80 +0,0 @@ -get('/repositories/'.$id.'/environments/'.rawurlencode($name).'/secrets'); - } - - /** - * @link https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#get-an-environment-secret - * - * @param int $id - * @param string $name - * @param string $secretName - * - * @return array|string - */ - public function show(int $id, string $name, string $secretName) - { - return $this->get('/repositories/'.$id.'/environments/'.rawurlencode($name).'/secrets/'.rawurlencode($secretName)); - } - - /** - * @link https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#create-or-update-an-environment-secret - * - * @param int $id - * @param string $name - * @param string $secretName - * @param array $parameters - * - * @return array|string - */ - public function createOrUpdate(int $id, string $name, string $secretName, array $parameters = []) - { - return $this->put('/repositories/'.$id.'/environments/'.rawurlencode($name).'/secrets/'.rawurlencode($secretName), $parameters); - } - - /** - * @link https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#delete-an-environment-secret - * - * @param int $id - * @param string $name - * @param string $secretName - * - * @return array|string - */ - public function remove(int $id, string $name, string $secretName) - { - return $this->delete('/repositories/'.$id.'/environments/'.rawurlencode($name).'/secrets/'.rawurlencode($secretName)); - } - - /** - * @link https://docs.github.com/en/rest/actions/secrets?apiVersion=2022-11-28#get-an-environment-public-key - * - * @param int $id - * @param string $name - * - * @return array|string - */ - public function publicKey(int $id, string $name) - { - return $this->get('/repositories/'.$id.'/environments/'.rawurlencode($name).'/secrets/public-key'); - } -} diff --git a/lib/Github/Api/Environment/Variables.php b/lib/Github/Api/Environment/Variables.php deleted file mode 100644 index 035a8f605a3..00000000000 --- a/lib/Github/Api/Environment/Variables.php +++ /dev/null @@ -1,81 +0,0 @@ -get('/repositories/'.$id.'/environments/'.rawurlencode($name).'/variables'); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-an-environment-variable - * - * @param int $id - * @param string $name - * @param string $variableName - * - * @return array|string - */ - public function show(int $id, string $name, string $variableName) - { - return $this->get('/repositories/'.$id.'/environments/'.rawurlencode($name).'/variables/'.rawurlencode($variableName)); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-an-environment-variable - * - * @param int $id - * @param string $name - * @param array $parameters - * - * @return array|string - */ - public function create(int $id, string $name, array $parameters) - { - return $this->post('/repositories/'.$id.'/environments/'.rawurlencode($name).'/variables', $parameters); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-an-environment-variable - * - * @param int $id - * @param string $name - * @param string $variableName - * @param array $parameters - * - * @return array|string - */ - public function update(int $id, string $name, string $variableName, array $parameters) - { - return $this->patch('/repositories/'.$id.'/environments/'.rawurlencode($name).'/variables/'.rawurlencode($variableName), $parameters); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-an-environment-variable - * - * @param int $id - * @param string $name - * @param string $variableName - * - * @return array|string - */ - public function remove(int $id, string $name, string $variableName) - { - return $this->delete('/repositories/'.$id.'/environments/'.rawurlencode($name).'/variables/'.rawurlencode($variableName)); - } -} diff --git a/lib/Github/Api/Gist/Comments.php b/lib/Github/Api/Gist/Comments.php deleted file mode 100644 index 31587d94016..00000000000 --- a/lib/Github/Api/Gist/Comments.php +++ /dev/null @@ -1,101 +0,0 @@ - - */ -class Comments extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * Configure the body type. - * - * @link https://developer.github.com/v3/gists/comments/#custom-media-types - * - * @param string|null $bodyType - * - * @return $this - */ - public function configure($bodyType = null) - { - if (!in_array($bodyType, ['text', 'html', 'full'])) { - $bodyType = 'raw'; - } - - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->getApiVersion(), $bodyType); - - return $this; - } - - /** - * Get all comments for a gist. - * - * @param string $gist - * - * @return array - */ - public function all($gist) - { - return $this->get('/gists/'.rawurlencode($gist).'/comments'); - } - - /** - * Get a comment of a gist. - * - * @param string $gist - * @param int $comment - * - * @return array - */ - public function show($gist, $comment) - { - return $this->get('/gists/'.rawurlencode($gist).'/comments/'.$comment); - } - - /** - * Create a comment for gist. - * - * @param string $gist - * @param string $body - * - * @return array - */ - public function create($gist, $body) - { - return $this->post('/gists/'.rawurlencode($gist).'/comments', ['body' => $body]); - } - - /** - * Create a comment for a gist. - * - * @param string $gist - * @param int $comment_id - * @param string $body - * - * @return array - */ - public function update($gist, $comment_id, $body) - { - return $this->patch('/gists/'.rawurlencode($gist).'/comments/'.$comment_id, ['body' => $body]); - } - - /** - * Delete a comment for a gist. - * - * @param string $gist - * @param int $comment - * - * @return array - */ - public function remove($gist, $comment) - { - return $this->delete('/gists/'.rawurlencode($gist).'/comments/'.$comment); - } -} diff --git a/lib/Github/Api/Gists.php b/lib/Github/Api/Gists.php deleted file mode 100644 index 42bbdb9c97b..00000000000 --- a/lib/Github/Api/Gists.php +++ /dev/null @@ -1,182 +0,0 @@ - - * @author Edoardo Rivello - */ -class Gists extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * Configure the body type. - * - * @link https://developer.github.com/v3/gists/#custom-media-types - * - * @param string|null $bodyType - * - * @return $this - */ - public function configure($bodyType = null) - { - if ('base64' !== $bodyType) { - $bodyType = 'raw'; - } - - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s', $this->getApiVersion(), $bodyType); - - return $this; - } - - /** - * @param string|null $type - * - * @return array|string - */ - public function all($type = null) - { - if (!in_array($type, ['public', 'starred'])) { - return $this->get('/gists'); - } - - return $this->get('/gists/'.rawurlencode($type)); - } - - /** - * @param string $number - * - * @return array - */ - public function show($number) - { - return $this->get('/gists/'.rawurlencode($number)); - } - - /** - * Get a specific revision of a gist. - * - * @param string $number - * @param string $sha - * - * @link https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist - * - * @return array - */ - public function revision($number, $sha) - { - return $this->get('/gists/'.rawurlencode($number).'/'.rawurlencode($sha)); - } - - public function create(array $params) - { - if (!isset($params['files']) || (!is_array($params['files']) || 0 === count($params['files']))) { - throw new MissingArgumentException('files'); - } - - $params['public'] = (bool) $params['public']; - - return $this->post('/gists', $params); - } - - /** - * @param string $id - * @param array $params - * - * @return array - */ - public function update($id, array $params) - { - return $this->patch('/gists/'.rawurlencode($id), $params); - } - - /** - * @param string $id - * - * @return array - */ - public function commits($id) - { - return $this->get('/gists/'.rawurlencode($id).'/commits'); - } - - /** - * @param string $id - * - * @return array - */ - public function fork($id) - { - return $this->post('/gists/'.rawurlencode($id).'/fork'); - } - - /** - * @param string $id - * - * @return array - */ - public function forks($id) - { - return $this->get('/gists/'.rawurlencode($id).'/forks'); - } - - /** - * @param string $id - * - * @return array - */ - public function remove($id) - { - return $this->delete('/gists/'.rawurlencode($id)); - } - - /** - * @param string $id - * - * @return array - */ - public function check($id) - { - return $this->get('/gists/'.rawurlencode($id).'/star'); - } - - /** - * @param string $id - * - * @return array - */ - public function star($id) - { - return $this->put('/gists/'.rawurlencode($id).'/star'); - } - - /** - * @param string $id - * - * @return array - */ - public function unstar($id) - { - return $this->delete('/gists/'.rawurlencode($id).'/star'); - } - - /** - * Get a gist's comments. - * - * @link http://developer.github.com/v3/gists/comments/ - * - * @return Comments - */ - public function comments() - { - return new Comments($this->getClient()); - } -} diff --git a/lib/Github/Api/GitData.php b/lib/Github/Api/GitData.php deleted file mode 100644 index b7a9f48c344..00000000000 --- a/lib/Github/Api/GitData.php +++ /dev/null @@ -1,59 +0,0 @@ - - */ -class GitData extends AbstractApi -{ - /** - * @return Blobs - */ - public function blobs() - { - return new Blobs($this->getClient()); - } - - /** - * @return Commits - */ - public function commits() - { - return new Commits($this->getClient()); - } - - /** - * @return References - */ - public function references() - { - return new References($this->getClient()); - } - - /** - * @return Tags - */ - public function tags() - { - return new Tags($this->getClient()); - } - - /** - * @return Trees - */ - public function trees() - { - return new Trees($this->getClient()); - } -} diff --git a/lib/Github/Api/GitData/Blobs.php b/lib/Github/Api/GitData/Blobs.php deleted file mode 100644 index 31aacda5674..00000000000 --- a/lib/Github/Api/GitData/Blobs.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @author Tobias Nyholm - */ -class Blobs extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * Configure the Accept header depending on the blob type. - * - * @param string|null $bodyType - * - * @return $this - */ - public function configure($bodyType = null) - { - if ('raw' === $bodyType) { - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.raw', $this->getApiVersion()); - } - - return $this; - } - - /** - * Show a blob of a sha for a repository. - * - * @param string $username - * @param string $repository - * @param string $sha - * - * @return array - */ - public function show($username, $repository, $sha) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/blobs/'.rawurlencode($sha)); - } - - /** - * Create a blob of a sha for a repository. - * - * @param string $username - * @param string $repository - * @param array $params - * - * @throws \Github\Exception\MissingArgumentException - * - * @return array - */ - public function create($username, $repository, array $params) - { - if (!isset($params['content'])) { - throw new MissingArgumentException('content'); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/blobs', $params); - } -} diff --git a/lib/Github/Api/GitData/Commits.php b/lib/Github/Api/GitData/Commits.php deleted file mode 100644 index 4205931f408..00000000000 --- a/lib/Github/Api/GitData/Commits.php +++ /dev/null @@ -1,48 +0,0 @@ - - */ -class Commits extends AbstractApi -{ - /** - * Show a commit for a repository. - * - * @param string $username - * @param string $repository - * @param string $sha - * - * @return array - */ - public function show($username, $repository, $sha) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/commits/'.rawurlencode($sha)); - } - - /** - * Create a commit for a repository. - * - * @param string $username - * @param string $repository - * @param array $params - * - * @throws \Github\Exception\MissingArgumentException - * - * @return array - */ - public function create($username, $repository, array $params) - { - if (!isset($params['message'], $params['tree'], $params['parents'])) { - throw new MissingArgumentException(['message', 'tree', 'parents']); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/commits', $params); - } -} diff --git a/lib/Github/Api/GitData/References.php b/lib/Github/Api/GitData/References.php deleted file mode 100644 index d67cbe512b9..00000000000 --- a/lib/Github/Api/GitData/References.php +++ /dev/null @@ -1,156 +0,0 @@ - - */ -class References extends AbstractApi -{ - /** - * Get all references of a repository. - * - * @param string $username - * @param string $repository - * - * @return array - */ - public function all($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs'); - } - - /** - * Get all matching references for the supplied reference name. - * - * @param string $username - * @param string $repository - * @param string $reference - * - * @return array - */ - public function matching(string $username, string $repository, string $reference): array - { - $reference = $this->encodeReference($reference); - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/matching-refs/'.$reference); - } - - /** - * Get all branches of a repository. - * - * @param string $username - * @param string $repository - * - * @return array - */ - public function branches($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/heads'); - } - - /** - * Get all tags of a repository. - * - * @param string $username - * @param string $repository - * - * @return array - */ - public function tags($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/tags'); - } - - /** - * Show the reference of a repository. - * - * @param string $username - * @param string $repository - * @param string $reference - * - * @return array - */ - public function show($username, $repository, $reference) - { - $reference = $this->encodeReference($reference); - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/'.$reference); - } - - /** - * Create a reference for a repository. - * - * @param string $username - * @param string $repository - * @param array $params - * - * @throws \Github\Exception\MissingArgumentException - * - * @return array - */ - public function create($username, $repository, array $params) - { - if (!isset($params['ref'], $params['sha'])) { - throw new MissingArgumentException(['ref', 'sha']); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs', $params); - } - - /** - * Update a reference for a repository. - * - * @param string $username - * @param string $repository - * @param string $reference - * @param array $params - * - * @throws \Github\Exception\MissingArgumentException - * - * @return array - */ - public function update($username, $repository, $reference, array $params) - { - if (!isset($params['sha'])) { - throw new MissingArgumentException('sha'); - } - - $reference = $this->encodeReference($reference); - - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/'.$reference, $params); - } - - /** - * Delete a reference of a repository. - * - * @param string $username - * @param string $repository - * @param string $reference - * - * @return array - */ - public function remove($username, $repository, $reference) - { - $reference = $this->encodeReference($reference); - - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/'.$reference); - } - - /** - * Encode the raw reference. - * - * @param string $rawReference - * - * @return string - */ - private function encodeReference($rawReference) - { - return implode('/', array_map('rawurlencode', explode('/', $rawReference))); - } -} diff --git a/lib/Github/Api/GitData/Tags.php b/lib/Github/Api/GitData/Tags.php deleted file mode 100644 index 11bf200a31f..00000000000 --- a/lib/Github/Api/GitData/Tags.php +++ /dev/null @@ -1,65 +0,0 @@ - - */ -class Tags extends AbstractApi -{ - /** - * Get all tags for a repository. - * - * @param string $username - * @param string $repository - * - * @return array - */ - public function all($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/tags'); - } - - /** - * Get a tag for a repository. - * - * @param string $username - * @param string $repository - * @param string $sha - * - * @return array - */ - public function show($username, $repository, $sha) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/tags/'.rawurlencode($sha)); - } - - /** - * Create a tag for a repository. - * - * @param string $username - * @param string $repository - * @param array $params - * - * @throws \Github\Exception\MissingArgumentException - * - * @return array - */ - public function create($username, $repository, array $params) - { - if (!isset($params['tag'], $params['message'], $params['object'], $params['type'])) { - throw new MissingArgumentException(['tag', 'message', 'object', 'type']); - } - - if (isset($params['tagger']) && !isset($params['tagger']['name'], $params['tagger']['email'], $params['tagger']['date'])) { - throw new MissingArgumentException(['tagger.name', 'tagger.email', 'tagger.date']); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/tags', $params); - } -} diff --git a/lib/Github/Api/GitData/Trees.php b/lib/Github/Api/GitData/Trees.php deleted file mode 100644 index 939e8619b73..00000000000 --- a/lib/Github/Api/GitData/Trees.php +++ /dev/null @@ -1,64 +0,0 @@ - - */ -class Trees extends AbstractApi -{ - /** - * Get the tree for a repository. - * - * @param string $username - * @param string $repository - * @param string $sha - * @param bool $recursive - * - * @return array - */ - public function show($username, $repository, $sha, $recursive = false) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/trees/'.rawurlencode($sha), $recursive ? ['recursive' => 1] : []); - } - - /** - * Create tree for a repository. - * - * @param string $username - * @param string $repository - * @param array $params - * - * @throws \Github\Exception\MissingArgumentException - * - * @return array - */ - public function create($username, $repository, array $params) - { - if (!isset($params['tree']) || !is_array($params['tree'])) { - throw new MissingArgumentException('tree'); - } - - if (!isset($params['tree'][0])) { - $params['tree'] = [$params['tree']]; - } - - foreach ($params['tree'] as $key => $tree) { - if (!isset($tree['path'], $tree['mode'], $tree['type'])) { - throw new MissingArgumentException(["tree.$key.path", "tree.$key.mode", "tree.$key.type"]); - } - - // If `sha` is not set, `content` is required - if (!array_key_exists('sha', $tree) && !isset($tree['content'])) { - throw new MissingArgumentException("tree.$key.content"); - } - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/trees', $params); - } -} diff --git a/lib/Github/Api/GraphQL.php b/lib/Github/Api/GraphQL.php deleted file mode 100644 index 02499ad8ef7..00000000000 --- a/lib/Github/Api/GraphQL.php +++ /dev/null @@ -1,48 +0,0 @@ - - */ -class GraphQL extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * @param string $query - * @param array $variables - * @param string $acceptHeaderValue - * - * @return array - */ - public function execute($query, array $variables = [], string $acceptHeaderValue = 'application/vnd.github.v4+json') - { - $this->acceptHeaderValue = $acceptHeaderValue; - $params = [ - 'query' => $query, - ]; - if (!empty($variables)) { - $params['variables'] = json_encode($variables); - } - - return $this->post('/graphql', $params); - } - - /** - * @param string $file - * @param array $variables - * - * @return array - */ - public function fromFile($file, array $variables = []) - { - return $this->execute(file_get_contents($file), $variables); - } -} diff --git a/lib/Github/Api/Issue.php b/lib/Github/Api/Issue.php deleted file mode 100644 index 764f5e442a9..00000000000 --- a/lib/Github/Api/Issue.php +++ /dev/null @@ -1,241 +0,0 @@ - - * @author Joseph Bielawski - */ -class Issue extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * Configure the body type. - * - * @link https://developer.github.com/v3/issues/#custom-media-types - * - * @param string|null $bodyType - * - * @return $this - */ - public function configure($bodyType = null) - { - if (!in_array($bodyType, ['text', 'html', 'full'])) { - $bodyType = 'raw'; - } - - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->getApiVersion(), $bodyType); - - return $this; - } - - /** - * List issues by username, repo and state. - * - * @link http://developer.github.com/v3/issues/ - * - * @param string $username the username - * @param string $repository the repository - * @param array $params the additional parameters like milestone, assignees, labels, sort, direction - * - * @return array list of issues found - */ - public function all($username, $repository, array $params = []) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues', array_merge(['page' => 1], $params)); - } - - /** - * List issues by organization. - * - * @link http://developer.github.com/v3/issues/ - * - * @param string $organization the organization - * @param string $state the issue state, can be open or closed - * @param array $params the additional parameters like milestone, assignees, labels, sort, direction - * - * @return array list of issues found - */ - public function org($organization, $state, array $params = []) - { - if (!in_array($state, ['open', 'closed'])) { - $state = 'open'; - } - - return $this->get('/orgs/'.rawurlencode($organization).'/issues', array_merge(['page' => 1, 'state' => $state], $params)); - } - - /** - * Get extended information about an issue by its username, repo and number. - * - * @link http://developer.github.com/v3/issues/ - * - * @param string $username the username - * @param string $repository the repository - * @param int $id the issue number - * - * @return array information about the issue - */ - public function show($username, $repository, $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$id); - } - - /** - * Create a new issue for the given username and repo. - * The issue is assigned to the authenticated user. Requires authentication. - * - * @link http://developer.github.com/v3/issues/ - * - * @param string $username the username - * @param string $repository the repository - * @param array $params the new issue data - * - * @throws MissingArgumentException - * - * @return array information about the issue - */ - public function create($username, $repository, array $params) - { - if (!isset($params['title'])) { - throw new MissingArgumentException(['title']); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues', $params); - } - - /** - * Update issue information's by username, repo and issue number. Requires authentication. - * - * @link http://developer.github.com/v3/issues/ - * - * @param string $username the username - * @param string $repository the repository - * @param int $id the issue number - * @param array $params key=>value user attributes to update. - * key can be title or body - * - * @return array information about the issue - */ - public function update($username, $repository, $id, array $params) - { - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$id, $params); - } - - /** - * Lock an issue. Users with push access can lock an issue's conversation. - * - * @link https://developer.github.com/v3/issues/#lock-an-issue - * - * @param string $username - * @param string $repository - * @param int $id - * - * @return string - */ - public function lock($username, $repository, $id) - { - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$id.'/lock'); - } - - /** - * Unlock an issue. Users with push access can unlock an issue's conversation. - * - * @link https://developer.github.com/v3/issues/#lock-an-issue - * - * @param string $username - * @param string $repository - * @param int $id - * - * @return string - */ - public function unlock($username, $repository, $id) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$id.'/lock'); - } - - /** - * List an issue comments. - * - * @link http://developer.github.com/v3/issues/comments/ - * - * @return Comments - */ - public function comments() - { - return new Comments($this->getClient()); - } - - /** - * List all project events. - * - * @link http://developer.github.com/v3/issues/events/ - * - * @return Events - */ - public function events() - { - return new Events($this->getClient()); - } - - /** - * List all project labels. - * - * @link http://developer.github.com/v3/issues/labels/ - * - * @return Labels - */ - public function labels() - { - return new Labels($this->getClient()); - } - - /** - * List all project milestones. - * - * @link http://developer.github.com/v3/issues/milestones/ - * - * @return Milestones - */ - public function milestones() - { - return new Milestones($this->getClient()); - } - - /** - * List all assignees. - * - * @link https://developer.github.com/v3/issues/assignees/ - * - * @return Assignees - */ - public function assignees() - { - return new Assignees($this->getClient()); - } - - /** - * List all events. - * - * @link https://developer.github.com/v3/issues/timeline/ - * - * @return Timeline - */ - public function timeline() - { - return new Timeline($this->getClient()); - } -} diff --git a/lib/Github/Api/Issue/Assignees.php b/lib/Github/Api/Issue/Assignees.php deleted file mode 100644 index 46435650823..00000000000 --- a/lib/Github/Api/Issue/Assignees.php +++ /dev/null @@ -1,91 +0,0 @@ -get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/assignees', $parameters); - } - - /** - * Check to see if a particular user is an assignee for a repository. - * - * @link https://developer.github.com/v3/issues/assignees/#check-assignee - * - * @param string $username - * @param string $repository - * @param string $assignee - * - * @return array - */ - public function check($username, $repository, $assignee) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/assignees/'.rawurlencode($assignee)); - } - - /** - * Add assignees to an Issue. - * - * @link https://developer.github.com/v3/issues/assignees/#add-assignees-to-an-issue - * - * @param string $username - * @param string $repository - * @param string $issue - * @param array $parameters - * - * @throws InvalidArgumentException - * @throws MissingArgumentException - * - * @return array - */ - public function add($username, $repository, $issue, array $parameters) - { - if (!isset($parameters['assignees'])) { - throw new MissingArgumentException('assignees'); - } - - if (!is_array($parameters['assignees'])) { - throw new InvalidArgumentException('The assignees parameter should be an array of assignees'); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($issue).'/assignees', $parameters); - } - - /** - * Remove assignees from an Issue. - * - * @link https://developer.github.com/v3/issues/assignees/#remove-assignees-from-an-issue - * - * @param string $username - * @param string $repository - * @param string $issue - * @param array $parameters - * - * @throws MissingArgumentException - * - * @return array - */ - public function remove($username, $repository, $issue, array $parameters) - { - if (!isset($parameters['assignees'])) { - throw new MissingArgumentException('assignees'); - } - - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.rawurlencode($issue).'/assignees', $parameters); - } -} diff --git a/lib/Github/Api/Issue/Comments.php b/lib/Github/Api/Issue/Comments.php deleted file mode 100644 index b0fe878797f..00000000000 --- a/lib/Github/Api/Issue/Comments.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @author Tobias Nyholm - */ -class Comments extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * Configure the body type. - * - * @link https://developer.github.com/v3/issues/comments/#custom-media-types - * - * @param string|null $bodyType - * - * @return $this - */ - public function configure($bodyType = null) - { - if (!in_array($bodyType, ['raw', 'text', 'html'])) { - $bodyType = 'full'; - } - - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->getApiVersion(), $bodyType); - - return $this; - } - - /** - * Get all comments for an issue. - * - * @link https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue - * - * @param string $username - * @param string $repository - * @param int $issue - * @param array $params - * - * @return array - */ - public function all($username, $repository, $issue, array $params = []) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/comments', $params); - } - - /** - * Get a comment for an issue. - * - * @link https://developer.github.com/v3/issues/comments/#get-a-single-comment - * - * @param string $username - * @param string $repository - * @param int $comment - * - * @return array - */ - public function show($username, $repository, $comment) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/comments/'.$comment); - } - - /** - * Create a comment for an issue. - * - * @link https://developer.github.com/v3/issues/comments/#create-a-comment - * - * @param string $username - * @param string $repository - * @param int $issue - * @param array $params - * - * @throws \Github\Exception\MissingArgumentException - * - * @return array - */ - public function create($username, $repository, $issue, array $params) - { - if (!isset($params['body'])) { - throw new MissingArgumentException('body'); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/comments', $params); - } - - /** - * Update a comment for an issue. - * - * @link https://developer.github.com/v3/issues/comments/#edit-a-comment - * - * @param string $username - * @param string $repository - * @param int $comment - * @param array $params - * - * @throws \Github\Exception\MissingArgumentException - * - * @return array - */ - public function update($username, $repository, $comment, array $params) - { - if (!isset($params['body'])) { - throw new MissingArgumentException('body'); - } - - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/comments/'.$comment, $params); - } - - /** - * Delete a comment for an issue. - * - * @link https://developer.github.com/v3/issues/comments/#delete-a-comment - * - * @param string $username - * @param string $repository - * @param int $comment - * - * @return array - */ - public function remove($username, $repository, $comment) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/comments/'.$comment); - } -} diff --git a/lib/Github/Api/Issue/Events.php b/lib/Github/Api/Issue/Events.php deleted file mode 100644 index a628b2c60bf..00000000000 --- a/lib/Github/Api/Issue/Events.php +++ /dev/null @@ -1,54 +0,0 @@ - - */ -class Events extends AbstractApi -{ - /** - * Get all events for an issue. - * - * @link https://developer.github.com/v3/issues/events/#list-events-for-an-issue - * - * @param string $username - * @param string $repository - * @param int|null $issue - * @param int $page - * - * @return array - */ - public function all($username, $repository, $issue = null, $page = 1) - { - if (null !== $issue) { - $path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/events'; - } else { - $path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/events'; - } - - return $this->get($path, [ - 'page' => $page, - ]); - } - - /** - * Display an event for an issue. - * - * @link https://developer.github.com/v3/issues/events/#get-a-single-event - * - * @param string $username - * @param string $repository - * @param string $event - * - * @return array - */ - public function show($username, $repository, $event) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/events/'.rawurlencode($event)); - } -} diff --git a/lib/Github/Api/Issue/Labels.php b/lib/Github/Api/Issue/Labels.php deleted file mode 100644 index 3cfad23d5b0..00000000000 --- a/lib/Github/Api/Issue/Labels.php +++ /dev/null @@ -1,192 +0,0 @@ - - */ -class Labels extends AbstractApi -{ - /** - * Get all labels for a repository or the labels for a specific issue. - * - * @link https://developer.github.com/v3/issues/labels/#list-labels-on-an-issue - * - * @param string $username - * @param string $repository - * @param int|null $issue - * - * @return array - */ - public function all($username, $repository, $issue = null) - { - if ($issue === null) { - $path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels'; - } else { - $path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/labels'; - } - - return $this->get($path); - } - - /** - * Get a single label. - * - * @link https://developer.github.com/v3/issues/labels/#get-a-single-label - * - * @param string $username - * @param string $repository - * @param string $label - * - * @return array - */ - public function show($username, $repository, $label) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels/'.rawurlencode($label)); - } - - /** - * Create a label for a repository. - * - * @link https://developer.github.com/v3/issues/labels/#create-a-label - * - * @param string $username - * @param string $repository - * @param array $params - * - * @throws \Github\Exception\MissingArgumentException - * - * @return array - */ - public function create($username, $repository, array $params) - { - if (!isset($params['name'])) { - throw new MissingArgumentException('name'); - } - if (!isset($params['color'])) { - $params['color'] = 'FFFFFF'; - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels', $params); - } - - /** - * Delete a label for a repository. - * - * @link https://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue - * - * @param string $username - * @param string $repository - * @param string $label - * - * @return array - */ - public function deleteLabel($username, $repository, $label) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels/'.rawurlencode($label)); - } - - /** - * Edit a label for a repository. - * - * @link https://developer.github.com/v3/issues/labels/#update-a-label - * - * @param string $username - * @param string $repository - * @param string $label - * @param string $newName - * @param string $color - * - * @return array - */ - public function update($username, $repository, $label, $newName, $color) - { - $params = [ - 'name' => $newName, - 'color' => $color, - ]; - - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels/'.rawurlencode($label), $params); - } - - /** - * Add a label to an issue. - * - * @link https://developer.github.com/v3/issues/labels/#add-labels-to-an-issue - * - * @param string $username - * @param string $repository - * @param int $issue - * @param string|array $labels - * - * @return array - * - * @thorws \Github\Exception\InvalidArgumentException - */ - public function add($username, $repository, $issue, $labels) - { - if (is_string($labels)) { - $labels = [$labels]; - } elseif (0 === count($labels)) { - throw new InvalidArgumentException('The labels parameter should be a single label or an array of labels'); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/labels', $labels); - } - - /** - * Replace labels for an issue. - * - * @link https://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue - * - * @param string $username - * @param string $repository - * @param int $issue - * @param array $params - * - * @return array - */ - public function replace($username, $repository, $issue, array $params) - { - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/labels', $params); - } - - /** - * Remove a label for an issue. - * - * @link https://developer.github.com/v3/issues/labels/#remove-a-label-from-an-issue - * - * @param string $username - * @param string $repository - * @param int $issue - * @param string $label - * - * @return array|string - */ - public function remove($username, $repository, $issue, $label) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/labels/'.rawurlencode($label)); - } - - /** - * Remove all labels from an issue. - * - * @link https://developer.github.com/v3/issues/labels/#replace-all-labels-for-an-issue - * - * @param string $username - * @param string $repository - * @param int $issue - * - * @return array|string - */ - public function clear($username, $repository, $issue) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/labels'); - } -} diff --git a/lib/Github/Api/Issue/Milestones.php b/lib/Github/Api/Issue/Milestones.php deleted file mode 100644 index fe9f2296dd6..00000000000 --- a/lib/Github/Api/Issue/Milestones.php +++ /dev/null @@ -1,139 +0,0 @@ - - */ -class Milestones extends AbstractApi -{ - /** - * Get all milestones for a repository. - * - * @link https://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository - * - * @param string $username - * @param string $repository - * @param array $params - * - * @return array - */ - public function all($username, $repository, array $params = []) - { - if (isset($params['state']) && !in_array($params['state'], ['open', 'closed', 'all'])) { - $params['state'] = 'open'; - } - if (isset($params['sort']) && !in_array($params['sort'], ['due_date', 'completeness'])) { - $params['sort'] = 'due_date'; - } - if (isset($params['direction']) && !in_array($params['direction'], ['asc', 'desc'])) { - $params['direction'] = 'asc'; - } - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/milestones', array_merge([ - 'page' => 1, - 'state' => 'open', - 'sort' => 'due_date', - 'direction' => 'asc', - ], $params)); - } - - /** - * Get a milestone for a repository. - * - * @link https://developer.github.com/v3/issues/milestones/#get-a-single-milestone - * - * @param string $username - * @param string $repository - * @param int $id - * - * @return array - */ - public function show($username, $repository, $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/milestones/'.$id); - } - - /** - * Create a milestone for a repository. - * - * @link https://developer.github.com/v3/issues/milestones/#create-a-milestone - * - * @param string $username - * @param string $repository - * @param array $params - * - * @throws \Github\Exception\MissingArgumentException - * - * @return array - */ - public function create($username, $repository, array $params) - { - if (!isset($params['title'])) { - throw new MissingArgumentException('title'); - } - if (isset($params['state']) && !in_array($params['state'], ['open', 'closed'])) { - $params['state'] = 'open'; - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/milestones', $params); - } - - /** - * Update a milestone for a repository. - * - * @link https://developer.github.com/v3/issues/milestones/#update-a-milestone - * - * @param string $username - * @param string $repository - * @param int $id - * @param array $params - * - * @return array - */ - public function update($username, $repository, $id, array $params) - { - if (isset($params['state']) && !in_array($params['state'], ['open', 'closed'])) { - $params['state'] = 'open'; - } - - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/milestones/'.$id, $params); - } - - /** - * Delete a milestone for a repository. - * - * @link https://developer.github.com/v3/issues/milestones/#delete-a-milestone - * - * @param string $username - * @param string $repository - * @param int $id - * - * @return array|string - */ - public function remove($username, $repository, $id) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/milestones/'.$id); - } - - /** - * Get the labels of a milestone. - * - * @link https://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone - * - * @param string $username - * @param string $repository - * @param int $id - * - * @return array - */ - public function labels($username, $repository, $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/milestones/'.$id.'/labels'); - } -} diff --git a/lib/Github/Api/Issue/Timeline.php b/lib/Github/Api/Issue/Timeline.php deleted file mode 100644 index 16ec4b069b2..00000000000 --- a/lib/Github/Api/Issue/Timeline.php +++ /dev/null @@ -1,34 +0,0 @@ -acceptHeaderValue = 'application/vnd.github.mockingbird-preview'; - - return $this; - } - - /** - * Get all events for a specific issue. - * - * @link https://developer.github.com/v3/issues/timeline/#list-events-for-an-issue - * - * @param string $username - * @param string $repository - * @param int $issue - * - * @return array - */ - public function all($username, $repository, $issue) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/timeline'); - } -} diff --git a/lib/Github/Api/Markdown.php b/lib/Github/Api/Markdown.php deleted file mode 100644 index 977b1d048e0..00000000000 --- a/lib/Github/Api/Markdown.php +++ /dev/null @@ -1,49 +0,0 @@ - - */ -class Markdown extends AbstractApi -{ - /** - * @param string $text - * @param string $mode - * @param string $context - * - * @return string - */ - public function render($text, $mode = 'markdown', $context = null) - { - if (!in_array($mode, ['gfm', 'markdown'])) { - $mode = 'markdown'; - } - - $params = [ - 'text' => $text, - 'mode' => $mode, - ]; - if (null !== $context && 'gfm' === $mode) { - $params['context'] = $context; - } - - return $this->post('/markdown', $params); - } - - /** - * @param string $file - * - * @return string - */ - public function renderRaw($file) - { - return $this->post('/markdown/raw', [ - 'file' => $file, - ]); - } -} diff --git a/lib/Github/Api/Meta.php b/lib/Github/Api/Meta.php deleted file mode 100644 index 0ec81f65ef9..00000000000 --- a/lib/Github/Api/Meta.php +++ /dev/null @@ -1,23 +0,0 @@ - - */ -class Meta extends AbstractApi -{ - /** - * Get the ip address of the hook and git servers for the GitHub.com service. - * - * @return array Information about the service of GitHub.com - */ - public function service() - { - return $this->get('/meta'); - } -} diff --git a/lib/Github/Api/Miscellaneous/CodeOfConduct.php b/lib/Github/Api/Miscellaneous/CodeOfConduct.php deleted file mode 100644 index 64bfaa8b420..00000000000 --- a/lib/Github/Api/Miscellaneous/CodeOfConduct.php +++ /dev/null @@ -1,44 +0,0 @@ -acceptHeaderValue = 'application/vnd.github.scarlet-witch-preview+json'; - - return $this; - } - - /** - * List all codes of conduct. - * - * @link https://developer.github.com/v3/codes_of_conduct/#list-all-codes-of-conduct - * - * @return array - */ - public function all() - { - return $this->get('/codes_of_conduct'); - } - - /** - * Get an individual code of conduct. - * - * @link https://developer.github.com/v3/codes_of_conduct/#get-an-individual-code-of-conduct - * - * @param string $key - * - * @return array - */ - public function show($key) - { - return $this->get('/codes_of_conduct/'.rawurlencode($key)); - } -} diff --git a/lib/Github/Api/Miscellaneous/Emojis.php b/lib/Github/Api/Miscellaneous/Emojis.php deleted file mode 100644 index 2a940f6dfb7..00000000000 --- a/lib/Github/Api/Miscellaneous/Emojis.php +++ /dev/null @@ -1,20 +0,0 @@ -get('/emojis'); - } -} diff --git a/lib/Github/Api/Miscellaneous/Gitignore.php b/lib/Github/Api/Miscellaneous/Gitignore.php deleted file mode 100644 index c5f03e7e0e0..00000000000 --- a/lib/Github/Api/Miscellaneous/Gitignore.php +++ /dev/null @@ -1,34 +0,0 @@ -get('/gitignore/templates'); - } - - /** - * Get a single template. - * - * @link https://developer.github.com/v3/gitignore/#get-a-single-template - * - * @param string $template - * - * @return array - */ - public function show($template) - { - return $this->get('/gitignore/templates/'.rawurlencode($template)); - } -} diff --git a/lib/Github/Api/Miscellaneous/Licenses.php b/lib/Github/Api/Miscellaneous/Licenses.php deleted file mode 100644 index f8e55782a89..00000000000 --- a/lib/Github/Api/Miscellaneous/Licenses.php +++ /dev/null @@ -1,34 +0,0 @@ -get('/licenses'); - } - - /** - * Get an individual license by its license key. - * - * @link https://developer.github.com/v3/licenses/#get-an-individual-license - * - * @param string $license - * - * @return array - */ - public function show($license) - { - return $this->get('/licenses/'.rawurlencode($license)); - } -} diff --git a/lib/Github/Api/Notification.php b/lib/Github/Api/Notification.php deleted file mode 100644 index f720ad0c88c..00000000000 --- a/lib/Github/Api/Notification.php +++ /dev/null @@ -1,91 +0,0 @@ - - */ -class Notification extends AbstractApi -{ - /** - * Get a listing of notifications. - * - * @link https://developer.github.com/v3/activity/notifications/ - * - * @param bool $includingRead - * @param bool $participating - * @param DateTime|null $since - * @param DateTime|null $before - * - * @return array array of notifications - */ - public function all($includingRead = false, $participating = false, ?DateTime $since = null, ?DateTime $before = null) - { - $parameters = [ - 'all' => $includingRead, - 'participating' => $participating, - ]; - - if ($since !== null) { - $parameters['since'] = $since->format(DateTime::ISO8601); - } - - if ($before !== null) { - $parameters['before'] = $before->format(DateTime::ISO8601); - } - - return $this->get('/notifications', $parameters); - } - - /** - * Marks all notifications as read from the current date. - * - * Optionally give DateTime to mark as read before that date. - * - * @link https://developer.github.com/v3/activity/notifications/#mark-as-read - * - * @param DateTime|null $since - */ - public function markRead(?DateTime $since = null) - { - $parameters = []; - - if ($since !== null) { - $parameters['last_read_at'] = $since->format(DateTime::ISO8601); - } - - $this->put('/notifications', $parameters); - } - - /** - * Mark a single thread as read using its ID. - * - * @link https://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read - * - * @param int $id - */ - public function markThreadRead($id) - { - $this->patch('/notifications/threads/'.$id); - } - - /** - * Gets a single thread using its ID. - * - * @link https://developer.github.com/v3/activity/notifications/#view-a-single-thread - * - * @param int $id - */ - public function id($id) - { - return $this->get('/notifications/threads/'.$id); - } -} diff --git a/lib/Github/Api/Organization.php b/lib/Github/Api/Organization.php deleted file mode 100644 index 0e1210c95b6..00000000000 --- a/lib/Github/Api/Organization.php +++ /dev/null @@ -1,167 +0,0 @@ - - * @author Joseph Bielawski - */ -class Organization extends AbstractApi -{ - /** - * @link https://developer.github.com/v3/orgs/#list-all-organizations - * - * @return array the organizations - */ - public function all($since = '') - { - return $this->get('/organizations?since='.rawurlencode($since)); - } - - /** - * Get extended information about an organization by its name. - * - * @link http://developer.github.com/v3/orgs/#get - * - * @param string $organization the organization to show - * - * @return array information about the organization - */ - public function show($organization) - { - return $this->get('/orgs/'.rawurlencode($organization)); - } - - public function update($organization, array $params) - { - return $this->patch('/orgs/'.rawurlencode($organization), $params); - } - - /** - * List all repositories across all the organizations that you can access. - * - * @link http://developer.github.com/v3/repos/#list-organization-repositories - * - * @param string $organization the user name - * @param string $type the type of repositories - * @param int $page the page - * @param string $sort sort by - * @param string $direction direction of sort, asc or desc - * - * @return array the repositories - */ - public function repositories($organization, $type = 'all', $page = 1, $sort = null, $direction = null) - { - $parameters = [ - 'type' => $type, - 'page' => $page, - ]; - - if ($sort !== null) { - $parameters['sort'] = $sort; - } - - if ($direction !== null) { - $parameters['direction'] = $direction; - } - - return $this->get('/orgs/'.rawurlencode($organization).'/repos', $parameters); - } - - /** - * @return Members - */ - public function members() - { - return new Members($this->getClient()); - } - - /** - * @return Hooks - */ - public function hooks() - { - return new Hooks($this->getClient()); - } - - /** - * @return Teams - */ - public function teams() - { - return new Teams($this->getClient()); - } - - /** - * @return Secrets - */ - public function secrets(): Secrets - { - return new Secrets($this->getClient()); - } - - /** - * @return Variables - */ - public function variables(): Variables - { - return new Variables($this->getClient()); - } - - /** - * @return OutsideCollaborators - */ - public function outsideCollaborators() - { - return new OutsideCollaborators($this->getClient()); - } - - /** - * @link http://developer.github.com/v3/issues/#list-issues - * - * @param string $organization - * @param array $params - * @param int $page - * - * @return array - */ - public function issues($organization, array $params = [], $page = 1) - { - return $this->get('/orgs/'.rawurlencode($organization).'/issues', array_merge(['page' => $page], $params)); - } - - /** - * @return SelfHostedRunners - */ - public function runners(): SelfHostedRunners - { - return new SelfHostedRunners($this->getClient()); - } - - /** - * @return SecretScanning - */ - public function secretScanning(): SecretScanning - { - return new SecretScanning($this->getClient()); - } - - public function organizationRoles(): OrganizationRoles - { - return new OrganizationRoles($this->getClient()); - } -} diff --git a/lib/Github/Api/Organization/Actions/Secrets.php b/lib/Github/Api/Organization/Actions/Secrets.php deleted file mode 100644 index 819e2c46738..00000000000 --- a/lib/Github/Api/Organization/Actions/Secrets.php +++ /dev/null @@ -1,144 +0,0 @@ -get('/orgs/'.rawurlencode($organization).'/actions/secrets'); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#get-an-organization-secret - * - * @param string $organization - * @param string $secretName - * - * @return array|string - */ - public function show(string $organization, string $secretName) - { - return $this->get('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName)); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#create-or-update-an-organization-secret - * - * @param string $organization - * @param string $secretName - * @param array $parameters - * - * @return array|string - */ - public function create(string $organization, string $secretName, array $parameters = []) - { - return $this->put('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName), $parameters); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#create-or-update-an-organization-secret - * - * @param string $organization - * @param string $secretName - * @param array $parameters - * - * @return array|string - */ - public function update(string $organization, string $secretName, array $parameters = []) - { - return $this->put('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName), $parameters); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#delete-an-organization-secret - * - * @param string $organization - * @param string $secretName - * - * @return array|string - */ - public function remove(string $organization, string $secretName) - { - return $this->delete('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName)); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#list-selected-repositories-for-an-organization-secret - * - * @param string $organization - * @param string $secretName - * - * @return array|string - */ - public function selectedRepositories(string $organization, string $secretName) - { - return $this->get('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName).'/repositories'); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#set-selected-repositories-for-an-organization-secret - * - * @param string $organization - * @param string $secretName - * @param array $parameters - * - * @return array|string - */ - public function setSelectedRepositories(string $organization, string $secretName, array $parameters = []) - { - return $this->put('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName).'/repositories', $parameters); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#add-selected-repository-to-an-organization-secret - * - * @param string $organization - * @param string $repositoryId - * @param string $secretName - * - * @return array|string - */ - public function addSecret(string $organization, string $repositoryId, string $secretName) - { - return $this->put('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName).'/repositories/'.$repositoryId); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#remove-selected-repository-from-an-organization-secret - * - * @param string $organization - * @param string $repositoryId - * @param string $secretName - * - * @return array|string - */ - public function removeSecret(string $organization, string $repositoryId, string $secretName) - { - return $this->delete('/orgs/'.rawurlencode($organization).'/actions/secrets/'.rawurlencode($secretName).'/repositories/'.$repositoryId); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#get-an-organization-public-key - * - * @param string $organization - * - * @return array|string - */ - public function publicKey(string $organization) - { - return $this->get('/orgs/'.rawurlencode($organization).'/actions/secrets/public-key'); - } -} diff --git a/lib/Github/Api/Organization/Actions/SelfHostedRunners.php b/lib/Github/Api/Organization/Actions/SelfHostedRunners.php deleted file mode 100644 index f0b989f5751..00000000000 --- a/lib/Github/Api/Organization/Actions/SelfHostedRunners.php +++ /dev/null @@ -1,59 +0,0 @@ -get('/orgs/'.rawurlencode($organization).'/actions/runners', $parameters); - } - - /** - * @link https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#get-a-self-hosted-runner-for-an-organization - * - * @param string $organization - * @param int $runnerId - * - * @return array|string - */ - public function show(string $organization, int $runnerId) - { - return $this->get('/orgs/'.rawurlencode($organization).'/actions/runners/'.$runnerId); - } - - /** - * @link https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#delete-a-self-hosted-runner-from-an-organization - * - * @param string $organization - * @param int $runnerId - * - * @return array|string - */ - public function remove(string $organization, int $runnerId) - { - return $this->delete('/orgs/'.rawurlencode($organization).'/actions/runners/'.$runnerId); - } - - /** - * @link https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-runner-applications-for-an-organization - * - * @param string $organization - * - * @return array|string - */ - public function applications(string $organization) - { - return $this->get('/orgs/'.rawurlencode($organization).'/actions/runners/downloads'); - } -} diff --git a/lib/Github/Api/Organization/Actions/Variables.php b/lib/Github/Api/Organization/Actions/Variables.php deleted file mode 100644 index 88c037238d3..00000000000 --- a/lib/Github/Api/Organization/Actions/Variables.php +++ /dev/null @@ -1,131 +0,0 @@ -get('/orgs/'.rawurlencode($organization).'/actions/variables'); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#get-an-organization-secret - * - * @param string $organization - * @param string $variableName - * - * @return array|string - */ - public function show(string $organization, string $variableName) - { - return $this->get('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName)); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-an-organization-variable - * - * @param string $organization - * @param array $parameters - * - * @return array|string - */ - public function create(string $organization, array $parameters) - { - return $this->post('/orgs/'.rawurlencode($organization).'/actions/variables', $parameters); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-an-organization-variable - * - * @param string $organization - * @param string $variableName - * @param array $parameters - * - * @return array|string - */ - public function update(string $organization, string $variableName, array $parameters = []) - { - return $this->patch('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName), $parameters); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-an-organization-variable - * - * @param string $organization - * @param string $variableName - * - * @return array|string - */ - public function remove(string $organization, string $variableName) - { - return $this->delete('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName)); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#list-selected-repositories-for-an-organization-variable - * - * @param string $organization - * @param string $variableName - * - * @return array|string - */ - public function selectedRepositories(string $organization, string $variableName) - { - return $this->get('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName).'/repositories'); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#set-selected-repositories-for-an-organization-variable - * - * @param string $organization - * @param string $variableName - * @param array $parameters - * - * @return array|string - */ - public function setSelectedRepositories(string $organization, string $variableName, array $parameters = []) - { - return $this->put('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName).'/repositories', $parameters); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#add-selected-repository-to-an-organization-variable - * - * @param string $organization - * @param int $repositoryId - * @param string $variableName - * - * @return array|string - */ - public function addRepository(string $organization, int $repositoryId, string $variableName) - { - return $this->put('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName).'/repositories/'.$repositoryId); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#remove-selected-repository-from-an-organization-variable - * - * @param string $organization - * @param int $repositoryId - * @param string $variableName - * - * @return array|string - */ - public function removeRepository(string $organization, int $repositoryId, string $variableName) - { - return $this->delete('/orgs/'.rawurlencode($organization).'/actions/variables/'.rawurlencode($variableName).'/repositories/'.$repositoryId); - } -} diff --git a/lib/Github/Api/Organization/Hooks.php b/lib/Github/Api/Organization/Hooks.php deleted file mode 100644 index 945cabc8667..00000000000 --- a/lib/Github/Api/Organization/Hooks.php +++ /dev/null @@ -1,111 +0,0 @@ -get('/orgs/'.rawurlencode($organization).'/hooks'); - } - - /** - * Get a single hook. - * - * @link https://developer.github.com/v3/orgs/hooks/#get-single-hook - * - * @param string $organization - * @param int $id - * - * @return array - */ - public function show($organization, $id) - { - return $this->get('/orgs/'.rawurlencode($organization).'/hooks/'.$id); - } - - /** - * Create a hook. - * - * @link https://developer.github.com/v3/orgs/hooks/#create-a-hook - * - * @param string $organization - * @param array $params - * - * @throws \Github\Exception\MissingArgumentException - * - * @return array - */ - public function create($organization, array $params) - { - if (!isset($params['name'], $params['config'])) { - throw new MissingArgumentException(['name', 'config']); - } - - return $this->post('/orgs/'.rawurlencode($organization).'/hooks', $params); - } - - /** - * Edit a hook. - * - * @link https://developer.github.com/v3/orgs/hooks/#edit-a-hook - * - * @param string $organization - * @param int $id - * @param array $params - * - * @throws \Github\Exception\MissingArgumentException - * - * @return array - */ - public function update($organization, $id, array $params) - { - if (!isset($params['config'])) { - throw new MissingArgumentException(['config']); - } - - return $this->patch('/orgs/'.rawurlencode($organization).'/hooks/'.$id, $params); - } - - /** - * Ping a hook. - * - * @link https://developer.github.com/v3/orgs/hooks/#ping-a-hook - * - * @param string $organization - * @param int $id - * - * @return array|string - */ - public function ping($organization, $id) - { - return $this->post('/orgs/'.rawurlencode($organization).'/hooks/'.$id.'/pings'); - } - - /** - * Delete a hook. - * - * @link https://developer.github.com/v3/orgs/hooks/#delete-a-hook - * - * @param string $organization - * @param int $id - * - * @return array|string - */ - public function remove($organization, $id) - { - return $this->delete('/orgs/'.rawurlencode($organization).'/hooks/'.$id); - } -} diff --git a/lib/Github/Api/Organization/Members.php b/lib/Github/Api/Organization/Members.php deleted file mode 100644 index 023e3f8d545..00000000000 --- a/lib/Github/Api/Organization/Members.php +++ /dev/null @@ -1,75 +0,0 @@ - - */ -class Members extends AbstractApi -{ - public function all($organization, $type = null, $filter = 'all', $role = null) - { - $parameters = []; - $path = '/orgs/'.rawurlencode($organization).'/'; - if (null === $type) { - $path .= 'members'; - if (null !== $filter) { - $parameters['filter'] = $filter; - } - if (null !== $role) { - $parameters['role'] = $role; - } - } else { - $path .= 'public_members'; - } - - return $this->get($path, $parameters); - } - - public function show($organization, $username) - { - return $this->get('/orgs/'.rawurlencode($organization).'/members/'.rawurlencode($username)); - } - - public function member($organization, $username) - { - return $this->get('/orgs/'.rawurlencode($organization).'/memberships/'.rawurlencode($username)); - } - - public function check($organization, $username) - { - return $this->get('/orgs/'.rawurlencode($organization).'/public_members/'.rawurlencode($username)); - } - - public function publicize($organization, $username) - { - return $this->put('/orgs/'.rawurlencode($organization).'/public_members/'.rawurlencode($username)); - } - - public function conceal($organization, $username) - { - return $this->delete('/orgs/'.rawurlencode($organization).'/public_members/'.rawurlencode($username)); - } - - /* - * Add user to organization - */ - public function add($organization, $username, array $params = []) - { - return $this->put('/orgs/'.rawurlencode($organization).'/memberships/'.rawurlencode($username), $params); - } - - public function addMember($organization, $username) - { - return $this->add($organization, $username); - } - - public function remove($organization, $username) - { - return $this->delete('/orgs/'.rawurlencode($organization).'/members/'.rawurlencode($username)); - } -} diff --git a/lib/Github/Api/Organization/OrganizationRoles.php b/lib/Github/Api/Organization/OrganizationRoles.php deleted file mode 100644 index dd44fceceaf..00000000000 --- a/lib/Github/Api/Organization/OrganizationRoles.php +++ /dev/null @@ -1,61 +0,0 @@ -get('/orgs/'.rawurlencode($organization).'/organization-roles'); - } - - public function show(string $organization, int $roleId) - { - return $this->get('/orgs/'.rawurlencode($organization).'/organization-roles/'.$roleId); - } - - public function listTeamsWithRole(string $organization, int $roleId) - { - return $this->get('/orgs/'.rawurlencode($organization).'/organization-roles/'.$roleId.'/teams'); - } - - public function assignRoleToTeam(string $organization, int $roleId, string $teamSlug): void - { - $this->put('/orgs/'.rawurlencode($organization).'/organization-roles/teams/'.rawurlencode($teamSlug).'/'.$roleId); - } - - public function removeRoleFromTeam(string $organization, int $roleId, string $teamSlug): void - { - $this->delete('/orgs/'.rawurlencode($organization).'/organization-roles/teams/'.rawurlencode($teamSlug).'/'.$roleId); - } - - public function removeAllRolesFromTeam(string $organization, string $teamSlug): void - { - $this->delete('/orgs/'.rawurlencode($organization).'/organization-roles/teams/'.rawurlencode($teamSlug)); - } - - public function listUsersWithRole(string $organization, int $roleId): array - { - return $this->get('/orgs/'.rawurlencode($organization).'/organization-roles/'.$roleId.'/users'); - } - - public function assignRoleToUser(string $organization, int $roleId, string $username): void - { - $this->put('/orgs/'.rawurlencode($organization).'/organization-roles/users/'.rawurlencode($username).'/'.$roleId); - } - - public function removeRoleFromUser(string $organization, int $roleId, string $username): void - { - $this->delete('/orgs/'.rawurlencode($organization).'/organization-roles/users/'.rawurlencode($username).'/'.$roleId); - } - - public function removeAllRolesFromUser(string $organization, string $username): void - { - $this->delete('/orgs/'.rawurlencode($organization).'/organization-roles/users/'.rawurlencode($username)); - } -} diff --git a/lib/Github/Api/Organization/OutsideCollaborators.php b/lib/Github/Api/Organization/OutsideCollaborators.php deleted file mode 100644 index 958100a56ee..00000000000 --- a/lib/Github/Api/Organization/OutsideCollaborators.php +++ /dev/null @@ -1,52 +0,0 @@ - - */ -class OutsideCollaborators extends AbstractApi -{ - /** - * @link https://developer.github.com/v3/orgs/outside_collaborators/#list-outside-collaborators-for-an-organization - * - * @param string $organization the organization - * @param array $params - * - * @return array the organizations - */ - public function all($organization, array $params = []) - { - return $this->get('/orgs/'.rawurlencode($organization).'/outside_collaborators', $params); - } - - /** - * @link https://developer.github.com/v3/orgs/outside_collaborators/#convert-an-organization-member-to-outside-collaborator - * - * @param string $organization the organization - * @param string $username the github username - * - * @return array - */ - public function convert($organization, $username) - { - return $this->put('/orgs/'.rawurlencode($organization).'/outside_collaborators/'.rawurldecode($username)); - } - - /** - * @link https://developer.github.com/v3/orgs/outside_collaborators/#remove-outside-collaborator-from-an-organization - * - * @param string $organization the organization - * @param string $username the username - * - * @return array - */ - public function remove($organization, $username) - { - return $this->delete('/orgs/'.rawurlencode($organization).'/outside_collaborators/'.rawurldecode($username)); - } -} diff --git a/lib/Github/Api/Organization/Projects.php b/lib/Github/Api/Organization/Projects.php deleted file mode 100644 index 2bb7196e95a..00000000000 --- a/lib/Github/Api/Organization/Projects.php +++ /dev/null @@ -1,23 +0,0 @@ -get('/orgs/'.rawurlencode($organization).'/projects', array_merge(['page' => 1], $params)); - } - - public function create($organization, array $params) - { - if (!isset($params['name'])) { - throw new MissingArgumentException(['name']); - } - - return $this->post('/orgs/'.rawurlencode($organization).'/projects', $params); - } -} diff --git a/lib/Github/Api/Organization/SecretScanning.php b/lib/Github/Api/Organization/SecretScanning.php deleted file mode 100644 index a323fd06fcc..00000000000 --- a/lib/Github/Api/Organization/SecretScanning.php +++ /dev/null @@ -1,19 +0,0 @@ -get('/orgs/'.rawurlencode($organization).'/secret-scanning/alerts', $params); - } -} diff --git a/lib/Github/Api/Organization/Teams.php b/lib/Github/Api/Organization/Teams.php deleted file mode 100644 index 20bb2791a7a..00000000000 --- a/lib/Github/Api/Organization/Teams.php +++ /dev/null @@ -1,128 +0,0 @@ - - */ -class Teams extends AbstractApi -{ - public function all($organization) - { - return $this->get('/orgs/'.rawurlencode($organization).'/teams'); - } - - public function create($organization, array $params) - { - if (!isset($params['name'])) { - throw new MissingArgumentException('name'); - } - if (isset($params['repo_names']) && !is_array($params['repo_names'])) { - $params['repo_names'] = [$params['repo_names']]; - } - if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin'])) { - $params['permission'] = 'pull'; - } - - return $this->post('/orgs/'.rawurlencode($organization).'/teams', $params); - } - - /** - * @link https://developer.github.com/v3/teams/#list-teams - */ - public function show($team, $organization) - { - return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team)); - } - - /** - * @link https://developer.github.com/v3/teams/#edit-team - */ - public function update($team, array $params, $organization) - { - if (!isset($params['name'])) { - throw new MissingArgumentException('name'); - } - if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin'])) { - $params['permission'] = 'pull'; - } - - return $this->patch('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team), $params); - } - - /** - * @link https://developer.github.com/v3/teams/#delete-team - */ - public function remove($team, $organization) - { - return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team)); - } - - /** - * @link https://developer.github.com/v3/teams/members/#list-team-members - */ - public function members($team, $organization) - { - return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/members'); - } - - /** - * @link https://developer.github.com/v3/teams/members/#get-team-membership - */ - public function check($team, $username, $organization) - { - return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); - } - - /** - * @link https://developer.github.com/v3/teams/members/#add-or-update-team-membership - */ - public function addMember($team, $username, $organization) - { - return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); - } - - /** - * @link https://developer.github.com/v3/teams/members/#remove-team-membership - */ - public function removeMember($team, $username, $organization) - { - return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username)); - } - - /** - * @link https://docs.github.com/en/rest/teams/teams#list-team-repositories - */ - public function repositories($team, $organization = '') - { - if (empty($organization)) { - return $this->get('/teams/'.rawurlencode($team).'/repos'); - } - - return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos'); - } - - public function repository($team, $organization, $repository) - { - return $this->get('/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository)); - } - - public function addRepository($team, $organization, $repository, $params = []) - { - if (isset($params['permission']) && !in_array($params['permission'], ['pull', 'push', 'admin', 'maintain', 'triage'])) { - $params['permission'] = 'pull'; - } - - return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository), $params); - } - - public function removeRepository($team, $organization, $repository) - { - return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/repos/'.rawurlencode($organization).'/'.rawurlencode($repository)); - } -} diff --git a/lib/Github/Api/Project/AbstractProjectApi.php b/lib/Github/Api/Project/AbstractProjectApi.php deleted file mode 100644 index 049d67562c0..00000000000 --- a/lib/Github/Api/Project/AbstractProjectApi.php +++ /dev/null @@ -1,45 +0,0 @@ -acceptHeaderValue = 'application/vnd.github.inertia-preview+json'; - - return $this; - } - - public function show($id, array $params = []) - { - return $this->get('/projects/'.rawurlencode($id), array_merge(['page' => 1], $params)); - } - - public function update($id, array $params) - { - return $this->patch('/projects/'.rawurlencode($id), $params); - } - - public function deleteProject($id) - { - return $this->delete('/projects/'.rawurlencode($id)); - } - - public function columns() - { - return new Columns($this->getClient()); - } -} diff --git a/lib/Github/Api/Project/Cards.php b/lib/Github/Api/Project/Cards.php deleted file mode 100644 index 0d670f93863..00000000000 --- a/lib/Github/Api/Project/Cards.php +++ /dev/null @@ -1,60 +0,0 @@ -acceptHeaderValue = 'application/vnd.github.inertia-preview+json'; - - return $this; - } - - public function all($columnId, array $params = []) - { - return $this->get('/projects/columns/'.rawurlencode($columnId).'/cards', array_merge(['page' => 1], $params)); - } - - public function show($id) - { - return $this->get('/projects/columns/cards/'.rawurlencode($id)); - } - - public function create($columnId, array $params) - { - return $this->post('/projects/columns/'.rawurlencode($columnId).'/cards', $params); - } - - public function update($id, array $params) - { - return $this->patch('/projects/columns/cards/'.rawurlencode($id), $params); - } - - public function deleteCard($id) - { - return $this->delete('/projects/columns/cards/'.rawurlencode($id)); - } - - public function move($id, array $params) - { - if (!isset($params['position'])) { - throw new MissingArgumentException(['position']); - } - - return $this->post('/projects/columns/cards/'.rawurlencode($id).'/moves', $params); - } -} diff --git a/lib/Github/Api/Project/Columns.php b/lib/Github/Api/Project/Columns.php deleted file mode 100644 index 5146ac223af..00000000000 --- a/lib/Github/Api/Project/Columns.php +++ /dev/null @@ -1,73 +0,0 @@ -acceptHeaderValue = 'application/vnd.github.inertia-preview+json'; - - return $this; - } - - public function all($projectId, array $params = []) - { - return $this->get('/projects/'.rawurlencode($projectId).'/columns', array_merge(['page' => 1], $params)); - } - - public function show($id) - { - return $this->get('/projects/columns/'.rawurlencode($id)); - } - - public function create($projectId, array $params) - { - if (!isset($params['name'])) { - throw new MissingArgumentException(['name']); - } - - return $this->post('/projects/'.rawurlencode($projectId).'/columns', $params); - } - - public function update($id, array $params) - { - if (!isset($params['name'])) { - throw new MissingArgumentException(['name']); - } - - return $this->patch('/projects/columns/'.rawurlencode($id), $params); - } - - public function deleteColumn($id) - { - return $this->delete('/projects/columns/'.rawurlencode($id)); - } - - public function move($id, array $params) - { - if (!isset($params['position'])) { - throw new MissingArgumentException(['position']); - } - - return $this->post('/projects/columns/'.rawurlencode($id).'/moves', $params); - } - - public function cards() - { - return new Cards($this->getClient()); - } -} diff --git a/lib/Github/Api/PullRequest.php b/lib/Github/Api/PullRequest.php deleted file mode 100644 index 22922c1ee92..00000000000 --- a/lib/Github/Api/PullRequest.php +++ /dev/null @@ -1,207 +0,0 @@ - - */ -class PullRequest extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * Configure the body type. - * - * @link https://developer.github.com/v3/pulls/#custom-media-types - * - * @param string|null $bodyType - * @param string|null $apiVersion - * - * @return $this - */ - public function configure($bodyType = null, $apiVersion = null) - { - if (null === $apiVersion) { - $apiVersion = $this->getApiVersion(); - } - - if (!in_array($bodyType, ['text', 'html', 'full', 'diff', 'patch'])) { - $bodyType = 'raw'; - } - - if (!in_array($bodyType, ['diff', 'patch'])) { - $bodyType .= '+json'; - } - - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s', $apiVersion, $bodyType); - - return $this; - } - - /** - * Get a listing of a project's pull requests by the username, repository and (optionally) state. - * - * @link http://developer.github.com/v3/pulls/ - * - * @param string $username the username - * @param string $repository the repository - * @param array $parameters a list of extra parameters. - * - * @return array array of pull requests for the project - */ - public function all($username, $repository, array $parameters = []) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls', $parameters); - } - - /** - * Show all details of a pull request, including the discussions. - * - * @link http://developer.github.com/v3/pulls/ - * - * @param string $username the username - * @param string $repository the repository - * @param int $id the ID of the pull request for which details are retrieved - * - * @return array|string pull request details - */ - public function show($username, $repository, $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$id); - } - - public function commits($username, $repository, $id, array $parameters = []) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/commits', $parameters); - } - - public function files($username, $repository, $id, array $parameters = []) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/files', $parameters); - } - - /** - * All statuses which are the statuses of its head branch. - * - * @see http://developer.github.com/v3/pulls/ - * - * @param string $username the username - * @param string $repository the repository - * @param int $id the ID of the pull request for which statuses are retrieved - * - * @return array array of statuses for the project - */ - public function status($username, $repository, $id) - { - $link = $this->show($username, $repository, $id)['_links']['statuses']['href']; - - return $this->get($link); - } - - /** - * @return Comments - */ - public function comments() - { - return new Comments($this->getClient()); - } - - /** - * @return Review - */ - public function reviews() - { - return new Review($this->getClient()); - } - - /** - * @return ReviewRequest - */ - public function reviewRequests() - { - return new ReviewRequest($this->getClient()); - } - - /** - * Create a pull request. - * - * @link http://developer.github.com/v3/pulls/ - * - * @param string $username the username - * @param string $repository the repository - * @param array $params A String of the branch or commit SHA that you want your changes to be pulled to. - * A String of the branch or commit SHA of your changes. Typically this will be a branch. - * If the branch is in a fork of the original repository, specify the username first: - * "my-user:some-branch". The String title of the Pull Request. The String body of - * the Pull Request. The issue number. Used when title and body is not set. - * - * @throws MissingArgumentException - * - * @return array - */ - public function create($username, $repository, array $params) - { - // Two ways to create PR, using issue or title - if (!isset($params['issue']) && !isset($params['title'])) { - throw new MissingArgumentException(['issue', 'title']); - } - - if (!isset($params['base'], $params['head'])) { - throw new MissingArgumentException(['base', 'head']); - } - - // If `issue` is not sent, then `body` must be sent - if (!isset($params['issue']) && !isset($params['body'])) { - throw new MissingArgumentException(['issue', 'body']); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls', $params); - } - - public function update($username, $repository, $id, array $params) - { - if (isset($params['state']) && !in_array($params['state'], ['open', 'closed'])) { - $params['state'] = 'open'; - } - - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id), $params); - } - - public function merged($username, $repository, $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/merge'); - } - - public function merge($username, $repository, $id, $message, $sha, $mergeMethod = 'merge', $title = null) - { - if (is_bool($mergeMethod)) { - $mergeMethod = $mergeMethod ? 'squash' : 'merge'; - } - - if (!in_array($mergeMethod, ['merge', 'squash', 'rebase'], true)) { - throw new InvalidArgumentException(sprintf('"$mergeMethod" must be one of ["merge", "squash", "rebase"] ("%s" given).', $mergeMethod)); - } - - $params = [ - 'commit_message' => $message, - 'sha' => $sha, - 'merge_method' => $mergeMethod, - ]; - - if (is_string($title)) { - $params['commit_title'] = $title; - } - - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($id).'/merge', $params); - } -} diff --git a/lib/Github/Api/PullRequest/Comments.php b/lib/Github/Api/PullRequest/Comments.php deleted file mode 100644 index 3ded9456cf3..00000000000 --- a/lib/Github/Api/PullRequest/Comments.php +++ /dev/null @@ -1,153 +0,0 @@ - - */ -class Comments extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * Configure the body type. - * - * @link https://developer.github.com/v3/pulls/comments/#custom-media-types - * - * @param string|null $bodyType - * @param string|null $apiVersion - * - * @return $this - */ - public function configure($bodyType = null, $apiVersion = null) - { - if ($apiVersion !== 'squirrel-girl-preview') { - $apiVersion = $this->getApiVersion(); - } - - if (!in_array($bodyType, ['text', 'html', 'full'])) { - $bodyType = 'raw'; - } - - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $apiVersion, $bodyType); - - return $this; - } - - /** - * Get a listing of a pull request's comments by the username, repository and pull request number - * or all repository comments by the username and repository. - * - * @link https://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request - * @link https://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository - * - * @param string $username the username - * @param string $repository the repository - * @param int|null $pullRequest the pull request number - * @param array $params a list of extra parameters. - * - * @return array - */ - public function all($username, $repository, $pullRequest = null, array $params = []) - { - if (null !== $pullRequest) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/comments'); - } - - $parameters = array_merge([ - 'page' => 1, - 'per_page' => 30, - ], $params); - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/comments', $parameters); - } - - /** - * Get a single pull request comment by the username, repository and comment id. - * - * @link https://developer.github.com/v3/pulls/comments/#get-a-single-comment - * - * @param string $username the username - * @param string $repository the repository - * @param int $comment the comment id - * - * @return array - */ - public function show($username, $repository, $comment) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/comments/'.$comment); - } - - /** - * Create a pull request comment by the username, repository and pull request number. - * - * @link https://developer.github.com/v3/pulls/comments/#create-a-comment - * - * @param string $username the username - * @param string $repository the repository - * @param int $pullRequest the pull request number - * @param array $params a list of extra parameters. - * - * @throws MissingArgumentException - * - * @return array - */ - public function create($username, $repository, $pullRequest, array $params) - { - if (!isset($params['body'])) { - throw new MissingArgumentException('body'); - } - - // If `in_reply_to` is set, other options are not necessary anymore - if (!isset($params['in_reply_to']) && !isset($params['commit_id'], $params['path'], $params['position'])) { - throw new MissingArgumentException(['commit_id', 'path', 'position']); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/comments', $params); - } - - /** - * Update a pull request comment by the username, repository and comment id. - * - * @link https://developer.github.com/v3/pulls/comments/#edit-a-comment - * - * @param string $username the username - * @param string $repository the repository - * @param int $comment the comment id - * @param array $params a list of extra parameters. - * - * @throws MissingArgumentException - * - * @return array - */ - public function update($username, $repository, $comment, array $params) - { - if (!isset($params['body'])) { - throw new MissingArgumentException('body'); - } - - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/comments/'.$comment, $params); - } - - /** - * Delete a pull request comment by the username, repository and comment id. - * - * @link https://developer.github.com/v3/pulls/comments/#delete-a-comment - * - * @param string $username the username - * @param string $repository the repository - * @param int $comment the comment id - * - * @return string - */ - public function remove($username, $repository, $comment) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/comments/'.$comment); - } -} diff --git a/lib/Github/Api/PullRequest/Review.php b/lib/Github/Api/PullRequest/Review.php deleted file mode 100644 index ed586ddf6fc..00000000000 --- a/lib/Github/Api/PullRequest/Review.php +++ /dev/null @@ -1,211 +0,0 @@ - - */ -class Review extends AbstractApi -{ - use AcceptHeaderTrait; - - public function configure() - { - trigger_deprecation('KnpLabs/php-github-api', '3.2', 'The "%s" is deprecated and will be removed.', __METHOD__); - - return $this; - } - - /** - * Get a listing of a pull request's reviews by the username, repository and pull request number. - * - * @link https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request - * - * @param string $username the username - * @param string $repository the repository - * @param int $pullRequest the pull request number - * @param array $params a list of extra parameters. - * - * @return array array of pull request reviews for the pull request - */ - public function all($username, $repository, $pullRequest, array $params = []) - { - if (!empty($params)) { - trigger_deprecation('KnpLabs/php-github-api', '3.2', 'The "$params" parameter is deprecated, to paginate the results use the "ResultPager" instead.'); - } - - $parameters = array_merge([ - 'page' => 1, - 'per_page' => 30, - ], $params); - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/reviews', $parameters); - } - - /** - * Get a single pull request review by the username, repository, pull request number and the review id. - * - * @link https://developer.github.com/v3/pulls/reviews/#get-a-single-review - * - * @param string $username the username - * @param string $repository the repository - * @param int $pullRequest the pull request number - * @param int $id the review id - * - * @return array the pull request review - */ - public function show($username, $repository, $pullRequest, $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/reviews/'.$id); - } - - /** - * Delete a single pull request review by the username, repository, pull request number and the review id. - * - * @link https://developer.github.com/v3/pulls/reviews/#delete-a-pending-review - * - * @param string $username the username - * @param string $repository the repository - * @param int $pullRequest the pull request number - * @param int $id the review id - * - * @return array|string - */ - public function remove($username, $repository, $pullRequest, $id) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/reviews/'.$id); - } - - /** - * Get comments for a single pull request review. - * - * @link https://developer.github.com/v3/pulls/reviews/#get-comments-for-a-single-review - * - * @param string $username the username - * @param string $repository the repository - * @param int $pullRequest the pull request number - * @param int $id the review id - * - * @return array|string - */ - public function comments($username, $repository, $pullRequest, $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/reviews/'.$id.'/comments'); - } - - /** - * Create a pull request review by the username, repository and pull request number. - * - * @link https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review - * - * @param string $username the username - * @param string $repository the repository - * @param int $pullRequest the pull request number - * @param array $params a list of extra parameters. - * - * @throws MissingArgumentException - * - * @return array the pull request review - */ - public function create($username, $repository, $pullRequest, array $params = []) - { - if (array_key_exists('event', $params) && !in_array($params['event'], ['APPROVE', 'REQUEST_CHANGES', 'COMMENT'], true)) { - throw new InvalidArgumentException(sprintf('"event" must be one of ["APPROVE", "REQUEST_CHANGES", "COMMENT"] ("%s" given).', $params['event'])); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/reviews', $params); - } - - /** - * Submit a pull request review by the username, repository, pull request number and the review id. - * - * @link https://developer.github.com/v3/pulls/reviews/#submit-a-pull-request-review - * - * @param string $username the username - * @param string $repository the repository - * @param int $pullRequest the pull request number - * @param int $id the review id - * @param array $params a list of extra parameters. - * - * @throws MissingArgumentException - * - * @return array the pull request review - */ - public function submit($username, $repository, $pullRequest, $id, array $params = []) - { - if (!isset($params['event'])) { - throw new MissingArgumentException('event'); - } - - if (!in_array($params['event'], ['APPROVE', 'REQUEST_CHANGES', 'COMMENT'], true)) { - throw new InvalidArgumentException(sprintf('"event" must be one of ["APPROVE", "REQUEST_CHANGES", "COMMENT"] ("%s" given).', $params['event'])); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/reviews/'.$id.'/events', $params); - } - - /** - * Dismiss a pull request review by the username, repository, pull request number and the review id. - * - * @link https://developer.github.com/v3/pulls/reviews/#dismiss-a-pull-request-review - * - * @param string $username the username - * @param string $repository the repository - * @param int $pullRequest the pull request number - * @param int $id the review id - * @param string $message a mandatory dismissal message - * - * @return array|string - */ - public function dismiss($username, $repository, $pullRequest, $id, $message) - { - if (!is_string($message)) { - throw new InvalidArgumentException(sprintf('"message" must be a valid string ("%s" given).', gettype($message))); - } - - if (empty($message)) { - throw new InvalidArgumentException('"message" is mandatory and cannot be empty'); - } - - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/reviews/'.$id.'/dismissals', [ - 'message' => $message, - ]); - } - - /** - * Update a pull request review by the username, repository, pull request number and the review id. - * - * @link https://developer.github.com/v3/pulls/reviews/#update-a-pull-request-review - * - * @param string $username the username - * @param string $repository the repository - * @param int $pullRequest the pull request number - * @param int $id the review id - * @param string $body a mandatory dismissal message - * - * @return array|string - */ - public function update($username, $repository, $pullRequest, $id, $body) - { - if (!is_string($body)) { - throw new InvalidArgumentException(sprintf('"body" must be a valid string ("%s" given).', gettype($body))); - } - - if (empty($body)) { - throw new InvalidArgumentException('"body" is mandatory and cannot be empty'); - } - - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/reviews/'.$id, [ - 'body' => $body, - ]); - } -} diff --git a/lib/Github/Api/PullRequest/ReviewRequest.php b/lib/Github/Api/PullRequest/ReviewRequest.php deleted file mode 100644 index e9b9280a119..00000000000 --- a/lib/Github/Api/PullRequest/ReviewRequest.php +++ /dev/null @@ -1,72 +0,0 @@ -get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/requested_reviewers', $params); - } - - /** - * @link https://docs.github.com/en/rest/reference/pulls#request-reviewers-for-a-pull-request - * - * @param string $username - * @param string $repository - * @param int $pullRequest - * @param array $reviewers - * @param array $teamReviewers - * - * @return array - */ - public function create($username, $repository, $pullRequest, array $reviewers = [], array $teamReviewers = []) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/requested_reviewers', ['reviewers' => $reviewers, 'team_reviewers' => $teamReviewers]); - } - - /** - * @link https://developer.github.com/v3/pulls/review_requests/#delete-a-review-request - * - * @param string $username - * @param string $repository - * @param int $pullRequest - * @param array $reviewers - * @param array $teamReviewers - * - * @return array - */ - public function remove($username, $repository, $pullRequest, array $reviewers = [], array $teamReviewers = []) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.$pullRequest.'/requested_reviewers', ['reviewers' => $reviewers, 'team_reviewers' => $teamReviewers]); - } -} diff --git a/lib/Github/Api/RateLimit.php b/lib/Github/Api/RateLimit.php deleted file mode 100644 index 10b8b5b3288..00000000000 --- a/lib/Github/Api/RateLimit.php +++ /dev/null @@ -1,70 +0,0 @@ - - */ -class RateLimit extends AbstractApi -{ - /** - * @var RateLimitResource[] - */ - protected $resources = []; - - /** - * Gets the rate limit resource objects. - * - * @return RateLimitResource[] - */ - public function getResources() - { - $this->fetchLimits(); - - return $this->resources; - } - - /** - * Returns a rate limit resource object by the given name. - * - * @param string $name - * - * @return RateLimitResource|false - */ - public function getResource($name) - { - // Fetch once per instance - if (empty($this->resources)) { - $this->fetchLimits(); - } - - if (!isset($this->resources[$name])) { - return false; - } - - return $this->resources[$name]; - } - - /** - * Returns the data directly from the GitHub API endpoint. - * - * @return array - */ - protected function fetchLimits() - { - $result = $this->get('/rate_limit') ?: []; - - // Assemble Limit instances - foreach ($result['resources'] as $resourceName => $resource) { - $this->resources[$resourceName] = new RateLimitResource($resourceName, $resource); - } - - return $result; - } -} diff --git a/lib/Github/Api/RateLimit/RateLimitResource.php b/lib/Github/Api/RateLimit/RateLimitResource.php deleted file mode 100644 index 661a4e5287c..00000000000 --- a/lib/Github/Api/RateLimit/RateLimitResource.php +++ /dev/null @@ -1,73 +0,0 @@ -name = $name; - $this->limit = $data['limit']; - $this->remaining = $data['remaining']; - $this->reset = $data['reset']; - } - - /** - * The name of the Limit, e.g. "core", "graphql", "search". - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * The rate limit amount. - * - * @return int - */ - public function getLimit() - { - return $this->limit; - } - - /** - * Number of requests remaining in time period before hitting the rate limit. - * - * @return int - */ - public function getRemaining() - { - return $this->remaining; - } - - /** - * Timestamp for when the rate limit will be reset. - * - * @return int - */ - public function getReset() - { - return $this->reset; - } -} diff --git a/lib/Github/Api/Repo.php b/lib/Github/Api/Repo.php deleted file mode 100644 index 5653ae4c152..00000000000 --- a/lib/Github/Api/Repo.php +++ /dev/null @@ -1,909 +0,0 @@ - - * @author Thibault Duplessis - */ -class Repo extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * List all public repositories. - * - * @link https://developer.github.com/v3/repos/#list-all-public-repositories - * - * @param int|null $id The integer ID of the last Repository that you’ve seen. - * - * @return array list of users found - */ - public function all($id = null) - { - if (!is_int($id)) { - return $this->get('/repositories'); - } - - return $this->get('/repositories', ['since' => $id]); - } - - /** - * Get the last year of commit activity for a repository grouped by week. - * - * @link http://developer.github.com/v3/repos/statistics/#commit-activity - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * - * @return array commit activity grouped by week - */ - public function activity($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/stats/commit_activity'); - } - - /** - * Get contributor commit statistics for a repository. - * - * @link http://developer.github.com/v3/repos/statistics/#contributors - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * - * @return array list of contributors and their commit statistics - */ - public function statistics($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/stats/contributors'); - } - - /** - * Get a weekly aggregate of the number of additions and deletions pushed to a repository. - * - * @link http://developer.github.com/v3/repos/statistics/#code-frequency - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * - * @return array list of weeks and their commit statistics - */ - public function frequency($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/stats/code_frequency'); - } - - /** - * Get the weekly commit count for the repository owner and everyone else. - * - * @link http://developer.github.com/v3/repos/statistics/#participation - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * - * @return array list of weekly commit count grouped by 'all' and 'owner' - */ - public function participation($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/stats/participation'); - } - - /** - * List all repositories for an organization. - * - * @link http://developer.github.com/v3/repos/#list-organization-repositories - * - * @param string $organization the name of the organization - * @param array $params - * - * @return array list of organization repositories - */ - public function org($organization, array $params = []) - { - return $this->get('/orgs/'.$organization.'/repos', array_merge(['start_page' => 1], $params)); - } - - /** - * Get extended information about a repository by its username and repository name. - * - * @link http://developer.github.com/v3/repos/ - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * - * @return array information about the repository - */ - public function show($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository)); - } - - /** - * Get extended information about a repository by its id. - * Note: at time of writing this is an undocumented feature but GitHub support have advised that it can be relied on. - * - * @link http://developer.github.com/v3/repos/ - * @link https://github.com/piotrmurach/github/issues/283 - * @link https://github.com/piotrmurach/github/issues/282 - * - * @param int $id the id of the repository - * - * @return array information about the repository - */ - public function showById($id) - { - return $this->get('/repositories/'.$id); - } - - /** - * Create repository. - * - * @link http://developer.github.com/v3/repos/ - * - * @param string $name name of the repository - * @param string $description repository description - * @param string $homepage homepage url - * @param bool $public `true` for public, `false` for private - * @param string|null $organization username of organization if applicable - * @param bool $hasIssues `true` to enable issues for this repository, `false` to disable them - * @param bool $hasWiki `true` to enable the wiki for this repository, `false` to disable it - * @param bool $hasDownloads `true` to enable downloads for this repository, `false` to disable them - * @param int $teamId The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization. - * @param bool $autoInit `true` to create an initial commit with empty README, `false` for no initial commit - * @param bool $hasProjects `true` to enable projects for this repository or false to disable them. - * @param string|null $visibility - * - * @return array returns repository data - */ - public function create( - $name, - $description = '', - $homepage = '', - $public = true, - $organization = null, - $hasIssues = false, - $hasWiki = false, - $hasDownloads = false, - $teamId = null, - $autoInit = false, - $hasProjects = true, - $visibility = null - ) { - $path = null !== $organization ? '/orgs/'.$organization.'/repos' : '/user/repos'; - - $parameters = [ - 'name' => $name, - 'description' => $description, - 'homepage' => $homepage, - 'private' => ($visibility ?? ($public ? 'public' : 'private')) === 'private', - 'has_issues' => $hasIssues, - 'has_wiki' => $hasWiki, - 'has_downloads' => $hasDownloads, - 'auto_init' => $autoInit, - 'has_projects' => $hasProjects, - ]; - - if ($visibility) { - $parameters['visibility'] = $visibility; - } - - if ($organization && $teamId) { - $parameters['team_id'] = $teamId; - } - - return $this->post($path, $parameters); - } - - /** - * Set information of a repository. - * - * @link http://developer.github.com/v3/repos/ - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * @param array $values the key => value pairs to post - * - * @return array information about the repository - */ - public function update($username, $repository, array $values) - { - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository), $values); - } - - /** - * Delete a repository. - * - * @link http://developer.github.com/v3/repos/ - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * - * @return mixed null on success, array on error with 'message' - */ - public function remove($username, $repository) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository)); - } - - /** - * Get the readme content for a repository by its username and repository name. - * - * @link http://developer.github.com/v3/repos/contents/#get-the-readme - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * @param string $format one of formats: "raw", "html", or "v3+json" - * @param string $dir The alternate path to look for a README file - * @param array $params additional query params like "ref" to fetch readme for branch/tag - * - * @return string|array the readme content - */ - public function readme($username, $repository, $format = 'raw', $dir = null, $params = []) - { - $path = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/readme'; - - if (null !== $dir) { - $path .= '/'.rawurlencode($dir); - } - - return $this->get($path, $params, [ - 'Accept' => "application/vnd.github.$format", - ]); - } - - /** - * Create a repository dispatch event. - * - * @link https://developer.github.com/v3/repos/#create-a-repository-dispatch-event - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * @param string $eventType A custom webhook event name - * @param array|object $clientPayload The payload to pass to Github. - * - * @return mixed null on success, array on error with 'message' - */ - public function dispatch($username, $repository, $eventType, $clientPayload) - { - if (is_array($clientPayload)) { - $clientPayload = (object) $clientPayload; - } - - return $this->post(\sprintf('/repos/%s/%s/dispatches', rawurlencode($username), rawurlencode($repository)), [ - 'event_type' => $eventType, - 'client_payload' => $clientPayload, - ]); - } - - /** - * Manage the collaborators of a repository. - * - * @link http://developer.github.com/v3/repos/collaborators/ - * - * @return Collaborators - */ - public function collaborators() - { - return new Collaborators($this->getClient()); - } - - /** - * Manage the comments of a repository. - * - * @link http://developer.github.com/v3/repos/comments/ - * - * @return Comments - */ - public function comments() - { - return new Comments($this->getClient()); - } - - /** - * Manage the commits of a repository. - * - * @link http://developer.github.com/v3/repos/commits/ - * - * @return Commits - */ - public function commits() - { - return new Commits($this->getClient()); - } - - /** - * @link https://docs.github.com/en/rest/reference/checks#check-runs - */ - public function checkRuns(): CheckRuns - { - return new CheckRuns($this->getClient()); - } - - /** - * @link https://docs.github.com/en/rest/reference/checks#check-suites - */ - public function checkSuites(): CheckSuites - { - return new CheckSuites($this->getClient()); - } - - /** - * @link https://developer.github.com/v3/actions/artifacts/#artifacts - */ - public function artifacts(): Artifacts - { - return new Artifacts($this->getClient()); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#workflows - */ - public function workflows(): Workflows - { - return new Workflows($this->getClient()); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#workflow-runs - */ - public function workflowRuns(): WorkflowRuns - { - return new WorkflowRuns($this->getClient()); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#workflow-jobs - */ - public function workflowJobs(): WorkflowJobs - { - return new WorkflowJobs($this->getClient()); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#self-hosted-runners - */ - public function selfHostedRunners(): SelfHostedRunners - { - return new SelfHostedRunners($this->getClient()); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#secrets - */ - public function secrets(): Secrets - { - return new Secrets($this->getClient()); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#secrets - */ - public function variables(): Variables - { - return new Variables($this->getClient()); - } - - /** - * Manage the content of a repository. - * - * @link http://developer.github.com/v3/repos/contents/ - * - * @return Contents - */ - public function contents() - { - return new Contents($this->getClient()); - } - - /** - * Manage the content of a repository. - * - * @link http://developer.github.com/v3/repos/downloads/ - * - * @return Downloads - */ - public function downloads() - { - return new Downloads($this->getClient()); - } - - /** - * Manage the releases of a repository (Currently Undocumented). - * - * @link http://developer.github.com/v3/repos/ - * - * @return Releases - */ - public function releases() - { - return new Releases($this->getClient()); - } - - /** - * Manage the deploy keys of a repository. - * - * @link http://developer.github.com/v3/repos/keys/ - * - * @return DeployKeys - */ - public function keys() - { - return new DeployKeys($this->getClient()); - } - - /** - * Manage the forks of a repository. - * - * @link http://developer.github.com/v3/repos/forks/ - * - * @return Forks - */ - public function forks() - { - return new Forks($this->getClient()); - } - - /** - * Manage the stargazers of a repository. - * - * @link https://developer.github.com/v3/activity/starring/#list-stargazers - * - * @return Stargazers - */ - public function stargazers() - { - return new Stargazers($this->getClient()); - } - - /** - * Manage the hooks of a repository. - * - * @link http://developer.github.com/v3/issues/jooks/ - * - * @return Hooks - */ - public function hooks() - { - return new Hooks($this->getClient()); - } - - /** - * Manage the labels of a repository. - * - * @link http://developer.github.com/v3/issues/labels/ - * - * @return Labels - */ - public function labels() - { - return new Labels($this->getClient()); - } - - /** - * Manage the statuses of a repository. - * - * @link http://developer.github.com/v3/repos/statuses/ - * - * @return Statuses - */ - public function statuses() - { - return new Statuses($this->getClient()); - } - - /** - * Get the branch(es) of a repository. - * - * @link http://developer.github.com/v3/repos/ - * - * @param string $username the username - * @param string $repository the name of the repository - * @param string $branch the name of the branch - * @param array $parameters parameters for the query string - * - * @return array list of the repository branches - */ - public function branches($username, $repository, $branch = null, array $parameters = []) - { - $url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches'; - if (null !== $branch) { - $url .= '/'.rawurlencode($branch); - } - - return $this->get($url, $parameters); - } - - /** - * Sync a fork branch with the upstream repository. - * - * @link https://docs.github.com/en/rest/branches/branches#sync-a-fork-branch-with-the-upstream-repository - * - * @return array|string - */ - public function mergeUpstream(string $username, string $repository, string $branchName) - { - return $this->post( - '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/merge-upstream', - ['branch' => $branchName] - ); - } - - /** - * Manage the protection of a repository branch. - * - * @link https://developer.github.com/v3/repos/branches/#get-branch-protection - * - * @return Protection - */ - public function protection() - { - return new Protection($this->getClient()); - } - - /** - * Get the contributors of a repository. - * - * @link http://developer.github.com/v3/repos/ - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * @param bool $includingAnonymous by default, the list only shows GitHub users. - * You can include non-users too by setting this to true - * - * @return array list of the repo contributors - */ - public function contributors($username, $repository, $includingAnonymous = false) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contributors', [ - 'anon' => $includingAnonymous ?: null, - ]); - } - - /** - * Get the language breakdown of a repository. - * - * @link http://developer.github.com/v3/repos/ - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * - * @return array list of the languages - */ - public function languages($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/languages'); - } - - /** - * Get the tags of a repository. - * - * @link http://developer.github.com/v3/repos/ - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * @param array $params the additional parameters like milestone, assignees, labels, sort, direction - * - * @return array list of the repository tags - */ - public function tags($username, $repository, array $params = []) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/tags', $params); - } - - /** - * Get the teams of a repository. - * - * @link http://developer.github.com/v3/repos/ - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * - * @return array list of the languages - */ - public function teams($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/teams'); - } - - /** - * @param string $username - * @param string $repository - * @param int $page - * - * @return array - */ - public function subscribers($username, $repository, $page = 1) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/subscribers', [ - 'page' => $page, - ]); - } - - /** - * Perform a merge. - * - * @link http://developer.github.com/v3/repos/merging/ - * - * @param string $username - * @param string $repository - * @param string $base The name of the base branch that the head will be merged into. - * @param string $head The head to merge. This can be a branch name or a commit SHA1. - * @param string $message Commit message to use for the merge commit. If omitted, a default message will be used. - * - * @return array|string - */ - public function merge($username, $repository, $base, $head, $message = null) - { - $parameters = [ - 'base' => $base, - 'head' => $head, - ]; - - if (is_string($message)) { - $parameters['commit_message'] = $message; - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/merges', $parameters); - } - - /** - * @param string $username - * @param string $repository - * @param array $parameters - * - * @return array - */ - public function milestones($username, $repository, array $parameters = []) - { - return $this->get('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/milestones', $parameters); - } - - /** - * @link https://docs.github.com/en/rest/reference/repos#enable-automated-security-fixes - * - * @param string $username - * @param string $repository - * - * @return array|string - */ - public function enableAutomatedSecurityFixes(string $username, string $repository) - { - $this->acceptHeaderValue = 'application/vnd.github.london-preview+json'; - - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/automated-security-fixes'); - } - - /** - * @link https://docs.github.com/en/rest/reference/repos#disable-automated-security-fixes - * - * @param string $username - * @param string $repository - * - * @return array|string - */ - public function disableAutomatedSecurityFixes(string $username, string $repository) - { - $this->acceptHeaderValue = 'application/vnd.github.london-preview+json'; - - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/automated-security-fixes'); - } - - public function projects() - { - return new Projects($this->getClient()); - } - - public function traffic() - { - return new Traffic($this->getClient()); - } - - public function pages() - { - return new Pages($this->getClient()); - } - - /** - * @param string $username - * @param string $repository - * @param int $page - * - * @return array|string - * - * @see https://developer.github.com/v3/activity/events/#list-repository-events - */ - public function events($username, $repository, $page = 1) - { - return $this->get('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/events', ['page' => $page]); - } - - /** - * Get the community profile metrics for a repository. - * - * @link https://developer.github.com/v3/repos/community/#retrieve-community-profile-metrics - * - * @param string $username - * @param string $repository - * - * @return array - */ - public function communityProfile($username, $repository) - { - //This api is in preview mode, so set the correct accept-header - $this->acceptHeaderValue = 'application/vnd.github.black-panther-preview+json'; - - return $this->get('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/community/profile'); - } - - /** - * Get the contents of a repository's code of conduct. - * - * @link https://developer.github.com/v3/codes_of_conduct/#get-the-contents-of-a-repositorys-code-of-conduct - * - * @param string $username - * @param string $repository - * - * @return array - */ - public function codeOfConduct($username, $repository) - { - //This api is in preview mode, so set the correct accept-header - $this->acceptHeaderValue = 'application/vnd.github.scarlet-witch-preview+json'; - - return $this->get('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/community/code_of_conduct'); - } - - /** - * List all topics for a repository. - * - * @link https://developer.github.com/v3/repos/#list-all-topics-for-a-repository - * - * @param string $username - * @param string $repository - * - * @return array - */ - public function topics($username, $repository) - { - //This api is in preview mode, so set the correct accept-header - $this->acceptHeaderValue = 'application/vnd.github.mercy-preview+json'; - - return $this->get('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/topics'); - } - - /** - * Replace all topics for a repository. - * - * @link https://developer.github.com/v3/repos/#replace-all-topics-for-a-repository - * - * @param string $username - * @param string $repository - * @param array $topics - * - * @return array - */ - public function replaceTopics($username, $repository, array $topics) - { - //This api is in preview mode, so set the correct accept-header - $this->acceptHeaderValue = 'application/vnd.github.mercy-preview+json'; - - return $this->put('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/topics', ['names' => $topics]); - } - - /** - * Transfer a repository. - * - * @link https://developer.github.com/v3/repos/#transfer-a-repository - * - * @param string $username - * @param string $repository - * @param string $newOwner - * @param array $teamId - * - * @return array - */ - public function transfer($username, $repository, $newOwner, $teamId = []) - { - return $this->post('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/transfer', ['new_owner' => $newOwner, 'team_id' => $teamId]); - } - - /** - * Create a repository using a template. - * - * @link https://developer.github.com/v3/repos/#create-a-repository-using-a-template - * - * @return array - */ - public function createFromTemplate(string $templateOwner, string $templateRepo, array $parameters = []) - { - //This api is in preview mode, so set the correct accept-header - $this->acceptHeaderValue = 'application/vnd.github.baptiste-preview+json'; - - return $this->post('/repos/'.rawurldecode($templateOwner).'/'.rawurldecode($templateRepo).'/generate', $parameters); - } - - /** - * Check if vulnerability alerts are enabled for a repository. - * - * @link https://developer.github.com/v3/repos/#check-if-vulnerability-alerts-are-enabled-for-a-repository - * - * @param string $username the username - * @param string $repository the repository - * - * @return array|string - */ - public function isVulnerabilityAlertsEnabled(string $username, string $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/vulnerability-alerts'); - } - - /** - * Enable vulnerability alerts for a repository. - * - * @link https://developer.github.com/v3/repos/#enable-vulnerability-alerts - * - * @param string $username the username - * @param string $repository the repository - * - * @return array|string - */ - public function enableVulnerabilityAlerts(string $username, string $repository) - { - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/vulnerability-alerts'); - } - - /** - * Disable vulnerability alerts for a repository. - * - * @link https://developer.github.com/v3/repos/#disable-vulnerability-alerts - * - * @param string $username the username - * @param string $repository the repository - * - * @return array|string - */ - public function disableVulnerabilityAlerts(string $username, string $repository) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/vulnerability-alerts'); - } - - /** - * @return SecretScanning - */ - public function secretScanning(): SecretScanning - { - return new SecretScanning($this->getClient()); - } -} diff --git a/lib/Github/Api/Repository/Actions/Artifacts.php b/lib/Github/Api/Repository/Actions/Artifacts.php deleted file mode 100644 index 84f3b0604af..00000000000 --- a/lib/Github/Api/Repository/Actions/Artifacts.php +++ /dev/null @@ -1,82 +0,0 @@ -get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/artifacts', $parameters); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#list-workflow-run-artifacts - * - * @param string $username - * @param string $repository - * @param int $runId - * - * @return array - */ - public function runArtifacts(string $username, string $repository, int $runId) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/artifacts'); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#get-an-artifact - * - * @param string $username - * @param string $repository - * @param int $artifactId - * - * @return array - */ - public function show(string $username, string $repository, int $artifactId) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/artifacts/'.$artifactId); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#delete-an-artifact - * - * @param string $username - * @param string $repository - * @param int $artifactId - * - * @return array - */ - public function remove(string $username, string $repository, int $artifactId) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/artifacts/'.$artifactId); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#download-an-artifact - * - * @param string $username - * @param string $repository - * @param int $artifactId - * @param string $format - * - * @return array - */ - public function download(string $username, string $repository, int $artifactId, string $format = 'zip') - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/artifacts/'.$artifactId.'/'.$format); - } -} diff --git a/lib/Github/Api/Repository/Actions/Secrets.php b/lib/Github/Api/Repository/Actions/Secrets.php deleted file mode 100644 index 2085a133f7a..00000000000 --- a/lib/Github/Api/Repository/Actions/Secrets.php +++ /dev/null @@ -1,95 +0,0 @@ -get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/secrets'); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#get-a-repository-secret - * - * @param string $username - * @param string $repository - * @param string $secretName - * - * @return array|string - */ - public function show(string $username, string $repository, string $secretName) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/secrets/'.rawurlencode($secretName)); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#create-or-update-a-repository-secret - * - * @param string $username - * @param string $repository - * @param string $secretName - * @param array $parameters - * - * @return array|string - */ - public function create(string $username, string $repository, string $secretName, array $parameters = []) - { - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/secrets/'.rawurlencode($secretName), $parameters); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#create-or-update-a-repository-secret - * - * @param string $username - * @param string $repository - * @param string $secretName - * @param array $parameters - * - * @return array|string - */ - public function update(string $username, string $repository, string $secretName, array $parameters = []) - { - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/secrets/'.rawurlencode($secretName), $parameters); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#delete-a-repository-secret - * - * @param string $username - * @param string $repository - * @param string $secretName - * - * @return array|string - */ - public function remove(string $username, string $repository, string $secretName) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/secrets/'.rawurlencode($secretName)); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#get-a-repository-public-key - * - * @param string $username - * @param string $repository - * - * @return array|string - */ - public function publicKey(string $username, string $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/secrets/public-key'); - } -} diff --git a/lib/Github/Api/Repository/Actions/SelfHostedRunners.php b/lib/Github/Api/Repository/Actions/SelfHostedRunners.php deleted file mode 100644 index 7eb1a9d4e39..00000000000 --- a/lib/Github/Api/Repository/Actions/SelfHostedRunners.php +++ /dev/null @@ -1,65 +0,0 @@ -get('/repos/'.rawurlencode($username).'/'.rawurldecode($repository).'/actions/runners'); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#get-a-self-hosted-runner-for-a-repository - * - * @param string $username - * @param string $repository - * @param int $runnerId - * - * @return array|string - */ - public function show(string $username, string $repository, int $runnerId) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurldecode($repository).'/actions/runners/'.$runnerId); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#delete-a-self-hosted-runner-from-a-repository - * - * @param string $username - * @param string $repository - * @param int $runnerId - * - * @return array|string - */ - public function remove(string $username, string $repository, int $runnerId) - { - return $this->delete('/repos/'.rawurldecode($username).'/'.rawurldecode($repository).'/actions/runners/'.$runnerId); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#list-runner-applications-for-a-repository - * - * @param string $username - * @param string $repository - * - * @return array|string - */ - public function applications(string $username, string $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runners/downloads'); - } -} diff --git a/lib/Github/Api/Repository/Actions/Variables.php b/lib/Github/Api/Repository/Actions/Variables.php deleted file mode 100644 index 7414e82810b..00000000000 --- a/lib/Github/Api/Repository/Actions/Variables.php +++ /dev/null @@ -1,81 +0,0 @@ -get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/variables'); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-a-repository-variable - * - * @param string $username - * @param string $repository - * @param string $variableName - * - * @return array|string - */ - public function show(string $username, string $repository, string $variableName) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/variables/'.rawurlencode($variableName)); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#create-a-repository-variable - * - * @param string $username - * @param string $repository - * @param array $parameters - * - * @return array|string - */ - public function create(string $username, string $repository, array $parameters = []) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/variables', $parameters); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#update-a-repository-variable - * - * @param string $username - * @param string $repository - * @param string $variableName - * @param array $parameters - * - * @return array|string - */ - public function update(string $username, string $repository, string $variableName, array $parameters = []) - { - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/variables/'.rawurlencode($variableName), $parameters); - } - - /** - * @link https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#delete-a-repository-variable - * - * @param string $username - * @param string $repository - * @param string $variableName - * - * @return array|string - */ - public function remove(string $username, string $repository, string $variableName) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/variables/'.rawurlencode($variableName)); - } -} diff --git a/lib/Github/Api/Repository/Actions/WorkflowJobs.php b/lib/Github/Api/Repository/Actions/WorkflowJobs.php deleted file mode 100644 index 3167d3dbf81..00000000000 --- a/lib/Github/Api/Repository/Actions/WorkflowJobs.php +++ /dev/null @@ -1,54 +0,0 @@ -get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/jobs', $parameters); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#get-a-job-for-a-workflow-run - * - * @param string $username - * @param string $repository - * @param int $jobId - * - * @return array - */ - public function show(string $username, string $repository, int $jobId) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/jobs/'.$jobId); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#download-job-logs-for-a-workflow-run - * - * @param string $username - * @param string $repository - * @param int $jobId - * - * @return array - */ - public function downloadLogs(string $username, string $repository, int $jobId) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/jobs/'.$jobId.'/logs'); - } -} diff --git a/lib/Github/Api/Repository/Actions/WorkflowRuns.php b/lib/Github/Api/Repository/Actions/WorkflowRuns.php deleted file mode 100644 index d6f95f1ed94..00000000000 --- a/lib/Github/Api/Repository/Actions/WorkflowRuns.php +++ /dev/null @@ -1,155 +0,0 @@ -get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs', $parameters); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#list-workflow-runs - * - * @param string $username - * @param string $repository - * @param string $workflow - * @param array $parameters - * - * @return array - */ - public function listRuns(string $username, string $repository, string $workflow, array $parameters = []) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.rawurlencode($workflow).'/runs', $parameters); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#get-a-workflow-run - * - * @param string $username - * @param string $repository - * @param int $runId - * @param array $parameters - * - * @return array - */ - public function show(string $username, string $repository, int $runId, array $parameters = []) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId, $parameters); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#delete-a-workflow-run - * - * @param string $username - * @param string $repository - * @param int $runId - * - * @return array|string - */ - public function remove(string $username, string $repository, int $runId) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#re-run-a-workflow - * - * @param string $username - * @param string $repository - * @param int $runId - * - * @return array - */ - public function rerun(string $username, string $repository, int $runId) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/rerun'); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#cancel-a-workflow-run - * - * @param string $username - * @param string $repository - * @param int $runId - * - * @return array - */ - public function cancel(string $username, string $repository, int $runId) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/cancel'); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#get-workflow-run-usage - * - * @param string $username - * @param string $repository - * @param int $runId - * - * @return array - */ - public function usage(string $username, string $repository, int $runId) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/timing'); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#download-workflow-run-logs - * - * @param string $username - * @param string $repository - * @param int $runId - * - * @return array|string - */ - public function downloadLogs(string $username, string $repository, int $runId) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/logs'); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#delete-workflow-run-logs - * - * @param string $username - * @param string $repository - * @param int $runId - * - * @return array|string - */ - public function deleteLogs(string $username, string $repository, int $runId) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/logs'); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#approve-a-workflow-run-for-a-fork-pull-request - * - * @param string $username - * @param string $repository - * @param int $runId - * - * @return array|string - * - * @experimental This endpoint is currently in beta. - */ - public function approve(string $username, string $repository, int $runId) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/runs/'.$runId.'/approve'); - } -} diff --git a/lib/Github/Api/Repository/Actions/Workflows.php b/lib/Github/Api/Repository/Actions/Workflows.php deleted file mode 100644 index 9a1c9e31c7b..00000000000 --- a/lib/Github/Api/Repository/Actions/Workflows.php +++ /dev/null @@ -1,82 +0,0 @@ -get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows', $parameters); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#get-a-workflow - * - * @param string $username - * @param string $repository - * @param string|int $workflow - * - * @return array - */ - public function show(string $username, string $repository, $workflow) - { - if (is_string($workflow)) { - $workflow = rawurlencode($workflow); - } - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.$workflow); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#get-workflow-usage - * - * @param string $username - * @param string $repository - * @param string|int $workflow - * - * @return array|string - */ - public function usage(string $username, string $repository, $workflow) - { - if (is_string($workflow)) { - $workflow = rawurlencode($workflow); - } - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.$workflow.'/timing'); - } - - /** - * @link https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event - * - * @param string $username - * @param string $repository - * @param string|int $workflow - * @param string $ref - * @param array $inputs - * - * @return array|string empty - */ - public function dispatches(string $username, string $repository, $workflow, string $ref, ?array $inputs = null) - { - if (is_string($workflow)) { - $workflow = rawurlencode($workflow); - } - $parameters = array_filter(['ref' => $ref, 'inputs' => $inputs]); - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/actions/workflows/'.$workflow.'/dispatches', $parameters); - } -} diff --git a/lib/Github/Api/Repository/Assets.php b/lib/Github/Api/Repository/Assets.php deleted file mode 100644 index 043016e7801..00000000000 --- a/lib/Github/Api/Repository/Assets.php +++ /dev/null @@ -1,123 +0,0 @@ - - */ -class Assets extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * Get all release's assets in selected repository - * GET /repos/:owner/:repo/releases/:id/assets. - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * @param int $id the id of the release - * - * @return array - */ - public function all($username, $repository, $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.$id.'/assets'); - } - - /** - * Get an asset in selected repository's release - * GET /repos/:owner/:repo/releases/assets/:id. - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * @param int $id the id of the asset - * - * @return array|string - */ - public function show($username, $repository, $id, bool $returnBinaryContent = false) - { - if ($returnBinaryContent) { - $this->acceptHeaderValue = 'application/octet-stream'; - } - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/assets/'.$id); - } - - /** - * Create an asset for selected repository's release - * POST /repos/:owner/:repo/releases/:id/assets?name=:filename. - * - * Creating an asset requires support for server name indentification (SNI) - * so this must be supported by your PHP version. - * - * @see http://developer.github.com/v3/repos/releases/#upload-a-release-asset - * @see http://php.net/manual/en/openssl.constsni.php - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * @param int $id the id of the release - * @param string $name the filename for the asset - * @param string $contentType the content type for the asset - * @param string $content the content of the asset - * - * @throws MissingArgumentException - * @throws ErrorException - * - * @return array - */ - public function create($username, $repository, $id, $name, $contentType, $content) - { - if (!defined('OPENSSL_TLSEXT_SERVER_NAME') || OPENSSL_TLSEXT_SERVER_NAME == 0) { - throw new ErrorException('Asset upload support requires Server Name Indication. This is not supported by your PHP version. See https://www.php.net/manual/en/openssl.constsni.php.'); - } - - // Asset creation requires a separate endpoint, uploads.github.com. - // Change the base url for the HTTP client temporarily while we execute - // this request. - return $this->postRaw('https://uploads.github.com/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.$id.'/assets?name='.$name, $content, ['Content-Type' => $contentType]); - } - - /** - * Edit an asset in selected repository's release - * PATCH /repos/:owner/:repo/releases/assets/:id. - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * @param int $id the id of the asset - * @param array $params request parameters - * - * @throws MissingArgumentException - * - * @return array - */ - public function edit($username, $repository, $id, array $params) - { - if (!isset($params['name'])) { - throw new MissingArgumentException('name'); - } - - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/assets/'.$id, $params); - } - - /** - * Delete an asset in selected repository's release - * DELETE /repos/:owner/:repo/releases/assets/:id. - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * @param int $id the id of the asset - * - * @return array - */ - public function remove($username, $repository, $id) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/assets/'.$id); - } -} diff --git a/lib/Github/Api/Repository/Checks/CheckRuns.php b/lib/Github/Api/Repository/Checks/CheckRuns.php deleted file mode 100644 index 1ddee3770c8..00000000000 --- a/lib/Github/Api/Repository/Checks/CheckRuns.php +++ /dev/null @@ -1,96 +0,0 @@ -acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs', $params); - } - - /** - * @link https://docs.github.com/en/rest/reference/checks#get-a-check-run - * - * @return array - */ - public function show(string $username, string $repository, int $checkRunId) - { - $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.$checkRunId); - } - - /** - * @link https://docs.github.com/en/rest/reference/checks#update-a-check-run - * - * @return array - */ - public function update(string $username, string $repository, int $checkRunId, array $params = []) - { - $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; - - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.$checkRunId, $params); - } - - /** - * @link https://docs.github.com/en/rest/reference/checks#list-check-run-annotations - * - * @return array - */ - public function annotations(string $username, string $repository, int $checkRunId) - { - $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.$checkRunId.'/annotations'); - } - - /** - * @link https://docs.github.com/en/rest/reference/checks#list-check-runs-in-a-check-suite - * - * @return array - */ - public function allForCheckSuite(string $username, string $repository, int $checkSuiteId, array $params = []) - { - $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/'.$checkSuiteId.'/check-runs', $params); - } - - /** - * @link https://docs.github.com/en/rest/reference/checks#list-check-runs-for-a-git-reference - * - * @return array - */ - public function allForReference(string $username, string $repository, string $ref, array $params = []) - { - $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($ref).'/check-runs', $params); - } - - /** - * @link https://docs.github.com/en/rest/reference/checks#rerequest-a-check-run - * - * @return array - */ - public function rerequest(string $username, string $repository, int $checkRunId) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-runs/'.$checkRunId.'/rerequest'); - } -} diff --git a/lib/Github/Api/Repository/Checks/CheckSuites.php b/lib/Github/Api/Repository/Checks/CheckSuites.php deleted file mode 100644 index 40c83a566c1..00000000000 --- a/lib/Github/Api/Repository/Checks/CheckSuites.php +++ /dev/null @@ -1,74 +0,0 @@ -acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites', $params); - } - - /** - * @link https://docs.github.com/en/rest/reference/checks#update-repository-preferences-for-check-suites - * - * @return array - */ - public function updatePreferences(string $username, string $repository, array $params = []) - { - $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; - - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/preferences', $params); - } - - /** - * @link https://docs.github.com/en/rest/reference/checks#get-a-check-suite - * - * @return array - */ - public function getCheckSuite(string $username, string $repository, int $checkSuiteId) - { - $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/'.$checkSuiteId); - } - - /** - * @link https://docs.github.com/en/rest/reference/checks#rerequest-a-check-suite - * - * @return array - */ - public function rerequest(string $username, string $repository, int $checkSuiteId) - { - $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/check-suites/'.$checkSuiteId.'/rerequest'); - } - - /** - * @link https://docs.github.com/en/rest/reference/checks#list-check-suites-for-a-git-reference - * - * @return array - */ - public function allForReference(string $username, string $repository, string $ref, array $params = []) - { - $this->acceptHeaderValue = 'application/vnd.github.antiope-preview+json'; - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($ref).'/check-suites', $params); - } -} diff --git a/lib/Github/Api/Repository/Collaborators.php b/lib/Github/Api/Repository/Collaborators.php deleted file mode 100644 index 5c61b9bfee3..00000000000 --- a/lib/Github/Api/Repository/Collaborators.php +++ /dev/null @@ -1,84 +0,0 @@ - - */ -class Collaborators extends AbstractApi -{ - /** - * @link https://developer.github.com/v3/repos/collaborators/#list-collaborators - * - * @param string $username - * @param string $repository - * @param array $params - * - * @return array|string - */ - public function all($username, $repository, array $params = []) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/collaborators', $params); - } - - /** - * @link https://developer.github.com/v3/repos/collaborators/#check-if-a-user-is-a-collaborator - * - * @param string $username - * @param string $repository - * @param string $collaborator - * - * @return array|string - */ - public function check($username, $repository, $collaborator) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/collaborators/'.rawurlencode($collaborator)); - } - - /** - * @link https://developer.github.com/v3/repos/collaborators/#add-user-as-a-collaborator - * - * @param string $username - * @param string $repository - * @param string $collaborator - * @param array $params - * - * @return array|string - */ - public function add($username, $repository, $collaborator, array $params = []) - { - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/collaborators/'.rawurlencode($collaborator), $params); - } - - /** - * @link https://developer.github.com/v3/repos/collaborators/#remove-user-as-a-collaborator - * - * @param string $username - * @param string $repository - * @param string $collaborator - * - * @return array|string - */ - public function remove($username, $repository, $collaborator) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/collaborators/'.rawurlencode($collaborator)); - } - - /** - * @link https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level - * - * @param string $username - * @param string $repository - * @param string $collaborator - * - * @return array|string - */ - public function permission($username, $repository, $collaborator) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/collaborators/'.rawurlencode($collaborator).'/permission'); - } -} diff --git a/lib/Github/Api/Repository/Comments.php b/lib/Github/Api/Repository/Comments.php deleted file mode 100644 index 40eb2b53388..00000000000 --- a/lib/Github/Api/Repository/Comments.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @author Tobias Nyholm - */ -class Comments extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * Configure the body type. - * - * @link https://developer.github.com/v3/repos/comments/#custom-media-types - * - * @param string|null $bodyType - * - * @return $this - */ - public function configure($bodyType = null) - { - if (!in_array($bodyType, ['raw', 'text', 'html'])) { - $bodyType = 'full'; - } - - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s+json', $this->getApiVersion(), $bodyType); - - return $this; - } - - public function all($username, $repository, $sha = null) - { - if (null === $sha) { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/comments'); - } - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($sha).'/comments'); - } - - public function show($username, $repository, $comment) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/comments/'.rawurlencode($comment)); - } - - public function create($username, $repository, $sha, array $params) - { - if (!isset($params['body'])) { - throw new MissingArgumentException('body'); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($sha).'/comments', $params); - } - - public function update($username, $repository, $comment, array $params) - { - if (!isset($params['body'])) { - throw new MissingArgumentException('body'); - } - - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/comments/'.rawurlencode($comment), $params); - } - - public function remove($username, $repository, $comment) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/comments/'.rawurlencode($comment)); - } -} diff --git a/lib/Github/Api/Repository/Commits.php b/lib/Github/Api/Repository/Commits.php deleted file mode 100644 index 0bc5598cbff..00000000000 --- a/lib/Github/Api/Repository/Commits.php +++ /dev/null @@ -1,38 +0,0 @@ - - */ -class Commits extends AbstractApi -{ - public function all($username, $repository, array $params) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits', $params); - } - - public function compare($username, $repository, $base, $head, $mediaType = null, array $params = []) - { - $headers = []; - if (null !== $mediaType) { - $headers['Accept'] = $mediaType; - } - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/compare/'.rawurlencode($base).'...'.rawurlencode($head), $params, $headers); - } - - public function show($username, $repository, $sha) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($sha)); - } - - public function pulls($username, $repository, $sha, array $params = []) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($sha).'/pulls', $params); - } -} diff --git a/lib/Github/Api/Repository/Contents.php b/lib/Github/Api/Repository/Contents.php deleted file mode 100644 index a3cc1a3ea0e..00000000000 --- a/lib/Github/Api/Repository/Contents.php +++ /dev/null @@ -1,319 +0,0 @@ - - */ -class Contents extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * Configure the body type. - * - * @link https://developer.github.com/v3/repo/contents/#custom-media-types - * - * @param string|null $bodyType - * - * @return $this - */ - public function configure($bodyType = null) - { - if (!in_array($bodyType, ['html', 'object'])) { - $bodyType = 'raw'; - } - - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s', $this->getApiVersion(), $bodyType); - - return $this; - } - - /** - * Get content of README file in a repository. - * - * @link http://developer.github.com/v3/repos/contents/ - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * @param string|null $reference reference to a branch or commit - * - * @return array information for README file - */ - public function readme($username, $repository, $reference = null) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/readme', [ - 'ref' => $reference, - ]); - } - - /** - * Get contents of any file or directory in a repository. - * - * @link http://developer.github.com/v3/repos/contents/ - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * @param string|null $path path to file or directory - * @param string|null $reference reference to a branch or commit - * @param array $requestHeaders request headers - * - * @return array|string information for file | information for each item in directory - */ - public function show($username, $repository, $path = null, $reference = null, $requestHeaders = []) - { - $url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents'; - if (null !== $path) { - $url .= '/'.rawurlencode($path); - } - - return $this->get($url, [ - 'ref' => $reference, - ], $requestHeaders); - } - - /** - * Creates a new file in a repository. - * - * @link http://developer.github.com/v3/repos/contents/#create-a-file - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * @param string $path path to file - * @param string $content contents of the new file - * @param string $message the commit message - * @param string|null $branch name of a branch - * @param null|array $committer information about the committer - * - * @throws MissingArgumentException - * - * @return array information about the new file - */ - public function create($username, $repository, $path, $content, $message, $branch = null, ?array $committer = null) - { - $url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents/'.rawurlencode($path); - - $parameters = [ - 'content' => base64_encode($content), - 'message' => $message, - ]; - - if (null !== $branch) { - $parameters['branch'] = $branch; - } - - if (null !== $committer) { - if (!isset($committer['name'], $committer['email'])) { - throw new MissingArgumentException(['name', 'email']); - } - $parameters['committer'] = $committer; - } - - return $this->put($url, $parameters); - } - - /** - * Checks that a given path exists in a repository. - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * @param string $path path of file to check - * @param string|null $reference reference to a branch or commit - * - * @return bool - */ - public function exists($username, $repository, $path, $reference = null) - { - $url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents'; - - if (null !== $path) { - $url .= '/'.rawurlencode($path); - } - - try { - $response = $this->head($url, [ - 'ref' => $reference, - ]); - - if ($response->getStatusCode() !== 200) { - return false; - } - } catch (TwoFactorAuthenticationRequiredException $ex) { - throw $ex; - } catch (\Exception $ex) { - return false; - } - - return true; - } - - /** - * Updates the contents of a file in a repository. - * - * @link http://developer.github.com/v3/repos/contents/#update-a-file - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * @param string $path path to file - * @param string $content contents of the new file - * @param string $message the commit message - * @param string $sha blob SHA of the file being replaced - * @param string|null $branch name of a branch - * @param null|array $committer information about the committer - * - * @throws MissingArgumentException - * - * @return array information about the updated file - */ - public function update($username, $repository, $path, $content, $message, $sha, $branch = null, ?array $committer = null) - { - $url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents/'.rawurlencode($path); - - $parameters = [ - 'content' => base64_encode($content), - 'message' => $message, - 'sha' => $sha, - ]; - - if (null !== $branch) { - $parameters['branch'] = $branch; - } - - if (null !== $committer) { - if (!isset($committer['name'], $committer['email'])) { - throw new MissingArgumentException(['name', 'email']); - } - $parameters['committer'] = $committer; - } - - return $this->put($url, $parameters); - } - - /** - * Deletes a file from a repository. - * - * @link http://developer.github.com/v3/repos/contents/#delete-a-file - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * @param string $path path to file - * @param string $message the commit message - * @param string $sha blob SHA of the file being deleted - * @param string|null $branch name of a branch - * @param null|array $committer information about the committer - * - * @throws MissingArgumentException - * - * @return array information about the updated file - */ - public function rm($username, $repository, $path, $message, $sha, $branch = null, ?array $committer = null) - { - $url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents/'.rawurlencode($path); - - $parameters = [ - 'message' => $message, - 'sha' => $sha, - ]; - - if (null !== $branch) { - $parameters['branch'] = $branch; - } - - if (null !== $committer) { - if (!isset($committer['name'], $committer['email'])) { - throw new MissingArgumentException(['name', 'email']); - } - $parameters['committer'] = $committer; - } - - return $this->delete($url, $parameters); - } - - /** - * Get content of archives in a repository. - * - * @link http://developer.github.com/v3/repos/contents/ - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * @param string $format format of archive: tarball or zipball - * @param string|null $reference reference to a branch or commit - * - * @return string repository archive binary data - */ - public function archive($username, $repository, $format, $reference = null) - { - if (!in_array($format, ['tarball', 'zipball'])) { - $format = 'tarball'; - } - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/'.rawurlencode($format). - ((null !== $reference) ? ('/'.rawurlencode($reference)) : '')); - } - - /** - * Get the contents of a file in a repository. - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * @param string $path path to file - * @param string|null $reference reference to a branch or commit - * - * @throws InvalidArgumentException If $path is not a file or if its encoding is different from base64 - * @throws ErrorException If $path doesn't include a 'content' index - * - * @return string|null content of file, or null in case of base64_decode failure - */ - public function download($username, $repository, $path, $reference = null) - { - $file = $this->show($username, $repository, $path, $reference); - - if (!isset($file['type']) || !in_array($file['type'], ['file', 'symlink'], true)) { - throw new InvalidArgumentException(sprintf('Path "%s" is not a file or a symlink to a file.', $path)); - } - - if (!isset($file['content'])) { - throw new ErrorException(sprintf('Unable to access "content" for file "%s" (possible keys: "%s").', $path, implode(', ', array_keys($file)))); - } - - if (!isset($file['encoding'])) { - throw new InvalidArgumentException(sprintf('Can\'t decode content of file "%s", as no encoding is defined.', $path)); - } - - if ('base64' !== $file['encoding']) { - throw new InvalidArgumentException(sprintf('Encoding "%s" of file "%s" is not supported.', $file['encoding'], $path)); - } - - return base64_decode($file['content']) ?: null; - } - - /** - * Get the raw content of a file in a repository. - * - * Use this method instead of the download method if your file is bigger than 1MB - * - * @see https://docs.github.com/en/rest/repos/contents - * - * @param string $username the user who owns the repository - * @param string $repository the name of the repository - * @param string $path path to file - * @param string|null $reference reference to a branch or commit - * - * @return array|string - */ - public function rawDownload($username, $repository, $path, $reference = null) - { - return $this->show($username, $repository, $path, $reference, [ - 'Accept' => 'application/vnd.github.VERSION.raw', - ]); - } -} diff --git a/lib/Github/Api/Repository/DeployKeys.php b/lib/Github/Api/Repository/DeployKeys.php deleted file mode 100644 index 0e45ccb626a..00000000000 --- a/lib/Github/Api/Repository/DeployKeys.php +++ /dev/null @@ -1,49 +0,0 @@ - - */ -class DeployKeys extends AbstractApi -{ - public function all($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/keys'); - } - - public function show($username, $repository, $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/keys/'.rawurlencode($id)); - } - - public function create($username, $repository, array $params) - { - if (!isset($params['title'], $params['key'])) { - throw new MissingArgumentException(['title', 'key']); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/keys', $params); - } - - public function update($username, $repository, $id, array $params) - { - if (!isset($params['title'], $params['key'])) { - throw new MissingArgumentException(['title', 'key']); - } - - $this->remove($username, $repository, $id); - - return $this->create($username, $repository, $params); - } - - public function remove($username, $repository, $id) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/keys/'.rawurlencode($id)); - } -} diff --git a/lib/Github/Api/Repository/Downloads.php b/lib/Github/Api/Repository/Downloads.php deleted file mode 100644 index c959c61545e..00000000000 --- a/lib/Github/Api/Repository/Downloads.php +++ /dev/null @@ -1,60 +0,0 @@ - - */ -class Downloads extends AbstractApi -{ - /** - * List downloads in selected repository. - * - * @link http://developer.github.com/v3/repos/downloads/#list-downloads-for-a-repository - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * - * @return array - */ - public function all($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/downloads'); - } - - /** - * Get a download in selected repository. - * - * @link http://developer.github.com/v3/repos/downloads/#get-a-single-download - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * @param int $id the id of the download file - * - * @return array - */ - public function show($username, $repository, $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/downloads/'.$id); - } - - /** - * Delete a download in selected repository. - * - * @link http://developer.github.com/v3/repos/downloads/#delete-a-download - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * @param int $id the id of the download file - * - * @return array - */ - public function remove($username, $repository, $id) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/downloads/'.$id); - } -} diff --git a/lib/Github/Api/Repository/Forks.php b/lib/Github/Api/Repository/Forks.php deleted file mode 100644 index 961dc64944a..00000000000 --- a/lib/Github/Api/Repository/Forks.php +++ /dev/null @@ -1,27 +0,0 @@ - - */ -class Forks extends AbstractApi -{ - public function all($username, $repository, array $params = []) - { - if (isset($params['sort']) && !in_array($params['sort'], ['newest', 'oldest', 'watchers'])) { - $params['sort'] = 'newest'; - } - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/forks', array_merge(['page' => 1], $params)); - } - - public function create($username, $repository, array $params = []) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/forks', $params); - } -} diff --git a/lib/Github/Api/Repository/Hooks.php b/lib/Github/Api/Repository/Hooks.php deleted file mode 100644 index be87e0146b6..00000000000 --- a/lib/Github/Api/Repository/Hooks.php +++ /dev/null @@ -1,57 +0,0 @@ - - */ -class Hooks extends AbstractApi -{ - public function all($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/hooks'); - } - - public function show($username, $repository, $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/hooks/'.rawurlencode($id)); - } - - public function create($username, $repository, array $params) - { - if (!isset($params['name'], $params['config'])) { - throw new MissingArgumentException(['name', 'config']); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/hooks', $params); - } - - public function update($username, $repository, $id, array $params) - { - if (!isset($params['config'])) { - throw new MissingArgumentException(['config']); - } - - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/hooks/'.rawurlencode($id), $params); - } - - public function ping($username, $repository, $id) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/hooks/'.rawurlencode($id).'/pings'); - } - - public function test($username, $repository, $id) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/hooks/'.rawurlencode($id).'/tests'); - } - - public function remove($username, $repository, $id) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/hooks/'.rawurlencode($id)); - } -} diff --git a/lib/Github/Api/Repository/Labels.php b/lib/Github/Api/Repository/Labels.php deleted file mode 100644 index 28ca4d53c0f..00000000000 --- a/lib/Github/Api/Repository/Labels.php +++ /dev/null @@ -1,43 +0,0 @@ - - */ -class Labels extends AbstractApi -{ - public function all($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels'); - } - - public function show($username, $repository, $label) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels/'.rawurlencode($label)); - } - - public function create($username, $repository, array $params) - { - if (!isset($params['name'], $params['color'])) { - throw new MissingArgumentException(['name', 'color']); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels', $params); - } - - public function update($username, $repository, $label, array $params) - { - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels/'.rawurlencode($label), $params); - } - - public function remove($username, $repository, $label) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/labels/'.rawurlencode($label)); - } -} diff --git a/lib/Github/Api/Repository/Pages.php b/lib/Github/Api/Repository/Pages.php deleted file mode 100644 index b641cb957c0..00000000000 --- a/lib/Github/Api/Repository/Pages.php +++ /dev/null @@ -1,60 +0,0 @@ - - */ -class Pages extends AbstractApi -{ - use AcceptHeaderTrait; - - public function show($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages'); - } - - public function enable($username, $repository, array $params = []) - { - $this->acceptHeaderValue = 'application/vnd.github.switcheroo-preview+json'; - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages', $params); - } - - public function disable($username, $repository) - { - $this->acceptHeaderValue = 'application/vnd.github.switcheroo-preview+json'; - - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages'); - } - - public function update($username, $repository, array $params = []) - { - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages', $params); - } - - public function requestBuild($username, $repository) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages/builds'); - } - - public function builds($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages/builds'); - } - - public function showLatestBuild($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages/builds/latest'); - } - - public function showBuild($username, $repository, $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pages/builds/'.rawurlencode($id)); - } -} diff --git a/lib/Github/Api/Repository/Projects.php b/lib/Github/Api/Repository/Projects.php deleted file mode 100644 index 9db29f5578d..00000000000 --- a/lib/Github/Api/Repository/Projects.php +++ /dev/null @@ -1,23 +0,0 @@ -get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects', array_merge(['page' => 1], $params)); - } - - public function create($username, $repository, array $params) - { - if (!isset($params['name'])) { - throw new MissingArgumentException(['name']); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/projects', $params); - } -} diff --git a/lib/Github/Api/Repository/Protection.php b/lib/Github/Api/Repository/Protection.php deleted file mode 100644 index b559557a944..00000000000 --- a/lib/Github/Api/Repository/Protection.php +++ /dev/null @@ -1,440 +0,0 @@ - - */ -class Protection extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * Retrieves configured protection for the provided branch. - * - * @link https://developer.github.com/v3/repos/branches/#get-branch-protection - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * - * @return array The branch protection information - */ - public function show($username, $repository, $branch) - { - // Preview endpoint - $this->acceptHeaderValue = 'application/vnd.github.luke-cage-preview+json'; - - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection'); - } - - /** - * Updates the repo's branch protection. - * - * @link https://developer.github.com/v3/repos/branches/#update-branch-protection - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The branch protection information - * - * @return array The updated branch protection information - */ - public function update($username, $repository, $branch, array $params = []) - { - // Preview endpoint - $this->acceptHeaderValue = 'application/vnd.github.luke-cage-preview+json'; - - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection', $params); - } - - /** - * Remove the repo's branch protection. - * - * @link https://developer.github.com/v3/repos/branches/#remove-branch-protection - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - */ - public function remove($username, $repository, $branch) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection'); - } - - /** - * Get required status checks of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#get-required-status-checks-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * - * @return array The required status checks information - */ - public function showStatusChecks($username, $repository, $branch) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks'); - } - - /** - * Update required status checks of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#update-required-status-checks-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The branch status checks information - * - * @return array The updated branch status checks information - */ - public function updateStatusChecks($username, $repository, $branch, array $params = []) - { - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks', $params); - } - - /** - * Remove required status checks of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#remove-required-status-checks-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - */ - public function removeStatusChecks($username, $repository, $branch) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks'); - } - - /** - * List required status checks contexts of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#list-required-status-checks-contexts-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * - * @return array The required status checks contexts information - */ - public function showStatusChecksContexts($username, $repository, $branch) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks/contexts'); - } - - /** - * Replace required status checks contexts of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#replace-required-status-checks-contexts-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The branch status checks contexts information - * - * @return array The new branch status checks contexts information - */ - public function replaceStatusChecksContexts($username, $repository, $branch, array $params = []) - { - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks/contexts', $params); - } - - /** - * Add required status checks contexts of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#add-required-status-checks-contexts-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The branch status checks contexts information - * - * @return array The updated branch status checks contexts information - */ - public function addStatusChecksContexts($username, $repository, $branch, array $params = []) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks/contexts', $params); - } - - /** - * Remove required status checks contexts of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#remove-required-status-checks-contexts-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The branch status checks contexts information - * - * @return array The updated branch status checks contexts information - */ - public function removeStatusChecksContexts($username, $repository, $branch, array $params = []) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_status_checks/contexts', $params); - } - - /** - * Get pull request review enforcement of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#get-pull-request-review-enforcement-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * - * @return array The pull request review enforcement information - */ - public function showPullRequestReviewEnforcement($username, $repository, $branch) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_pull_request_reviews'); - } - - /** - * Update pull request review enforcement of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#update-pull-request-review-enforcement-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The branch status checks information - * - * @return array The updated branch status checks information - */ - public function updatePullRequestReviewEnforcement($username, $repository, $branch, array $params = []) - { - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_pull_request_reviews', $params); - } - - /** - * Remove pull request review enforcement of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#remove-pull-request-review-enforcement-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - */ - public function removePullRequestReviewEnforcement($username, $repository, $branch) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/required_pull_request_reviews'); - } - - /** - * Get admin enforcement of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#get-admin-enforcement-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * - * @return array The admin enforcement information - */ - public function showAdminEnforcement($username, $repository, $branch) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/enforce_admins'); - } - - /** - * Add admin enforcement of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#add-admin-enforcement-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * - * @return array The updated admin enforcement information - */ - public function addAdminEnforcement($username, $repository, $branch) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/enforce_admins'); - } - - /** - * Remove admin enforcement of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#remove-admin-enforcement-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - */ - public function removeAdminEnforcement($username, $repository, $branch) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/enforce_admins'); - } - - /** - * Get restrictions of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#get-restrictions-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * - * @return array The branch restrictions information - */ - public function showRestrictions($username, $repository, $branch) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions'); - } - - /** - * Remove restrictions of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#remove-restrictions-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - */ - public function removeRestrictions($username, $repository, $branch) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions'); - } - - /** - * List team restrictions of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#list-team-restrictions-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * - * @return array The branch team restrictions information - */ - public function showTeamRestrictions($username, $repository, $branch) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/teams'); - } - - /** - * Replace team restrictions of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#replace-team-restrictions-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The list of team slugs with push access - * - * @return array The new branch team restrictions information - */ - public function replaceTeamRestrictions($username, $repository, $branch, array $params = []) - { - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/teams', $params); - } - - /** - * Add team restrictions of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#add-team-restrictions-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The list of team slugs with push access - * - * @return array The branch team restrictions information - */ - public function addTeamRestrictions($username, $repository, $branch, array $params = []) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/teams', $params); - } - - /** - * Remove team restrictions of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#remove-team-restrictions-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The list of team slugs with push access - * - * @return array The updated branch team restrictions information - */ - public function removeTeamRestrictions($username, $repository, $branch, array $params = []) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/teams', $params); - } - - /** - * List user restrictions of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#list-user-restrictions-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * - * @return array The branch user restrictions information - */ - public function showUserRestrictions($username, $repository, $branch) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/users'); - } - - /** - * Replace user restrictions of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#replace-user-restrictions-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The list of user logins with push access - * - * @return array The new branch user restrictions information - */ - public function replaceUserRestrictions($username, $repository, $branch, array $params = []) - { - return $this->put('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/users', $params); - } - - /** - * Add user restrictions of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#add-user-restrictions-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The list of user logins with push access - * - * @return array The branch user restrictions information - */ - public function addUserRestrictions($username, $repository, $branch, array $params = []) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/users', $params); - } - - /** - * Remove user restrictions of protected branch. - * - * @link https://developer.github.com/v3/repos/branches/#remove-user-restrictions-of-protected-branch - * - * @param string $username The user who owns the repository - * @param string $repository The name of the repo - * @param string $branch The name of the branch - * @param array $params The list of user logins with push access - * - * @return array The updated branch user restrictions information - */ - public function removeUserRestrictions($username, $repository, $branch, array $params = []) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/branches/'.rawurlencode($branch).'/protection/restrictions/users', $params); - } -} diff --git a/lib/Github/Api/Repository/Releases.php b/lib/Github/Api/Repository/Releases.php deleted file mode 100644 index 6cd7fda4f0a..00000000000 --- a/lib/Github/Api/Repository/Releases.php +++ /dev/null @@ -1,141 +0,0 @@ - - * @author Evgeniy Guseletov - */ -class Releases extends AbstractApi -{ - /** - * Get the latest release. - * - * @param string $username - * @param string $repository - * - * @return array - */ - public function latest($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/latest'); - } - - /** - * List releases for a tag. - * - * @param string $username - * @param string $repository - * @param string $tag - * - * @return array - */ - public function tag($username, $repository, $tag) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/tags/'.rawurlencode($tag)); - } - - /** - * List releases in selected repository. - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * @param array $params the additional parameters like milestone, assignees, labels, sort, direction - * - * @return array - */ - public function all($username, $repository, array $params = []) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases', $params); - } - - /** - * Get a release in selected repository. - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * @param int $id the id of the release - * - * @return array - */ - public function show($username, $repository, $id) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.$id); - } - - /** - * Generate release notes content for a release. - * - * @param string $username - * @param string $repository - * @param array $params - * - * @return array - */ - public function generateNotes($username, $repository, array $params) - { - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/generate-notes', $params); - } - - /** - * Create new release in selected repository. - * - * @param string $username - * @param string $repository - * @param array $params - * - * @throws MissingArgumentException - * - * @return array - */ - public function create($username, $repository, array $params) - { - if (!isset($params['tag_name'])) { - throw new MissingArgumentException('tag_name'); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases', $params); - } - - /** - * Edit release in selected repository. - * - * @param string $username - * @param string $repository - * @param int $id - * @param array $params - * - * @return array - */ - public function edit($username, $repository, $id, array $params) - { - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.$id, $params); - } - - /** - * Delete a release in selected repository (Not thoroughly tested!). - * - * @param string $username the user who owns the repo - * @param string $repository the name of the repo - * @param int $id the id of the release - * - * @return array - */ - public function remove($username, $repository, $id) - { - return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.$id); - } - - /** - * @return Assets - */ - public function assets() - { - return new Assets($this->getClient()); - } -} diff --git a/lib/Github/Api/Repository/SecretScanning.php b/lib/Github/Api/Repository/SecretScanning.php deleted file mode 100644 index 968d352c3ec..00000000000 --- a/lib/Github/Api/Repository/SecretScanning.php +++ /dev/null @@ -1,64 +0,0 @@ -get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/secret-scanning/alerts', $params); - } - - /** - * @link https://docs.github.com/en/enterprise-server@3.5/rest/secret-scanning#get-a-secret-scanning-alert - * - * @param string $username - * @param string $repository - * @param int $alertNumber - * - * @return array|string - */ - public function getAlert(string $username, string $repository, int $alertNumber) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/secret-scanning/alerts/'.$alertNumber); - } - - /** - * @link https://docs.github.com/en/enterprise-server@3.5/rest/secret-scanning#update-a-secret-scanning-alert - * - * @param string $username - * @param string $repository - * @param int $alertNumber - * @param array $params - * - * @return array|string - */ - public function updateAlert(string $username, string $repository, int $alertNumber, array $params = []) - { - return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/secret-scanning/alerts/'.$alertNumber, $params); - } - - /** - * @link https://docs.github.com/en/enterprise-server@3.5/rest/secret-scanning#list-locations-for-a-secret-scanning-alert - * - * @param string $username - * @param string $repository - * @param int $alertNumber - * @param array $params - * - * @return array|string - */ - public function locations(string $username, string $repository, int $alertNumber, array $params = []) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/secret-scanning/alerts/'.$alertNumber.'/locations', $params); - } -} diff --git a/lib/Github/Api/Repository/Stargazers.php b/lib/Github/Api/Repository/Stargazers.php deleted file mode 100644 index bef73b9a6bd..00000000000 --- a/lib/Github/Api/Repository/Stargazers.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @author Tobias Nyholm - */ -class Stargazers extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * Configure the body type. - * - * @see https://developer.github.com/v3/activity/starring/#alternative-response-with-star-creation-timestamps - * - * @param string $bodyType - * - * @return $this - */ - public function configure($bodyType = null) - { - if ('star' === $bodyType) { - $this->acceptHeaderValue = sprintf('application/vnd.github.%s.star+json', $this->getApiVersion()); - } - - return $this; - } - - public function all($username, $repository) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/stargazers'); - } -} diff --git a/lib/Github/Api/Repository/Statuses.php b/lib/Github/Api/Repository/Statuses.php deleted file mode 100644 index c62f4edd8b6..00000000000 --- a/lib/Github/Api/Repository/Statuses.php +++ /dev/null @@ -1,63 +0,0 @@ - - */ -class Statuses extends AbstractApi -{ - /** - * @link http://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-sha - * - * @param string $username - * @param string $repository - * @param string $sha - * - * @return array - */ - public function show($username, $repository, $sha) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($sha).'/statuses'); - } - - /** - * @link https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref - * - * @param string $username - * @param string $repository - * @param string $sha - * - * @return array - */ - public function combined($username, $repository, $sha) - { - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($sha).'/status'); - } - - /** - * @link http://developer.github.com/v3/repos/statuses/#create-a-status - * - * @param string $username - * @param string $repository - * @param string $sha - * @param array $params - * - * @throws MissingArgumentException - * - * @return array - */ - public function create($username, $repository, $sha, array $params = []) - { - if (!isset($params['state'])) { - throw new MissingArgumentException('state'); - } - - return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/statuses/'.rawurlencode($sha), $params); - } -} diff --git a/lib/Github/Api/Repository/Traffic.php b/lib/Github/Api/Repository/Traffic.php deleted file mode 100644 index d5b550c8521..00000000000 --- a/lib/Github/Api/Repository/Traffic.php +++ /dev/null @@ -1,67 +0,0 @@ - - */ -class Traffic extends AbstractApi -{ - /** - * @link https://developer.github.com/v3/repos/traffic/#list-referrers - * - * @param string $owner - * @param string $repository - * - * @return array - */ - public function referers($owner, $repository) - { - return $this->get('/repos/'.rawurlencode($owner).'/'.rawurlencode($repository).'/traffic/popular/referrers'); - } - - /** - * @link https://developer.github.com/v3/repos/traffic/#list-paths - * - * @param string $owner - * @param string $repository - * - * @return array - */ - public function paths($owner, $repository) - { - return $this->get('/repos/'.rawurlencode($owner).'/'.rawurlencode($repository).'/traffic/popular/paths'); - } - - /** - * @link https://developer.github.com/v3/repos/traffic/#views - * - * @param string $owner - * @param string $repository - * @param string $per - * - * @return array - */ - public function views($owner, $repository, $per = 'day') - { - return $this->get('/repos/'.rawurlencode($owner).'/'.rawurlencode($repository).'/traffic/views?per='.rawurlencode($per)); - } - - /** - * @link https://developer.github.com/v3/repos/traffic/#clones - * - * @param string $owner - * @param string $repository - * @param string $per - * - * @return array - */ - public function clones($owner, $repository, $per = 'day') - { - return $this->get('/repos/'.rawurlencode($owner).'/'.rawurlencode($repository).'/traffic/clones?per='.rawurlencode($per)); - } -} diff --git a/lib/Github/Api/Search.php b/lib/Github/Api/Search.php deleted file mode 100644 index 96a51ea6a46..00000000000 --- a/lib/Github/Api/Search.php +++ /dev/null @@ -1,130 +0,0 @@ - - */ -class Search extends AbstractApi -{ - use AcceptHeaderTrait; - - /** - * Search repositories by filter (q). - * - * @link https://developer.github.com/v3/search/#search-repositories - * - * @param string $q the filter - * @param string $sort the sort field - * @param string $order asc/desc - * - * @return array list of repositories found - */ - public function repositories($q, $sort = 'updated', $order = 'desc') - { - return $this->get('/search/repositories', ['q' => $q, 'sort' => $sort, 'order' => $order]); - } - - /** - * Search issues by filter (q). - * - * @link https://developer.github.com/v3/search/#search-issues - * - * @param string $q the filter - * @param string $sort the sort field - * @param string $order asc/desc - * - * @return array list of issues found - */ - public function issues($q, $sort = 'updated', $order = 'desc') - { - return $this->get('/search/issues', ['q' => $q, 'sort' => $sort, 'order' => $order]); - } - - /** - * Search code by filter (q). - * - * @link https://developer.github.com/v3/search/#search-code - * - * @param string $q the filter - * @param string $sort the sort field - * @param string $order asc/desc - * - * @return array list of code found - */ - public function code($q, $sort = 'updated', $order = 'desc') - { - return $this->get('/search/code', ['q' => $q, 'sort' => $sort, 'order' => $order]); - } - - /** - * Search code by filter (q), but will return additional data to highlight - * the matched results. - * - * @link https://docs.github.com/en/rest/reference/search#text-match-metadata - * - * @return array list of code found - */ - public function codeWithMatch(string $q, string $sort = 'updated', string $order = 'desc'): array - { - $this->acceptHeaderValue = 'application/vnd.github.v3.text-match+json'; - - return $this->code($q, $sort, $order); - } - - /** - * Search users by filter (q). - * - * @link https://developer.github.com/v3/search/#search-users - * - * @param string $q the filter - * @param string $sort the sort field - * @param string $order asc/desc - * - * @return array list of users found - */ - public function users($q, $sort = 'updated', $order = 'desc') - { - return $this->get('/search/users', ['q' => $q, 'sort' => $sort, 'order' => $order]); - } - - /** - * Search commits by filter (q). - * - * @link https://developer.github.com/v3/search/#search-commits - * - * @param string $q the filter - * @param string $sort the sort field - * @param string $order sort order. asc/desc - * - * @return array - */ - public function commits($q, $sort = null, $order = 'desc') - { - // This api is in preview mode, so set the correct accept-header - $this->acceptHeaderValue = 'application/vnd.github.cloak-preview'; - - return $this->get('/search/commits', ['q' => $q, 'sort' => $sort, 'order' => $order]); - } - - /** - * Search topics by filter (q). - * - * @link https://developer.github.com/v3/search/#search-topics - * - * @param string $q the filter - * - * @return array - */ - public function topics($q) - { - // This api is in preview mode, so set the correct accept-header - $this->acceptHeaderValue = 'application/vnd.github.mercy-preview+json'; - - return $this->get('/search/topics', ['q' => $q]); - } -} diff --git a/lib/Github/Api/User.php b/lib/Github/Api/User.php deleted file mode 100644 index d436a2b835e..00000000000 --- a/lib/Github/Api/User.php +++ /dev/null @@ -1,259 +0,0 @@ - - * @author Thibault Duplessis - */ -class User extends AbstractApi -{ - /** - * Request all users. - * - * @link https://developer.github.com/v3/users/#get-all-users - * - * @param int|null $id ID of the last user that you've seen - * - * @return array list of users found - */ - public function all($id = null) - { - if (!is_int($id)) { - return $this->get('/users'); - } - - return $this->get('/users', ['since' => $id]); - } - - /** - * Get extended information about a user by its username. - * - * @link http://developer.github.com/v3/users/ - * - * @param string $username the username to show - * - * @return array information about the user - */ - public function show($username) - { - return $this->get('/users/'.rawurlencode($username)); - } - - /** - * Get extended information about a user by its id. - * Note: at time of writing this is an undocumented feature but GitHub support have advised that it can be relied on. - * - * @link http://developer.github.com/v3/users/ - * - * @param int $id the id of the user to show - * - * @return array information about the user - */ - public function showById($id) - { - return $this->get('/user/'.$id); - } - - /** - * Get extended information about a user by its username. - * - * @link https://developer.github.com/v3/orgs/ - * - * @param string $username the username to show - * - * @return array information about organizations that user belongs to - */ - public function organizations($username) - { - return $this->get('/users/'.rawurlencode($username).'/orgs'); - } - - /** - * Get user organizations. - * - * @link https://developer.github.com/v3/orgs/#list-your-organizations - * - * @return array information about organizations that authenticated user belongs to - */ - public function orgs() - { - return $this->get('/user/orgs'); - } - - /** - * Request the users that a specific user is following. - * - * @link http://developer.github.com/v3/users/followers/ - * - * @param string $username the username - * @param array $parameters parameters for the query string - * @param array $requestHeaders additional headers to set in the request - * - * @return array list of followed users - */ - public function following($username, array $parameters = [], array $requestHeaders = []) - { - return $this->get('/users/'.rawurlencode($username).'/following', $parameters, $requestHeaders); - } - - /** - * Request the users following a specific user. - * - * @link http://developer.github.com/v3/users/followers/ - * - * @param string $username the username - * @param array $parameters parameters for the query string - * @param array $requestHeaders additional headers to set in the request - * - * @return array list of following users - */ - public function followers($username, array $parameters = [], array $requestHeaders = []) - { - return $this->get('/users/'.rawurlencode($username).'/followers', $parameters, $requestHeaders); - } - - /** - * Request starred repositories that a specific user has starred. - * - * @link http://developer.github.com/v3/activity/starring/ - * - * @param string $username the username - * @param int $page the page number of the paginated result set - * @param int $perPage the number of results per page - * @param string $sort sort by (possible values: created, updated) - * @param string $direction direction of sort (possible values: asc, desc) - * - * @return array list of starred repositories - */ - public function starred($username, $page = 1, $perPage = 30, $sort = 'created', $direction = 'desc') - { - return $this->get('/users/'.rawurlencode($username).'/starred', [ - 'page' => $page, - 'per_page' => $perPage, - 'sort' => $sort, - 'direction' => $direction, - ]); - } - - /** - * Request the repository that a specific user is watching. - * - * @link http://developer.github.com/v3/activity/watching/ - * - * @param string $username the username - * - * @return array list of watched repositories - */ - public function subscriptions($username) - { - return $this->get('/users/'.rawurlencode($username).'/subscriptions'); - } - - /** - * List public repositories for the specified user. - * - * @link https://developer.github.com/v3/repos/#list-user-repositories - * - * @param string $username the username - * @param string $type role in the repository - * @param string $sort sort by - * @param string $direction direction of sort, asc or desc - * @param string $visibility visibility of repository - * @param string $affiliation relationship to repository - * - * @return array list of the user repositories - */ - public function repositories($username, $type = 'owner', $sort = 'full_name', $direction = 'asc', $visibility = 'all', $affiliation = 'owner,collaborator,organization_member') - { - return $this->get('/users/'.rawurlencode($username).'/repos', [ - 'type' => $type, - 'sort' => $sort, - 'direction' => $direction, - 'visibility' => $visibility, - 'affiliation' => $affiliation, - ]); - } - - /** - * List repositories that are accessible to the authenticated user. - * - * @link https://developer.github.com/v3/repos/#list-your-repositories - * - * @param array $params visibility, affiliation, type, sort, direction - * - * @return array list of the user repositories - */ - public function myRepositories(array $params = []) - { - return $this->get('/user/repos', $params); - } - - /** - * Get the public gists for a user. - * - * @link http://developer.github.com/v3/gists/ - * - * @param string $username the username - * - * @return array list of the user gists - */ - public function gists($username) - { - return $this->get('/users/'.rawurlencode($username).'/gists'); - } - - /** - * Get the public keys for a user. - * - * @link http://developer.github.com/v3/users/keys/#list-public-keys-for-a-user - * - * @param string $username the username - * - * @return array list of the user public keys - */ - public function keys($username) - { - return $this->get('/users/'.rawurlencode($username).'/keys'); - } - - /** - * List events performed by a user. - * - * @link http://developer.github.com/v3/activity/events/#list-public-events-performed-by-a-user - * - * @param string $username - * - * @return array - */ - public function publicEvents($username) - { - return $this->get('/users/'.rawurlencode($username).'/events/public'); - } - - /** - * List events performed by an authenticated user. - * - * @link https://docs.github.com/en/rest/reference/activity#list-events-for-the-authenticated-user - * - * @return array - */ - public function events(string $username) - { - return $this->get('/users/'.rawurlencode($username).'/events'); - } - - /** - * @return Migration - */ - public function migration(): Migration - { - return new Migration($this->getClient()); - } -} diff --git a/lib/Github/Api/User/Migration.php b/lib/Github/Api/User/Migration.php deleted file mode 100644 index 4e1b61ca244..00000000000 --- a/lib/Github/Api/User/Migration.php +++ /dev/null @@ -1,83 +0,0 @@ -get('/user/migrations', $params); - } - - /** - * @link https://docs.github.com/en/rest/migrations/users?apiVersion=2022-11-28#start-a-user-migration - * - * @param array $params - * - * @return array|string - */ - public function start(array $params) - { - return $this->post('/user/migrations', $params); - } - - /** - * @link https://docs.github.com/en/rest/migrations/users?apiVersion=2022-11-28#get-a-user-migration-status - * - * @param int $migrationId - * @param array $params - * - * @return array|string - */ - public function status(int $migrationId, array $params = []) - { - return $this->get('/user/migrations/'.$migrationId, $params); - } - - /** - * @link https://docs.github.com/en/rest/migrations/users?apiVersion=2022-11-28#delete-a-user-migration-archive - * - * @param int $migrationId - * - * @return array|string - */ - public function deleteArchive(int $migrationId) - { - return $this->delete('/user/migrations/'.$migrationId.'/archive'); - } - - /** - * @link https://docs.github.com/en/rest/migrations/users?apiVersion=2022-11-28#unlock-a-user-repository - * - * @param int $migrationId - * @param string $repository - * - * @return array|string - */ - public function unlockRepo(int $migrationId, string $repository) - { - return $this->delete('/user/migrations/'.$migrationId.'/repos/'.rawurlencode($repository).'/lock'); - } - - /** - * @link https://docs.github.com/en/rest/migrations/users?apiVersion=2022-11-28#list-repositories-for-a-user-migration - * - * @param int $migrationId - * @param array $params - * - * @return array|string - */ - public function repos(int $migrationId, array $params = []) - { - return $this->get('/user/migrations/'.$migrationId.'/repositories', $params); - } -} diff --git a/lib/Github/AuthMethod.php b/lib/Github/AuthMethod.php deleted file mode 100644 index 4a390699a3c..00000000000 --- a/lib/Github/AuthMethod.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * Website: http://github.com/KnpLabs/php-github-api - */ -class Client -{ - /** - * Authenticate using a client_id/client_secret combination. - * - * @var string - * - * @deprecated Use the AuthMethod const - */ - const AUTH_CLIENT_ID = AuthMethod::CLIENT_ID; - - /** - * Authenticate using a GitHub access token. - * - * @var string - * - * @deprecated Use the AuthMethod const - */ - const AUTH_ACCESS_TOKEN = AuthMethod::ACCESS_TOKEN; - - /** - * Constant for authentication method. - * - * Indicates JSON Web Token authentication required for GitHub apps access - * to the API. - * - * @var string - * - * @deprecated Use the AuthMethod const - */ - const AUTH_JWT = AuthMethod::JWT; - - /** - * @var string - */ - private $apiVersion; - - /** - * @var Builder - */ - private $httpClientBuilder; - - /** - * @var History - */ - private $responseHistory; - - /** - * Instantiate a new GitHub client. - * - * @param Builder|null $httpClientBuilder - * @param string|null $apiVersion - * @param string|null $enterpriseUrl - */ - public function __construct(?Builder $httpClientBuilder = null, $apiVersion = null, $enterpriseUrl = null) - { - $this->responseHistory = new History(); - $this->httpClientBuilder = $builder = $httpClientBuilder ?? new Builder(); - $this->apiVersion = $apiVersion ?: 'v3'; - - $builder->addPlugin(new GithubExceptionThrower()); - $builder->addPlugin(new Plugin\HistoryPlugin($this->responseHistory)); - $builder->addPlugin(new Plugin\RedirectPlugin()); - $builder->addPlugin(new Plugin\AddHostPlugin(Psr17FactoryDiscovery::findUriFactory()->createUri('https://api.github.com'))); - $builder->addPlugin(new Plugin\HeaderDefaultsPlugin([ - 'User-Agent' => 'php-github-api (http://github.com/KnpLabs/php-github-api)', - 'Accept' => sprintf('application/vnd.github.%s+json', $this->apiVersion), - ])); - - if ($enterpriseUrl) { - $this->setEnterpriseUrl($enterpriseUrl); - } - } - - /** - * Create a Github\Client using a HTTP client. - * - * @param ClientInterface $httpClient - * - * @return Client - */ - public static function createWithHttpClient(ClientInterface $httpClient): self - { - $builder = new Builder($httpClient); - - return new self($builder); - } - - /** - * @param string $name - * - * @throws InvalidArgumentException - * - * @return AbstractApi - */ - public function api($name): AbstractApi - { - switch ($name) { - case 'me': - case 'current_user': - case 'currentUser': - $api = new Api\CurrentUser($this); - break; - case 'codeOfConduct': - $api = new Api\Miscellaneous\CodeOfConduct($this); - break; - - case 'deployment': - case 'deployments': - $api = new Api\Deployment($this); - break; - - case 'ent': - case 'enterprise': - $api = new Api\Enterprise($this); - break; - - case 'emojis': - $api = new Api\Miscellaneous\Emojis($this); - break; - - case 'git': - case 'git_data': - case 'gitData': - $api = new Api\GitData($this); - break; - - case 'gist': - case 'gists': - $api = new Api\Gists($this); - break; - - case 'gitignore': - $api = new Api\Miscellaneous\Gitignore($this); - break; - - case 'apps': - $api = new Api\Apps($this); - break; - - case 'issue': - case 'issues': - $api = new Api\Issue($this); - break; - - case 'markdown': - $api = new Api\Markdown($this); - break; - - case 'licenses': - $api = new Api\Miscellaneous\Licenses($this); - break; - - case 'notification': - case 'notifications': - $api = new Api\Notification($this); - break; - - case 'organization': - case 'organizations': - $api = new Api\Organization($this); - break; - - case 'org_project': - case 'orgProject': - case 'org_projects': - case 'orgProjects': - case 'organization_project': - case 'organizationProject': - case 'organization_projects': - case 'organizationProjects': - $api = new Api\Organization\Projects($this); - break; - - case 'pr': - case 'pulls': - case 'pullRequest': - case 'pull_request': - case 'pullRequests': - case 'pull_requests': - $api = new Api\PullRequest($this); - break; - - case 'rateLimit': - case 'rate_limit': - $api = new Api\RateLimit($this); - break; - - case 'repo': - case 'repos': - case 'repository': - case 'repositories': - $api = new Api\Repo($this); - break; - - case 'search': - $api = new Api\Search($this); - break; - - case 'team': - case 'teams': - $api = new Api\Organization\Teams($this); - break; - - case 'member': - case 'members': - $api = new Api\Organization\Members($this); - break; - - case 'user': - case 'users': - $api = new Api\User($this); - break; - - case 'authorization': - case 'authorizations': - $api = new Api\Authorizations($this); - break; - - case 'meta': - $api = new Api\Meta($this); - break; - - case 'graphql': - $api = new Api\GraphQL($this); - break; - - case 'outsideCollaborators': - case 'outside_collaborators': - $api = new Api\Organization\OutsideCollaborators($this); - break; - - case 'copilotUsage': - case 'copilot_usage': - $api = new Api\Copilot\Usage($this); - break; - - default: - throw new InvalidArgumentException(sprintf('Undefined api instance called: "%s"', $name)); - } - - return $api; - } - - /** - * Authenticate a user for all next requests. - * - * @param string $tokenOrLogin GitHub private token/username/client ID - * @param string|null $password GitHub password/secret (optionally can contain $authMethod) - * @param string|null $authMethod One of the AUTH_* class constants - * - * @throws InvalidArgumentException If no authentication method was given - * - * @return void - */ - public function authenticate($tokenOrLogin, $password = null, $authMethod = null): void - { - if (null === $authMethod && (AuthMethod::JWT === $password || AuthMethod::ACCESS_TOKEN === $password)) { - $authMethod = $password; - $password = null; - } - - if (null === $authMethod) { - throw new InvalidArgumentException('You need to specify authentication method!'); - } - - $this->getHttpClientBuilder()->removePlugin(Authentication::class); - $this->getHttpClientBuilder()->addPlugin(new Authentication($tokenOrLogin, $password, $authMethod)); - } - - /** - * Sets the URL of your GitHub Enterprise instance. - * - * @param string $enterpriseUrl URL of the API in the form of http(s)://hostname - * - * @return void - */ - private function setEnterpriseUrl($enterpriseUrl): void - { - $builder = $this->getHttpClientBuilder(); - $builder->removePlugin(Plugin\AddHostPlugin::class); - $builder->removePlugin(PathPrepend::class); - - $builder->addPlugin(new Plugin\AddHostPlugin(Psr17FactoryDiscovery::findUriFactory()->createUri($enterpriseUrl))); - - // For GHE, v4 API endpoint is at `api/graphql` so we don't want to add the version number - // For earlier versions add the version number after /api - if ($this->getApiVersion() === 'v4') { - $builder->addPlugin(new PathPrepend('/api')); - } else { - $builder->addPlugin(new PathPrepend(sprintf('/api/%s', $this->getApiVersion()))); - } - } - - /** - * @return string - */ - public function getApiVersion(): string - { - return $this->apiVersion; - } - - /** - * Add a cache plugin to cache responses locally. - * - * @param CacheItemPoolInterface $cachePool - * @param array $config - * - * @return void - */ - public function addCache(CacheItemPoolInterface $cachePool, array $config = []): void - { - $this->getHttpClientBuilder()->addCache($cachePool, $config); - } - - /** - * Remove the cache plugin. - * - * @return void - */ - public function removeCache(): void - { - $this->getHttpClientBuilder()->removeCache(); - } - - /** - * @param string $name - * @param array $args - * - * @return AbstractApi - */ - public function __call($name, $args): AbstractApi - { - try { - return $this->api($name); - } catch (InvalidArgumentException $e) { - throw new BadMethodCallException(sprintf('Undefined method called: "%s"', $name)); - } - } - - /** - * @return null|\Psr\Http\Message\ResponseInterface - */ - public function getLastResponse(): ?ResponseInterface - { - return $this->responseHistory->getLastResponse(); - } - - /** - * @return HttpMethodsClientInterface - */ - public function getHttpClient(): HttpMethodsClientInterface - { - return $this->getHttpClientBuilder()->getHttpClient(); - } - - /** - * @return Builder - */ - protected function getHttpClientBuilder(): Builder - { - return $this->httpClientBuilder; - } -} diff --git a/lib/Github/Exception/ApiLimitExceedException.php b/lib/Github/Exception/ApiLimitExceedException.php deleted file mode 100644 index c21f5c2729e..00000000000 --- a/lib/Github/Exception/ApiLimitExceedException.php +++ /dev/null @@ -1,46 +0,0 @@ - - */ -class ApiLimitExceedException extends RuntimeException -{ - /** @var int */ - private $limit; - /** @var int */ - private $reset; - - /** - * @param int $limit - * @param int $reset - * @param int $code - * @param Throwable|null $previous - */ - public function __construct(int $limit = 5000, int $reset = 1800, int $code = 0, ?Throwable $previous = null) - { - $this->limit = (int) $limit; - $this->reset = (int) $reset; - - parent::__construct(sprintf('You have reached GitHub hourly limit! Actual limit is: %d', $limit), $code, $previous); - } - - /** - * @return int - */ - public function getLimit(): int - { - return $this->limit; - } - - /** - * @return int - */ - public function getResetTime(): int - { - return $this->reset; - } -} diff --git a/lib/Github/Exception/BadMethodCallException.php b/lib/Github/Exception/BadMethodCallException.php deleted file mode 100644 index 22753d082f3..00000000000 --- a/lib/Github/Exception/BadMethodCallException.php +++ /dev/null @@ -1,10 +0,0 @@ - - */ -class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface -{ -} diff --git a/lib/Github/Exception/ErrorException.php b/lib/Github/Exception/ErrorException.php deleted file mode 100644 index b569f730779..00000000000 --- a/lib/Github/Exception/ErrorException.php +++ /dev/null @@ -1,10 +0,0 @@ - - */ -class ErrorException extends \ErrorException implements ExceptionInterface -{ -} diff --git a/lib/Github/Exception/ExceptionInterface.php b/lib/Github/Exception/ExceptionInterface.php deleted file mode 100644 index 87e6d2f77fa..00000000000 --- a/lib/Github/Exception/ExceptionInterface.php +++ /dev/null @@ -1,9 +0,0 @@ - - */ -class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface -{ -} diff --git a/lib/Github/Exception/MissingArgumentException.php b/lib/Github/Exception/MissingArgumentException.php deleted file mode 100644 index 742cdc5ac7f..00000000000 --- a/lib/Github/Exception/MissingArgumentException.php +++ /dev/null @@ -1,25 +0,0 @@ - - */ -class MissingArgumentException extends ErrorException -{ - /** - * @param string|array $required - * @param int $code - * @param Throwable|null $previous - */ - public function __construct($required, int $code = 0, ?Throwable $previous = null) - { - if (is_string($required)) { - $required = [$required]; - } - - parent::__construct(sprintf('One or more of required ("%s") parameters is missing!', implode('", "', $required)), $code, 1, __FILE__, __LINE__, $previous); - } -} diff --git a/lib/Github/Exception/RuntimeException.php b/lib/Github/Exception/RuntimeException.php deleted file mode 100644 index 827632e97f5..00000000000 --- a/lib/Github/Exception/RuntimeException.php +++ /dev/null @@ -1,10 +0,0 @@ - - */ -class RuntimeException extends \RuntimeException implements ExceptionInterface -{ -} diff --git a/lib/Github/Exception/SsoRequiredException.php b/lib/Github/Exception/SsoRequiredException.php deleted file mode 100644 index 09b9d63db08..00000000000 --- a/lib/Github/Exception/SsoRequiredException.php +++ /dev/null @@ -1,31 +0,0 @@ -url = $url; - - parent::__construct('Resource protected by organization SAML enforcement. You must grant your personal token access to this organization.', $code, $previous); - } - - /** - * @return string - */ - public function getUrl() - { - return $this->url; - } -} diff --git a/lib/Github/Exception/TwoFactorAuthenticationRequiredException.php b/lib/Github/Exception/TwoFactorAuthenticationRequiredException.php deleted file mode 100644 index 139033dff5b..00000000000 --- a/lib/Github/Exception/TwoFactorAuthenticationRequiredException.php +++ /dev/null @@ -1,30 +0,0 @@ -type = $type; - parent::__construct('Two factor authentication is enabled on this account', $code, $previous); - } - - /** - * @return string - */ - public function getType(): string - { - return $this->type; - } -} diff --git a/lib/Github/Exception/ValidationFailedException.php b/lib/Github/Exception/ValidationFailedException.php deleted file mode 100644 index c689e2d695d..00000000000 --- a/lib/Github/Exception/ValidationFailedException.php +++ /dev/null @@ -1,12 +0,0 @@ - - */ -class ValidationFailedException extends ErrorException -{ -} diff --git a/lib/Github/HttpClient/Builder.php b/lib/Github/HttpClient/Builder.php deleted file mode 100644 index c77f1ac83d8..00000000000 --- a/lib/Github/HttpClient/Builder.php +++ /dev/null @@ -1,214 +0,0 @@ - - */ -class Builder -{ - /** - * The object that sends HTTP messages. - * - * @var ClientInterface - */ - private $httpClient; - - /** - * A HTTP client with all our plugins. - * - * @var HttpMethodsClientInterface - */ - private $pluginClient; - - /** - * @var RequestFactoryInterface - */ - private $requestFactory; - - /** - * @var StreamFactoryInterface - */ - private $streamFactory; - - /** - * True if we should create a new Plugin client at next request. - * - * @var bool - */ - private $httpClientModified = true; - - /** - * @var Plugin[] - */ - private $plugins = []; - - /** - * This plugin is special treated because it has to be the very last plugin. - * - * @var Plugin\CachePlugin|null - */ - private $cachePlugin; - - /** - * Http headers. - * - * @var array - */ - private $headers = []; - - /** - * @param ClientInterface|null $httpClient - * @param RequestFactoryInterface|null $requestFactory - * @param StreamFactoryInterface|null $streamFactory - */ - public function __construct( - ?ClientInterface $httpClient = null, - ?RequestFactoryInterface $requestFactory = null, - ?StreamFactoryInterface $streamFactory = null - ) { - $this->httpClient = $httpClient ?? Psr18ClientDiscovery::find(); - $this->requestFactory = $requestFactory ?? Psr17FactoryDiscovery::findRequestFactory(); - $this->streamFactory = $streamFactory ?? Psr17FactoryDiscovery::findStreamFactory(); - } - - /** - * @return HttpMethodsClientInterface - */ - public function getHttpClient(): HttpMethodsClientInterface - { - if ($this->httpClientModified) { - $this->httpClientModified = false; - - $plugins = $this->plugins; - if ($this->cachePlugin) { - $plugins[] = $this->cachePlugin; - } - - $this->pluginClient = new HttpMethodsClient( - (new PluginClientFactory())->createClient($this->httpClient, $plugins), - $this->requestFactory, - $this->streamFactory - ); - } - - return $this->pluginClient; - } - - /** - * Add a new plugin to the end of the plugin chain. - * - * @param Plugin $plugin - * - * @return void - */ - public function addPlugin(Plugin $plugin): void - { - $this->plugins[] = $plugin; - $this->httpClientModified = true; - } - - /** - * Remove a plugin by its fully qualified class name (FQCN). - * - * @param string $fqcn - * - * @return void - */ - public function removePlugin(string $fqcn): void - { - foreach ($this->plugins as $idx => $plugin) { - if ($plugin instanceof $fqcn) { - unset($this->plugins[$idx]); - $this->httpClientModified = true; - } - } - } - - /** - * Clears used headers. - * - * @return void - */ - public function clearHeaders(): void - { - $this->headers = []; - - $this->removePlugin(Plugin\HeaderAppendPlugin::class); - $this->addPlugin(new Plugin\HeaderAppendPlugin($this->headers)); - } - - /** - * @param array $headers - * - * @return void - */ - public function addHeaders(array $headers): void - { - $this->headers = array_merge($this->headers, $headers); - - $this->removePlugin(Plugin\HeaderAppendPlugin::class); - $this->addPlugin(new Plugin\HeaderAppendPlugin($this->headers)); - } - - /** - * @param string $header - * @param string $headerValue - * - * @return void - */ - public function addHeaderValue(string $header, string $headerValue): void - { - if (!isset($this->headers[$header])) { - $this->headers[$header] = $headerValue; - } else { - $this->headers[$header] = array_merge((array) $this->headers[$header], [$headerValue]); - } - - $this->removePlugin(Plugin\HeaderAppendPlugin::class); - $this->addPlugin(new Plugin\HeaderAppendPlugin($this->headers)); - } - - /** - * Add a cache plugin to cache responses locally. - * - * @param CacheItemPoolInterface $cachePool - * @param array $config - * - * @return void - */ - public function addCache(CacheItemPoolInterface $cachePool, array $config = []): void - { - if (!isset($config['cache_key_generator'])) { - $config['cache_key_generator'] = new HeaderCacheKeyGenerator(['Authorization', 'Cookie', 'Accept', 'Content-type']); - } - $this->cachePlugin = Plugin\CachePlugin::clientCache($cachePool, $this->streamFactory, $config); - $this->httpClientModified = true; - } - - /** - * Remove the cache plugin. - * - * @return void - */ - public function removeCache(): void - { - $this->cachePlugin = null; - $this->httpClientModified = true; - } -} diff --git a/lib/Github/HttpClient/Message/ResponseMediator.php b/lib/Github/HttpClient/Message/ResponseMediator.php deleted file mode 100644 index a72ccef7ed4..00000000000 --- a/lib/Github/HttpClient/Message/ResponseMediator.php +++ /dev/null @@ -1,90 +0,0 @@ -getBody()->__toString(); - if (strpos($response->getHeaderLine('Content-Type'), 'application/json') === 0) { - $content = json_decode($body, true); - if (JSON_ERROR_NONE === json_last_error()) { - return $content; - } - } - - return $body; - } - - /** - * @param ResponseInterface $response - * - * @return array - */ - public static function getPagination(ResponseInterface $response): array - { - $header = self::getHeader($response, 'Link'); - - if (null === $header) { - return []; - } - - $pagination = []; - foreach (explode(',', $header) as $link) { - preg_match('/<(.*)>; rel="(.*)"/i', trim($link, ','), $match); - - /** @var string[] $match */ - if (3 === count($match)) { - $pagination[$match[2]] = $match[1]; - } - } - - return $pagination; - } - - /** - * @param ResponseInterface $response - * - * @return string|null - */ - public static function getApiLimit(ResponseInterface $response): ?string - { - $remainingCallsHeader = self::getHeader($response, 'X-RateLimit-Remaining'); - - if (null === $remainingCallsHeader) { - return null; - } - - $remainingCalls = (int) $remainingCallsHeader; - - if (1 > $remainingCalls) { - throw new ApiLimitExceedException($remainingCalls); - } - - return $remainingCallsHeader; - } - - /** - * Get the value for a single header. - * - * @param ResponseInterface $response - * @param string $name - * - * @return string|null - */ - public static function getHeader(ResponseInterface $response, string $name): ?string - { - $headers = $response->getHeader($name); - - return array_shift($headers); - } -} diff --git a/lib/Github/HttpClient/Plugin/Authentication.php b/lib/Github/HttpClient/Plugin/Authentication.php deleted file mode 100644 index 91ed9caa2cf..00000000000 --- a/lib/Github/HttpClient/Plugin/Authentication.php +++ /dev/null @@ -1,71 +0,0 @@ - - */ -final class Authentication implements Plugin -{ - /** - * @var string - */ - private $tokenOrLogin; - - /** - * @var string|null - */ - private $password; - - /** - * @var string|null - */ - private $method; - - /** - * @param string $tokenOrLogin GitHub private token/username/client ID - * @param string|null $password GitHub password/secret (optionally can contain $method) - * @param string|null $method One of the AUTH_* class constants - */ - public function __construct(string $tokenOrLogin, ?string $password, ?string $method) - { - $this->tokenOrLogin = $tokenOrLogin; - $this->password = $password; - $this->method = $method; - } - - /** - * @return Promise - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise - { - $request = $request->withHeader( - 'Authorization', - $this->getAuthorizationHeader() - ); - - return $next($request); - } - - private function getAuthorizationHeader(): string - { - switch ($this->method) { - case AuthMethod::CLIENT_ID: - return sprintf('Basic %s', base64_encode($this->tokenOrLogin.':'.$this->password)); - case AuthMethod::ACCESS_TOKEN: - return sprintf('token %s', $this->tokenOrLogin); - case AuthMethod::JWT: - return sprintf('Bearer %s', $this->tokenOrLogin); - default: - throw new RuntimeException(sprintf('%s not yet implemented', $this->method)); - } - } -} diff --git a/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php b/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php deleted file mode 100644 index 9479aaaf2be..00000000000 --- a/lib/Github/HttpClient/Plugin/GithubExceptionThrower.php +++ /dev/null @@ -1,174 +0,0 @@ - - * @author Tobias Nyholm - */ -final class GithubExceptionThrower implements Plugin -{ - /** - * @return Promise - */ - public function handleRequest(RequestInterface $request, callable $next, callable $first): Promise - { - return $next($request)->then(function (ResponseInterface $response) use ($request) { - if ($response->getStatusCode() < 400 || $response->getStatusCode() > 600) { - $this->checkGraphqlErrors($response); - - return $response; - } - - // If error: - $remaining = ResponseMediator::getHeader($response, 'X-RateLimit-Remaining'); - if ((429 === $response->getStatusCode()) && null !== $remaining && 1 > $remaining && 'rate_limit' !== substr($request->getRequestTarget(), 1, 10)) { - $limit = (int) ResponseMediator::getHeader($response, 'X-RateLimit-Limit'); - $reset = (int) ResponseMediator::getHeader($response, 'X-RateLimit-Reset'); - - throw new ApiLimitExceedException($limit, $reset); - } - - if ((401 === $response->getStatusCode()) && $response->hasHeader('X-GitHub-OTP') && 0 === strpos((string) ResponseMediator::getHeader($response, 'X-GitHub-OTP'), 'required;')) { - $type = substr((string) ResponseMediator::getHeader($response, 'X-GitHub-OTP'), 9); - - throw new TwoFactorAuthenticationRequiredException($type); - } - - $content = ResponseMediator::getContent($response); - if (is_array($content) && isset($content['message'])) { - if (400 === $response->getStatusCode()) { - throw new ErrorException(sprintf('%s (%s)', $content['message'], $response->getReasonPhrase()), 400); - } - - if (422 === $response->getStatusCode() && isset($content['errors'])) { - $errors = []; - foreach ($content['errors'] as $error) { - switch ($error['code'] ?? null) { - case 'missing': - $errors[] = sprintf('The %s %s does not exist, for resource "%s"', $error['field'], $error['value'], $error['resource']); - break; - - case 'missing_field': - $errors[] = sprintf('Field "%s" is missing, for resource "%s"', $error['field'], $error['resource']); - break; - - case 'invalid': - if (isset($error['message'])) { - $errors[] = sprintf('Field "%s" is invalid, for resource "%s": "%s"', $error['field'], $error['resource'], $error['message']); - } else { - $errors[] = sprintf('Field "%s" is invalid, for resource "%s"', $error['field'], $error['resource']); - } - break; - - case 'already_exists': - $errors[] = sprintf('Field "%s" already exists, for resource "%s"', $error['field'], $error['resource']); - break; - - default: - if (is_string($error)) { - $errors[] = $error; - - break; - } - - if (isset($error['message'])) { - $errors[] = $error['message']; - } - break; - } - } - - throw new ValidationFailedException( - $errors ? 'Validation Failed: '.implode(', ', $errors) : 'Validation Failed', - 422 - ); - } - } - - if (502 == $response->getStatusCode() && isset($content['errors']) && is_array($content['errors'])) { - $errors = []; - foreach ($content['errors'] as $error) { - if (isset($error['message'])) { - $errors[] = $error['message']; - } - } - - throw new RuntimeException(implode(', ', $errors), 502); - } - - if ((403 === $response->getStatusCode()) && $response->hasHeader('X-GitHub-SSO') && 0 === strpos((string) ResponseMediator::getHeader($response, 'X-GitHub-SSO'), 'required;')) { - // The header will look something like this: - // required; url=https://github.com/orgs/octodocs-test/sso?authorization_request=AZSCKtL4U8yX1H3sCQIVnVgmjmon5fWxks5YrqhJgah0b2tlbl9pZM4EuMz4 - // So we strip out the first 14 characters, leaving only the URL. - // @see https://developer.github.com/v3/auth/#authenticating-for-saml-sso - $url = substr((string) ResponseMediator::getHeader($response, 'X-GitHub-SSO'), 14); - - throw new SsoRequiredException($url); - } - - $remaining = ResponseMediator::getHeader($response, 'X-RateLimit-Remaining'); - if ((403 === $response->getStatusCode()) && null !== $remaining && 1 > $remaining && isset($content['message']) && (0 === strpos($content['message'], 'API rate limit exceeded'))) { - $limit = (int) ResponseMediator::getHeader($response, 'X-RateLimit-Limit'); - $reset = (int) ResponseMediator::getHeader($response, 'X-RateLimit-Reset'); - - throw new ApiLimitExceedException($limit, $reset); - } - - $reset = (int) ResponseMediator::getHeader($response, 'X-RateLimit-Reset'); - if ((403 === $response->getStatusCode()) && 0 < $reset && isset($content['message']) && (0 === strpos($content['message'], 'You have exceeded a secondary rate limit'))) { - $limit = (int) ResponseMediator::getHeader($response, 'X-RateLimit-Limit'); - - throw new ApiLimitExceedException($limit, $reset); - } - - throw new RuntimeException(isset($content['message']) ? $content['message'] : $content, $response->getStatusCode()); - }); - } - - /** - * The graphql api doesn't return a 5xx http status for errors. Instead it returns a 200 with an error body. - * - * @throws RuntimeException - */ - private function checkGraphqlErrors(ResponseInterface $response): void - { - if ($response->getStatusCode() !== 200) { - return; - } - - $content = ResponseMediator::getContent($response); - if (!is_array($content)) { - return; - } - - if (!isset($content['errors']) || !is_array($content['errors'])) { - return; - } - - $errors = []; - foreach ($content['errors'] as $error) { - if (isset($error['message'])) { - $errors[] = $error['message']; - } - } - - if (empty($errors)) { - return; - } - - throw new RuntimeException(implode(', ', $errors)); - } -} diff --git a/lib/Github/ResultPager.php b/lib/Github/ResultPager.php deleted file mode 100644 index fb8739c4a1c..00000000000 --- a/lib/Github/ResultPager.php +++ /dev/null @@ -1,216 +0,0 @@ - - * @author Mitchel Verschoof - * @author Graham Campbell - */ -class ResultPager implements ResultPagerInterface -{ - /** - * The default number of entries to request per page. - * - * @var int - */ - private const PER_PAGE = 100; - - /** - * The client to use for pagination. - * - * @var Client - */ - private $client; - - /** - * The number of entries to request per page. - * - * @var int - */ - private $perPage; - - /** - * The pagination result from the API. - * - * @var array - */ - private $pagination; - - /** - * Create a new result pager instance. - * - * Example code: - * - * $client = new \Github\Client(); - * $api = $client->api('someApi'); - * $pager = new \Github\ResultPager($client); - * - * @param Client $client - * @param int|null $perPage - * - * @return void - */ - public function __construct(Client $client, ?int $perPage = null) - { - if (null !== $perPage && ($perPage < 1 || $perPage > 100)) { - throw new ValueError(sprintf('%s::__construct(): Argument #2 ($perPage) must be between 1 and 100, or null', self::class)); - } - - $this->client = $client; - $this->perPage = $perPage ?? self::PER_PAGE; - $this->pagination = []; - } - - /** - * {@inheritdoc} - */ - public function fetch(AbstractApi $api, string $method, array $parameters = []): array - { - $paginatorPerPage = $this->perPage; - $closure = Closure::bind(function (AbstractApi $api) use ($paginatorPerPage) { - $clone = clone $api; - $clone->perPage = $paginatorPerPage; - - return $clone; - }, null, AbstractApi::class); - - $api = $closure($api); - $result = $api->$method(...$parameters); - - if ($result === '') { - $result = []; - } - - $this->postFetch(true); - - return $result; - } - - /** - * {@inheritdoc} - */ - public function fetchAll(AbstractApi $api, string $method, array $parameters = []): array - { - return iterator_to_array($this->fetchAllLazy($api, $method, $parameters)); - } - - /** - * {@inheritdoc} - */ - public function fetchAllLazy(AbstractApi $api, string $method, array $parameters = []): Generator - { - $result = $this->fetch($api, $method, $parameters); - - foreach ($result['items'] ?? $result as $key => $item) { - if (is_string($key)) { - yield $key => $item; - } else { - yield $item; - } - } - - while ($this->hasNext()) { - $result = $this->fetchNext(); - - foreach ($result['items'] ?? $result as $key => $item) { - if (is_string($key)) { - yield $key => $item; - } else { - yield $item; - } - } - } - } - - /** - * {@inheritdoc} - */ - public function postFetch(/* $skipDeprecation = false */): void - { - if (func_num_args() === 0 || (func_num_args() > 0 && false === func_get_arg(0))) { - trigger_deprecation('KnpLabs/php-github-api', '3.2', 'The "%s" method is deprecated and will be removed.', __METHOD__); - } - - $this->setPagination(); - } - - /** - * {@inheritdoc} - */ - public function hasNext(): bool - { - return isset($this->pagination['next']); - } - - /** - * {@inheritdoc} - */ - public function fetchNext(): array - { - return $this->get('next'); - } - - /** - * {@inheritdoc} - */ - public function hasPrevious(): bool - { - return isset($this->pagination['prev']); - } - - /** - * {@inheritdoc} - */ - public function fetchPrevious(): array - { - return $this->get('prev'); - } - - /** - * {@inheritdoc} - */ - public function fetchFirst(): array - { - return $this->get('first'); - } - - /** - * {@inheritdoc} - */ - public function fetchLast(): array - { - return $this->get('last'); - } - - /** - * @param string $key - * - * @return array - */ - protected function get(string $key): array - { - if (!isset($this->pagination[$key])) { - return []; - } - - $result = $this->client->getHttpClient()->get($this->pagination[$key]); - - $this->postFetch(true); - - return ResponseMediator::getContent($result); - } - - private function setPagination(): void - { - $this->pagination = ResponseMediator::getPagination($this->client->getLastResponse()); - } -} diff --git a/lib/Github/ResultPagerInterface.php b/lib/Github/ResultPagerInterface.php deleted file mode 100644 index bf7618ee411..00000000000 --- a/lib/Github/ResultPagerInterface.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @author Mitchel Verschoof - * @author Graham Campbell - */ -interface ResultPagerInterface -{ - /** - * Fetch a single result (page) from an api call. - * - * @param AbstractApi $api the Api instance - * @param string $method the method name to call on the Api instance - * @param array $parameters the method parameters in an array - * - * @return array returns the result of the Api::$method() call - */ - public function fetch(AbstractApi $api, string $method, array $parameters = []): array; - - /** - * Fetch all results (pages) from an api call. - * - * Use with care - there is no maximum. - * - * @param AbstractApi $api the Api instance - * @param string $method the method name to call on the Api instance - * @param array $parameters the method parameters in an array - * - * @return array returns a merge of the results of the Api::$method() call - */ - public function fetchAll(AbstractApi $api, string $method, array $parameters = []): array; - - /** - * Lazily fetch all results (pages) from an api call. - * - * Use with care - there is no maximum. - * - * @param AbstractApi $api the Api instance - * @param string $method the method name to call on the Api instance - * @param array $parameters the method parameters in an array - * - * @return \Generator returns a merge of the results of the Api::$method() call - */ - public function fetchAllLazy(AbstractApi $api, string $method, array $parameters = []): Generator; - - /** - * Method that performs the actual work to refresh the pagination property. - * - * @deprecated since 3.2 and will be removed in 4.0. - * - * @return void - */ - public function postFetch(): void; - - /** - * Check to determine the availability of a next page. - * - * @return bool - */ - public function hasNext(): bool; - - /** - * Check to determine the availability of a previous page. - * - * @return bool - */ - public function hasPrevious(): bool; - - /** - * Fetch the next page. - * - * @return array - */ - public function fetchNext(): array; - - /** - * Fetch the previous page. - * - * @return array - */ - public function fetchPrevious(): array; - - /** - * Fetch the first page. - * - * @return array - */ - public function fetchFirst(): array; - - /** - * Fetch the last page. - * - * @return array - */ - public function fetchLast(): array; -} diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 98d2e51cc8f..f3db89780b3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -11,8 +11,8 @@ bootstrap="vendor/autoload.php" > - - ./test/Github/ + + ./test/ArgoCD/ @@ -24,7 +24,7 @@ - ./lib/Github/ + ./src/ArgoCD/ diff --git a/test/Github/Tests/Api/Organization/TeamsTest.php b/test/ArgoCD/Tests/Api/Organization/TeamsTest.php similarity index 98% rename from test/Github/Tests/Api/Organization/TeamsTest.php rename to test/ArgoCD/Tests/Api/Organization/TeamsTest.php index 18b476986aa..aa586ae89ef 100644 --- a/test/Github/Tests/Api/Organization/TeamsTest.php +++ b/test/ArgoCD/Tests/Api/Organization/TeamsTest.php @@ -1,9 +1,9 @@ getApiMock(); - $this->assertInstanceOf(\Github\Api\Organization\Members::class, $api->members()); + $this->assertInstanceOf(\ArgoCD\Api\Organization\Members::class, $api->members()); } /** @@ -85,7 +85,7 @@ public function shouldGetTeamsApiObject() { $api = $this->getApiMock(); - $this->assertInstanceOf(\Github\Api\Organization\Teams::class, $api->teams()); + $this->assertInstanceOf(\ArgoCD\Api\Organization\Teams::class, $api->teams()); } /** @@ -95,7 +95,7 @@ public function shouldGetSelfHostedRunnersApiObject() { $api = $this->getApiMock(); - $this->assertInstanceOf(\Github\Api\Organization\Actions\SelfHostedRunners::class, $api->runners()); + $this->assertInstanceOf(\ArgoCD\Api\Organization\Actions\SelfHostedRunners::class, $api->runners()); } /** @@ -105,7 +105,7 @@ public function shouldGetVariablesApiObject() { $api = $this->getApiMock(); - $this->assertInstanceOf(\Github\Api\Organization\Actions\Variables::class, $api->variables()); + $this->assertInstanceOf(\ArgoCD\Api\Organization\Actions\Variables::class, $api->variables()); } /** @@ -113,6 +113,6 @@ public function shouldGetVariablesApiObject() */ protected function getApiClass() { - return \Github\Api\Organization::class; + return \ArgoCD\Api\Organization::class; } } diff --git a/test/Github/Tests/Api/TestCase.php b/test/ArgoCD/Tests/Api/TestCase.php similarity index 96% rename from test/Github/Tests/Api/TestCase.php rename to test/ArgoCD/Tests/Api/TestCase.php index 4fd6a49234c..8cfc314daf4 100644 --- a/test/Github/Tests/Api/TestCase.php +++ b/test/ArgoCD/Tests/Api/TestCase.php @@ -1,8 +1,8 @@ method('removePlugin') ->with(Authentication::class); - $client = $this->getMockBuilder(\Github\Client::class) + $client = $this->getMockBuilder(\ArgoCD\Client::class) ->disableOriginalConstructor() ->setMethods(['getHttpClientBuilder']) ->getMock(); @@ -92,7 +92,7 @@ public function shouldAuthenticateUsingGivenParameters() ->method('removePlugin') ->with(Authentication::class); - $client = $this->getMockBuilder(\Github\Client::class) + $client = $this->getMockBuilder(\ArgoCD\Client::class) ->disableOriginalConstructor() ->setMethods(['getHttpClientBuilder']) ->getMock(); @@ -154,7 +154,7 @@ public function shouldNotGetApiInstance() public function shouldNotGetMagicApiInstance() { $this->expectException(BadMethodCallException::class); - $client = new Client(); + $client = new Client('http://localhost'); $client->doNotExist(); } diff --git a/test/Github/Tests/HttpClient/BuilderTest.php b/test/ArgoCD/Tests/HttpClient/BuilderTest.php similarity index 89% rename from test/Github/Tests/HttpClient/BuilderTest.php rename to test/ArgoCD/Tests/HttpClient/BuilderTest.php index 33d21025f0e..7dcced8f91b 100644 --- a/test/Github/Tests/HttpClient/BuilderTest.php +++ b/test/ArgoCD/Tests/HttpClient/BuilderTest.php @@ -1,6 +1,6 @@ getMockBuilder(\Github\HttpClient\Builder::class) + $builder = $this->getMockBuilder(\ArgoCD\HttpClient\Builder::class) ->setMethods(['addPlugin', 'removePlugin']) ->getMock(); $builder->expects($this->once()) @@ -35,7 +35,7 @@ public function shouldAddHeaders() { $headers = ['header1', 'header2']; - $client = $this->getMockBuilder(\Github\HttpClient\Builder::class) + $client = $this->getMockBuilder(\ArgoCD\HttpClient\Builder::class) ->setMethods(['addPlugin', 'removePlugin']) ->getMock(); $client->expects($this->once()) @@ -59,7 +59,7 @@ public function appendingHeaderShouldAddAndRemovePlugin() 'Accept' => 'application/vnd.github.v3', ]; - $client = $this->getMockBuilder(\Github\HttpClient\Builder::class) + $client = $this->getMockBuilder(\ArgoCD\HttpClient\Builder::class) ->setMethods(['removePlugin', 'addPlugin']) ->getMock(); diff --git a/test/Github/Tests/HttpClient/Message/ResponseMediatorTest.php b/test/ArgoCD/Tests/HttpClient/Message/ResponseMediatorTest.php similarity index 68% rename from test/Github/Tests/HttpClient/Message/ResponseMediatorTest.php rename to test/ArgoCD/Tests/HttpClient/Message/ResponseMediatorTest.php index b6216d57044..d1fa5ffd1b9 100644 --- a/test/Github/Tests/HttpClient/Message/ResponseMediatorTest.php +++ b/test/ArgoCD/Tests/HttpClient/Message/ResponseMediatorTest.php @@ -1,8 +1,8 @@ assertEquals($body, ResponseMediator::getContent($response)); } - public function testGetPagination() - { - $header = '; rel="first",; rel="next",; rel="prev",; rel="last",'; - - $pagination = [ - 'first' => 'https://github.com', - 'next' => 'https://github.com', - 'prev' => 'https://github.com', - 'last' => 'https://github.com', - ]; - - // response mock - $response = new Response(200, ['link' => $header]); - $result = ResponseMediator::getPagination($response); - - $this->assertEquals($pagination, $result); - } - public function testGetHeader() { $header = 'application/json'; diff --git a/test/Github/Tests/HttpClient/Plugin/AuthenticationTest.php b/test/ArgoCD/Tests/HttpClient/Plugin/AuthenticationTest.php similarity index 93% rename from test/Github/Tests/HttpClient/Plugin/AuthenticationTest.php rename to test/ArgoCD/Tests/HttpClient/Plugin/AuthenticationTest.php index be937684d01..5c14a7812bc 100644 --- a/test/Github/Tests/HttpClient/Plugin/AuthenticationTest.php +++ b/test/ArgoCD/Tests/HttpClient/Plugin/AuthenticationTest.php @@ -1,9 +1,9 @@ new \Github\Exception\ApiLimitExceedException(5000), + 'exception' => new \ArgoCD\Exception\ApiLimitExceedException(5000), ], 'Rate Limit Exceeded via 403 status' => [ 'response' => new Response( @@ -90,7 +90,7 @@ public static function responseProvider() ] ) ), - 'exception' => new \Github\Exception\ApiLimitExceedException(5000), + 'exception' => new \ArgoCD\Exception\ApiLimitExceedException(5000), ], 'Secondary Rate Limit Exceeded via 403 status' => [ 'response' => new Response( @@ -107,7 +107,7 @@ public static function responseProvider() ] ) ), - 'exception' => new \Github\Exception\ApiLimitExceedException(5000), + 'exception' => new \ArgoCD\Exception\ApiLimitExceedException(5000), ], 'Two Factor Authentication Required' => [ 'response' => new Response( @@ -118,7 +118,7 @@ public static function responseProvider() ], '' ), - 'exception' => new \Github\Exception\TwoFactorAuthenticationRequiredException('2fa-type'), + 'exception' => new \ArgoCD\Exception\TwoFactorAuthenticationRequiredException('2fa-type'), ], '400 Bad Request' => [ 'response' => new Response( @@ -132,7 +132,7 @@ public static function responseProvider() ] ) ), - 'exception' => new \Github\Exception\ErrorException('Problems parsing JSON (Bad Request)', 400), + 'exception' => new \ArgoCD\Exception\ErrorException('Problems parsing JSON (Bad Request)', 400), ], '422 Unprocessable Entity' => [ 'response' => new Response( @@ -154,7 +154,7 @@ public static function responseProvider() ] ) ), - 'exception' => new \Github\Exception\ErrorException('Validation Failed: The field value does not exist, for resource "resource"', 422), + 'exception' => new \ArgoCD\Exception\ErrorException('Validation Failed: The field value does not exist, for resource "resource"', 422), ], '502 Response' => [ 'response' => new Response( @@ -170,7 +170,7 @@ public static function responseProvider() ] ) ), - 'exception' => new \Github\Exception\RuntimeException('Something went wrong with executing your query', 502), + 'exception' => new \ArgoCD\Exception\RuntimeException('Something went wrong with executing your query', 502), ], 'Sso required Response' => [ 'response' => new Response( @@ -180,7 +180,7 @@ public static function responseProvider() 'X-GitHub-SSO' => 'required; url=https://github.com/orgs/octodocs-test/sso?authorization_request=AZSCKtL4U8yX1H3sCQIVnVgmjmon5fWxks5YrqhJgah0b2tlbl9pZM4EuMz4', ] ), - 'exception' => new \Github\Exception\SsoRequiredException('https://github.com/orgs/octodocs-test/sso?authorization_request=AZSCKtL4U8yX1H3sCQIVnVgmjmon5fWxks5YrqhJgah0b2tlbl9pZM4EuMz4'), + 'exception' => new \ArgoCD\Exception\SsoRequiredException('https://github.com/orgs/octodocs-test/sso?authorization_request=AZSCKtL4U8yX1H3sCQIVnVgmjmon5fWxks5YrqhJgah0b2tlbl9pZM4EuMz4'), ], 'Default handling' => [ 'response' => new Response( @@ -188,7 +188,7 @@ public static function responseProvider() [], 'Error message' ), - 'exception' => new \Github\Exception\RuntimeException('Error message', 555), + 'exception' => new \ArgoCD\Exception\RuntimeException('Error message', 555), ], 'Graphql error response (200)' => [ 'response' => new Response( @@ -211,7 +211,7 @@ public static function responseProvider() ] ) ), - 'exception' => new \Github\Exception\RuntimeException('Field "xxxx" doesn\'t exist on type "Issue", Field "dummy" doesn\'t exist on type "PullRequest"'), + 'exception' => new \ArgoCD\Exception\RuntimeException('Field "xxxx" doesn\'t exist on type "Issue", Field "dummy" doesn\'t exist on type "PullRequest"'), ], 'Grapql requires authentication' => [ 'response' => new Response( @@ -230,7 +230,7 @@ public static function responseProvider() ] ) ), - 'exception' => new \Github\Exception\RuntimeException('This endpoint requires you to be authenticated.', 401), + 'exception' => new \ArgoCD\Exception\RuntimeException('This endpoint requires you to be authenticated.', 401), ], 'Cannot delete active deployment' => [ 'response' => new Response( @@ -246,7 +246,7 @@ public static function responseProvider() ] ) ), - 'exception' => new \Github\Exception\ValidationFailedException('Validation Failed: We cannot delete an active deployment unless it is the only deployment in a given environment.', 422), + 'exception' => new \ArgoCD\Exception\ValidationFailedException('Validation Failed: We cannot delete an active deployment unless it is the only deployment in a given environment.', 422), ], ]; } diff --git a/test/Github/Tests/HttpClient/Plugin/PathPrependTest.php b/test/ArgoCD/Tests/HttpClient/Plugin/PathPrependTest.php similarity index 92% rename from test/Github/Tests/HttpClient/Plugin/PathPrependTest.php rename to test/ArgoCD/Tests/HttpClient/Plugin/PathPrependTest.php index f5d4052d94d..5297eaee13d 100644 --- a/test/Github/Tests/HttpClient/Plugin/PathPrependTest.php +++ b/test/ArgoCD/Tests/HttpClient/Plugin/PathPrependTest.php @@ -1,8 +1,8 @@ getHttpMethodsMock(['get']); - $httpClient - ->expects($this->any()) - ->method('get') - ->with('/path?param1=param1value', ['header1' => 'header1value']) - ->will($this->returnValue($this->getPSR7Response($expectedArray))); - $client = $this->getMockBuilder(\Github\Client::class) - ->setMethods(['getHttpClient']) - ->getMock(); - $client->expects($this->any()) - ->method('getHttpClient') - ->willReturn($httpClient); - - $api = $this->getAbstractApiObject($client); - - $actual = $this->getMethod($api, 'get') - ->invokeArgs($api, ['/path', ['param1' => 'param1value'], ['header1' => 'header1value']]); - - $this->assertEquals($expectedArray, $actual); - } - - /** - * @test - */ - public function shouldPassPOSTRequestToClient() - { - $expectedArray = ['value']; - - $httpClient = $this->getHttpMethodsMock(['post']); - $httpClient - ->expects($this->once()) - ->method('post') - ->with('/path', ['option1' => 'option1value'], json_encode(['param1' => 'param1value'])) - ->will($this->returnValue($this->getPSR7Response($expectedArray))); - - $client = $this->getMockBuilder(\Github\Client::class) - ->setMethods(['getHttpClient']) - ->getMock(); - $client->expects($this->any()) - ->method('getHttpClient') - ->willReturn($httpClient); - - $api = $this->getAbstractApiObject($client); - $actual = $this->getMethod($api, 'post') - ->invokeArgs($api, ['/path', ['param1' => 'param1value'], ['option1' => 'option1value']]); - - $this->assertEquals($expectedArray, $actual); - } - - /** - * @test - */ - public function shouldPassPATCHRequestToClient() - { - $expectedArray = ['value']; - - $httpClient = $this->getHttpMethodsMock(['patch']); - $httpClient - ->expects($this->once()) - ->method('patch') - ->with('/path', ['option1' => 'option1value'], json_encode(['param1' => 'param1value'])) - ->will($this->returnValue($this->getPSR7Response($expectedArray))); - - $client = $this->getMockBuilder(\Github\Client::class) - ->setMethods(['getHttpClient']) - ->getMock(); - $client->expects($this->any()) - ->method('getHttpClient') - ->willReturn($httpClient); - - $api = $this->getAbstractApiObject($client); - $actual = $this->getMethod($api, 'patch') - ->invokeArgs($api, ['/path', ['param1' => 'param1value'], ['option1' => 'option1value']]); - - $this->assertEquals($expectedArray, $actual); - } - - /** - * @test - */ - public function shouldPassPUTRequestToClient() - { - $expectedArray = ['value']; - - $httpClient = $this->getHttpMethodsMock(['put']); - $httpClient - ->expects($this->once()) - ->method('put') - ->with('/path', ['option1' => 'option1value'], json_encode(['param1' => 'param1value'])) - ->will($this->returnValue($this->getPSR7Response($expectedArray))); - - $client = $this->getMockBuilder('Github\Client') - ->setMethods(['getHttpClient']) - ->getMock(); - $client->expects($this->any()) - ->method('getHttpClient') - ->willReturn($httpClient); - - $api = $this->getAbstractApiObject($client); - $actual = $this->getMethod($api, 'put') - ->invokeArgs($api, ['/path', ['param1' => 'param1value'], ['option1' => 'option1value']]); - - $this->assertEquals($expectedArray, $actual); - } - - /** - * @test - */ - public function shouldPassDELETERequestToClient() - { - $expectedArray = ['value']; - - $httpClient = $this->getHttpMethodsMock(['delete']); - $httpClient - ->expects($this->once()) - ->method('delete') - ->with('/path', ['option1' => 'option1value'], json_encode(['param1' => 'param1value'])) - ->will($this->returnValue($this->getPSR7Response($expectedArray))); - - $client = $this->getMockBuilder('Github\Client') - ->setMethods(['getHttpClient']) - ->getMock(); - $client->expects($this->any()) - ->method('getHttpClient') - ->willReturn($httpClient); - - $api = $this->getAbstractApiObject($client); - $actual = $this->getMethod($api, 'delete') - ->invokeArgs($api, ['/path', ['param1' => 'param1value'], ['option1' => 'option1value']]); - - $this->assertEquals($expectedArray, $actual); - } - - /** - * @test - */ - public function shouldNotPassEmptyRefToClient() - { - $expectedArray = ['value']; - - $httpClient = $this->getHttpMethodsMock(['get']); - $httpClient - ->expects($this->any()) - ->method('get') - ->with('/path', []) - ->will($this->returnValue($this->getPSR7Response($expectedArray))); - - $client = $this->getMockBuilder(\Github\Client::class) - ->setMethods(['getHttpClient']) - ->getMock(); - $client->expects($this->any()) - ->method('getHttpClient') - ->willReturn($httpClient); - - $api = $this->getAbstractApiObject($client); - $actual = $this->getMethod($api, 'get')->invokeArgs($api, ['/path', ['ref' => null]]); - - $this->assertIsArray($actual); - } - - /** - * @param $client - * - * @return \PHPUnit\Framework\MockObject\MockObject - */ - protected function getAbstractApiObject($client) - { - return $this->getMockBuilder($this->getApiClass()) - ->setMethods(null) - ->setConstructorArgs([$client]) - ->getMock(); - } - - /** - * @return string - */ - protected function getApiClass() - { - return AbstractApi::class; - } - - /** - * @return \Github\Client - */ - protected function getClientMock() - { - return new \Github\Client($this->getHttpMethodsMock()); - } - - /** - * Return a HttpMethods client mock. - * - * @param array $methods - * - * @return \Http\Client\Common\HttpMethodsClientInterface - */ - protected function getHttpMethodsMock(array $methods = []) - { - $mock = $this->createMock(HttpMethodsClientInterface::class); - - $mock - ->expects($this->any()) - ->method('sendRequest'); - - return $mock; - } - - /** - * @param $expectedArray - * - * @return Response - */ - private function getPSR7Response($expectedArray) - { - return new Response( - 200, - ['Content-Type' => 'application/json'], - Utils::streamFor(json_encode($expectedArray)) - ); - } -} diff --git a/test/Github/Tests/Api/App/HookTest.php b/test/Github/Tests/Api/App/HookTest.php deleted file mode 100644 index f2ed6ae5ab4..00000000000 --- a/test/Github/Tests/Api/App/HookTest.php +++ /dev/null @@ -1,109 +0,0 @@ - 'json', - 'insecure_ssl' => 0, - 'secret' => '********', - 'url' => 'https://localhost/', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/app/hook/config', []) - ->willReturn($result); - - $this->assertEquals($result, $api->showConfig()); - } - - /** - * @test - */ - public function shouldUpdateHookConfiguration() - { - $parameters = [ - 'content_type' => 'json', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/app/hook/config', $parameters) - ->willReturn([]); - - $this->assertEquals([], $api->updateConfig($parameters)); - } - - /** - * @test - */ - public function shouldListHookDelivieries() - { - $result = []; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/app/hook/deliveries', []) - ->willReturn($result); - - $this->assertEquals($result, $api->deliveries()); - } - - /** - * @test - */ - public function shouldListHookDeliviery() - { - $result = []; - - $delivery = 1234567; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/app/hook/deliveries/'.$delivery, []) - ->willReturn($result); - - $this->assertEquals($result, $api->delivery($delivery)); - } - - /** - * @test - */ - public function shouldRedeliveryHook() - { - $result = []; - - $delivery = 1234567; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/app/hook/deliveries/'.$delivery.'/attempts', []) - ->willReturn($result); - - $this->assertEquals($result, $api->redeliver($delivery)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\App\Hook::class; - } -} diff --git a/test/Github/Tests/Api/AppTest.php b/test/Github/Tests/Api/AppTest.php deleted file mode 100644 index b813a11dd1f..00000000000 --- a/test/Github/Tests/Api/AppTest.php +++ /dev/null @@ -1,187 +0,0 @@ - 'v1.1f699f1069f60xxx', - 'expires_at' => '2016-07-11T22:14:10Z', - ]; - $installationId = 'installation1'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/app/installations/'.$installationId.'/access_tokens', []) - ->willReturn($result); - - $this->assertEquals($result, $api->createInstallationToken($installationId)); - } - - /** - * @test - */ - public function shouldFindInstallationsForApplication() - { - $result = ['installation1', 'installation2']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/app/installations') - ->willReturn($result); - - $this->assertEquals($result, $api->findInstallations()); - } - - /** - * @test - */ - public function shouldGetInstallationForApplication() - { - $result = ['installation1']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/app/installations/1234') - ->willReturn($result); - - $this->assertEquals($result, $api->getInstallation('1234')); - } - - /** - * @test - */ - public function shouldGetInstallationForOrganization() - { - $result = ['installation1']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/1234/installation') - ->willReturn($result); - - $this->assertEquals($result, $api->getInstallationForOrganization('1234')); - } - - /** - * @test - */ - public function shouldGetInstallationForRepo() - { - $result = ['installation1']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/MyOrg/MyRepo/installation') - ->willReturn($result); - - $this->assertEquals($result, $api->getInstallationForRepo('MyOrg', 'MyRepo')); - } - - /** - * @test - */ - public function shouldGetInstallationForUser() - { - $result = ['installation1']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/users/octocat/installation') - ->willReturn($result); - - $this->assertEquals($result, $api->getInstallationForUser('octocat')); - } - - /** - * @test - */ - public function shouldDeleteInstallationForApplication() - { - $id = 123; - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/app/installations/'.$id); - - $api->removeInstallation($id); - } - - /** - * @test - */ - public function shouldGetRepositoriesFromInstallation() - { - $result = ['repo1', 'repo2']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/installation/repositories', ['user_id' => '1234']) - ->willReturn($result); - - $this->assertEquals($result, $api->listRepositories('1234')); - } - - /** - * @test - */ - public function shouldAddRepositoryToInstallation() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/installations/1234/repositories/5678'); - - $api->addRepository('1234', '5678'); - } - - /** - * @test - */ - public function shouldRemoveRepositoryToInstallation() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/installations/1234/repositories/5678'); - - $api->removeRepository('1234', '5678'); - } - - /** - * @test - */ - public function shouldGetAuthenticatedApp() - { - $api = $this->getApiMock(); - - $result = ['authenticatedApp1']; - - $api->expects($this->once()) - ->method('get') - ->with('/app') - ->willReturn($result); - - $this->assertEquals($result, $api->getAuthenticatedApp()); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Apps::class; - } -} diff --git a/test/Github/Tests/Api/Copilot/UsageTest.php b/test/Github/Tests/Api/Copilot/UsageTest.php deleted file mode 100644 index c14c3e3ffa8..00000000000 --- a/test/Github/Tests/Api/Copilot/UsageTest.php +++ /dev/null @@ -1,78 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/copilot/usage', []) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->orgUsageSummary('KnpLabs')); - } - - /** - * @test - */ - public function shouldGetOrgTeamUsageSummary(): void - { - $expectedValue = ['usage1', 'usage2']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/team/php-github-api/copilot/usage', []) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->orgTeamUsageSummary('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetEnterpriseUsageSummary(): void - { - $expectedValue = ['usage1', 'usage2']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/enterprises/KnpLabs/copilot/usage', []) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->enterpriseUsageSummary('KnpLabs')); - } - - /** - * @test - */ - public function shouldGetEnterpriseTeamUsageSummary(): void - { - $expectedValue = ['usage1', 'usage2']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/enterprises/KnpLabs/team/php-github-api/copilot/usage', []) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->enterpriseTeamUsageSummary('KnpLabs', 'php-github-api')); - } - - protected function getApiClass(): string - { - return Usage::class; - } -} diff --git a/test/Github/Tests/Api/CurrentUser/DeployKeysTest.php b/test/Github/Tests/Api/CurrentUser/DeployKeysTest.php deleted file mode 100644 index 4f147e25e02..00000000000 --- a/test/Github/Tests/Api/CurrentUser/DeployKeysTest.php +++ /dev/null @@ -1,112 +0,0 @@ - '12', 'key' => 'ssh-rsa ...']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/keys/12') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show(12)); - } - - /** - * @test - */ - public function shouldGetKeys() - { - $expectedValue = [['id' => '12', 'key' => 'ssh-rsa ...']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/keys') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all()); - } - - /** - * @test - */ - public function shouldCreateKey() - { - $expectedValue = ['id' => '123', 'key' => 'ssh-rsa ...']; - $data = ['title' => 'my key', 'key' => 'ssh-rsa ...']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/user/keys', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create($data)); - } - - /** - * @test - */ - public function shouldNotCreateKeyWithoutTitleParam() - { - $this->expectException(MissingArgumentException::class); - $data = ['key' => 'ssh-rsa ...']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create($data); - } - - /** - * @test - */ - public function shouldNotCreateKeyWithoutKeyParam() - { - $this->expectException(MissingArgumentException::class); - $data = ['title' => 'my key']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create($data); - } - - /** - * @test - */ - public function shouldRemoveKey() - { - $expectedValue = ['some value']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/user/keys/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove(123)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\CurrentUser\PublicKeys::class; - } -} diff --git a/test/Github/Tests/Api/CurrentUser/EmailsTest.php b/test/Github/Tests/Api/CurrentUser/EmailsTest.php deleted file mode 100644 index 1fed2a0d780..00000000000 --- a/test/Github/Tests/Api/CurrentUser/EmailsTest.php +++ /dev/null @@ -1,139 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/emails') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all()); - } - - /** - * @test - */ - public function shouldRemoveEmail() - { - $expectedValue = ['some value']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/user/emails', ['email@example.com']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('email@example.com')); - } - - /** - * @test - */ - public function shouldRemoveEmails() - { - $expectedValue = ['some value']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/user/emails', ['email@example.com', 'email2@example.com']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove(['email@example.com', 'email2@example.com'])); - } - - /** - * @test - */ - public function shouldNotRemoveEmailsWhenAreNotPass() - { - $this->expectException(InvalidArgumentException::class); - $api = $this->getApiMock(); - $api->expects($this->any()) - ->method('delete'); - - $api->remove([]); - } - - /** - * @test - */ - public function shouldAddEmail() - { - $expectedValue = ['some value']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/user/emails', ['email@example.com']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->add('email@example.com')); - } - - /** - * @test - */ - public function shouldAddEmails() - { - $expectedValue = ['some value']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/user/emails', ['email@example.com', 'email2@example.com']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->add(['email@example.com', 'email2@example.com'])); - } - - /** - * @test - */ - public function shouldNotAddEmailsWhenAreNotPass() - { - $this->expectException(InvalidArgumentException::class); - $api = $this->getApiMock(); - $api->expects($this->any()) - ->method('post'); - - $api->add([]); - } - - /** - * @test - */ - public function shouldToggleVisibility() - { - $expectedValue = ['primary email info']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/user/email/visibility') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->toggleVisibility()); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\CurrentUser\Emails::class; - } -} diff --git a/test/Github/Tests/Api/CurrentUser/FollowersTest.php b/test/Github/Tests/Api/CurrentUser/FollowersTest.php deleted file mode 100644 index 19b4b0faab6..00000000000 --- a/test/Github/Tests/Api/CurrentUser/FollowersTest.php +++ /dev/null @@ -1,77 +0,0 @@ - 'l3l0'], - ['login' => 'cordoval'], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/following') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all()); - } - - /** - * @test - */ - public function shouldCheckFollower() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/following/l3l0') - ->will($this->returnValue(null)); - - $this->assertNull($api->check('l3l0')); - } - - /** - * @test - */ - public function shouldFollowUser() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/user/following/l3l0') - ->will($this->returnValue(null)); - - $this->assertNull($api->follow('l3l0')); - } - - /** - * @test - */ - public function shouldUnfollowUser() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/user/following/l3l0') - ->will($this->returnValue(null)); - - $this->assertNull($api->unfollow('l3l0')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\CurrentUser\Followers::class; - } -} diff --git a/test/Github/Tests/Api/CurrentUser/MembershipsTest.php b/test/Github/Tests/Api/CurrentUser/MembershipsTest.php deleted file mode 100644 index aef9f374c23..00000000000 --- a/test/Github/Tests/Api/CurrentUser/MembershipsTest.php +++ /dev/null @@ -1,96 +0,0 @@ - [ - 'login' => 'octocat', - 'id' => 1, - ], - 'user' => [ - 'login' => 'defunkt', - 'id' => 3, - ], - ], - [ - 'organization' => [ - 'login' => 'invitocat', - 'id' => 2, - ], - 'user' => [ - 'login' => 'defunkt', - 'id' => 3, - ], - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/memberships/orgs') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all()); - } - - /** - * @test - */ - public function shouldGetMembershipsForOrganization() - { - $expectedValue = [ - 'organization' => [ - 'login' => 'invitocat', - 'id' => 2, - ], - 'user' => [ - 'login' => 'defunkt', - 'id' => 3, - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/memberships/orgs/invitocat') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->organization('invitocat')); - } - - /** - * @test - */ - public function shouldEditMembershipsForOrganization() - { - $expectedValue = [ - 'state' => 'active', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/user/memberships/orgs/invitocat') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->edit('invitocat')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\CurrentUser\Memberships::class; - } -} diff --git a/test/Github/Tests/Api/CurrentUser/StarringTest.php b/test/Github/Tests/Api/CurrentUser/StarringTest.php deleted file mode 100644 index 2210aaf2197..00000000000 --- a/test/Github/Tests/Api/CurrentUser/StarringTest.php +++ /dev/null @@ -1,77 +0,0 @@ - 'l3l0/test'], - ['name' => 'cordoval/test'], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/starred') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all()); - } - - /** - * @test - */ - public function shouldCheckStar() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/starred/l3l0/test') - ->will($this->returnValue(null)); - - $this->assertNull($api->check('l3l0', 'test')); - } - - /** - * @test - */ - public function shouldStarUser() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/user/starred/l3l0/test') - ->will($this->returnValue(null)); - - $this->assertNull($api->star('l3l0', 'test')); - } - - /** - * @test - */ - public function shouldUnstarUser() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/user/starred/l3l0/test') - ->will($this->returnValue(null)); - - $this->assertNull($api->unstar('l3l0', 'test')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\CurrentUser\Starring::class; - } -} diff --git a/test/Github/Tests/Api/CurrentUser/WatchersTest.php b/test/Github/Tests/Api/CurrentUser/WatchersTest.php deleted file mode 100644 index 81491eab153..00000000000 --- a/test/Github/Tests/Api/CurrentUser/WatchersTest.php +++ /dev/null @@ -1,77 +0,0 @@ - 'l3l0/test'], - ['name' => 'cordoval/test'], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/subscriptions') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all()); - } - - /** - * @test - */ - public function shouldCheckWatcher() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/subscriptions/l3l0/test') - ->will($this->returnValue(null)); - - $this->assertNull($api->check('l3l0', 'test')); - } - - /** - * @test - */ - public function shouldWatchUser() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/user/subscriptions/l3l0/test') - ->will($this->returnValue(null)); - - $this->assertNull($api->watch('l3l0', 'test')); - } - - /** - * @test - */ - public function shouldUnwatchUser() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/user/subscriptions/l3l0/test') - ->will($this->returnValue(null)); - - $this->assertNull($api->unwatch('l3l0', 'test')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\CurrentUser\Watchers::class; - } -} diff --git a/test/Github/Tests/Api/CurrentUserTest.php b/test/Github/Tests/Api/CurrentUserTest.php deleted file mode 100644 index 5de99f5c911..00000000000 --- a/test/Github/Tests/Api/CurrentUserTest.php +++ /dev/null @@ -1,170 +0,0 @@ - 1, 'username' => 'l3l0']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show()); - } - - /** - * @test - */ - public function shouldUpdateCurrentUserData() - { - $expectedArray = ['id' => 1, 'username' => 'l3l0']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/user', ['value' => 'toChange']) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->update(['value' => 'toChange'])); - } - - /** - * @test - */ - public function shouldGetUserFollowers() - { - $expectedArray = [['id' => 1, 'username' => 'l3l0test']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/followers', ['page' => 1]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->followers(1)); - } - - /** - * @test - */ - public function shouldGetIssuesAssignedToUser() - { - $expectedArray = [['id' => 1, 'title' => 'issues']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/issues', ['page' => 1, 'some' => 'param']) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->issues(['some' => 'param'])); - } - - /** - * @test - */ - public function shouldGetInstallations() - { - $result = ['installation1', 'installation2']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/installations') - ->willReturn($result); - - $this->assertEquals($result, $api->installations()); - } - - /** - * @test - */ - public function shouldGetRepositoriesByInstallation() - { - $expectedArray = [['id' => 1, 'name' => 'l3l0repo']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/installations/42/repositories', ['page' => 1]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->repositoriesByInstallation(42)); - } - - /** - * @test - */ - public function shouldGetDeployKeysApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\CurrentUser\PublicKeys::class, $api->keys()); - } - - /** - * @test - */ - public function shouldGetEmailsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\CurrentUser\Emails::class, $api->emails()); - } - - /** - * @test - */ - public function shouldGetFollowersApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\CurrentUser\Followers::class, $api->follow()); - } - - /** - * @test - */ - public function shouldGetNotificationsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\CurrentUser\Notifications::class, $api->notifications()); - } - - /** - * @test - */ - public function shouldGetWatchersApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\CurrentUser\Watchers::class, $api->watchers()); - } - - /** - * @test - */ - public function shouldGetStarredApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\CurrentUser\Starring::class, $api->starring()); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\CurrentUser::class; - } -} diff --git a/test/Github/Tests/Api/Deployment/EnvironmentsTest.php b/test/Github/Tests/Api/Deployment/EnvironmentsTest.php deleted file mode 100644 index ab761ab90cf..00000000000 --- a/test/Github/Tests/Api/Deployment/EnvironmentsTest.php +++ /dev/null @@ -1,73 +0,0 @@ -getApiMock(); - - $api->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/environments/production'); - - $api->createOrUpdate('KnpLabs', 'php-github-api', 'production'); - } - - /** - * @test - */ - public function shouldGetAllEnvironments() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/environments'); - - $api->all('KnpLabs', 'php-github-api'); - } - - /** - * @test - */ - public function shouldShowEnvironment() - { - $expectedValue = 'production'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/environments/production') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'production')); - } - - /** - * @test - */ - public function shouldDeleteEnvironment() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/environments/production') - ->will($this->returnValue(null)); - - $this->assertNull($api->remove('KnpLabs', 'php-github-api', 'production')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Deployment\Environments::class; - } -} diff --git a/test/Github/Tests/Api/Deployment/PoliciesTest.php b/test/Github/Tests/Api/Deployment/PoliciesTest.php deleted file mode 100644 index 6b387881ce7..00000000000 --- a/test/Github/Tests/Api/Deployment/PoliciesTest.php +++ /dev/null @@ -1,91 +0,0 @@ -getApiMock(); - - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/environments/production/deployment-branch-policies'); - - $api->create('KnpLabs', 'php-github-api', 'production', [ - 'name' => 'name', - ]); - } - - /** - * @test - */ - public function shouldUpdatePolicy() - { - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/environments/production/deployment-branch-policies/1'); - - $api->update('KnpLabs', 'php-github-api', 'production', 1, [ - 'name' => 'name', - ]); - } - - /** - * @test - */ - public function shouldGetAllPolicies() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/environments/production/deployment-branch-policies'); - - $api->all('KnpLabs', 'php-github-api', 'production'); - } - - /** - * @test - */ - public function shouldShowPolicy() - { - $expectedValue = 'production'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/environments/production/deployment-branch-policies/1') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'production', 1)); - } - - /** - * @test - */ - public function shouldDeletePolicy() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/environments/production/deployment-branch-policies/1') - ->will($this->returnValue(null)); - - $this->assertNull($api->remove('KnpLabs', 'php-github-api', 'production', 1)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Deployment\Policies::class; - } -} diff --git a/test/Github/Tests/Api/DeploymentTest.php b/test/Github/Tests/Api/DeploymentTest.php deleted file mode 100644 index 8741ee625f7..00000000000 --- a/test/Github/Tests/Api/DeploymentTest.php +++ /dev/null @@ -1,148 +0,0 @@ -getApiMock(); - $deploymentData = ['ref' => 'fd6a5f9e5a430dddae8d6a8ea378f913d3a766f9']; - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/deployments', $deploymentData); - - $api->create('KnpLabs', 'php-github-api', $deploymentData); - } - - /** - * @test - */ - public function shouldGetAllDeployments() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/deployments'); - - $api->all('KnpLabs', 'php-github-api'); - } - - /** - * @test - */ - public function shouldGetAllDeploymentsWithFilterParameters() - { - $api = $this->getApiMock(); - $filterData = ['foo' => 'bar', 'bar' => 'foo']; - - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/deployments', $filterData); - - $api->all('KnpLabs', 'php-github-api', $filterData); - } - - /** - * @test - */ - public function shouldShowDeployment() - { - $expectedValue = ['id' => 123, 'ref' => 'master']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/deployments/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldDeleteDeployment() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/deployments/123') - ->will($this->returnValue(null)); - - $this->assertNull($api->remove('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldCreateStatusUpdate() - { - $api = $this->getApiMock(); - $statusData = ['state' => 'pending', 'description' => 'waiting to start']; - - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/deployments/1/statuses', $statusData); - - $api->updateStatus('KnpLabs', 'php-github-api', 1, $statusData); - } - - /** - * @test - */ - public function shouldRejectStatusUpdateWithoutStateField() - { - $this->expectException(MissingArgumentException::class); - $api = $this->getApiMock(); - $statusData = ['description' => 'waiting to start']; - - $api->updateStatus('KnpLabs', 'php-github-api', 1, $statusData); - } - - /** - * @test - */ - public function shouldGetAllStatuses() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/deployments/1/statuses'); - - $api->getStatuses('KnpLabs', 'php-github-api', 1); - } - - /** - * @test - */ - public function shouldGetEnvironmentsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Deployment\Environments::class, $api->environments()); - } - - /** - * @test - */ - public function shouldGetPoliciesApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Deployment\Policies::class, $api->policies()); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Deployment::class; - } -} diff --git a/test/Github/Tests/Api/Enterprise/LicenseTest.php b/test/Github/Tests/Api/Enterprise/LicenseTest.php deleted file mode 100644 index b8d988a6146..00000000000 --- a/test/Github/Tests/Api/Enterprise/LicenseTest.php +++ /dev/null @@ -1,39 +0,0 @@ - 1400, - 'seats_used' => 1316, - 'seats_available' => 84, - 'kind' => 'standard', - 'days_until_expiration' => 365, - 'expire_at' => '2016/02/06 12:41:52 -0600', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/enterprise/settings/license') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show()); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Enterprise\License::class; - } -} diff --git a/test/Github/Tests/Api/Enterprise/ManagementConsoleTest.php b/test/Github/Tests/Api/Enterprise/ManagementConsoleTest.php deleted file mode 100644 index fd1d2064f66..00000000000 --- a/test/Github/Tests/Api/Enterprise/ManagementConsoleTest.php +++ /dev/null @@ -1,117 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/setup/api/configcheck', ['license_md5' => $this->getLicenseHash()]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->configcheck($this->getLicenseHash())); - } - - /** - * @test - */ - public function shouldShowSettingsData() - { - $expectedJson = '{ "enterprise": { "private_mode": false, "github_hostname": "ghe.local", "auth_mode": - "default", "storage_mode": "rootfs", "admin_password": null, "configuration_id": 1401777404, - "configuration_run_count": 4, "package_version": "11.10.332", "avatar": { "enabled": false, "uri": "" }, - "customer": { "name": "GitHub", "email": "stannis@themannis.biz", "uuid": - "af6cac80-e4e1-012e-d822-1231380e52e9", - "secret_key_data": "-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: GnuPG v1.4.10 (GNU/Linux)\n\nlQcYBE5TCgsBEACk4yHpUcapplebaumBMXYMiLF+nCQ0lxpx...\n-----END PGP PRIVATE KEY BLOCK-----\n", - "public_key_data": "-----BEGIN PGP PUBLIC KEY BLOCK-----\nVersion: GnuPG v1.4.10 (GNU/Linux)\n\nmI0ETqzZYgEEALSe6snowdenXyqvLfSQ34HWD6C7....\n-----END PGP PUBLIC KEY BLOCK-----\n" }, - "license": { "seats": 0, "evaluation": false, "expire_at": "2015-04-27T00:00:00-07:00", "perpetual": false, - "unlimited_seating": true, "support_key": "ssh-rsa AAAAB3N....", "ssh_allowed": true }, "github_ssl": - { "enabled": false, "cert": null, "key": null }, "ldap": { "host": "", "port": "", "base": [ ], "uid": "", - "bind_dn": "", "password": "", "method": "Plain", "user_groups": [ ], "admin_group": "" }, "cas": { "url": "" }, - "github_oauth": { "client_id": "12313412", "client_secret": "kj123131132", "organization_name": - "Homestar Runners", "organization_team": "homestarrunners/owners" }, "smtp": { "enabled": true, "address": - "smtp.example.com", "authentication": "plain", "port": "1234", "domain": "blah", "username": "foo", "user_name": - "mr_foo", "enable_starttls_auto": true, "password": "bar", "support_address": "enterprise@github.com", - "noreply_address": "noreply@github.com" }, "dns": { "primary_nameserver": "8.8.8.8", "secondary_nameserver": - "8.8.4.4" }, "ntp": { "primary_server": "0.ubuntu.pool.ntp.org", "secondary_server": "1.ubuntu.pool.ntp.org" }, - "timezone": { "identifier": "UTC" }, "device": { "path": "/dev/xyz" }, "snmp": { "enabled": false, - "community": "" }, "rsyslog": { "enabled": false, "server": "", "protocol_name": "TCP" }, "assets": { "storage": - "file", "bucket": null, "host_name": null, "key_id": null, "access_key": null }, "pages": { "enabled": true }, - "collectd": { "enabled": false, "server": "", "port": "", "encryption": "", "username": "foo", "password": - "bar" } }, "run_list": [ "role[configure]" ] }'; - $expectedArray = json_decode($expectedJson, true); - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/setup/api/settings', ['license_md5' => $this->getLicenseHash()]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->settings($this->getLicenseHash())); - } - - /** - * @test - */ - public function shouldShowMaintenanceStatus() - { - $expectedJson = '{ "status": "scheduled", "scheduled_time": "Tuesday, January 22 at 15 => 34 -0800", - "connection_services": [ { "name": "git operations", "number": 0 }, { "name": "mysql queries", "number": 233 }, - { "name": "resque jobs", "number": 54 } ] }'; - $expectedArray = json_decode($expectedJson, true); - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/setup/api/maintenance', ['license_md5' => $this->getLicenseHash()]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->maintenance($this->getLicenseHash())); - } - - /** - * @test - */ - public function shouldShowAuthorizedKeys() - { - $expectedJson = '[ { "key": "ssh-rsa AAAAB3NzaC1yc2EAAAAB...", "pretty-print": - "ssh-rsa 01:14:0f:f2:0f:e2:fe:e8:f4:72:62:af:75:f7:1a:88:3e:04:92:64" }, - { "key": "ssh-rsa AAAAB3NzaC1yc2EAAAAB...", "pretty-print": - "ssh-rsa 01:14:0f:f2:0f:e2:fe:e8:f4:72:62:af:75:f7:1a:88:3e:04:92:64" } ]'; - $expectedArray = json_decode($expectedJson, true); - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/setup/api/settings/authorized-keys', ['license_md5' => $this->getLicenseHash()]) - ->will($this->returnValue($expectedArray)); - $this->assertEquals($expectedArray, $api->keys($this->getLicenseHash())); - } - - protected function getLicenseHash() - { - return '1234567890abcdefghijklmnopqrstuv'; - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Enterprise\ManagementConsole::class; - } -} diff --git a/test/Github/Tests/Api/Enterprise/SecretScanningTest.php b/test/Github/Tests/Api/Enterprise/SecretScanningTest.php deleted file mode 100644 index cc5b14b6547..00000000000 --- a/test/Github/Tests/Api/Enterprise/SecretScanningTest.php +++ /dev/null @@ -1,41 +0,0 @@ - 1, 'state' => 'resolved', 'resolution' => 'false_positive'], - ['number' => 2, 'state' => 'open', 'resolution' => null], - ['number' => 3, 'state' => 'resolved', 'resolution' => 'wont_fix'], - ['number' => 4, 'state' => 'resolved', 'resolution' => 'revoked'], - ]; - - /** @var SecretScanning|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/enterprises/KnpLabs/secret-scanning/alerts') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->alerts('KnpLabs', [ - 'state' => 'all', - ])); - } - - protected function getApiClass() - { - return \Github\Api\Enterprise\SecretScanning::class; - } -} diff --git a/test/Github/Tests/Api/Enterprise/StatsTest.php b/test/Github/Tests/Api/Enterprise/StatsTest.php deleted file mode 100644 index f97060e0a14..00000000000 --- a/test/Github/Tests/Api/Enterprise/StatsTest.php +++ /dev/null @@ -1,94 +0,0 @@ -getStatsData(); - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/enterprise/stats/all') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('all')); - } - - /** - * @test - * - * @dataProvider getTypes - */ - public function shouldShowStatsByType($type) - { - $expectedArray = $this->getStatsData($type); - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with(sprintf('/enterprise/stats/%s', $type)) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, call_user_func([$api, $type])); - } - - /** - * @return array - */ - public function getTypes() - { - return [ - ['issues'], - ['hooks'], - ['milestones'], - ['orgs'], - ['comments'], - ['pages'], - ['users'], - ['gists'], - ['pulls'], - ['repos'], - ['all'], - ]; - } - - /** - * @param string $key - * - * @return mixed - */ - protected function getStatsData($key = '') - { - $json = '{"repos":{"total_repos": 212, "root_repos": 194, "fork_repos": 18, "org_repos": 51, - "total_pushes": 3082, "total_wikis": 15 }, "hooks": { "total_hooks": 27, "active_hooks": 23, - "inactive_hooks": 4 }, "pages": { "total_pages": 36 }, "orgs": { "total_orgs": 33, "disabled_orgs": 0, - "total_teams": 60, "total_team_members": 314 }, "users": { "total_users": 254, "admin_users": 45, - "suspended_users": 21 }, "pulls": { "total_pulls": 86, "merged_pulls": 60, "mergeable_pulls": 21, - "unmergeable_pulls": 3 }, "issues": { "total_issues": 179, "open_issues": 83, "closed_issues": 96 }, - "milestones": { "total_milestones": 7, "open_milestones": 6, "closed_milestones": 1 }, "gists": - { "total_gists": 178, "private_gists": 151, "public_gists": 25 }, "comments": { "total_commit_comments": 6, - "total_gist_comments": 28, "total_issue_comments": 366, "total_pull_request_comments": 30 } }'; - $stats = json_decode($json, true); - if (is_null($key)) { - return $stats; - } elseif (array_key_exists($key, $stats)) { - return $stats[$key]; - } - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Enterprise\Stats::class; - } -} diff --git a/test/Github/Tests/Api/Enterprise/UserAdminTest.php b/test/Github/Tests/Api/Enterprise/UserAdminTest.php deleted file mode 100644 index 37b97a43447..00000000000 --- a/test/Github/Tests/Api/Enterprise/UserAdminTest.php +++ /dev/null @@ -1,47 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/users/l3l0/suspended') - ->will($this->returnValue($expectedArray)); - $this->assertEquals($expectedArray, $api->suspend('l3l0')); - } - - /** - * @test - */ - public function shouldUnsuspendUser() - { - $expectedArray = []; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/users/l3l0/suspended') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->unsuspend('l3l0')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Enterprise\UserAdmin::class; - } -} diff --git a/test/Github/Tests/Api/EnterpriseTest.php b/test/Github/Tests/Api/EnterpriseTest.php deleted file mode 100644 index eb69b8e05d0..00000000000 --- a/test/Github/Tests/Api/EnterpriseTest.php +++ /dev/null @@ -1,54 +0,0 @@ -getApiMock(); - - $this->assertInstanceOf(\Github\Api\Enterprise\Stats::class, $api->stats()); - } - - /** - * @test - */ - public function shouldGetEnterpriseLicenseApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Enterprise\License::class, $api->license()); - } - - /** - * @test - */ - public function shouldGetEnterpriseManagementConsoleApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Enterprise\ManagementConsole::class, $api->console()); - } - - /** - * @test - */ - public function shouldGetEnterpriseUserAdminApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Enterprise\UserAdmin::class, $api->userAdmin()); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Enterprise::class; - } -} diff --git a/test/Github/Tests/Api/Environment/SecretsTest.php b/test/Github/Tests/Api/Environment/SecretsTest.php deleted file mode 100644 index 0609a64f0f6..00000000000 --- a/test/Github/Tests/Api/Environment/SecretsTest.php +++ /dev/null @@ -1,116 +0,0 @@ - 'name', 'created_at' => 'created_at', 'updated_at' => 'updated_at'], - ['name' => 'name', 'created_at' => 'created_at', 'updated_at' => 'updated_at'], - ['name' => 'name', 'created_at' => 'created_at', 'updated_at' => 'updated_at'], - ]; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repositories/3948501/environments/production/secrets') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all(3948501, 'production')); - } - - /** - * @test - */ - public function shouldGetEnvironmentSecret() - { - $expectedArray = []; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repositories/3948501/environments/production/secrets/secretName') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show(3948501, 'production', 'secretName')); - } - - /** - * @test - */ - public function shouldUpdateOrCreateEnvironmentSecret() - { - $expectedValue = 'response'; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('put') - ->with('/repositories/3948501/environments/production/secrets/secretName') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->createOrUpdate(3948501, 'production', 'secretName', [ - 'encrypted_value' => 'foo', 'key_id' => 'key_id', - ])); - } - - /** - * @test - */ - public function shouldRemoveEnvironmentSecret() - { - $expectedValue = 'response'; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('delete') - ->with('/repositories/3948501/environments/production/secrets/secretName') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove(3948501, 'production', 'secretName')); - } - - /** - * @test - */ - public function shouldGetPublicKey() - { - $expectedArray = ['key_id' => 'key_id', 'key' => 'foo']; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repositories/3948501/environments/production/secrets/public-key') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->publicKey(3948501, 'production')); - } - - protected function getApiClass() - { - return Secrets::class; - } -} diff --git a/test/Github/Tests/Api/Environment/VariablesTest.php b/test/Github/Tests/Api/Environment/VariablesTest.php deleted file mode 100644 index 0fc01193fd1..00000000000 --- a/test/Github/Tests/Api/Environment/VariablesTest.php +++ /dev/null @@ -1,118 +0,0 @@ - 'name', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at'], - ['name' => 'name', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at'], - ['name' => 'name', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at'], - ]; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repositories/3948501/environments/production/variables') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all(3948501, 'production')); - } - - /** - * @test - */ - public function shouldGetEnvironmentVariable() - { - $expectedArray = []; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repositories/3948501/environments/production/variables/variableName') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show(3948501, 'production', 'variableName')); - } - - /** - * @test - */ - public function shouldCreateEnvironmentVariable() - { - $expectedValue = 'response'; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('post') - ->with('/repositories/3948501/environments/production/variables') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create(3948501, 'production', [ - 'name' => 'foo', 'value' => 'bar', - ])); - } - - /** - * @test - */ - public function shouldUpdateEnvironmentVariable() - { - $expectedValue = 'response'; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('patch') - ->with('/repositories/3948501/environments/production/variables/variableName') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update(3948501, 'production', 'variableName', [ - 'name' => 'variableName', 'value' => 'bar', - ])); - } - - /** - * @test - */ - public function shouldRemoveEnvironmentVariable() - { - $expectedValue = 'response'; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('delete') - ->with('/repositories/3948501/environments/production/variables/variableName') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove(3948501, 'production', 'variableName')); - } - - protected function getApiClass() - { - return Variables::class; - } -} diff --git a/test/Github/Tests/Api/Gist/CommentsTest.php b/test/Github/Tests/Api/Gist/CommentsTest.php deleted file mode 100644 index 9f0b88fda9e..00000000000 --- a/test/Github/Tests/Api/Gist/CommentsTest.php +++ /dev/null @@ -1,97 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/gists/123/comments') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('123')); - } - - /** - * @test - */ - public function shouldShowGistComment() - { - $expectedValue = ['comment1']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/gists/123/comments/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show(123, 123)); - } - - /** - * @test - */ - public function shouldCreateGistComment() - { - $expectedValue = ['comment1data']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/gists/123/comments', ['body' => 'Test body']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('123', 'Test body')); - } - - /** - * @test - */ - public function shouldUpdateGistComment() - { - $expectedValue = ['comment1data']; - $data = ['body' => 'body test']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/gists/123/comments/233', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update(123, 233, 'body test')); - } - - /** - * @test - */ - public function shouldRemoveComment() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/gists/123/comments/233') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove(123, 233)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Gist\Comments::class; - } -} diff --git a/test/Github/Tests/Api/GistsTest.php b/test/Github/Tests/Api/GistsTest.php deleted file mode 100644 index ff4673e4082..00000000000 --- a/test/Github/Tests/Api/GistsTest.php +++ /dev/null @@ -1,266 +0,0 @@ - '123']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/gists/starred') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all('starred')); - } - - /** - * @test - */ - public function shouldGetAllGists() - { - $expectedArray = [['id' => '123']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/gists') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all()); - } - - /** - * @test - */ - public function shouldShowGist() - { - $expectedArray = ['id' => '123']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/gists/123') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show(123)); - } - - /** - * @test - */ - public function shouldShowGistWithSpecificReference() - { - $expectedArray = ['id' => '123', 'sha' => 'd189dbd4c5d96442db74ebcb62bb38e661a0c8ce']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/gists/123/d189dbd4c5d96442db74ebcb62bb38e661a0c8ce') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->revision(123, 'd189dbd4c5d96442db74ebcb62bb38e661a0c8ce')); - } - - /** - * @test - */ - public function shouldShowCommits() - { - $expectedArray = ['id' => '123']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/gists/123/commits') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->commits(123)); - } - - /** - * @test - */ - public function shouldGetCommentsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Gist\Comments::class, $api->comments()); - } - - /** - * @test - */ - public function shouldForkGist() - { - $expectedArray = ['id' => '123']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/gists/123/fork') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->fork(123)); - } - - /** - * @test - */ - public function shouldListGistForks() - { - $expectedArray = ['id' => '123']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/gists/123/forks') - ->will($this->returnValue($expectedArray)); - - $api->forks(123); - } - - /** - * @test - */ - public function shouldNotCreateGistWithoutFile() - { - $this->expectException(MissingArgumentException::class); - $input = [ - 'description' => '', - 'public' => false, - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create($input); - } - - /** - * @test - */ - public function shouldCheckGist() - { - $expectedArray = ['id' => '123']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/gists/123/star') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->check(123)); - } - - /** - * @test - */ - public function shouldStarGist() - { - $expectedArray = ['id' => '123']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/gists/123/star') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->star(123)); - } - - /** - * @test - */ - public function shouldUnstarGist() - { - $expectedArray = ['id' => '123']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/gists/123/star') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->unstar(123)); - } - - /** - * @test - */ - public function shouldCreateAnonymousGist() - { - $input = [ - 'description' => '', - 'public' => false, - 'files' => [ - 'filename.txt' => [ - 'content' => 'content', - ], - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/gists', $input); - - $api->create($input); - } - - /** - * @test - */ - public function shouldUpdateGist() - { - $input = [ - 'description' => 'jimbo', - 'files' => [ - 'filename.txt' => [ - 'filename' => 'new_name.txt', - 'content' => 'content', - ], - 'filename_new.txt' => [ - 'content' => 'content new', - ], - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/gists/5', $input); - - $api->update(5, $input); - } - - /** - * @test - */ - public function shouldDeleteGist() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/gists/5'); - - $api->remove(5); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Gists::class; - } -} diff --git a/test/Github/Tests/Api/GitData/BlobsTest.php b/test/Github/Tests/Api/GitData/BlobsTest.php deleted file mode 100644 index 4b87ed33e41..00000000000 --- a/test/Github/Tests/Api/GitData/BlobsTest.php +++ /dev/null @@ -1,93 +0,0 @@ - 'some data']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/l3l0/l3l0repo/git/blobs/123456sha') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('l3l0', 'l3l0repo', '123456sha')); - } - - /** - * @test - */ - public function shouldShowRawBlob() - { - $expectedValue = ['blob' => 'some data']; - - $client = $this->getMockBuilder('Github\Client') - ->disableOriginalConstructor() - ->getMock(); - - $api = $this->getMockBuilder($this->getApiClass()) - ->setMethods(['configure', 'get']) - ->setConstructorArgs([$client]) - ->getMock(); - $api->expects($this->once()) - ->method('configure') - ->with('raw'); - $api->expects($this->once()) - ->method('get') - ->with('/repos/l3l0/l3l0repo/git/blobs/123456sha') - ->will($this->returnValue($expectedValue)); - - $api->configure('raw'); - - $this->assertEquals($expectedValue, $api->show('l3l0', 'l3l0repo', '123456sha')); - } - - /** - * @test - */ - public function shouldCreateBlob() - { - $expectedValue = ['blob' => 'some data']; - $data = ['content' => 'some cotent', 'encoding' => 'utf8']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/l3l0/l3l0repo/git/blobs', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('l3l0', 'l3l0repo', $data)); - } - - /** - * @test - */ - public function shouldNotCreateBlobWithoutContent() - { - $this->expectException(MissingArgumentException::class); - $data = ['encoding' => 'utf8']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('l3l0', 'l3l0repo', $data); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\GitData\Blobs::class; - } -} diff --git a/test/Github/Tests/Api/GitData/CommitsTest.php b/test/Github/Tests/Api/GitData/CommitsTest.php deleted file mode 100644 index 20903f3e1f2..00000000000 --- a/test/Github/Tests/Api/GitData/CommitsTest.php +++ /dev/null @@ -1,95 +0,0 @@ - '123', 'comitter']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/git/commits/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldCreateCommit() - { - $expectedValue = ['sha' => '123', 'comitter']; - $data = ['message' => 'some message', 'tree' => 1234, 'parents' => []]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/git/commits', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldNotCreateCommitWithoutMessageParam() - { - $this->expectException(MissingArgumentException::class); - $data = ['tree' => 1234, 'parents' => []]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateCommitWithoutTreeParam() - { - $this->expectException(MissingArgumentException::class); - $data = ['message' => 'some message', 'parents' => []]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateCommitWithoutParentsParam() - { - $this->expectException(MissingArgumentException::class); - $data = ['message' => 'some message', 'tree' => '12334']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\GitData\Commits::class; - } -} diff --git a/test/Github/Tests/Api/GitData/ReferencesTest.php b/test/Github/Tests/Api/GitData/ReferencesTest.php deleted file mode 100644 index 70f17cde1d8..00000000000 --- a/test/Github/Tests/Api/GitData/ReferencesTest.php +++ /dev/null @@ -1,208 +0,0 @@ - 'some data']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/l3l0/l3l0repo/git/refs/master/some%2A%26%40%23branch/dasd1212') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('l3l0', 'l3l0repo', 'master/some*&@#branch/dasd1212')); - } - - /** - * @test - */ - public function shouldShowReference() - { - $expectedValue = ['reference' => 'some data']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/l3l0/l3l0repo/git/refs/123456sha') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('l3l0', 'l3l0repo', '123456sha')); - } - - /** - * @test - */ - public function shouldRemoveReference() - { - $expectedValue = ['reference' => 'some data']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/l3l0/l3l0repo/git/refs/123456sha') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('l3l0', 'l3l0repo', '123456sha')); - } - - /** - * @test - */ - public function shouldGetAllRepoReferences() - { - $expectedValue = [['reference' => 'some data']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/l3l0/l3l0repo/git/refs') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('l3l0', 'l3l0repo')); - } - - /** - * @test - */ - public function shouldGetAllMatchingReferences() - { - $expectedValue = [['reference' => 'some data']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/l3l0/l3l0repo/git/matching-refs/heads/refName') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->matching('l3l0', 'l3l0repo', 'heads/refName')); - } - - /** - * @test - */ - public function shouldGetAllRepoBranches() - { - $expectedValue = [['branch' => 'some data']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/l3l0/l3l0repo/git/refs/heads') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->branches('l3l0', 'l3l0repo')); - } - - /** - * @test - */ - public function shouldGetAllRepoTags() - { - $expectedValue = [['tag' => 'some data']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/l3l0/l3l0repo/git/refs/tags') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->tags('l3l0', 'l3l0repo')); - } - - /** - * @test - */ - public function shouldCreateReference() - { - $expectedValue = ['reference' => 'some data']; - $data = ['ref' => '122', 'sha' => '1234']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/l3l0/l3l0repo/git/refs', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('l3l0', 'l3l0repo', $data)); - } - - /** - * @test - */ - public function shouldNotCreateReferenceWithoutShaParam() - { - $this->expectException(MissingArgumentException::class); - $data = ['ref' => '123']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('l3l0', 'l3l0repo', $data); - } - - /** - * @test - */ - public function shouldNotCreateReferenceWithoutRefsParam() - { - $this->expectException(MissingArgumentException::class); - $data = ['sha' => '1234']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('l3l0', 'l3l0repo', $data); - } - - /** - * @test - */ - public function shouldUpdateReference() - { - $expectedValue = ['reference' => 'some data']; - $data = ['sha' => '12345sha']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/l3l0/l3l0repo/git/refs/someRefs', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('l3l0', 'l3l0repo', 'someRefs', $data)); - } - - /** - * @test - */ - public function shouldNoUpdateReferenceWithoutSha() - { - $this->expectException(MissingArgumentException::class); - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('patch'); - - $api->update('l3l0', 'l3l0repo', 'someRefs', $data); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\GitData\References::class; - } -} diff --git a/test/Github/Tests/Api/GitData/TagsTest.php b/test/Github/Tests/Api/GitData/TagsTest.php deleted file mode 100644 index 83230175554..00000000000 --- a/test/Github/Tests/Api/GitData/TagsTest.php +++ /dev/null @@ -1,263 +0,0 @@ - '123', 'comitter']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/git/tags/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldGetAllTags() - { - $expectedValue = [['sha' => '123', 'tagger']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/git/refs/tags') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldCreateTag() - { - $expectedValue = ['sha' => '123', 'comitter']; - $data = [ - 'message' => 'some message', - 'tag' => 'v2.2', - 'object' => 'test', - 'type' => 'unsigned', - 'tagger' => [ - 'name' => 'l3l0', - 'email' => 'leszek.prabucki@gmail.com', - 'date' => date('Y-m-d H:i:s'), - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/git/tags', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldNotCreateTagWithoutMessageParam() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'tag' => 'v2.2', - 'object' => 'test', - 'type' => 'unsigned', - 'tagger' => [ - 'name' => 'l3l0', - 'email' => 'leszek.prabucki@gmail.com', - 'date' => date('Y-m-d H:i:s'), - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldCreateTagWithoutTaggerParam() - { - $data = [ - 'message' => 'some message', - 'tag' => 'v2.2', - 'object' => 'test', - 'type' => 'unsigned', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateTagWithoutTaggerNameParam() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'message' => 'some message', - 'tag' => 'v2.2', - 'object' => 'test', - 'type' => 'unsigned', - 'tagger' => [ - 'email' => 'leszek.prabucki@gmail.com', - 'date' => date('Y-m-d H:i:s'), - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateTagWithoutTaggerEmailParam() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'message' => 'some message', - 'tag' => 'v2.2', - 'object' => 'test', - 'type' => 'unsigned', - 'tagger' => [ - 'name' => 'l3l0', - 'date' => date('Y-m-d H:i:s'), - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateTagWithoutTaggerDateParam() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'message' => 'some message', - 'tag' => 'v2.2', - 'object' => 'test', - 'type' => 'unsigned', - 'tagger' => [ - 'name' => 'l3l0', - 'email' => 'leszek.prabucki@gmail.com', - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateTagWithoutTagParam() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'message' => 'some message', - 'object' => 'test', - 'type' => 'unsigned', - 'tagger' => [ - 'name' => 'l3l0', - 'email' => 'leszek.prabucki@gmail.com', - 'date' => date('Y-m-d H:i:s'), - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateTagWithoutObjectParam() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'message' => 'some message', - 'tag' => 'v2.2', - 'type' => 'unsigned', - 'tagger' => [ - 'name' => 'l3l0', - 'email' => 'leszek.prabucki@gmail.com', - 'date' => date('Y-m-d H:i:s'), - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateTagWithoutTypeParam() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'message' => 'some message', - 'tag' => 'v2.2', - 'object' => 'test', - 'tagger' => [ - 'name' => 'l3l0', - 'email' => 'leszek.prabucki@gmail.com', - 'date' => date('Y-m-d H:i:s'), - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\GitData\Tags::class; - } -} diff --git a/test/Github/Tests/Api/GitData/TreesTest.php b/test/Github/Tests/Api/GitData/TreesTest.php deleted file mode 100644 index 0b415f1fb1c..00000000000 --- a/test/Github/Tests/Api/GitData/TreesTest.php +++ /dev/null @@ -1,213 +0,0 @@ - '123', 'comitter']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/git/trees/123', []) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldCreateTreeUsingSha() - { - $expectedValue = ['sha' => '123', 'comitter']; - $data = [ - 'tree' => [ - [ - 'path' => 'path', - 'mode' => 'mode', - 'type' => 'type', - 'sha' => '1234', - ], - [ - 'path' => 'htap', - 'mode' => 'edom', - 'type' => 'epyt', - 'sha' => '4321', - ], - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/git/trees', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldCreateTreeUsingContent() - { - $expectedValue = ['sha' => '123', 'comitter']; - $data = [ - 'tree' => [ - [ - 'path' => 'path', - 'mode' => 'mode', - 'type' => 'type', - 'content' => 'content', - ], - [ - 'path' => 'htap', - 'mode' => 'edom', - 'type' => 'epyt', - 'content' => 'tnetnoc', - ], - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/git/trees', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldNotCreateTreeWithoutShaAndContentParam() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'tree' => [ - 'path' => 'path', - 'mode' => 'mode', - 'type' => 'type', - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateTreeWithoutPathParam() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'tree' => [ - 'mode' => 'mode', - 'type' => 'type', - 'content' => 'content', - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateTreeWithoutModeParam() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'tree' => [ - 'path' => 'path', - 'type' => 'type', - 'content' => 'content', - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateTreeWithoutTypeParam() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'tree' => [ - 'path' => 'path', - 'mode' => 'mode', - 'content' => 'content', - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateTreeWithoutTreeParam() - { - $this->expectException(MissingArgumentException::class); - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateTreeWhenTreeParamIsNotArray() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'tree' => '', - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\GitData\Trees::class; - } -} diff --git a/test/Github/Tests/Api/GitDataTest.php b/test/Github/Tests/Api/GitDataTest.php deleted file mode 100644 index 4c25936b994..00000000000 --- a/test/Github/Tests/Api/GitDataTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getApiMock(); - - $this->assertInstanceOf(\Github\Api\GitData\Blobs::class, $api->blobs()); - } - - /** - * @test - */ - public function shouldGetCommitsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\GitData\Commits::class, $api->commits()); - } - - /** - * @test - */ - public function shouldGetReferencesApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\GitData\References::class, $api->references()); - } - - /** - * @test - */ - public function shouldGetTagsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\GitData\Tags::class, $api->tags()); - } - - /** - * @test - */ - public function shouldGetTreesApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\GitData\Trees::class, $api->trees()); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\GitData::class; - } -} diff --git a/test/Github/Tests/Api/GraphQLTest.php b/test/Github/Tests/Api/GraphQLTest.php deleted file mode 100644 index b241cc5ae90..00000000000 --- a/test/Github/Tests/Api/GraphQLTest.php +++ /dev/null @@ -1,58 +0,0 @@ -getApiMock(); - - $api->expects($this->once()) - ->method('post') - ->with($this->equalTo('/graphql'), $this->equalTo(['query' => 'bar'])) - ->will($this->returnValue('foo')); - - $result = $api->execute('bar'); - $this->assertEquals('foo', $result); - } - - /** - * @test - */ - public function shouldSupportGraphQLVariables() - { - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('post') - ->with('/graphql', $this->arrayHasKey('variables')); - - $api->execute('bar', ['variable' => 'foo']); - } - - /** - * @test - */ - public function shouldJSONEncodeGraphQLVariables() - { - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('post') - ->with('/graphql', $this->equalTo([ - 'query' => 'bar', - 'variables' => '{"variable":"foo"}', - ])); - - $api->execute('bar', ['variable' => 'foo']); - } - - protected function getApiClass() - { - return \Github\Api\GraphQL::class; - } -} diff --git a/test/Github/Tests/Api/Issue/AssigneesTest.php b/test/Github/Tests/Api/Issue/AssigneesTest.php deleted file mode 100644 index b6939a1b59e..00000000000 --- a/test/Github/Tests/Api/Issue/AssigneesTest.php +++ /dev/null @@ -1,108 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/knplabs/php-github-api/assignees'); - - $api->listAvailable('knplabs', 'php-github-api'); - } - - /** - * @test - */ - public function shouldCheckAssignee() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/knplabs/php-github-api/assignees/test-user'); - - $api->check('knplabs', 'php-github-api', 'test-user'); - } - - /** - * @test - */ - public function shouldNotAddAssigneeMissingParameter() - { - $this->expectException(MissingArgumentException::class); - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->add('knplabs', 'php-github-api', 4, $data); - } - - /** - * @test - */ - public function shouldAddAssignee() - { - $data = [ - 'assignees' => ['test-user'], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/knplabs/php-github-api/issues/4/assignees', $data); - - $api->add('knplabs', 'php-github-api', 4, $data); - } - - /** - * @test - */ - public function shouldNotRemoveAssigneeMissingParameter() - { - $this->expectException(MissingArgumentException::class); - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('delete'); - - $api->remove('knplabs', 'php-github-api', 4, $data); - } - - /** - * @test - */ - public function shouldRemoveAssignee() - { - $data = [ - 'assignees' => ['test-user'], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/knplabs/php-github-api/issues/4/assignees', $data); - - $api->remove('knplabs', 'php-github-api', 4, $data); - } - - /** - * @return string - */ - protected function getApiClass() - { - return Assignees::class; - } -} diff --git a/test/Github/Tests/Api/Issue/CommentsTest.php b/test/Github/Tests/Api/Issue/CommentsTest.php deleted file mode 100644 index 3a8db85a922..00000000000 --- a/test/Github/Tests/Api/Issue/CommentsTest.php +++ /dev/null @@ -1,147 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/issues/123/comments', []) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldGetAllIssueCommentsBySpecifyParameters() - { - $expectedValue = [['comment1data'], ['comment2data']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/issues/123/comments', ['since' => '1990-08-03T00:00:00Z']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 123, [ - 'since' => '1990-08-03T00:00:00Z', - ])); - } - - /** - * @test - */ - public function shouldShowIssueComment() - { - $expectedValue = ['comment1']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/issues/comments/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldNotCreateWithoutBody() - { - $this->expectException(MissingArgumentException::class); - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', '123', $data); - } - - /** - * @test - */ - public function shouldCreateIssueComment() - { - $expectedValue = ['comment1data']; - $data = ['body' => 'test body']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/issues/123/comments', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', '123', $data)); - } - - /** - * @test - */ - public function shouldNotUpdateWithoutBody() - { - $this->expectException(MissingArgumentException::class); - $data = ['somedata']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('patch'); - - $api->update('KnpLabs', 'php-github-api', '123', $data); - } - - /** - * @test - */ - public function shouldUpdateIssueComment() - { - $expectedValue = ['comment1data']; - $data = ['body' => 'body test']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/issues/comments/233', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', '233', $data)); - } - - /** - * @test - */ - public function shouldRemoveComment() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/issues/comments/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 123)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Issue\Comments::class; - } -} diff --git a/test/Github/Tests/Api/Issue/EventsTest.php b/test/Github/Tests/Api/Issue/EventsTest.php deleted file mode 100644 index 37139936c63..00000000000 --- a/test/Github/Tests/Api/Issue/EventsTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/issues/events', ['page' => 1]) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetIssueEvents() - { - $expectedValue = [['event1data'], ['event2data']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/issues/123/events', ['page' => 1]) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldShowIssueEvent() - { - $expectedValue = ['event1']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/issues/events/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Issue\Events::class; - } -} diff --git a/test/Github/Tests/Api/Issue/LabelsTest.php b/test/Github/Tests/Api/Issue/LabelsTest.php deleted file mode 100644 index ec55ccc54cb..00000000000 --- a/test/Github/Tests/Api/Issue/LabelsTest.php +++ /dev/null @@ -1,229 +0,0 @@ - 'l3l0repo'], - ['name' => 'other'], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/labels', []) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetAllIssueLabels() - { - $expectedValue = [['name' => 'label']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/issues/123/labels') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', '123')); - } - - /** - * @test - */ - public function shouldCreateLabel() - { - $expectedValue = [['name' => 'label', 'color' => 'FFFFFF']]; - $data = ['name' => 'label']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/labels', $data + ['color' => 'FFFFFF']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldGetSingleLabel() - { - $expectedValue = [['name' => 'label1']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/labels/label1') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'label1')); - } - - /** - * @test - */ - public function shouldCreateLabelWithColor() - { - $expectedValue = [['name' => 'label', 'color' => '111111']]; - $data = ['name' => 'label', 'color' => '111111']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/labels', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldDeleteLabel() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/labels/foo') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->deleteLabel('KnpLabs', 'php-github-api', 'foo')); - } - - /** - * @test - */ - public function shouldUpdateLabel() - { - $expectedValue = [['name' => 'bar', 'color' => 'FFF']]; - $data = ['name' => 'bar', 'color' => 'FFF']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/labels/foo', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 'foo', 'bar', 'FFF')); - } - - /** - * @test - */ - public function shouldRemoveLabel() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/issues/123/labels/somename') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 123, 'somename')); - } - - /** - * @test - */ - public function shouldAddOneLabel() - { - $expectedValue = ['label' => 'somename']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/issues/123/labels', ['labelname']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->add('KnpLabs', 'php-github-api', 123, 'labelname')); - } - - /** - * @test - */ - public function shouldAddManyLabels() - { - $expectedValue = ['label' => 'somename']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/issues/123/labels', ['labelname', 'labelname2']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->add('KnpLabs', 'php-github-api', 123, ['labelname', 'labelname2'])); - } - - /** - * @test - */ - public function shouldReplaceLabels() - { - $expectedValue = [['label' => 'somename']]; - $data = ['labels' => ['labelname']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/issues/123/labels', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->replace('KnpLabs', 'php-github-api', 123, $data)); - } - - /** - * @test - */ - public function shouldNotAddWhenDoNotHaveLabelsToAdd() - { - $this->expectException(InvalidArgumentException::class); - $api = $this->getApiMock(); - $api->expects($this->any()) - ->method('post'); - - $api->add('KnpLabs', 'php-github-api', 123, []); - } - - /** - * @test - */ - public function shouldClearLabels() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/issues/123/labels') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->clear('KnpLabs', 'php-github-api', 123)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Issue\Labels::class; - } -} diff --git a/test/Github/Tests/Api/Issue/MilestonesTest.php b/test/Github/Tests/Api/Issue/MilestonesTest.php deleted file mode 100644 index 6a1996e0bbc..00000000000 --- a/test/Github/Tests/Api/Issue/MilestonesTest.php +++ /dev/null @@ -1,229 +0,0 @@ - 'l3l0repo']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/milestones', ['page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldCreateMilestone() - { - $expectedValue = [['title' => 'milestone']]; - $data = ['title' => 'milestone']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/milestones', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldNotCreateMilestoneWithoutTitle() - { - $this->expectException(MissingArgumentException::class); - $expectedValue = [['title' => 'milestone']]; - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldSetStateToOpenWhileCreationWhenStateParamNotRecognized() - { - $expectedValue = ['title' => 'l3l0repo']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/milestones', ['state' => 'open', 'title' => 'milestone']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', ['state' => 'clos', 'title' => 'milestone'])); - } - - /** - * @test - */ - public function shouldUpdateMilestone() - { - $expectedValue = [['title' => 'milestone']]; - $data = ['title' => 'milestone']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/milestones/123', ['title' => 'milestone']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data)); - } - - /** - * @test - */ - public function shouldUpdateMilestoneWithClosedStatus() - { - $expectedValue = [['title' => 'milestone']]; - $data = ['title' => 'milestone', 'status' => 'closed']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/milestones/123', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data)); - } - - /** - * @test - */ - public function shouldSetStateToOpenWhileUpdateWhenStateParamNotRecognized() - { - $expectedValue = ['title' => 'l3l0repo']; - $data = ['title' => 'milestone', 'state' => 'some']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/milestones/123', ['state' => 'open', 'title' => 'milestone']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data)); - } - - /** - * @test - */ - public function shouldSortByDueDateWhenSortParamNotRecognized() - { - $expectedValue = [['name' => 'l3l0repo']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/milestones', ['page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', ['sort' => 'completenes'])); - } - - /** - * @test - */ - public function shouldSetStateToOpenWhenStateParamNotRecognized() - { - $expectedValue = [['name' => 'l3l0repo']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/milestones', ['page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', ['state' => 'clos'])); - } - - /** - * @test - */ - public function shouldSetDirectionToDescWhenDirectionParamNotRecognized() - { - $expectedValue = [['name' => 'l3l0repo']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/milestones', ['page' => 1, 'state' => 'open', 'sort' => 'due_date', 'direction' => 'asc']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', ['direction' => 'asc'])); - } - - /** - * @test - */ - public function shouldRemoveMilestones() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/milestones/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldShowMilestone() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/milestones/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldGetMilestoneLabels() - { - $expectedValue = [['label'], ['label2']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/milestones/123/labels') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->labels('KnpLabs', 'php-github-api', 123)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Issue\Milestones::class; - } -} diff --git a/test/Github/Tests/Api/Issue/TimelineTest.php b/test/Github/Tests/Api/Issue/TimelineTest.php deleted file mode 100644 index 401219af32b..00000000000 --- a/test/Github/Tests/Api/Issue/TimelineTest.php +++ /dev/null @@ -1,35 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/issues/123/timeline', []) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 123)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Issue\Timeline::class; - } -} diff --git a/test/Github/Tests/Api/IssueTest.php b/test/Github/Tests/Api/IssueTest.php deleted file mode 100644 index a151076ce1f..00000000000 --- a/test/Github/Tests/Api/IssueTest.php +++ /dev/null @@ -1,246 +0,0 @@ - 'open', - ]; - $sentData = $data + [ - 'page' => 1, - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/ornicar/php-github-api/issues', $sentData); - - $api->all('ornicar', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldGetIssuesUsingAdditionalParameters() - { - $expectedArray = [['id' => '123']]; - $data = [ - 'state' => 'open', - 'milestone' => '*', - 'assignee' => 'l3l0', - 'mentioned' => 'l3l0', - 'labels' => 'bug,@high', - 'sort' => 'created', - 'direction' => 'asc', - ]; - $sentData = $data + [ - 'page' => 1, - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/ornicar/php-github-api/issues', $sentData) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all('ornicar', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldShowIssue() - { - $expectedArray = ['id' => '123']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/ornicar/php-github-api/issues/14') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('ornicar', 'php-github-api', 14)); - } - - /** - * @test - */ - public function shouldCreateIssue() - { - $data = [ - 'title' => 'some title', - 'body' => 'some body', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/ornicar/php-github-api/issues', $data); - - $api->create('ornicar', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateIssueWithoutTitle() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'body' => 'some body', - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('ornicar', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldCreateIssueWithoutBody() - { - $data = [ - 'title' => 'some title', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/ornicar/php-github-api/issues', $data); - - $api->create('ornicar', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldCloseIssue() - { - $data = [ - 'state' => 'closed', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/ornicar/php-github-api/issues/14', $data); - - $api->update('ornicar', 'php-github-api', 14, $data); - } - - /** - * @test - */ - public function shouldReOpenIssue() - { - $data = [ - 'state' => 'open', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/ornicar/php-github-api/issues/14', $data); - - $api->update('ornicar', 'php-github-api', 14, $data); - } - - /** - * @test - */ - public function shouldGetCommentsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Issue\Comments::class, $api->comments()); - } - - /** - * @test - */ - public function shouldGetEventsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Issue\Events::class, $api->events()); - } - - /** - * @test - */ - public function shouldGetLabelsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Issue\Labels::class, $api->labels()); - } - - /** - * @test - */ - public function shouldGetMilestonesApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Issue\Milestones::class, $api->milestones()); - } - - /** - * @test - */ - public function shouldGetTimelineApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Issue\Timeline::class, $api->timeline()); - } - - /** - * @test - */ - public function shouldLockIssue() - { - $parameters = []; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/repos/knplabs/php-github-api/issues/1/lock', $parameters); - - $api->lock('knplabs', 'php-github-api', '1'); - } - - /** - * @test - */ - public function shouldUnlockIssue() - { - $parameters = []; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/knplabs/php-github-api/issues/1/lock', $parameters); - - $api->unlock('knplabs', 'php-github-api', '1'); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Issue::class; - } -} diff --git a/test/Github/Tests/Api/MetaTest.php b/test/Github/Tests/Api/MetaTest.php deleted file mode 100644 index 9275e5a1f1b..00000000000 --- a/test/Github/Tests/Api/MetaTest.php +++ /dev/null @@ -1,37 +0,0 @@ - [ - '127.0.0.1/32', - ], - 'git' => [ - '127.0.0.1/32', - ], - 'verifiable_password_authentication' => true, - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->service()); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Meta::class; - } -} diff --git a/test/Github/Tests/Api/Miscellaneous/CodeOfConductTest.php b/test/Github/Tests/Api/Miscellaneous/CodeOfConductTest.php deleted file mode 100644 index 0e07dea5752..00000000000 --- a/test/Github/Tests/Api/Miscellaneous/CodeOfConductTest.php +++ /dev/null @@ -1,54 +0,0 @@ - 'CoC1'], - ['name' => 'CoC2'], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/codes_of_conduct') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all()); - } - - /** - * @test - */ - public function shouldGetSingleCodeOfConducts() - { - $expectedArray = [ - 'name' => 'CoC', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/codes_of_conduct/contributor_covenant') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('contributor_covenant')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return CodeOfConduct::class; - } -} diff --git a/test/Github/Tests/Api/Miscellaneous/EmojisTest.php b/test/Github/Tests/Api/Miscellaneous/EmojisTest.php deleted file mode 100644 index b4408b80aa1..00000000000 --- a/test/Github/Tests/Api/Miscellaneous/EmojisTest.php +++ /dev/null @@ -1,36 +0,0 @@ - 'https://github.global.ssl.fastly.net/images/icons/emoji/+1.png?v5', - '-1' => 'https://github.global.ssl.fastly.net/images/icons/emoji/-1.png?v5', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/emojis') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all()); - } - - /** - * @return string - */ - protected function getApiClass() - { - return Emojis::class; - } -} diff --git a/test/Github/Tests/Api/Miscellaneous/GitignoreTest.php b/test/Github/Tests/Api/Miscellaneous/GitignoreTest.php deleted file mode 100644 index 6a244adaef5..00000000000 --- a/test/Github/Tests/Api/Miscellaneous/GitignoreTest.php +++ /dev/null @@ -1,60 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/gitignore/templates') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all()); - } - - /** - * @test - */ - public function shouldGetTemplate() - { - $expectedArray = [ - 'name' => 'C', - 'source' => "# Object files\n*.o\n\n# Libraries\n*.lib\n*.a", - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/gitignore/templates/C') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('C')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return Gitignore::class; - } -} diff --git a/test/Github/Tests/Api/Miscellaneous/LicensesTest.php b/test/Github/Tests/Api/Miscellaneous/LicensesTest.php deleted file mode 100644 index ed504c9b4aa..00000000000 --- a/test/Github/Tests/Api/Miscellaneous/LicensesTest.php +++ /dev/null @@ -1,54 +0,0 @@ - 'mit'], - ['key' => 'apache-2.0'], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/licenses') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all()); - } - - /** - * @test - */ - public function shouldGetSingleLicenses() - { - $expectedArray = [ - 'key' => 'gpl-2.0', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/licenses/gpl-2.0') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('gpl-2.0')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return Licenses::class; - } -} diff --git a/test/Github/Tests/Api/Miscellaneous/MarkdownTest.php b/test/Github/Tests/Api/Miscellaneous/MarkdownTest.php deleted file mode 100644 index b327a1b83c8..00000000000 --- a/test/Github/Tests/Api/Miscellaneous/MarkdownTest.php +++ /dev/null @@ -1,97 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/markdown', ['text' => $input, 'mode' => 'markdown']); - - $api->render($input); - } - - /** - * @test - */ - public function shouldRenderMarkdownUsingGfmMode() - { - $input = 'Hello world github/linguist#1 **cool**, and #1!'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/markdown', ['text' => $input, 'mode' => 'gfm']); - - $api->render($input, 'gfm'); - } - - /** - * @test - */ - public function shouldSetModeToMarkdownWhenIsNotRecognized() - { - $input = 'Hello world github/linguist#1 **cool**, and #1!'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/markdown', ['text' => $input, 'mode' => 'markdown']); - - $api->render($input, 'abc'); - } - - /** - * @test - */ - public function shouldSetContextOnlyForGfmMode() - { - $input = 'Hello world github/linguist#1 **cool**, and #1!'; - - $apiWithMarkdown = $this->getApiMock(); - $apiWithMarkdown->expects($this->once()) - ->method('post') - ->with('/markdown', ['text' => $input, 'mode' => 'markdown']); - - $apiWithGfm = $this->getApiMock(); - $apiWithGfm->expects($this->once()) - ->method('post') - ->with('/markdown', ['text' => $input, 'mode' => 'gfm', 'context' => 'someContext']); - - $apiWithMarkdown->render($input, 'markdown', 'someContext'); - $apiWithGfm->render($input, 'gfm', 'someContext'); - } - - /** - * @test - */ - public function shouldRenderRawFile() - { - $file = 'file'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/markdown/raw', ['file' => $file]); - - $api->renderRaw($file); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Markdown::class; - } -} diff --git a/test/Github/Tests/Api/NotificationTest.php b/test/Github/Tests/Api/NotificationTest.php deleted file mode 100644 index 7ef3e64ba45..00000000000 --- a/test/Github/Tests/Api/NotificationTest.php +++ /dev/null @@ -1,153 +0,0 @@ - false, - 'participating' => false, - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/notifications', $parameters); - - $api->all(); - } - - /** - * @test - */ - public function shouldGetNotificationsSince() - { - $since = new DateTime('now'); - - $parameters = [ - 'all' => false, - 'participating' => false, - 'since' => $since->format(DateTime::ISO8601), - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/notifications', $parameters); - - $api->all(false, false, $since); - } - - /** - * @test - */ - public function shouldGetNotificationsBefore() - { - $before = new DateTime('now'); - - $parameters = [ - 'all' => false, - 'participating' => false, - 'before' => $before->format(DateTime::ISO8601), - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/notifications', $parameters); - - $api->all(false, false, null, $before); - } - - /** - * @test - */ - public function shouldGetNotificationsIncludingAndParticipating() - { - $parameters = [ - 'all' => true, - 'participating' => true, - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/notifications', $parameters); - - $api->all(true, true); - } - - /** - * @test - */ - public function shouldMarkNotificationsAsRead() - { - $parameters = []; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/notifications', $parameters); - - $api->markRead(); - } - - /** - * @test - */ - public function shouldMarkNotificationsAsReadForGivenDate() - { - $since = new DateTime('now'); - - $parameters = [ - 'last_read_at' => $since->format(DateTime::ISO8601), - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/notifications', $parameters); - - $api->markRead($since); - } - - /** - * @test - */ - public function shouldMarkThreadAsRead() - { - $id = mt_rand(1, time()); - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/notifications/threads/'.$id); - - $api->markThreadRead($id); - } - - public function shouldGetNotification() - { - $id = mt_rand(1, time()); - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/notification/'.$id); - - $api->id($id); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Notification::class; - } -} diff --git a/test/Github/Tests/Api/Organization/Actions/SecretsTest.php b/test/Github/Tests/Api/Organization/Actions/SecretsTest.php deleted file mode 100644 index 324b706975d..00000000000 --- a/test/Github/Tests/Api/Organization/Actions/SecretsTest.php +++ /dev/null @@ -1,219 +0,0 @@ - 'name', 'created_at' => 'created_at', 'updated_at' => 'updated_at', 'visibility' => 'all'], - ['name' => 'name', 'created_at' => 'created_at', 'updated_at' => 'updated_at', 'visibility' => 'private'], - ['name' => 'name', 'created_at' => 'created_at', 'updated_at' => 'updated_at', 'visibility' => 'selected'], - ]; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/actions/secrets') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all('KnpLabs')); - } - - /** - * @test - */ - public function shouldGetOrganizationSecret() - { - $expectedArray = []; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/actions/secrets/secretName') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('KnpLabs', 'secretName')); - } - - /** - * @test - */ - public function shouldCreateOrganizationSecret() - { - $expectedValue = 'response'; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('put') - ->with('/orgs/KnpLabs/actions/secrets/secretName') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'secretName', [ - 'encrypted_value' => 'foo', 'visibility' => 'all', 'selected_repository_ids' => [1, 2, 3], - ])); - } - - /** - * @test - */ - public function shouldUpdateOrganizationSecret() - { - $expectedValue = 'response'; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('put') - ->with('/orgs/KnpLabs/actions/secrets/secretName') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 'secretName', [ - 'key_id' => 'keyId', - 'encrypted_value' => 'encryptedValue', - 'visibility' => 'private', - ])); - } - - /** - * @test - */ - public function shouldRemoveOrganizationSecret() - { - $expectedValue = 'response'; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('delete') - ->with('/orgs/KnpLabs/actions/secrets/secretName') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'secretName')); - } - - /** - * @test - */ - public function shouldGetSelectedRepositories() - { - $expectedArray = [1, 2, 3]; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/actions/secrets/secretName/repositories') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->selectedRepositories('KnpLabs', 'secretName')); - } - - /** - * @test - */ - public function shouldSetSelectedRepositories() - { - $expectedArray = [ - 'selected_repository_ids' => [1, 2, 3], - ]; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('put') - ->with('/orgs/KnpLabs/actions/secrets/secretName/repositories') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->setSelectedRepositories('KnpLabs', 'secretName', [ - 'selected_repository_ids' => [1, 2, 3], - ])); - } - - /** - * @test - */ - public function shouldAddSecret() - { - $expectedValue = 'response'; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('put') - ->with('/orgs/KnpLabs/actions/secrets/secretName/repositories/1') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->addSecret('KnpLabs', '1', 'secretName')); - } - - /** - * @test - */ - public function shouldRemoveSecret() - { - $expectedValue = 'response'; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('delete') - ->with('/orgs/KnpLabs/actions/secrets/secretName/repositories/1') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->removeSecret('KnpLabs', '1', 'secretName')); - } - - /** - * @test - */ - public function shouldGetPublicKey() - { - $expectedArray = ['key_id' => 'key_id', 'key' => 'foo']; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/actions/secrets/public-key') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->publicKey('KnpLabs')); - } - - protected function getApiClass() - { - return Secrets::class; - } -} diff --git a/test/Github/Tests/Api/Organization/Actions/SelfHostedRunnersTest.php b/test/Github/Tests/Api/Organization/Actions/SelfHostedRunnersTest.php deleted file mode 100644 index e313a88202a..00000000000 --- a/test/Github/Tests/Api/Organization/Actions/SelfHostedRunnersTest.php +++ /dev/null @@ -1,115 +0,0 @@ - 1, - 'name' => 'MBP', - 'os' => 'macos', - 'status' => 'online', - ], - [ - 'id' => 2, - 'name' => 'iMac', - 'os' => 'macos', - 'status' => 'offline', - ], - ]; - - /** @var SelfHostedRunners|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/actions/runners') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all('KnpLabs')); - } - - /** - * @test - */ - public function shouldGetSelfHostedRunner() - { - $expectedArray = [ - 'id' => 1, - 'name' => 'MBP', - 'os' => 'macos', - 'status' => 'online', - ]; - - /** @var SelfHostedRunners|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/actions/runners/1') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('KnpLabs', 1)); - } - - /** - * @test - */ - public function shouldRemoveSelfHostedRunner() - { - $expectedValue = 'response'; - - /** @var SelfHostedRunners|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('delete') - ->with('/orgs/KnpLabs/actions/runners/1') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 1)); - } - - /** - * @test - */ - public function shouldGetSelfHostedRunnerApps() - { - $expectedArray = [ - ['os' => 'osx', 'architecture' => 'x64', 'download_url' => 'download_url', 'filename' => 'filename'], - ['os' => 'linux', 'architecture' => 'x64', 'download_url' => 'download_url', 'filename' => 'filename'], - ['os' => 'linux', 'architecture' => 'arm', 'download_url' => 'download_url', 'filename' => 'filename'], - ['os' => 'win', 'architecture' => 'x64', 'download_url' => 'download_url', 'filename' => 'filename'], - ['os' => 'linux', 'architecture' => 'arm64', 'download_url' => 'download_url', 'filename' => 'filename'], - ]; - - /** @var SelfHostedRunners|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/actions/runners/downloads') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->applications('KnpLabs')); - } - - protected function getApiClass() - { - return SelfHostedRunners::class; - } -} diff --git a/test/Github/Tests/Api/Organization/Actions/VariablesTest.php b/test/Github/Tests/Api/Organization/Actions/VariablesTest.php deleted file mode 100644 index 98d5072377e..00000000000 --- a/test/Github/Tests/Api/Organization/Actions/VariablesTest.php +++ /dev/null @@ -1,198 +0,0 @@ - 'name', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at', 'visibility' => 'all'], - ['name' => 'name', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at', 'visibility' => 'private'], - ['name' => 'name', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at', 'visibility' => 'selected'], - ]; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/actions/variables') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all('KnpLabs')); - } - - /** - * @test - */ - public function shouldGetOrganizationVariable() - { - $expectedArray = []; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/actions/variables/variableName') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('KnpLabs', 'variableName')); - } - - /** - * @test - */ - public function shouldCreateOrganizationVariable() - { - $expectedValue = 'response'; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('post') - ->with('/orgs/KnpLabs/actions/variables') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', [ - 'name' => 'foo', 'value' => 'value', 'visibility' => 'all', - ])); - } - - /** - * @test - */ - public function shouldUpdateOrganizationVariable() - { - $expectedValue = 'response'; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('patch') - ->with('/orgs/KnpLabs/actions/variables/variableName') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 'variableName', [ - 'name' => 'foo', 'value' => 'value', 'visibility' => 'private', - ])); - } - - /** - * @test - */ - public function shouldRemoveOrganizationVariable() - { - $expectedValue = 'response'; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('delete') - ->with('/orgs/KnpLabs/actions/variables/variableName') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'variableName')); - } - - /** - * @test - */ - public function shouldGetSelectedRepositories() - { - $expectedArray = [1, 2, 3]; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/actions/variables/variableName/repositories') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->selectedRepositories('KnpLabs', 'variableName')); - } - - /** - * @test - */ - public function shouldSetSelectedRepositories() - { - $expectedArray = [ - 'selected_repository_ids' => [1, 2, 3], - ]; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('put') - ->with('/orgs/KnpLabs/actions/variables/variableName/repositories') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->setSelectedRepositories('KnpLabs', 'variableName', [ - 'selected_repository_ids' => [1, 2, 3], - ])); - } - - /** - * @test - */ - public function shouldAddRepository() - { - $expectedValue = 'response'; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('put') - ->with('/orgs/KnpLabs/actions/variables/variableName/repositories/1') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->addRepository('KnpLabs', 1, 'variableName')); - } - - /** - * @test - */ - public function shouldRemoveRepository() - { - $expectedValue = 'response'; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('delete') - ->with('/orgs/KnpLabs/actions/variables/variableName/repositories/1') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->removeRepository('KnpLabs', 1, 'variableName')); - } - - protected function getApiClass() - { - return Variables::class; - } -} diff --git a/test/Github/Tests/Api/Organization/HooksTest.php b/test/Github/Tests/Api/Organization/HooksTest.php deleted file mode 100644 index 82d586a087e..00000000000 --- a/test/Github/Tests/Api/Organization/HooksTest.php +++ /dev/null @@ -1,160 +0,0 @@ - 'hook']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/hooks') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs')); - } - - /** - * @test - */ - public function shouldShowHook() - { - $expectedValue = ['hook' => 'somename']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/hooks/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 123)); - } - - /** - * @test - */ - public function shouldRemoveHook() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/orgs/KnpLabs/hooks/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 123)); - } - - /** - * @test - */ - public function shouldNotCreateHookWithoutName() - { - $this->expectException(MissingArgumentException::class); - $data = ['config' => 'conf']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', $data); - } - - /** - * @test - */ - public function shouldNotCreateHookWithoutConfig() - { - $this->expectException(MissingArgumentException::class); - $data = ['name' => 'test']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', $data); - } - - /** - * @test - */ - public function shouldCreateHook() - { - $expectedValue = ['hook' => 'somename']; - $data = ['name' => 'test', 'config' => 'someconfig']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/orgs/KnpLabs/hooks', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', $data)); - } - - /** - * @test - */ - public function shouldNotUpdateHookWithoutConfig() - { - $this->expectException(MissingArgumentException::class); - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('patch'); - - $api->update('KnpLabs', 123, $data); - } - - /** - * @test - */ - public function shouldUpdateHook() - { - $expectedValue = ['hook' => 'somename']; - $data = ['config' => 'config']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/orgs/KnpLabs/hooks/123', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 123, $data)); - } - - /** - * @test - */ - public function shouldPingHook() - { - $expectedValue = null; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/orgs/KnpLabs/hooks/123/pings') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->ping('KnpLabs', 123)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Organization\Hooks::class; - } -} diff --git a/test/Github/Tests/Api/Organization/MembersTest.php b/test/Github/Tests/Api/Organization/MembersTest.php deleted file mode 100644 index 58ff1ea3c08..00000000000 --- a/test/Github/Tests/Api/Organization/MembersTest.php +++ /dev/null @@ -1,144 +0,0 @@ - 'l3l0']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/members') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs')); - } - - /** - * @test - */ - public function shouldGetPublicOrganizationMembers() - { - $expectedValue = [['username' => 'l3l0']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/public_members') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', true)); - } - - /** - * @test - */ - public function shouldCheckIfOrganizationMember() - { - $expectedValue = 'response'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/public_members/l3l0') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->check('KnpLabs', 'l3l0')); - } - - /** - * @test - */ - public function shouldAddOrganizationMember() - { - $expectedValue = 'response'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/orgs/KnpLabs/memberships/l3l0') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->add('KnpLabs', 'l3l0')); - } - - /** - * @test - */ - public function shouldRemoveOrganizationMember() - { - $expectedValue = 'response'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/orgs/KnpLabs/members/l3l0') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'l3l0')); - } - - /** - * @test - */ - public function shouldPublicizeOrganizationMembership() - { - $expectedValue = 'response'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/orgs/KnpLabs/public_members/l3l0') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->publicize('KnpLabs', 'l3l0')); - } - - /** - * @test - */ - public function shouldConcealOrganizationMembership() - { - $expectedValue = 'response'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/orgs/KnpLabs/public_members/l3l0') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->conceal('KnpLabs', 'l3l0')); - } - - /** - * @test - */ - public function shouldShowOrganizationMember() - { - $expectedValue = ['username' => 'l3l0']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/members/l3l0') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'l3l0')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Organization\Members::class; - } -} diff --git a/test/Github/Tests/Api/Organization/OrganizationRolesTest.php b/test/Github/Tests/Api/Organization/OrganizationRolesTest.php deleted file mode 100644 index f2d801afceb..00000000000 --- a/test/Github/Tests/Api/Organization/OrganizationRolesTest.php +++ /dev/null @@ -1,187 +0,0 @@ - 1, - 'roles' => [[ - 'id' => 1, - 'name' => 'all_repo_admin', - 'description' => 'Grants admin access to all repositories in the organization.', - 'permissions' => [], - 'organization' => null, - 'created_at' => '2023-01-01T00:00:00Z', - 'updated_at' => '2023-01-01T00:00:00Z', - 'source' => 'Predefined', - 'base_role' => 'admin', - ]], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/acme/organization-roles') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('acme')); - } - - /** - * @test - */ - public function shouldShowSingleOrganizationRole() - { - $expectedValue = [ - 'id' => 1, - 'name' => 'all_repo_admin', - 'description' => 'Grants admin access to all repositories in the organization.', - 'permissions' => [], - 'organization' => null, - 'created_at' => '2023-01-01T00:00:00Z', - 'updated_at' => '2023-01-01T00:00:00Z', - 'source' => 'Predefined', - 'base_role' => 'admin', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/acme/organization-roles/1') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('acme', 1)); - } - - /** - * @test - */ - public function shouldGetAllTeamsWithRole() - { - $expectedValue = [['name' => 'Acme Admins']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/acme/organization-roles/1/teams') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->listTeamsWithRole('acme', 1)); - } - - /** - * @test - */ - public function shouldAssignRoleToTeam() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/orgs/acme/organization-roles/teams/acme-admins/1') - ->will($this->returnValue('')); - - $api->assignRoleToTeam('acme', 1, 'acme-admins'); - } - - /** - * @test - */ - public function shouldRemoveRoleFromTeam() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/orgs/acme/organization-roles/teams/acme-admins/1') - ->will($this->returnValue('')); - - $api->removeRoleFromTeam('acme', 1, 'acme-admins'); - } - - /** - * @test - */ - public function shouldRemoveAllRolesFromTeam() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/orgs/acme/organization-roles/teams/acme-admins') - ->will($this->returnValue('')); - - $api->removeAllRolesFromTeam('acme', 'acme-admins'); - } - - /** - * @test - */ - public function shouldGetAllUsersWithRole() - { - $expectedValue = [['username' => 'Admin']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/acme/organization-roles/1/users') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->listUsersWithRole('acme', 1)); - } - - /** - * @test - */ - public function shouldAssignRoleToUser() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/orgs/acme/organization-roles/users/admin/1') - ->will($this->returnValue('')); - - $api->assignRoleToUser('acme', 1, 'admin'); - } - - /** - * @test - */ - public function shouldRemoveRoleFromUser() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/orgs/acme/organization-roles/users/admin/1') - ->will($this->returnValue('')); - - $api->removeRoleFromUser('acme', 1, 'admin'); - } - - /** - * @test - */ - public function shouldRemoveAllRolesFromUser() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/orgs/acme/organization-roles/users/admin') - ->will($this->returnValue('')); - - $api->removeAllRolesFromUser('acme', 'admin'); - } - - protected function getApiClass(): string - { - return OrganizationRoles::class; - } -} diff --git a/test/Github/Tests/Api/Organization/OutsideCollaboratorsTest.php b/test/Github/Tests/Api/Organization/OutsideCollaboratorsTest.php deleted file mode 100644 index eb74b266c09..00000000000 --- a/test/Github/Tests/Api/Organization/OutsideCollaboratorsTest.php +++ /dev/null @@ -1,66 +0,0 @@ - 'KnpLabs']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/outside_collaborators') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs')); - } - - /** - * @test - */ - public function shouldConvertAnOrganizationMemberToOutsideCollaborator() - { - $expectedValue = 'expectedResponse'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/orgs/KnpLabs/outside_collaborators/username') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->convert('KnpLabs', 'username')); - } - - /** - * @test - */ - public function shouldRemoveAnOutsideCollaboratorFromAnOrganization() - { - $expectedValue = 'expectedResponse'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/orgs/KnpLabs/outside_collaborators/username') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'username')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Organization\OutsideCollaborators::class; - } -} diff --git a/test/Github/Tests/Api/Organization/ProjectsTest.php b/test/Github/Tests/Api/Organization/ProjectsTest.php deleted file mode 100644 index 05d607e34d8..00000000000 --- a/test/Github/Tests/Api/Organization/ProjectsTest.php +++ /dev/null @@ -1,65 +0,0 @@ - 'Test project 1']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/projects') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs')); - } - - /** - * @test - */ - public function shouldNotCreateWithoutName() - { - $this->expectException(MissingArgumentException::class); - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', $data); - } - - /** - * @test - */ - public function shouldCreateColumn() - { - $expectedValue = ['project1data']; - $data = ['name' => 'Project 1']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/orgs/KnpLabs/projects', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', $data)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Organization\Projects::class; - } -} diff --git a/test/Github/Tests/Api/Organization/SecretScanningTest.php b/test/Github/Tests/Api/Organization/SecretScanningTest.php deleted file mode 100644 index 01b8f844007..00000000000 --- a/test/Github/Tests/Api/Organization/SecretScanningTest.php +++ /dev/null @@ -1,41 +0,0 @@ - 1, 'state' => 'resolved', 'resolution' => 'false_positive'], - ['number' => 2, 'state' => 'open', 'resolution' => null], - ['number' => 3, 'state' => 'resolved', 'resolution' => 'wont_fix'], - ['number' => 4, 'state' => 'resolved', 'resolution' => 'revoked'], - ]; - - /** @var SecretScanning|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/secret-scanning/alerts') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->alerts('KnpLabs', [ - 'state' => 'all', - ])); - } - - protected function getApiClass() - { - return \Github\Api\Organization\SecretScanning::class; - } -} diff --git a/test/Github/Tests/Api/Project/CardsTest.php b/test/Github/Tests/Api/Project/CardsTest.php deleted file mode 100644 index 8b3b37090db..00000000000 --- a/test/Github/Tests/Api/Project/CardsTest.php +++ /dev/null @@ -1,131 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/projects/columns/123/cards') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all(123)); - } - - /** - * @test - */ - public function shouldShowCard() - { - $expectedValue = ['card1']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/projects/columns/cards/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show(123)); - } - - /** - * @test - */ - public function shouldCreateCard() - { - $expectedValue = ['card1data']; - $data = ['content_id' => '123', 'content_type' => 'Issue']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/projects/columns/1234/cards', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('1234', $data)); - } - - /** - * @test - */ - public function shouldUpdateCard() - { - $expectedValue = ['note1data']; - $data = ['note' => 'note test']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/projects/columns/cards/123', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update(123, $data)); - } - - /** - * @test - */ - public function shouldRemoveCard() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/projects/columns/cards/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->deleteCard(123)); - } - - /** - * @test - */ - public function shouldNotMoveWithoutPosition() - { - $this->expectException(MissingArgumentException::class); - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->move('123', $data); - } - - /** - * @test - */ - public function shouldMoveCard() - { - $expectedValue = ['card1']; - $data = ['position' => 'top']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/projects/columns/cards/123/moves') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->move(123, $data)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Project\Cards::class; - } -} diff --git a/test/Github/Tests/Api/Project/ColumnsTest.php b/test/Github/Tests/Api/Project/ColumnsTest.php deleted file mode 100644 index 7df1225190b..00000000000 --- a/test/Github/Tests/Api/Project/ColumnsTest.php +++ /dev/null @@ -1,171 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/projects/123/columns') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all(123)); - } - - /** - * @test - */ - public function shouldShowColumn() - { - $expectedValue = ['column1']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/projects/columns/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show(123)); - } - - /** - * @test - */ - public function shouldNotCreateWithoutName() - { - $this->expectException(MissingArgumentException::class); - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('123', $data); - } - - /** - * @test - */ - public function shouldCreateColumn() - { - $expectedValue = ['column1data']; - $data = ['name' => 'column 1']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/projects/123/columns', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create(123, $data)); - } - - /** - * @test - */ - public function shouldNotUpdateWithoutName() - { - $this->expectException(MissingArgumentException::class); - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->update('123', $data); - } - - /** - * @test - */ - public function shouldUpdateColumn() - { - $expectedValue = ['column1data']; - $data = ['name' => 'column 1 update']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/projects/columns/123', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update(123, $data)); - } - - /** - * @test - */ - public function shouldRemoveCard() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/projects/columns/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->deleteColumn(123)); - } - - /** - * @test - */ - public function shouldNotMoveWithoutPosition() - { - $this->expectException(MissingArgumentException::class); - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->move('123', $data); - } - - /** - * @test - */ - public function shouldMoveCard() - { - $expectedValue = ['card1']; - $data = ['position' => 'first']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/projects/columns/123/moves') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->move(123, $data)); - } - - /** - * @test - */ - public function shouldGetCardsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf('Github\Api\Project\Cards', $api->cards()); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Project\Columns::class; - } -} diff --git a/test/Github/Tests/Api/Project/ProjectsTest.php b/test/Github/Tests/Api/Project/ProjectsTest.php deleted file mode 100644 index 0dc7e2645a5..00000000000 --- a/test/Github/Tests/Api/Project/ProjectsTest.php +++ /dev/null @@ -1,76 +0,0 @@ - 'Test project 1']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/projects/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show(123)); - } - - /** - * @test - */ - public function shouldUpdateProject() - { - $expectedValue = ['project1data']; - $data = ['name' => 'Project 1 update']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/projects/123', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update(123, $data)); - } - - /** - * @test - */ - public function shouldRemoveProject() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/projects/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->deleteProject(123)); - } - - /** - * @test - */ - public function shouldGetColumnsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf('Github\Api\Project\Columns', $api->columns()); - } - - /** - * @return string - */ - protected function getApiClass() - { - return AbstractProjectApi::class; - } -} diff --git a/test/Github/Tests/Api/PullRequest/CommentsTest.php b/test/Github/Tests/Api/PullRequest/CommentsTest.php deleted file mode 100644 index c180607e837..00000000000 --- a/test/Github/Tests/Api/PullRequest/CommentsTest.php +++ /dev/null @@ -1,495 +0,0 @@ - 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', - 'id' => 1, - 'pull_request_review_id' => 42, - 'diff_hunk' => '@@ -16,33 +16,40 @@ public class Connection => IConnection...', - 'path' => 'file1.txt', - 'position' => 1, - 'original_position' => 4, - 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e', - 'original_commit_id' => '9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840', - 'user' => [ - 'login' => 'octocat', - 'id' => 1, - 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif', - 'gravatar_id' => '', - 'url' => 'https://api.github.com/users/octocat', - 'html_url' => 'https://github.com/octocat', - 'followers_url' => 'https://api.github.com/users/octocat/followers', - 'following_url' => 'https://api.github.com/users/octocat/following[/other_user]', - 'gists_url' => 'https://api.github.com/users/octocat/gists[/gist_id]', - 'starred_url' => 'https://api.github.com/users/octocat/starred[/owner][/repo]', - 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions', - 'organizations_url' => 'https://api.github.com/users/octocat/orgs', - 'repos_url' => 'https://api.github.com/users/octocat/repos', - 'events_url' => 'https://api.github.com/users/octocat/events[/privacy]', - 'received_events_url' => 'https://api.github.com/users/octocat/received_events', - 'type' => 'User', - 'site_admin' => false, - ], - 'body' => 'Great stuff', - 'created_at' => '2011-04-14T16:00:49Z', - 'updated_at' => '2011-04-14T16:00:49Z', - 'html_url' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', - 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', - '_links' => [ - 'self' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', - ], - 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', - ], - 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', - ], - ], - ], - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/octocat/Hello-World/pulls/12/comments') - ->willReturn($expectedValue); - - $this->assertSame($expectedValue, $api->all('octocat', 'Hello-World', 12)); - } - - /** - * @test - */ - public function shouldGetAllReviewComments() - { - $expectedValue = [ - [ - 'url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', - 'id' => 1, - 'pull_request_review_id' => 42, - 'diff_hunk' => '@@ -16,33 +16,40 @@ public class Connection => IConnection...', - 'path' => 'file1.txt', - 'position' => 1, - 'original_position' => 4, - 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e', - 'original_commit_id' => '9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840', - 'user' => [ - 'login' => 'octocat', - 'id' => 1, - 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif', - 'gravatar_id' => '', - 'url' => 'https://api.github.com/users/octocat', - 'html_url' => 'https://github.com/octocat', - 'followers_url' => 'https://api.github.com/users/octocat/followers', - 'following_url' => 'https://api.github.com/users/octocat/following[/other_user]', - 'gists_url' => 'https://api.github.com/users/octocat/gists[/gist_id]', - 'starred_url' => 'https://api.github.com/users/octocat/starred[/owner][/repo]', - 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions', - 'organizations_url' => 'https://api.github.com/users/octocat/orgs', - 'repos_url' => 'https://api.github.com/users/octocat/repos', - 'events_url' => 'https://api.github.com/users/octocat/events[/privacy]', - 'received_events_url' => 'https://api.github.com/users/octocat/received_events', - 'type' => 'User', - 'site_admin' => false, - ], - 'body' => 'Great stuff', - 'created_at' => '2011-04-14T16:00:49Z', - 'updated_at' => '2011-04-14T16:00:49Z', - 'html_url' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', - 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', - '_links' => [ - 'self' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', - ], - 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', - ], - 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', - ], - ], - ], - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/octocat/Hello-World/pulls/comments') - ->willReturn($expectedValue); - - $this->assertSame($expectedValue, $api->all('octocat', 'Hello-World')); - } - - /** - * @test - */ - public function shouldShowReviewComment() - { - $expectedValue = [ - 'url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', - 'id' => 1, - 'pull_request_review_id' => 42, - 'diff_hunk' => '@@ -16,33 +16,40 @@ public class Connection => IConnection...', - 'path' => 'file1.txt', - 'position' => 1, - 'original_position' => 4, - 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e', - 'original_commit_id' => '9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840', - 'user' => [ - 'login' => 'octocat', - 'id' => 1, - 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif', - 'gravatar_id' => '', - 'url' => 'https://api.github.com/users/octocat', - 'html_url' => 'https://github.com/octocat', - 'followers_url' => 'https://api.github.com/users/octocat/followers', - 'following_url' => 'https://api.github.com/users/octocat/following[/other_user]', - 'gists_url' => 'https://api.github.com/users/octocat/gists[/gist_id]', - 'starred_url' => 'https://api.github.com/users/octocat/starred[/owner][/repo]', - 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions', - 'organizations_url' => 'https://api.github.com/users/octocat/orgs', - 'repos_url' => 'https://api.github.com/users/octocat/repos', - 'events_url' => 'https://api.github.com/users/octocat/events[/privacy]', - 'received_events_url' => 'https://api.github.com/users/octocat/received_events', - 'type' => 'User', - 'site_admin' => false, - ], - 'body' => 'Great stuff', - 'created_at' => '2011-04-14T16:00:49Z', - 'updated_at' => '2011-04-14T16:00:49Z', - 'html_url' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', - 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', - '_links' => [ - 'self' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', - ], - 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', - ], - 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', - ], - ], - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/octocat/Hello-World/pulls/comments/1') - ->willReturn($expectedValue); - - $this->assertSame($expectedValue, $api->show('octocat', 'Hello-World', 1)); - } - - /** - * @test - */ - public function shouldCreateReviewComment() - { - $expectedValue = [ - 'url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', - 'id' => 1, - 'pull_request_review_id' => 42, - 'diff_hunk' => '@@ -16,33 +16,40 @@ public class Connection => IConnection...', - 'path' => 'file1.txt', - 'position' => 1, - 'original_position' => 4, - 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e', - 'original_commit_id' => '9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840', - 'user' => [ - 'login' => 'octocat', - 'id' => 1, - 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif', - 'gravatar_id' => '', - 'url' => 'https://api.github.com/users/octocat', - 'html_url' => 'https://github.com/octocat', - 'followers_url' => 'https://api.github.com/users/octocat/followers', - 'following_url' => 'https://api.github.com/users/octocat/following[/other_user]', - 'gists_url' => 'https://api.github.com/users/octocat/gists[/gist_id]', - 'starred_url' => 'https://api.github.com/users/octocat/starred[/owner][/repo]', - 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions', - 'organizations_url' => 'https://api.github.com/users/octocat/orgs', - 'repos_url' => 'https://api.github.com/users/octocat/repos', - 'events_url' => 'https://api.github.com/users/octocat/events[/privacy]', - 'received_events_url' => 'https://api.github.com/users/octocat/received_events', - 'type' => 'User', - 'site_admin' => false, - ], - 'body' => 'Great stuff', - 'created_at' => '2011-04-14T16:00:49Z', - 'updated_at' => '2011-04-14T16:00:49Z', - 'html_url' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', - 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', - '_links' => [ - 'self' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', - ], - 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', - ], - 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', - ], - ], - ]; - $data = [ - 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e', - 'path' => 'file1.txt', - 'position' => 4, - 'body' => 'Nice change', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/octocat/Hello-World/pulls/1/comments', $data) - ->willReturn($expectedValue); - - $this->assertSame($expectedValue, $api->create('octocat', 'Hello-World', 1, $data)); - } - - /** - * @test - */ - public function shouldNotCreateReviewCommentWithoutCommitId() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'path' => 'file1.txt', - 'position' => 4, - 'body' => 'Nice change', - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->never()) - ->method('post') - ; - - $api->create('octocat', 'Hello-World', 1, $data); - } - - /** - * @test - */ - public function shouldNotCreateReviewCommentWithoutPath() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e', - 'position' => 4, - 'body' => 'Nice change', - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->never()) - ->method('post') - ; - - $api->create('octocat', 'Hello-World', 1, $data); - } - - /** - * @test - */ - public function shouldNotCreateReviewCommentWithoutPosition() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e', - 'path' => 'file1.txt', - 'body' => 'Nice change', - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->never()) - ->method('post') - ; - - $api->create('octocat', 'Hello-World', 1, $data); - } - - /** - * @test - */ - public function shouldNotCreateReviewCommentWithoutBody() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e', - 'path' => 'file1.txt', - 'position' => 4, - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->never()) - ->method('post') - ; - - $api->create('octocat', 'Hello-World', 1, $data); - } - - /** - * @test - */ - public function shouldUpdateReviewComment() - { - $expectedValue = [ - 'url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', - 'id' => 1, - 'pull_request_review_id' => 42, - 'diff_hunk' => '@@ -16,33 +16,40 @@ public class Connection => IConnection...', - 'path' => 'file1.txt', - 'position' => 1, - 'original_position' => 4, - 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e', - 'original_commit_id' => '9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840', - 'user' => [ - 'login' => 'octocat', - 'id' => 1, - 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif', - 'gravatar_id' => '', - 'url' => 'https://api.github.com/users/octocat', - 'html_url' => 'https://github.com/octocat', - 'followers_url' => 'https://api.github.com/users/octocat/followers', - 'following_url' => 'https://api.github.com/users/octocat/following[/other_user]', - 'gists_url' => 'https://api.github.com/users/octocat/gists[/gist_id]', - 'starred_url' => 'https://api.github.com/users/octocat/starred[/owner][/repo]', - 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions', - 'organizations_url' => 'https://api.github.com/users/octocat/orgs', - 'repos_url' => 'https://api.github.com/users/octocat/repos', - 'events_url' => 'https://api.github.com/users/octocat/events[/privacy]', - 'received_events_url' => 'https://api.github.com/users/octocat/received_events', - 'type' => 'User', - 'site_admin' => false, - ], - 'body' => 'Great stuff', - 'created_at' => '2011-04-14T16:00:49Z', - 'updated_at' => '2011-04-14T16:00:49Z', - 'html_url' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', - 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', - '_links' => [ - 'self' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', - ], - 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', - ], - 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', - ], - ], - ]; - $data = [ - 'body' => 'Nice change', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/octocat/Hello-World/pulls/comments/1', $data) - ->willReturn($expectedValue); - - $this->assertSame($expectedValue, $api->update('octocat', 'Hello-World', 1, $data)); - } - - /** - * @test - */ - public function shouldNotUpdateReviewCommentWithoutBody() - { - $this->expectException(MissingArgumentException::class); - $expectedValue = [ - 'url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', - 'id' => 1, - 'pull_request_review_id' => 42, - 'diff_hunk' => '@@ -16,33 +16,40 @@ public class Connection => IConnection...', - 'path' => 'file1.txt', - 'position' => 1, - 'original_position' => 4, - 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e', - 'original_commit_id' => '9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840', - 'user' => [ - 'login' => 'octocat', - 'id' => 1, - 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif', - 'gravatar_id' => '', - 'url' => 'https://api.github.com/users/octocat', - 'html_url' => 'https://github.com/octocat', - 'followers_url' => 'https://api.github.com/users/octocat/followers', - 'following_url' => 'https://api.github.com/users/octocat/following[/other_user]', - 'gists_url' => 'https://api.github.com/users/octocat/gists[/gist_id]', - 'starred_url' => 'https://api.github.com/users/octocat/starred[/owner][/repo]', - 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions', - 'organizations_url' => 'https://api.github.com/users/octocat/orgs', - 'repos_url' => 'https://api.github.com/users/octocat/repos', - 'events_url' => 'https://api.github.com/users/octocat/events[/privacy]', - 'received_events_url' => 'https://api.github.com/users/octocat/received_events', - 'type' => 'User', - 'site_admin' => false, - ], - 'body' => 'Great stuff', - 'created_at' => '2011-04-14T16:00:49Z', - 'updated_at' => '2011-04-14T16:00:49Z', - 'html_url' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', - 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', - '_links' => [ - 'self' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', - ], - 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', - ], - 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', - ], - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('patch') - ; - - $this->assertSame($expectedValue, $api->update('octocat', 'Hello-World', 1, [])); - } - - /** - * @test - */ - public function shouldDeleteReviewComment() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/octocat/Hello-World/pulls/comments/1') - ; - - $api->remove('octocat', 'Hello-World', 1); - } - - protected function getApiClass() - { - return Comments::class; - } -} diff --git a/test/Github/Tests/Api/PullRequest/ReviewRequestTest.php b/test/Github/Tests/Api/PullRequest/ReviewRequestTest.php deleted file mode 100644 index 3335b4a3494..00000000000 --- a/test/Github/Tests/Api/PullRequest/ReviewRequestTest.php +++ /dev/null @@ -1,65 +0,0 @@ - 80], - ['id' => 81], - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/octocat/Hello-World/pulls/12/requested_reviewers') - ->willReturn($expectedValue); - - $this->assertSame($expectedValue, $api->all('octocat', 'Hello-World', 12)); - } - - /** - * @test - */ - public function shouldCreateReviewRequest() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/octocat/Hello-World/pulls/12/requested_reviewers', ['reviewers' => ['testuser'], 'team_reviewers' => ['testteam']]) - ; - - $api->create('octocat', 'Hello-World', 12, ['testuser'], ['testteam']); - } - - /** - * @test - */ - public function shouldDeleteReviewRequest() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/octocat/Hello-World/pulls/12/requested_reviewers', ['reviewers' => ['testuser'], 'team_reviewers' => ['testteam']]) - ; - - $api->remove('octocat', 'Hello-World', 12, ['testuser'], ['testteam']); - } - - /** - * @return string - */ - protected function getApiClass() - { - return ReviewRequest::class; - } -} diff --git a/test/Github/Tests/Api/PullRequest/ReviewTest.php b/test/Github/Tests/Api/PullRequest/ReviewTest.php deleted file mode 100644 index eb94203bc68..00000000000 --- a/test/Github/Tests/Api/PullRequest/ReviewTest.php +++ /dev/null @@ -1,455 +0,0 @@ - 80, - 'user' => [ - 'login' => 'octocat', - 'id' => 1, - 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif', - 'gravatar_id' => '', - 'url' => 'https://api.github.com/users/octocat', - 'html_url' => 'https://github.com/octocat', - 'followers_url' => 'https://api.github.com/users/octocat/followers', - 'following_url' => 'https://api.github.com/users/octocat/following{/other_user}', - 'gists_url' => 'https://api.github.com/users/octocat/gists{/gist_id}', - 'starred_url' => 'https://api.github.com/users/octocat/starred{/owner}{/repo}', - 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions', - 'organizations_url' => 'https://api.github.com/users/octocat/orgs', - 'repos_url' => 'https://api.github.com/users/octocat/repos', - 'events_url' => 'https://api.github.com/users/octocat/events{/privacy}', - 'received_events_url' => 'https://api.github.com/users/octocat/received_events', - 'type' => 'User', - 'site_admin' => false, - ], - 'body' => 'Here is the body for the review.', - 'commit_id' => 'ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091', - 'state' => 'APPROVED', - 'html_url' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80', - 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', - '_links' => [ - 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80', - ], - 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', - ], - ], - ], - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/octocat/Hello-World/pulls/12/reviews') - ->willReturn($expectedValue); - - $this->assertSame($expectedValue, $api->all('octocat', 'Hello-World', 12)); - } - - /** - * @test - */ - public function shouldShowReview() - { - $expectedValue = [ - 'id' => 80, - 'user' => [ - 'login' => 'octocat', - 'id' => 1, - 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif', - 'gravatar_id' => '', - 'url' => 'https://api.github.com/users/octocat', - 'html_url' => 'https://github.com/octocat', - 'followers_url' => 'https://api.github.com/users/octocat/followers', - 'following_url' => 'https://api.github.com/users/octocat/following{/other_user}', - 'gists_url' => 'https://api.github.com/users/octocat/gists{/gist_id}', - 'starred_url' => 'https://api.github.com/users/octocat/starred{/owner}{/repo}', - 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions', - 'organizations_url' => 'https://api.github.com/users/octocat/orgs', - 'repos_url' => 'https://api.github.com/users/octocat/repos', - 'events_url' => 'https://api.github.com/users/octocat/events{/privacy}', - 'received_events_url' => 'https://api.github.com/users/octocat/received_events', - 'type' => 'User', - 'site_admin' => false, - ], - 'body' => 'Here is the body for the review.', - 'commit_id' => 'ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091', - 'state' => 'APPROVED', - 'html_url' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80', - 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', - '_links' => [ - 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80', - ], - 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', - ], - ], - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/octocat/Hello-World/pulls/12/reviews/80') - ->willReturn($expectedValue); - - $this->assertSame($expectedValue, $api->show('octocat', 'Hello-World', 12, 80)); - } - - /** - * @test - */ - public function shouldDeleteReview() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/octocat/Hello-World/pulls/12/reviews/80') - ; - - $api->remove('octocat', 'Hello-World', 12, 80); - } - - /** - * @test - */ - public function shouldShowReviewComments() - { - $expectedValue = [ - [ - 'url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', - 'id' => 1, - 'pull_request_review_id' => 42, - 'diff_hunk' => '@@ -16,33 +16,40 @@ public class Connection => IConnection...', - 'path' => 'file1.txt', - 'position' => 1, - 'original_position' => 4, - 'commit_id' => '6dcb09b5b57875f334f61aebed695e2e4193db5e', - 'original_commit_id' => '9c48853fa3dc5c1c3d6f1f1cd1f2743e72652840', - 'user' => [ - 'login' => 'octocat', - 'id' => 1, - 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif', - 'gravatar_id' => '', - 'url' => 'https://api.github.com/users/octocat', - 'html_url' => 'https://github.com/octocat', - 'followers_url' => 'https://api.github.com/users/octocat/followers', - 'following_url' => 'https://api.github.com/users/octocat/following[/other_user]', - 'gists_url' => 'https://api.github.com/users/octocat/gists[/gist_id]', - 'starred_url' => 'https://api.github.com/users/octocat/starred[/owner][/repo]', - 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions', - 'organizations_url' => 'https://api.github.com/users/octocat/orgs', - 'repos_url' => 'https://api.github.com/users/octocat/repos', - 'events_url' => 'https://api.github.com/users/octocat/events[/privacy]', - 'received_events_url' => 'https://api.github.com/users/octocat/received_events', - 'type' => 'User', - 'site_admin' => false, - ], - 'body' => 'Great stuff', - 'created_at' => '2011-04-14T16:00:49Z', - 'updated_at' => '2011-04-14T16:00:49Z', - 'html_url' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', - 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', - '_links' => [ - 'self' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/comments/1', - ], - 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/1#discussion-diff-1', - ], - 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/1', - ], - ], - ], - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/octocat/Hello-World/pulls/1/reviews/42/comments') - ->willReturn($expectedValue); - - $this->assertSame($expectedValue, $api->comments('octocat', 'Hello-World', 1, 42)); - } - - /** - * @test - */ - public function shouldCreateReviewComment() - { - $data = [ - 'event' => 'APPROVE', - 'body' => 'Nice change', - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->once()) - ->method('post') - ->with('/repos/octocat/Hello-World/pulls/12/reviews') - ; - - $api->create('octocat', 'Hello-World', 12, $data); - } - - /** - * @test - */ - public function shouldCreatePendingReviewWithoutEvent() - { - $data = [ - 'body' => 'Nice change', - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->once()) - ->method('post') - ->with('/repos/octocat/Hello-World/pulls/12/reviews') - ; - - $api->create('octocat', 'Hello-World', 12, $data); - } - - /** - * @test - */ - public function shouldNotCreateReviewWithInvalidEvent() - { - $this->expectException(InvalidArgumentException::class); - $data = [ - 'event' => 'DISMISSED', - 'body' => 'Nice change', - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->never()) - ->method('post') - ; - - $api->create('octocat', 'Hello-World', 12, $data); - } - - /** - * @test - */ - public function shouldSubmitReviewComment() - { - $expectedValue = [ - 'id' => 80, - 'user' => [ - 'login' => 'octocat', - 'id' => 1, - 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif', - 'gravatar_id' => '', - 'url' => 'https://api.github.com/users/octocat', - 'html_url' => 'https://github.com/octocat', - 'followers_url' => 'https://api.github.com/users/octocat/followers', - 'following_url' => 'https://api.github.com/users/octocat/following{/other_user}', - 'gists_url' => 'https://api.github.com/users/octocat/gists{/gist_id}', - 'starred_url' => 'https://api.github.com/users/octocat/starred{/owner}{/repo}', - 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions', - 'organizations_url' => 'https://api.github.com/users/octocat/orgs', - 'repos_url' => 'https://api.github.com/users/octocat/repos', - 'events_url' => 'https://api.github.com/users/octocat/events{/privacy}', - 'received_events_url' => 'https://api.github.com/users/octocat/received_events', - 'type' => 'User', - 'site_admin' => false, - ], - 'body' => 'Here is the body for the review.', - 'commit_id' => 'ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091', - 'state' => 'APPROVED', - 'html_url' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80', - 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', - '_links' => [ - 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80', - ], - 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', - ], - ], - ]; - $data = [ - 'event' => 'APPROVE', - 'body' => 'Nice change', - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->once()) - ->method('post') - ->with('/repos/octocat/Hello-World/pulls/12/reviews/80/events') - ->willReturn($expectedValue); - - $this->assertSame($expectedValue, $api->submit('octocat', 'Hello-World', 12, 80, $data)); - } - - /** - * @test - */ - public function shouldNotSubmitReviewWithoutEvent() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'body' => 'Nice change', - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->never()) - ->method('post') - ; - - $api->submit('octocat', 'Hello-World', 12, 80, $data); - } - - /** - * @test - */ - public function shouldNotSubmitReviewWithInvalidEvent() - { - $this->expectException(InvalidArgumentException::class); - $data = [ - 'event' => 'DISMISSED', - 'body' => 'Nice change', - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->never()) - ->method('post') - ; - - $api->submit('octocat', 'Hello-World', 12, 80, $data); - } - - /** - * @test - */ - public function shouldDismissReview() - { - $expectedValue = [ - 'id' => 80, - 'user' => [ - 'login' => 'octocat', - 'id' => 1, - 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif', - 'gravatar_id' => '', - 'url' => 'https://api.github.com/users/octocat', - 'html_url' => 'https://github.com/octocat', - 'followers_url' => 'https://api.github.com/users/octocat/followers', - 'following_url' => 'https://api.github.com/users/octocat/following{/other_user}', - 'gists_url' => 'https://api.github.com/users/octocat/gists{/gist_id}', - 'starred_url' => 'https://api.github.com/users/octocat/starred{/owner}{/repo}', - 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions', - 'organizations_url' => 'https://api.github.com/users/octocat/orgs', - 'repos_url' => 'https://api.github.com/users/octocat/repos', - 'events_url' => 'https://api.github.com/users/octocat/events{/privacy}', - 'received_events_url' => 'https://api.github.com/users/octocat/received_events', - 'type' => 'User', - 'site_admin' => false, - ], - 'body' => 'Here is the body for the review.', - 'commit_id' => 'ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091', - 'state' => 'APPROVED', - 'html_url' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80', - 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', - '_links' => [ - 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80', - ], - 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', - ], - ], - ]; - - $api = $this->getApiMock(); - $api - ->expects($this->once()) - ->method('put') - ->with('/repos/octocat/Hello-World/pulls/12/reviews/80/dismissals') - ->willReturn($expectedValue); - - $this->assertSame($expectedValue, $api->dismiss('octocat', 'Hello-World', 12, 80, 'Dismiss reason')); - } - - /** - * @test - */ - public function shouldUpdateReviewComment() - { - $expectedValue = [ - 'id' => 80, - 'node_id' => 'MDE3OlB1bGxSZXF1ZXN0UmV2aWV3ODA=', - 'user' => [ - 'login' => 'octocat', - 'id' => 1, - 'avatar_url' => 'https://github.com/images/error/octocat_happy.gif', - 'gravatar_id' => '', - 'url' => 'https://api.github.com/users/octocat', - 'html_url' => 'https://github.com/octocat', - 'followers_url' => 'https://api.github.com/users/octocat/followers', - 'following_url' => 'https://api.github.com/users/octocat/following{/other_user}', - 'gists_url' => 'https://api.github.com/users/octocat/gists{/gist_id}', - 'starred_url' => 'https://api.github.com/users/octocat/starred{/owner}{/repo}', - 'subscriptions_url' => 'https://api.github.com/users/octocat/subscriptions', - 'organizations_url' => 'https://api.github.com/users/octocat/orgs', - 'repos_url' => 'https://api.github.com/users/octocat/repos', - 'events_url' => 'https://api.github.com/users/octocat/events{/privacy}', - 'received_events_url' => 'https://api.github.com/users/octocat/received_events', - 'type' => 'User', - 'site_admin' => false, - ], - 'body' => 'Great stuff', - 'commit_id' => 'ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091', - 'state' => 'CHANGES_REQUESTED', - 'html_url' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80', - 'pull_request_url' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', - '_links' => [ - 'html' => [ - 'href' => 'https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80', - ], - 'pull_request' => [ - 'href' => 'https://api.github.com/repos/octocat/Hello-World/pulls/12', - ], - ], - ]; - $body = 'Nice change'; - - $api = $this->getApiMock(); - $api - ->expects($this->once()) - ->method('put') - ->with('/repos/octocat/Hello-World/pulls/12/reviews/80') - ->willReturn($expectedValue); - - $this->assertSame($expectedValue, $api->update('octocat', 'Hello-World', 12, 80, $body)); - } - - protected function getApiClass() - { - return Review::class; - } -} diff --git a/test/Github/Tests/Api/PullRequestTest.php b/test/Github/Tests/Api/PullRequestTest.php deleted file mode 100644 index 54cc34f55e0..00000000000 --- a/test/Github/Tests/Api/PullRequestTest.php +++ /dev/null @@ -1,402 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/ezsystems/ezpublish/pulls') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all('ezsystems', 'ezpublish')); - } - - /** - * @test - */ - public function shouldGetOpenPullRequests() - { - $expectedArray = ['pr1', 'pr2']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/ezsystems/ezpublish/pulls', ['state' => 'open']) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all('ezsystems', 'ezpublish', ['state' => 'open'])); - } - - /** - * @test - */ - public function shouldGetClosedPullRequests() - { - $expectedArray = ['pr1', 'pr2']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/ezsystems/ezpublish/pulls', ['state' => 'closed']) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all('ezsystems', 'ezpublish', ['state' => 'closed'])); - } - - /** - * @test - */ - public function shouldShowPullRequest() - { - $expectedArray = ['id' => 'id', 'sha' => '123123']; - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with('/repos/ezsystems/ezpublish/pulls/15') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('ezsystems', 'ezpublish', '15')); - } - - /** - * @test - */ - public function shouldShowCommitsFromPullRequest() - { - $expectedArray = [['id' => 'id', 'sha' => '123123']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/ezsystems/ezpublish/pulls/15/commits') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->commits('ezsystems', 'ezpublish', '15')); - } - - /** - * @test - */ - public function shouldShowCommitsFromPullRequestForPage() - { - $expectedArray = [['id' => 'id', 'sha' => '123123']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/ezsystems/ezpublish/pulls/15/commits', ['page' => 2, 'per_page' => 30]) - ->willReturn($expectedArray); - - $this->assertEquals($expectedArray, $api->commits('ezsystems', 'ezpublish', '15', ['page' => 2, 'per_page' => 30])); - } - - /** - * @test - */ - public function shouldShowFilesFromPullRequest() - { - $expectedArray = [['id' => 'id', 'sha' => '123123']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/ezsystems/ezpublish/pulls/15/files') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->files('ezsystems', 'ezpublish', '15')); - } - - /** - * @test - */ - public function shouldShowFilesFromPullRequestForPage() - { - $expectedArray = [['id' => 'id', 'sha' => '123123']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/ezsystems/ezpublish/pulls/15/files', ['page' => 2, 'per_page' => 30]) - ->willReturn($expectedArray); - - $this->assertSame($expectedArray, $api->files('ezsystems', 'ezpublish', '15', ['page' => 2, 'per_page' => 30])); - } - - /** - * @test - */ - public function shouldShowStatusesFromPullRequest() - { - $expectedArray = [['id' => 'id', 'sha' => '123123']]; - $expectedArray['_links']['statuses']['href'] = '/repos/ezsystems/ezpublish/pulls/15/statuses'; - - $api = $this->getApiMock(); - - $api->expects($this->exactly(2)) - ->method('get') - ->withConsecutive( - [$this->equalTo('/repos/ezsystems/ezpublish/pulls/15')], - [$this->equalTo('/repos/ezsystems/ezpublish/pulls/15/statuses')] - ) - ->willReturn($expectedArray) - ; - - $this->assertEquals($expectedArray, $api->status('ezsystems', 'ezpublish', '15')); - } - - /** - * @test - */ - public function shouldUpdatePullRequests() - { - $expectedArray = ['id' => 15, 'sha' => '123123']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/ezsystems/ezpublish/pulls/15', ['state' => 'open', 'some' => 'param']) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->update('ezsystems', 'ezpublish', 15, ['state' => 'aa', 'some' => 'param'])); - } - - /** - * @test - */ - public function shouldCheckIfPullRequestIsMerged() - { - $expectedArray = ['some' => 'response']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/ezsystems/ezpublish/pulls/15/merge') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->merged('ezsystems', 'ezpublish', 15)); - } - - /** - * @test - */ - public function shouldMergePullRequest() - { - $expectedArray = ['some' => 'response']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/repos/ezsystems/ezpublish/pulls/15/merge', ['commit_message' => 'Merged something', 'sha' => str_repeat('A', 40), 'merge_method' => 'merge']) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->merge('ezsystems', 'ezpublish', 15, 'Merged something', str_repeat('A', 40))); - } - - /** - * @test - */ - public function shouldMergePullRequestWithSquashAsBool() - { - $expectedArray = ['some' => 'response']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/repos/ezsystems/ezpublish/pulls/15/merge', ['commit_message' => 'Merged something', 'sha' => str_repeat('A', 40), 'merge_method' => 'squash']) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->merge('ezsystems', 'ezpublish', 15, 'Merged something', str_repeat('A', 40), true)); - } - - /** - * @test - */ - public function shouldMergePullRequestWithMergeMethod() - { - $expectedArray = ['some' => 'response']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/repos/ezsystems/ezpublish/pulls/15/merge', ['commit_message' => 'Merged something', 'sha' => str_repeat('A', 40), 'merge_method' => 'rebase']) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->merge('ezsystems', 'ezpublish', 15, 'Merged something', str_repeat('A', 40), 'rebase')); - } - - /** - * @test - */ - public function shouldCreatePullRequestUsingTitle() - { - $data = [ - 'base' => 'master', - 'head' => 'virtualtestbranch', - 'title' => 'TITLE: Testing pull-request creation from PHP Github API', - 'body' => 'BODY: Testing pull-request creation from PHP Github API', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/ezsystems/ezpublish/pulls', $data); - - $api->create('ezsystems', 'ezpublish', $data); - } - - /** - * @test - */ - public function shouldCreatePullRequestUsingIssueId() - { - $data = [ - 'base' => 'master', - 'head' => 'virtualtestbranch', - 'issue' => 25, - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/ezsystems/ezpublish/pulls', $data); - - $api->create('ezsystems', 'ezpublish', $data); - } - - /** - * @test - */ - public function shouldCreateDraftPullRequest() - { - $data = [ - 'base' => 'master', - 'head' => 'virtualtestbranch', - 'title' => 'TITLE: Testing draft pull-request creation from PHP Github API', - 'body' => 'BODY: Testing draft pull-request creation from PHP Github API', - 'draft' => 'true', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/ezsystems/ezpublish/pulls', $data); - - $api->create('ezsystems', 'ezpublish', $data); - } - - /** - * @test - */ - public function shouldNotCreatePullRequestWithoutBase() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'head' => 'virtualtestbranch', - 'title' => 'TITLE: Testing pull-request creation from PHP Github API', - 'body' => 'BODY: Testing pull-request creation from PHP Github API', - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('ezsystems', 'ezpublish', $data); - } - - /** - * @test - */ - public function shouldNotCreatePullRequestWithoutHead() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'base' => 'master', - 'title' => 'TITLE: Testing pull-request creation from PHP Github API', - 'body' => 'BODY: Testing pull-request creation from PHP Github API', - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('ezsystems', 'ezpublish', $data); - } - - /** - * @test - */ - public function shouldNotCreatePullRequestUsingTitleButWithoutBody() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'base' => 'master', - 'head' => 'virtualtestbranch', - 'title' => 'TITLE: Testing pull-request creation from PHP Github API', - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('ezsystems', 'ezpublish', $data); - } - - /** - * @test - */ - public function shouldNotCreatePullRequestWithoutIssueIdOrTitle() - { - $this->expectException(MissingArgumentException::class); - $data = [ - 'base' => 'master', - 'head' => 'virtualtestbranch', - ]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('ezsystems', 'ezpublish', $data); - } - - /** - * @test - */ - public function shouldGetCommentsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\PullRequest\Comments::class, $api->comments()); - } - - /** - * @test - */ - public function shouldGetReviewApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\PullRequest\Review::class, $api->reviews()); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\PullRequest::class; - } -} diff --git a/test/Github/Tests/Api/RateLimitTest.php b/test/Github/Tests/Api/RateLimitTest.php deleted file mode 100644 index d13d001d890..00000000000 --- a/test/Github/Tests/Api/RateLimitTest.php +++ /dev/null @@ -1,90 +0,0 @@ - [ - 'core' => [ - 'limit' => 5000, - 'remaining' => 4999, - 'reset' => 1372700873, - ], - 'search' => [ - 'limit' => 30, - 'remaining' => 18, - 'reset' => 1372697452, - ], - 'graphql' => [ - 'limit' => 5000, - 'remaining' => 4030, - 'reset' => 1372697452, - ], - ], - ]; - - /** - * @var RateLimit - */ - protected $api; - - /** - * @before - */ - public function initMocks() - { - $this->api = $this->getApiMock(); - $this->api->expects($this->once()) - ->method('get') - ->with('/rate_limit') - ->will($this->returnValue($this->expectedArray)); - } - - /** - * @test - */ - public function shouldReturnArrayOfLimitInstances() - { - $this->assertContainsOnlyInstancesOf(RateLimit\RateLimitResource::class, $this->api->getResources()); - } - - /** - * @test - */ - public function shouldReturnRemainingGraphQLRequests() - { - $this->assertSame(4030, $this->api->getResource('graphql')->getRemaining()); - } - - /** - * @test - */ - public function shouldReturnResetForSearch() - { - $this->assertSame(1372697452, $this->api->getResource('search')->getReset()); - } - - /** - * @test - */ - public function shouldReturnFalseWhenResourceIsNotFound() - { - $this->assertFalse($this->api->getResource('non-exitent')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\RateLimit::class; - } -} diff --git a/test/Github/Tests/Api/RepoTest.php b/test/Github/Tests/Api/RepoTest.php deleted file mode 100644 index 786c27d97b5..00000000000 --- a/test/Github/Tests/Api/RepoTest.php +++ /dev/null @@ -1,789 +0,0 @@ - 1, 'name' => 'repoName']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldShowRepositoryById() - { - $expectedArray = ['id' => 123456, 'name' => 'repoName']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repositories/123456') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->showById(123456)); - } - - /** - * @test - */ - public function shouldGetAllRepositories() - { - $expectedArray = [ - ['id' => 1, 'name' => 'dummy project'], - ['id' => 2, 'name' => 'awesome another project'], - ['id' => 3, 'name' => 'fork of php'], - ['id' => 4, 'name' => 'fork of php-cs'], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repositories') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all()); - } - - /** - * @test - */ - public function shouldGetAllRepositoriesStartingIndex() - { - $expectedArray = [ - ['id' => 1, 'name' => 'dummy project'], - ['id' => 2, 'name' => 'awesome another project'], - ['id' => 3, 'name' => 'fork of php'], - ['id' => 4, 'name' => 'fork of php-cs'], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repositories', ['since' => 2]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all(2)); - } - - /** - * @test - */ - public function shouldCreateRepositoryUsingNameOnly() - { - $expectedArray = ['id' => 1, 'name' => 'l3l0Repo']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/user/repos', [ - 'name' => 'l3l0Repo', - 'description' => '', - 'homepage' => '', - 'private' => false, - 'has_issues' => false, - 'has_wiki' => false, - 'has_downloads' => false, - 'auto_init' => false, - 'has_projects' => true, - ]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->create('l3l0Repo')); - } - - /** - * @test - */ - public function shouldCreateRepositoryForOrganization() - { - $expectedArray = ['id' => 1, 'name' => 'KnpLabsRepo']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/orgs/KnpLabs/repos', [ - 'name' => 'KnpLabsRepo', - 'description' => '', - 'homepage' => '', - 'private' => false, - 'has_issues' => false, - 'has_wiki' => false, - 'has_downloads' => false, - 'auto_init' => false, - 'has_projects' => true, - ]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->create('KnpLabsRepo', '', '', true, 'KnpLabs')); - } - - /** - * @test - */ - public function shouldCreateRepositoryWithInternalVisibility() - { - $expectedArray = ['id' => 1, 'name' => 'KnpLabsRepo']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/user/repos', [ - 'name' => 'KnpLabsRepo', - 'description' => '', - 'homepage' => '', - 'has_issues' => false, - 'has_wiki' => false, - 'has_downloads' => false, - 'auto_init' => false, - 'has_projects' => true, - 'visibility' => 'internal', - 'private' => false, - ]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals( - $expectedArray, - $api->create( - 'KnpLabsRepo', - '', - '', - false, - null, - false, - false, - false, - null, - false, - true, - 'internal' - ) - ); - } - - /** - * @test - */ - public function shouldGetRepositorySubscribers() - { - $expectedArray = [['id' => 1, 'username' => 'l3l0']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/subscribers', ['page' => 2]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->subscribers('KnpLabs', 'php-github-api', 2)); - } - - /** - * @test - */ - public function shouldGetRepositoryTags() - { - $expectedArray = [['sha' => 1234]]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/tags') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->tags('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetRepositoryBranches() - { - $expectedArray = [['sha' => 1234, 'name' => 'master']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/branches') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->branches('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetRepositoryBranch() - { - $expectedArray = ['sha' => 1234, 'name' => 'master']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/branches/master') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->branches('KnpLabs', 'php-github-api', 'master')); - } - - /** - * @test - */ - public function shouldMergeUpstreamRepository() - { - $expectedArray = [ - 'message' => 'Successfully fetched and fast-forwarded from upstream upstreamRepo:main', - 'merge_type' => 'fast-forward', - 'merge_branch' => 'upstreamRepo:main', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/merge-upstream', ['branch' => 'main']) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->mergeUpstream('KnpLabs', 'php-github-api', 'main')); - } - - /** - * @test - */ - public function shouldGetRepositoryLanguages() - { - $expectedArray = ['lang1', 'lang2']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/languages') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->languages('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetRepositoryMilestones() - { - $expectedArray = ['milestone1', 'milestone2']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/milestones') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->milestones('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldEnableAutomatedSecurityFixes() - { - $expectedResponse = 'response'; - - /** @var Repo|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/automated-security-fixes') - ->will($this->returnValue($expectedResponse)); - - $this->assertEquals($expectedResponse, $api->enableAutomatedSecurityFixes('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldDisableAutomatedSecurityFixes() - { - $expectedResponse = 'response'; - - /** @var Repo|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/automated-security-fixes') - ->will($this->returnValue($expectedResponse)); - - $this->assertEquals($expectedResponse, $api->disableAutomatedSecurityFixes('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetContributorsExcludingAnonymousOnes() - { - $expectedArray = ['contrib1', 'contrib2']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/contributors', ['anon' => null]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->contributors('KnpLabs', 'php-github-api', false)); - } - - /** - * @test - */ - public function shouldGetContributorsIncludingAnonymousOnes() - { - $expectedArray = ['contrib1', 'contrib2']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/contributors', ['anon' => true]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->contributors('KnpLabs', 'php-github-api', true)); - } - - /** - * @test - */ - public function shouldGetRepositoryTeams() - { - $expectedArray = [['id' => 1234], ['id' => 2345]]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/teams') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->teams('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldCreateUsingAllParams() - { - $expectedArray = ['id' => 1, 'name' => 'l3l0Repo']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/user/repos', [ - 'name' => 'l3l0Repo', - 'description' => 'test', - 'homepage' => 'http://l3l0.eu', - 'private' => true, - 'has_issues' => false, - 'has_wiki' => false, - 'has_downloads' => false, - 'auto_init' => false, - 'has_projects' => true, - ]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->create('l3l0Repo', 'test', 'http://l3l0.eu', false)); - } - - /** - * @test - */ - public function shouldUpdate() - { - $expectedArray = ['id' => 1, 'name' => 'l3l0Repo']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/l3l0Repo/test', ['description' => 'test', 'homepage' => 'http://l3l0.eu']) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->update('l3l0Repo', 'test', ['description' => 'test', 'homepage' => 'http://l3l0.eu'])); - } - - /** - * @test - */ - public function shouldDelete() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/l3l0Repo/test') - ->will($this->returnValue(null)); - - $this->assertNull($api->remove('l3l0Repo', 'test')); - } - - /** - * @test - */ - public function shouldNotDelete() - { - $expectedArray = ['message' => 'Not Found']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/l3l0Repo/unknown-repo') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->remove('l3l0Repo', 'unknown-repo')); - } - - /** - * @test - */ - public function shouldGetCollaboratorsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Repository\Collaborators::class, $api->collaborators()); - } - - /** - * @test - */ - public function shouldGetCommentsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Repository\Comments::class, $api->comments()); - } - - /** - * @test - */ - public function shouldGetCommitsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Repository\Commits::class, $api->commits()); - } - - /** - * @test - */ - public function shouldGetContentsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Repository\Contents::class, $api->contents()); - } - - /** - * @test - */ - public function shouldGetDeployKeysApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Repository\DeployKeys::class, $api->keys()); - } - - /** - * @test - */ - public function shouldGetDownloadsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Repository\Downloads::class, $api->downloads()); - } - - /** - * @test - */ - public function shouldGetForksApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Repository\Forks::class, $api->forks()); - } - - /** - * @test - */ - public function shouldGetHooksApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Repository\Hooks::class, $api->hooks()); - } - - /** - * @test - */ - public function shouldGetLabelsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Repository\Labels::class, $api->labels()); - } - - /** - * @test - */ - public function shouldGetStatusesApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Repository\Statuses::class, $api->statuses()); - } - - /** - * @test - */ - public function shouldGetStargazersApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Repository\Stargazers::class, $api->stargazers()); - } - - /** - * @test - */ - public function shouldGetReleasesApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Repository\Releases::class, $api->releases()); - } - - /** - * @test - */ - public function shouldGetVariablesApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\Github\Api\Repository\Actions\Variables::class, $api->variables()); - } - - /** - * @test - */ - public function shouldGetCommitActivity() - { - $expectedArray = [['days' => [0, 3, 26, 20, 39, 1, 0], 'total' => 89, 'week' => 1336280400]]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/stats/commit_activity') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->activity('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetRepositoryEvents() - { - $expectedArray = ['id' => 6122723754, 'type' => 'ForkEvent']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/events', [ - 'page' => 3, - ]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->events('KnpLabs', 'php-github-api', 3)); - } - - /** - * @test - */ - public function shouldGetRepositoryCommunityProfile() - { - $expectedArray = ['health_percentage' => 100, 'description' => 'A simple PHP GitHub API client...']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/community/profile') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->communityProfile('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetRepositoryCodeOfConduct() - { - $expectedArray = ['name' => 'Contributor Covenant', 'url' => 'http://...']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/community/code_of_conduct') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->codeOfConduct('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetRepositoryTopics() - { - $expectedArray = ['names' => ['octocat', 'atom', 'electron', 'API']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/topics') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->topics('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldReplaceRepositoryTopics() - { - $expectedArray = ['id' => 6122723754, 'type' => 'ForkEvent']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/topics', [ - 'names' => ['octocat', 'atom', 'electron', 'API'], - ]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->replaceTopics('KnpLabs', 'php-github-api', ['octocat', 'atom', 'electron', 'API'])); - } - - /** - * @test - */ - public function shouldTransferRepository() - { - $expectedArray = ['id' => 1, 'name' => 'php-github-api']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/transfer', [ - 'new_owner' => 'github', - 'team_id' => [1234, 1235], - ]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->transfer('KnpLabs', 'php-github-api', 'github', [1234, 1235])); - } - - /** - * @test - */ - public function shouldCreateRepositoryUsingTemplate() - { - $expectedArray = [ - 'id' => 1, - 'name' => 'newrepo', - 'full_name' => 'johndoe/newrepo', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/acme/template/generate', [ - 'name' => 'newrepo', - 'owner' => 'johndoe', - ]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->createFromTemplate('acme', 'template', [ - 'name' => 'newrepo', - 'owner' => 'johndoe', - ])); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repo::class; - } - - /** - * @test - */ - public function shouldCheckVulnerabilityAlertsEnabled() - { - $expectedResponse = ''; - - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/vulnerability-alerts') - ->will($this->returnValue($expectedResponse)); - - $this->assertEquals($expectedResponse, $api->isVulnerabilityAlertsEnabled('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldEnableVulnerabilityAlerts() - { - $expectedResponse = ''; - - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/vulnerability-alerts') - ->will($this->returnValue($expectedResponse)); - - $this->assertEquals($expectedResponse, $api->enableVulnerabilityAlerts('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldDisableVulnerabilityAlerts() - { - $expectedResponse = ''; - - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/vulnerability-alerts') - ->will($this->returnValue($expectedResponse)); - - $this->assertEquals($expectedResponse, $api->disableVulnerabilityAlerts('KnpLabs', 'php-github-api')); - } -} diff --git a/test/Github/Tests/Api/Repository/Actions/ArtifactsTest.php b/test/Github/Tests/Api/Repository/Actions/ArtifactsTest.php deleted file mode 100644 index 90ace988bab..00000000000 --- a/test/Github/Tests/Api/Repository/Actions/ArtifactsTest.php +++ /dev/null @@ -1,96 +0,0 @@ - 'id', - 'node_id' => 'node_id', - 'name' => 'name', - 'size_in_bytes' => 453, - 'url' => 'foo', - 'archive_download_url' => 'foo', - 'expired' => false, - 'created_at' => '2020-01-10T14:59:22Z', - 'expires_at' => '2020-01-21T14:59:22Z', - ], - ]; - - /** @var Artifacts|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/artifacts') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetRunArtifacts() - { - $expectedArray = [ - [ - 'id' => 'id', - 'node_id' => 'node_id', - 'name' => 'name', - 'size_in_bytes' => 453, - 'url' => 'foo', - 'archive_download_url' => 'foo', - 'expired' => false, - 'created_at' => '2020-01-10T14:59:22Z', - 'expires_at' => '2020-01-21T14:59:22Z', - ], - ]; - - /** @var Artifacts|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/runs/1/artifacts') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->runArtifacts('KnpLabs', 'php-github-api', 1)); - } - - /** - * @test - */ - public function shouldRemoveArtifact() - { - $expectedValue = 'response'; - - /** @var Artifacts|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/actions/artifacts/1') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 1)); - } - - protected function getApiClass() - { - return Artifacts::class; - } -} diff --git a/test/Github/Tests/Api/Repository/Actions/SecretsTest.php b/test/Github/Tests/Api/Repository/Actions/SecretsTest.php deleted file mode 100644 index 5a5e20a4616..00000000000 --- a/test/Github/Tests/Api/Repository/Actions/SecretsTest.php +++ /dev/null @@ -1,136 +0,0 @@ - 'GH_TOKEN', 'created_at' => 'created_at', 'updated_at' => 'updated_at'], - ['name' => 'GIST_ID', 'created_at' => 'created_at', 'updated_at' => 'updated_at'], - ]; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/secrets') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetSecret() - { - $expectedArray = ['name' => 'name', 'created_at' => 'created_at', 'updated_at' => 'updated_at']; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/secrets/secretName') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('KnpLabs', 'php-github-api', 'secretName')); - } - - /** - * @test - */ - public function shouldCreateSecret() - { - $expectedValue = 'response'; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/actions/secrets/secretName') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', 'secretName', [ - 'encrypted_value' => 'encryptedValue', - ])); - } - - /** - * @test - */ - public function shouldUpdateSecret() - { - $expectedValue = 'response'; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/actions/secrets/secretName') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 'secretName', [ - 'key_id' => 'keyId', 'encrypted_value' => 'encryptedValue', - ])); - } - - /** - * @test - */ - public function shouldRemoveSecret() - { - $expectedValue = 'response'; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/actions/secrets/secretName') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 'secretName')); - } - - /** - * @test - */ - public function shouldGetPublicKey() - { - $expectedArray = ['key_id' => 'key_id', 'key' => 'foo']; - - /** @var Secrets|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/secrets/public-key') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->publicKey('KnpLabs', 'php-github-api')); - } - - protected function getApiClass() - { - return Secrets::class; - } -} diff --git a/test/Github/Tests/Api/Repository/Actions/SelfHostedRunnersTest.php b/test/Github/Tests/Api/Repository/Actions/SelfHostedRunnersTest.php deleted file mode 100644 index 67c8eade4bd..00000000000 --- a/test/Github/Tests/Api/Repository/Actions/SelfHostedRunnersTest.php +++ /dev/null @@ -1,115 +0,0 @@ - 1, - 'name' => 'MBP', - 'os' => 'macos', - 'status' => 'online', - ], - [ - 'id' => 2, - 'name' => 'iMac', - 'os' => 'macos', - 'status' => 'offline', - ], - ]; - - /** @var SelfHostedRunners|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/runners') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetSelfHostedRunner() - { - $expectedArray = [ - 'id' => 1, - 'name' => 'MBP', - 'os' => 'macos', - 'status' => 'online', - ]; - - /** @var SelfHostedRunners|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/runners/1') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('KnpLabs', 'php-github-api', 1)); - } - - /** - * @test - */ - public function shouldRemoveSelfHostedRunner() - { - $expectedValue = 'response'; - - /** @var SelfHostedRunners|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/actions/runners/1') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 1)); - } - - /** - * @test - */ - public function shouldGetSelfHostedRunnerApps() - { - $expectedArray = [ - ['os' => 'osx', 'architecture' => 'x64', 'download_url' => 'download_url', 'filename' => 'filename'], - ['os' => 'linux', 'architecture' => 'x64', 'download_url' => 'download_url', 'filename' => 'filename'], - ['os' => 'linux', 'architecture' => 'arm', 'download_url' => 'download_url', 'filename' => 'filename'], - ['os' => 'win', 'architecture' => 'x64', 'download_url' => 'download_url', 'filename' => 'filename'], - ['os' => 'linux', 'architecture' => 'arm64', 'download_url' => 'download_url', 'filename' => 'filename'], - ]; - - /** @var SelfHostedRunners|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/runners/downloads') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->applications('KnpLabs', 'php-github-api')); - } - - protected function getApiClass() - { - return SelfHostedRunners::class; - } -} diff --git a/test/Github/Tests/Api/Repository/Actions/VariablesTest.php b/test/Github/Tests/Api/Repository/Actions/VariablesTest.php deleted file mode 100644 index e362d31f7bc..00000000000 --- a/test/Github/Tests/Api/Repository/Actions/VariablesTest.php +++ /dev/null @@ -1,119 +0,0 @@ - 'GH_TOKEN', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at'], - ['name' => 'GIST_ID', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at'], - ]; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/variables') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetVariable() - { - $expectedArray = ['name' => 'name', 'value' => 'value', 'created_at' => 'created_at', 'updated_at' => 'updated_at']; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/variables/variableName') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('KnpLabs', 'php-github-api', 'variableName')); - } - - /** - * @test - */ - public function shouldCreateVariable() - { - $expectedValue = 'response'; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/actions/variables') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', [ - 'name' => 'name', - 'value' => 'value', - ])); - } - - /** - * @test - */ - public function shouldUpdateVariable() - { - $expectedValue = 'response'; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/actions/variables/variableName') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 'variableName', [ - 'name' => 'name', - 'value' => 'value', - ])); - } - - /** - * @test - */ - public function shouldRemoveVariable() - { - $expectedValue = 'response'; - - /** @var Variables|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/actions/variables/variableName') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 'variableName')); - } - - protected function getApiClass() - { - return Variables::class; - } -} diff --git a/test/Github/Tests/Api/Repository/Actions/WorkflowJobsTest.php b/test/Github/Tests/Api/Repository/Actions/WorkflowJobsTest.php deleted file mode 100644 index 4af8b52ebc9..00000000000 --- a/test/Github/Tests/Api/Repository/Actions/WorkflowJobsTest.php +++ /dev/null @@ -1,57 +0,0 @@ - 'id', 'run_id' => 'run_id', 'status' => 'completed', 'conclusion' => 'success'], - ]; - - /** @var WorkflowJobs|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/runs/1/jobs') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all('KnpLabs', 'php-github-api', 1)); - } - - /** - * @test - */ - public function shouldShowWorkflowJob() - { - $expectedArray = [ - 'id' => 'id', 'run_id' => 'run_id', 'status' => 'completed', 'conclusion' => 'success', - ]; - - /** @var WorkflowJobs|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/jobs/1') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('KnpLabs', 'php-github-api', 1)); - } - - protected function getApiClass() - { - return WorkflowJobs::class; - } -} diff --git a/test/Github/Tests/Api/Repository/Actions/WorkflowRunsTest.php b/test/Github/Tests/Api/Repository/Actions/WorkflowRunsTest.php deleted file mode 100644 index 1c5af0badc9..00000000000 --- a/test/Github/Tests/Api/Repository/Actions/WorkflowRunsTest.php +++ /dev/null @@ -1,223 +0,0 @@ - 'id', - 'event' => 'push', - 'status' => 'queued', - ], - ]; - - /** @var WorkflowRuns|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/runs') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetWorkflowRuns() - { - $expectedArray = [ - [ - 'id' => 'id', - 'name' => 'CI', - 'event' => 'push', - 'status' => 'completed', - 'conclusion' => 'success', - 'workflow_id' => 3441570, - ], - ]; - - /** @var WorkflowRuns|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/workflows/3441570/runs') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->listRuns('KnpLabs', 'php-github-api', 3441570)); - } - - /** - * @test - */ - public function shouldShowWorkflowRun() - { - $expectedArray = ['id' => 'id', 'name' => 'CI']; - - /** @var WorkflowRuns|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('KnpLabs', 'php-github-api', 374473304)); - } - - /** - * @test - */ - public function shouldDeleteWorkflowRun() - { - $expectedValue = 'response'; - - /** @var WorkflowRuns|MockObject $api */ - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 374473304)); - } - - /** - * @test - */ - public function shouldGetWorkflowRunUsage() - { - $expectedArray = [ - 'billable' => [ - 'UBUNTU' => ['total_ms' => 180000, 'jobs' => 1], - 'MACOS' => ['total_ms' => 240000, 'jobs' => 1], - 'WINDOWS' => ['total_ms' => 300000, 'jobs' => 1], - ], - 'run_duration_ms' => 500000, - ]; - - /** @var WorkflowRuns|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304/timing') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->usage('KnpLabs', 'php-github-api', 374473304)); - } - - /** - * @test - */ - public function shouldRerunWorkflowRun() - { - $expectedValue = 'response'; - - /** @var WorkflowRuns|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304/rerun') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->rerun('KnpLabs', 'php-github-api', 374473304)); - } - - /** - * @test - */ - public function shouldCancelWorkflowRun() - { - $expectedValue = 'response'; - - /** @var WorkflowRuns|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304/cancel') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->cancel('KnpLabs', 'php-github-api', 374473304)); - } - - /** - * @test - */ - public function shouldDownloadWorkflowRunLogs() - { - $expectedValue = 'response'; - - /** @var WorkflowRuns|MockObject $api */ - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304/logs') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->downloadLogs('KnpLabs', 'php-github-api', 374473304)); - } - - /** - * @test - */ - public function shouldDeleteWorkflowRunLogs() - { - $expectedValue = 'response'; - - /** @var WorkflowRuns|MockObject $api */ - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304/logs') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->deleteLogs('KnpLabs', 'php-github-api', 374473304)); - } - - /** - * @test - */ - public function shouldApproveWorkflowRunLogs() - { - $expectedValue = 'response'; - - /** @var WorkflowRuns|MockObject $api */ - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/actions/runs/374473304/approve') - ->will($this->returnValue($expectedValue)); - - $this->assertSame($expectedValue, $api->approve('KnpLabs', 'php-github-api', 374473304)); - } - - protected function getApiClass() - { - return WorkflowRuns::class; - } -} diff --git a/test/Github/Tests/Api/Repository/Actions/WorkflowsTest.php b/test/Github/Tests/Api/Repository/Actions/WorkflowsTest.php deleted file mode 100644 index 7413fc5d7c0..00000000000 --- a/test/Github/Tests/Api/Repository/Actions/WorkflowsTest.php +++ /dev/null @@ -1,116 +0,0 @@ - 'id', - 'node_id' => 'node_id', - 'name' => 'CI', - 'path' => '.github/workflows/ci.yml', - 'state' => 'active', - 'created_at' => '2020-11-07T15:09:45.000Z', - 'updated_at' => '2020-11-07T15:09:45.000Z', - ], - ]; - - /** @var Workflows|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/workflows') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldShowWorkflow() - { - $expectedArray = [ - 'id' => 'id', - 'node_id' => 'node_id', - 'name' => 'CI', - 'path' => '.github/workflows/ci.yml', - 'state' => 'active', - 'created_at' => '2020-11-07T15:09:45.000Z', - 'updated_at' => '2020-11-07T15:09:45.000Z', - ]; - - /** @var Workflows|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/workflows/1') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('KnpLabs', 'php-github-api', 1)); - } - - /** - * @test - */ - public function shouldGetWorkflowUsage() - { - $expectedArray = [ - 'billable' => [ - 'UBUNTU' => ['total_ms' => 180000, 'jobs' => 1], - 'MACOS' => ['total_ms' => 240000, 'jobs' => 1], - 'WINDOWS' => ['total_ms' => 300000, 'jobs' => 1], - ], - ]; - - /** @var Workflows|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/actions/workflows/1/timing') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->usage('KnpLabs', 'php-github-api', 1)); - } - - /** - * @test - */ - public function shouldDispatchWorkflow() - { - // empty - $expectedArray = []; - - /** @var Workflows|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/actions/workflows/1/dispatches') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->dispatches('KnpLabs', 'php-github-api', 1, 'main')); - } - - protected function getApiClass() - { - return Workflows::class; - } -} diff --git a/test/Github/Tests/Api/Repository/AssetsTest.php b/test/Github/Tests/Api/Repository/AssetsTest.php deleted file mode 100644 index 6cea75fe975..00000000000 --- a/test/Github/Tests/Api/Repository/AssetsTest.php +++ /dev/null @@ -1,129 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/releases/'.$id.'/assets') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', $id)); - } - - /** - * @test - */ - public function shouldGetSingleReleaseAsset() - { - $expectedValue = ['assetData']; - $assetId = 2; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/releases/assets/'.$assetId) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', $assetId)); - } - - /** - * @test - * - * @requires PHP 5.3.4 - */ - public function shouldCreateReleaseAsset() - { - if (!defined('OPENSSL_TLSEXT_SERVER_NAME') || !OPENSSL_TLSEXT_SERVER_NAME) { - return $this->markTestSkipped( - 'Asset upload support requires Server Name Indication. This is not supported by your PHP version.' - ); - } - - $name = 'asset.gzip'; - $body = 'assetCreatedData'; - $contentType = 'application/gzip'; - $releaseId = '12345'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('postRaw') - ->with('https://uploads.github.com/repos/KnpLabs/php-github-api/releases/'.$releaseId.'/assets?name='.$name) - ->will($this->returnValue($body)); - - $this->assertEquals($body, $api->create('KnpLabs', 'php-github-api', $releaseId, $name, $contentType, $body)); - } - - /** - * @test - */ - public function shouldEditReleaseAsset() - { - $expectedValue = ['assetUpdatedData']; - $assetId = 5; - $data = ['name' => 'asset111_name_qweqwe']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/releases/assets/'.$assetId) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->edit('KnpLabs', 'php-github-api', $assetId, $data)); - } - - /** - * @test - */ - public function shouldNotEditReleaseAssetWithoutName() - { - $this->expectException(MissingArgumentException::class); - $assetId = 5; - $data = ['not_a_name' => 'just a value']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('patch'); - - $api->edit('KnpLabs', 'php-github-api', $assetId, $data); - } - - /** - * @test - */ - public function shouldRemoveReleaseAsset() - { - $expectedValue = ['assetUpdatedData']; - $assetId = 5; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/releases/assets/'.$assetId) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', $assetId)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\Assets::class; - } -} diff --git a/test/Github/Tests/Api/Repository/Checks/CheckRunsTest.php b/test/Github/Tests/Api/Repository/Checks/CheckRunsTest.php deleted file mode 100644 index 66bb5277c4b..00000000000 --- a/test/Github/Tests/Api/Repository/Checks/CheckRunsTest.php +++ /dev/null @@ -1,123 +0,0 @@ - 'success']; - $data = ['head_sha' => 'commitSHA123456', 'name' => 'my check']; - - /** @var CheckRuns|MockObject $api */ - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/check-runs', $data) - ->willReturn($expectedValue); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldShowSingleCheckRun() - { - /** @var CheckRuns|MockObject $api */ - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/check-runs/14'); - - $api->show('KnpLabs', 'php-github-api', 14); - } - - /** - * @test - */ - public function shouldUpdateCheck() - { - $expectedValue = ['state' => 'success']; - $data = ['head_sha' => 'commitSHA123456', 'name' => 'my check']; - - /** @var CheckRuns|MockObject $api */ - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/check-runs/123', $data) - ->willReturn($expectedValue); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data)); - } - - /** - * @test - */ - public function shouldListCheckRunAnnotations() - { - /** @var CheckRuns|MockObject $api */ - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/check-runs/14/annotations'); - - $api->annotations('KnpLabs', 'php-github-api', 14); - } - - /** - * @test - */ - public function shouldGetAllChecksForCheckSuite() - { - $params = ['test' => true]; - /** @var CheckRuns|MockObject $api */ - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/check-suites/123/check-runs', $params); - - $api->allForCheckSuite('KnpLabs', 'php-github-api', 123, $params); - } - - /** - * @test - */ - public function shouldGetAllChecksForReference() - { - $params = ['test' => true]; - /** @var CheckRuns|MockObject $api */ - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/commits/cb4abc15424c0015b4468d73df55efb8b60a4a3d/check-runs', $params); - - $api->allForReference('KnpLabs', 'php-github-api', 'cb4abc15424c0015b4468d73df55efb8b60a4a3d', $params); - } - - /** - * @test - */ - public function shouldRerequestCheckRun() - { - /** @var CheckRuns|MockObject $api */ - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/check-runs/123/rerequest'); - - $api->rerequest('KnpLabs', 'php-github-api', 123); - } - - protected function getApiClass(): string - { - return CheckRuns::class; - } -} diff --git a/test/Github/Tests/Api/Repository/Checks/CheckSuitsTest.php b/test/Github/Tests/Api/Repository/Checks/CheckSuitsTest.php deleted file mode 100644 index 87d8831d0da..00000000000 --- a/test/Github/Tests/Api/Repository/Checks/CheckSuitsTest.php +++ /dev/null @@ -1,93 +0,0 @@ - 'success']; - $data = ['head_sha' => 'commitSHA123456', 'name' => 'my check']; - - /** @var CheckSuites|MockObject $api */ - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/check-suites', $data) - ->willReturn($expectedValue); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldUpdateCheckSuitePreferences() - { - $expectedValue = ['preferences' => []]; - $data = ['preference_1' => true]; - - /** @var CheckSuites|MockObject $api */ - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/check-suites/preferences', $data) - ->willReturn($expectedValue); - - $this->assertEquals($expectedValue, $api->updatePreferences('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldGetCheckSuite() - { - /** @var CheckSuites|MockObject $api */ - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/check-suites/14'); - - $api->getCheckSuite('KnpLabs', 'php-github-api', 14); - } - - /** - * @test - */ - public function shouldRerequest() - { - /** @var CheckSuites|MockObject $api */ - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/check-suites/14/rerequest'); - - $api->rerequest('KnpLabs', 'php-github-api', 14); - } - - /** - * @test - */ - public function shouldGetAllCheckSuitesForReference() - { - /** @var CheckSuites|MockObject $api */ - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/commits/cb4abc15424c0015b4468d73df55efb8b60a4a3d/check-suites'); - - $api->allForReference('KnpLabs', 'php-github-api', 'cb4abc15424c0015b4468d73df55efb8b60a4a3d'); - } - - protected function getApiClass(): string - { - return CheckSuites::class; - } -} diff --git a/test/Github/Tests/Api/Repository/CollaboratorsTest.php b/test/Github/Tests/Api/Repository/CollaboratorsTest.php deleted file mode 100644 index 8bf57d96791..00000000000 --- a/test/Github/Tests/Api/Repository/CollaboratorsTest.php +++ /dev/null @@ -1,96 +0,0 @@ - 'l3l0']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/collaborators') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldCheckIfRepositoryCollaborator() - { - $expectedValue = 'response'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/collaborators/l3l0') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->check('KnpLabs', 'php-github-api', 'l3l0')); - } - - /** - * @test - */ - public function shouldAddRepositoryCollaborator() - { - $expectedValue = 'response'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/collaborators/l3l0') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->add('KnpLabs', 'php-github-api', 'l3l0')); - } - - /** - * @test - */ - public function shouldRemoveRepositoryCollaborator() - { - $expectedValue = 'response'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/collaborators/l3l0') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 'l3l0')); - } - - /** - * @test - */ - public function shouldGetRepositoryCollaboratorPermission() - { - $expectedValue = [['permission' => 'admin', 'user' => 'l3l0']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/collaborators/l3l0/permission') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->permission('KnpLabs', 'php-github-api', 'l3l0')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\Collaborators::class; - } -} diff --git a/test/Github/Tests/Api/Repository/CommentsTest.php b/test/Github/Tests/Api/Repository/CommentsTest.php deleted file mode 100644 index 949bf4e231d..00000000000 --- a/test/Github/Tests/Api/Repository/CommentsTest.php +++ /dev/null @@ -1,160 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/comments') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetSpecificCommitRepositoryComments() - { - $expectedValue = [['comment1data'], ['comment2data']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/commits/commitSHA123456/comments') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', 'commitSHA123456')); - } - - /** - * @test - */ - public function shouldShowComment() - { - $expectedValue = ['comment1']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/comments/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldNotCreateWithoutBody() - { - $this->expectException(MissingArgumentException::class); - $data = ['line' => 53, 'path' => 'test.php', 'position' => 2]; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', 'commitSHA123456', $data); - } - - /** - * @test - */ - public function shouldCreateRepositoryCommitComment() - { - $expectedValue = ['comment1data']; - $data = ['body' => 'test body', 'line' => 53, 'path' => 'test.php', 'position' => 2]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/commits/commitSHA123456/comments', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', 'commitSHA123456', $data)); - } - - /** - * @test - */ - public function shouldCreateRepositoryCommitCommentWithoutLine() - { - $expectedValue = ['comment1data']; - $data = ['body' => 'body', 'path' => 'test.php', 'position' => 2]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/commits/commitSHA123456/comments', $data) - ->will($this->returnValue($expectedValue)); - - $api->create('KnpLabs', 'php-github-api', 'commitSHA123456', $data); - } - - /** - * @test - */ - public function shouldNotUpdateWithoutBody() - { - $this->expectException(MissingArgumentException::class); - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('patch'); - - $api->update('KnpLabs', 'php-github-api', 'commitSHA123456', []); - } - - /** - * @test - */ - public function shouldUpdateComment() - { - $expectedValue = ['comment1data']; - $data = ['body' => 'body test']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/comments/123', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data)); - } - - /** - * @test - */ - public function shouldRemoveComment() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/comments/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 123)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\Comments::class; - } -} diff --git a/test/Github/Tests/Api/Repository/CommitsTest.php b/test/Github/Tests/Api/Repository/CommitsTest.php deleted file mode 100644 index 9d1b3288afe..00000000000 --- a/test/Github/Tests/Api/Repository/CommitsTest.php +++ /dev/null @@ -1,84 +0,0 @@ - [], 'comitter']; - $data = ['sha' => 'v3']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/commits', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldCompareTwoCommits() - { - $expectedValue = ['someCompareChanges']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/compare/v3...HEAD') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->compare('KnpLabs', 'php-github-api', 'v3', 'HEAD')); - } - - /** - * @test - */ - public function shouldShowCommitUsingSha() - { - $expectedValue = ['sha' => '123', 'comitter']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/commits/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldGetAllPullRequestsUsingSha() - { - $expectedValue = [ - ['number' => '1', 'title' => 'My first PR'], - ['number' => '2', 'title' => 'Another PR'], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/commits/123/pulls') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->pulls('KnpLabs', 'php-github-api', 123)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\Commits::class; - } -} diff --git a/test/Github/Tests/Api/Repository/ContentsTest.php b/test/Github/Tests/Api/Repository/ContentsTest.php deleted file mode 100644 index 81a79db64fa..00000000000 --- a/test/Github/Tests/Api/Repository/ContentsTest.php +++ /dev/null @@ -1,347 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', ['ref' => null]) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php')); - } - - /** - * @test - */ - public function shouldShowReadme() - { - $expectedValue = 'README...'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/readme', ['ref' => null]) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->readme('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldReturnTrueWhenFileExists() - { - $response = new Response(200); - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('head') - ->with('/repos/KnpLabs/php-github-api/contents/composer.json', ['ref' => null]) - ->will($this->returnValue($response)); - - $this->assertTrue($api->exists('KnpLabs', 'php-github-api', 'composer.json')); - } - - public function getFailureStubsForExistsTest() - { - $response = new Response(403); - - return [ - [$this->throwException(new \ErrorException())], - [$this->returnValue($response)], - ]; - } - - /** - * @param \PHPUnit_Framework_MockObject_Stub|\PHPUnit\Framework\MockObject\Stub\Exception - * - * @test - * - * @dataProvider getFailureStubsForExistsTest - */ - public function shouldReturnFalseWhenFileIsNotFound($failureStub) - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('head') - ->with('/repos/KnpLabs/php-github-api/contents/composer.json', ['ref' => null]) - ->will($failureStub); - - $this->assertFalse($api->exists('KnpLabs', 'php-github-api', 'composer.json')); - } - - /** - * @test - */ - public function shouldBubbleTwoFactorAuthenticationRequiredExceptionsWhenCheckingFileRequiringAuth() - { - $this->expectException(TwoFactorAuthenticationRequiredException::class); - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('head') - ->with('/repos/KnpLabs/php-github-api/contents/composer.json', ['ref' => null]) - ->will($this->throwException(new TwoFactorAuthenticationRequiredException(0))); - - $api->exists('KnpLabs', 'php-github-api', 'composer.json'); - } - - /** - * @test - */ - public function shouldCreateNewFile() - { - $expectedArray = ['content' => 'some data']; - $content = ' 'committer name', 'email' => 'email@example.com']; - $parameters = [ - 'content' => base64_encode($content), - 'message' => $message, - 'committer' => $committer, - 'branch' => $branch, - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', $parameters) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->create('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php', $content, $message, $branch, $committer)); - } - - /** - * @test - */ - public function shouldThrowExceptionWhenCreateNewFileWithInvalidCommitter() - { - $this->expectException(MissingArgumentException::class); - $this->expectExceptionMessage('One or more of required ("name", "email") parameters is missing!'); - $committer = ['invalid_key' => 'some data']; - $api = $this->getApiMock(); - $api->create('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php', 'some content', 'a commit message', null, $committer); - } - - /** - * @test - */ - public function shouldUpdateFile() - { - $expectedArray = ['content' => 'some data']; - $content = ' 'committer name', 'email' => 'email@example.com']; - $parameters = [ - 'content' => base64_encode($content), - 'message' => $message, - 'committer' => $committer, - 'branch' => $branch, - 'sha' => $sha, - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', $parameters) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->update('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php', $content, $message, $sha, $branch, $committer)); - } - - /** - * @test - */ - public function shouldThrowExceptionWhenUpdateFileWithInvalidCommitter() - { - $this->expectException(MissingArgumentException::class); - $this->expectExceptionMessage('One or more of required ("name", "email") parameters is missing!'); - $committer = ['invalid_key' => 'some data']; - $api = $this->getApiMock(); - $api->update('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php', 'some content', 'a commit message', null, null, $committer); - } - - /** - * @test - */ - public function shouldDeleteFile() - { - $expectedArray = ['content' => 'some data']; - $message = 'a commit message'; - $sha = 'a sha'; - $branch = 'master'; - $committer = ['name' => 'committer name', 'email' => 'email@example.com']; - $parameters = [ - 'message' => $message, - 'committer' => $committer, - 'branch' => $branch, - 'sha' => $sha, - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', $parameters) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->rm('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php', $message, $sha, $branch, $committer)); - } - - /** - * @test - */ - public function shouldThrowExceptionWhenDeleteFileWithInvalidCommitter() - { - $this->expectException(MissingArgumentException::class); - $this->expectExceptionMessage('One or more of required ("name", "email") parameters is missing!'); - $committer = ['invalid_key' => 'some data']; - $api = $this->getApiMock(); - $api->rm('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php', 'a commit message', null, null, $committer); - } - - /** - * @test - */ - public function shouldFetchTarballArchiveWhenFormatNotRecognized() - { - $expectedValue = 'tar'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/tarball') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->archive('KnpLabs', 'php-github-api', 'someFormat')); - } - - /** - * @test - */ - public function shouldFetchTarballArchive() - { - $expectedValue = 'tar'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/tarball') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->archive('KnpLabs', 'php-github-api', 'tarball')); - } - - /** - * @test - */ - public function shouldFetchZipballArchive() - { - $expectedValue = 'zip'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/zipball') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->archive('KnpLabs', 'php-github-api', 'zipball')); - } - - /** - * @test - */ - public function shouldFetchZipballArchiveByReference() - { - $expectedValue = 'zip'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/zipball/master') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->archive('KnpLabs', 'php-github-api', 'zipball', 'master')); - } - - /** - * @test - */ - public function shouldDownloadForGivenPath() - { - // The show() method return - $getValue = include __DIR__.'/fixtures/ContentsDownloadFixture.php'; - - // The download() method return - $expectedValue = base64_decode($getValue['content']); - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', ['ref' => null]) - ->will($this->returnValue($getValue)); - - $this->assertEquals($expectedValue, $api->download('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php')); - } - - /** - * @test - */ - public function shouldDownloadForSpacedPath() - { - // The show() method return - $getValue = include __DIR__.'/fixtures/ContentsDownloadSpacedFixture.php'; - - // The download() method return - $expectedValue = base64_decode($getValue['content']); - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/mads379/scala.tmbundle/contents/Syntaxes%2FSimple%20Build%20Tool.tmLanguage', ['ref' => null]) - ->will($this->returnValue($getValue)); - - $this->assertEquals($expectedValue, $api->download('mads379', 'scala.tmbundle', 'Syntaxes/Simple Build Tool.tmLanguage')); - } - - /** - * @test - */ - public function shouldRawDownloadForGivenPath() - { - // The show() method return - $getValue = include __DIR__.'/fixtures/ContentsDownloadFixture.php'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/contents/test%2FGithub%2FTests%2FApi%2FRepository%2FContentsTest.php', ['ref' => null]) - ->will($this->returnValue($getValue)); - - $this->assertEquals($getValue, $api->rawDownload('KnpLabs', 'php-github-api', 'test/Github/Tests/Api/Repository/ContentsTest.php')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\Contents::class; - } -} diff --git a/test/Github/Tests/Api/Repository/DeployKeysTest.php b/test/Github/Tests/Api/Repository/DeployKeysTest.php deleted file mode 100644 index 2962390bc83..00000000000 --- a/test/Github/Tests/Api/Repository/DeployKeysTest.php +++ /dev/null @@ -1,167 +0,0 @@ - 'key']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/keys') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldShowDeployKey() - { - $expectedValue = ['key' => 'somename']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/keys/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldRemoveDeployKey() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/keys/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldNotCreateDeployKeyWithoutName() - { - $this->expectException(MissingArgumentException::class); - $data = ['config' => 'conf']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateDeployKeyWithoutColor() - { - $this->expectException(MissingArgumentException::class); - $data = ['name' => 'test']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldCreateDeployKey() - { - $expectedValue = ['key' => 'somename']; - $data = ['title' => 'test', 'key' => 'ssh-rsa 1231234232']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/keys', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldNotUpdateDeployKeyWithoutTitle() - { - $this->expectException(MissingArgumentException::class); - $data = ['key' => 'ssh-rsa 12323213']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('delete'); - $api->expects($this->never()) - ->method('post'); - - $api->update('KnpLabs', 'php-github-api', 123, $data); - } - - /** - * @test - */ - public function shouldNotUpdateDeployKeyWithoutKey() - { - $this->expectException(MissingArgumentException::class); - $data = ['title' => 'test']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('delete'); - $api->expects($this->never()) - ->method('post'); - - $api->update('KnpLabs', 'php-github-api', 123, $data); - } - - /** - * @test - */ - public function shouldUpdateDeployKey() - { - $expectedValue = ['key' => 'somename']; - $data = ['title' => 'test', 'key' => 'ssh-rsa 12312312321...']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/keys/123') - ->will($this->returnValue($expectedValue)); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/keys', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\DeployKeys::class; - } -} diff --git a/test/Github/Tests/Api/Repository/DownloadsTest.php b/test/Github/Tests/Api/Repository/DownloadsTest.php deleted file mode 100644 index f73b71491e4..00000000000 --- a/test/Github/Tests/Api/Repository/DownloadsTest.php +++ /dev/null @@ -1,64 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/downloads') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldShowRepositoryDownload() - { - $expectedValue = ['download']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/downloads/l3l0') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'l3l0')); - } - - /** - * @test - */ - public function shouldRemoveRepositoryDownload() - { - $expectedValue = 'response'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/downloads/l3l0') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 'l3l0')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\Downloads::class; - } -} diff --git a/test/Github/Tests/Api/Repository/ForksTest.php b/test/Github/Tests/Api/Repository/ForksTest.php deleted file mode 100644 index fbc6eb67212..00000000000 --- a/test/Github/Tests/Api/Repository/ForksTest.php +++ /dev/null @@ -1,65 +0,0 @@ - 'l3l0repo']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/forks', ['page' => 1]) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldCreateFork() - { - $expectedValue = [['name' => 'l3l0repo']]; - $data = ['someparam']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/forks', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldSortByNewestWhenSortParamNotRecognized() - { - $expectedValue = [['name' => 'l3l0repo']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/forks', ['page' => 1, 'sort' => 'newest']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api', ['sort' => 'oldes'])); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\Forks::class; - } -} diff --git a/test/Github/Tests/Api/Repository/HooksTest.php b/test/Github/Tests/Api/Repository/HooksTest.php deleted file mode 100644 index 00cdc69df2c..00000000000 --- a/test/Github/Tests/Api/Repository/HooksTest.php +++ /dev/null @@ -1,160 +0,0 @@ - 'hook']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/hooks') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldShowHook() - { - $expectedValue = ['hook' => 'somename']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/hooks/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldRemoveHook() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/hooks/123') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 123)); - } - - /** - * @test - */ - public function shouldNotCreateHookWithoutName() - { - $this->expectException(MissingArgumentException::class); - $data = ['config' => 'conf']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateHookWithoutColor() - { - $this->expectException(MissingArgumentException::class); - $data = ['name' => 'test']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldCreateHook() - { - $expectedValue = ['hook' => 'somename']; - $data = ['name' => 'test', 'config' => 'someconfig']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/hooks', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldNotUpdateHookWithoutConfig() - { - $this->expectException(MissingArgumentException::class); - $data = ['name' => 'test']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('patch'); - - $api->update('KnpLabs', 'php-github-api', 123, $data); - } - - /** - * @test - */ - public function shouldUpdateHook() - { - $expectedValue = ['hook' => 'somename']; - $data = ['name' => 'test', 'config' => 'config']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/hooks/123', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 123, $data)); - } - - /** - * @test - */ - public function shouldTestHook() - { - $expectedValue = [['name' => 'hook']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/hooks/123/tests') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->test('KnpLabs', 'php-github-api', 123)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\Hooks::class; - } -} diff --git a/test/Github/Tests/Api/Repository/LabelsTest.php b/test/Github/Tests/Api/Repository/LabelsTest.php deleted file mode 100644 index 4fe2fd81493..00000000000 --- a/test/Github/Tests/Api/Repository/LabelsTest.php +++ /dev/null @@ -1,129 +0,0 @@ - 'label']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/labels') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldShowLabel() - { - $expectedValue = ['label' => 'somename']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/labels/somename') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'somename')); - } - - /** - * @test - */ - public function shouldRemoveLabel() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/labels/somename') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 'somename')); - } - - /** - * @test - */ - public function shouldNotCreateLabelWithoutName() - { - $this->expectException(MissingArgumentException::class); - $data = ['color' => 'red']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldNotCreateLabelWithoutColor() - { - $this->expectException(MissingArgumentException::class); - $data = ['name' => 'test']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldCreateLabel() - { - $expectedValue = ['label' => 'somename']; - $data = ['name' => 'test', 'color' => 'red']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/labels', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldUpdateLabel() - { - $expectedValue = ['name' => 'test']; - $data = ['new_name' => 'test', 'color' => 'red']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/labels/labelName', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 'labelName', $data)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\Labels::class; - } -} diff --git a/test/Github/Tests/Api/Repository/PagesTest.php b/test/Github/Tests/Api/Repository/PagesTest.php deleted file mode 100644 index 2fde0df1622..00000000000 --- a/test/Github/Tests/Api/Repository/PagesTest.php +++ /dev/null @@ -1,150 +0,0 @@ - 'built']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/pages') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldEnablePages() - { - $params = [ - 'source' => [ - 'branch' => 'master', - 'path' => '/path', - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/pages', $params); - - $api->enable('KnpLabs', 'php-github-api', $params); - } - - /** - * @test - */ - public function shouldDisablePages() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/pages'); - - $api->disable('KnpLabs', 'php-github-api'); - } - - /** - * @test - */ - public function shouldUpdatePages() - { - $params = [ - 'source' => 'master /docs', - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/pages', $params); - - $api->update('KnpLabs', 'php-github-api', $params); - } - - /** - * @test - */ - public function shouldRequestPagesBuild() - { - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/pages/builds'); - - $api->requestBuild('KnpLabs', 'php-github-api'); - } - - /** - * @test - */ - public function shouldGetAllPagesBuilds() - { - $expectedValue = [['status' => 'built']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/pages/builds') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->builds('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetLatestPagesBuild() - { - $expectedValue = ['status' => 'built']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/pages/builds/latest') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->showLatestBuild('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function showGetOnePagesBuild() - { - $expectedValue = ['status' => 'built']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/pages/builds/some') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->showBuild('KnpLabs', 'php-github-api', 'some')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\Pages::class; - } -} diff --git a/test/Github/Tests/Api/Repository/ProjectsTest.php b/test/Github/Tests/Api/Repository/ProjectsTest.php deleted file mode 100644 index 225bda4baf6..00000000000 --- a/test/Github/Tests/Api/Repository/ProjectsTest.php +++ /dev/null @@ -1,65 +0,0 @@ - 'Test project 1']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/projects') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldNotCreateWithoutName() - { - $this->expectException(MissingArgumentException::class); - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldCreateColumn() - { - $expectedValue = ['project1data']; - $data = ['name' => 'Project 1']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/projects', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\Projects::class; - } -} diff --git a/test/Github/Tests/Api/Repository/ProtectionTest.php b/test/Github/Tests/Api/Repository/ProtectionTest.php deleted file mode 100644 index f4f711dce74..00000000000 --- a/test/Github/Tests/Api/Repository/ProtectionTest.php +++ /dev/null @@ -1,444 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'master')); - } - - /** - * @test - */ - public function shouldUpdateProtection() - { - $expectedValue = ['required_status_checks', 'required_pull_reqeust_reviews', 'restrictions']; - $data = ['required_status_checks' => null]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpLabs', 'php-github-api', 'master', $data)); - } - - /** - * @test - */ - public function shouldRemoveProtection() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', 'master')); - } - - /** - * @test - */ - public function shouldShowStatusChecks() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_status_checks') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->showStatusChecks('KnpLabs', 'php-github-api', 'master')); - } - - /** - * @test - */ - public function shouldUpdateStatusChecks() - { - $expectedValue = ['someOutput']; - $data = ['someInput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_status_checks') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->updateStatusChecks('KnpLabs', 'php-github-api', 'master', $data)); - } - - /** - * @test - */ - public function shouldRemoveStatusChecks() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_status_checks') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->removeStatusChecks('KnpLabs', 'php-github-api', 'master')); - } - - /** - * @test - */ - public function shouldShowStatusChecksContexts() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_status_checks/contexts') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->showStatusChecksContexts('KnpLabs', 'php-github-api', 'master')); - } - - /** - * @test - */ - public function shouldReplaceStatusChecksContexts() - { - $expectedValue = ['someOutput']; - $data = ['someInput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_status_checks/contexts') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->replaceStatusChecksContexts('KnpLabs', 'php-github-api', 'master', $data)); - } - - /** - * @test - */ - public function shouldAddStatusChecksContexts() - { - $expectedValue = ['someOutput']; - $data = ['someInput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_status_checks/contexts') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->addStatusChecksContexts('KnpLabs', 'php-github-api', 'master', $data)); - } - - /** - * @test - */ - public function shouldRemoveStatusChecksContexts() - { - $expectedValue = ['someOutput']; - $data = ['someInput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_status_checks/contexts') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->removeStatusChecksContexts('KnpLabs', 'php-github-api', 'master', $data)); - } - - /** - * @test - */ - public function shouldShowPullRequestReviewEnforcement() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_pull_request_reviews') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->showPullRequestReviewEnforcement('KnpLabs', 'php-github-api', 'master')); - } - - /** - * @test - */ - public function shouldUpdatePullRequestReviewEnforcement() - { - $expectedValue = ['someOutput']; - $data = ['someInput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_pull_request_reviews') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->updatePullRequestReviewEnforcement('KnpLabs', 'php-github-api', 'master', $data)); - } - - /** - * @test - */ - public function shouldRemovePullRequestReviewEnforcement() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/required_pull_request_reviews') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->removePullRequestReviewEnforcement('KnpLabs', 'php-github-api', 'master')); - } - - /** - * @test - */ - public function shouldShowAdminEnforcement() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/enforce_admins') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->showAdminEnforcement('KnpLabs', 'php-github-api', 'master')); - } - - /** - * @test - */ - public function shouldAddAdminEnforcement() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/enforce_admins') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->addAdminEnforcement('KnpLabs', 'php-github-api', 'master')); - } - - /** - * @test - */ - public function shouldRemoveAdminEnforcement() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/enforce_admins') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->removeAdminEnforcement('KnpLabs', 'php-github-api', 'master')); - } - - /** - * @test - */ - public function shouldShowRestrictions() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->showRestrictions('KnpLabs', 'php-github-api', 'master')); - } - - /** - * @test - */ - public function shouldRemoveRestrictions() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->removeRestrictions('KnpLabs', 'php-github-api', 'master')); - } - - /** - * @test - */ - public function shouldShowTeamRestrictions() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/teams') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->showTeamRestrictions('KnpLabs', 'php-github-api', 'master')); - } - - /** - * @test - */ - public function shouldReplaceTeamRestrictions() - { - $expectedValue = ['someOutput']; - $data = ['someInput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/teams') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->replaceTeamRestrictions('KnpLabs', 'php-github-api', 'master', $data)); - } - - /** - * @test - */ - public function shouldAddTeamRestrictions() - { - $expectedValue = ['someOutput']; - $data = ['someInput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/teams') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->addTeamRestrictions('KnpLabs', 'php-github-api', 'master', $data)); - } - - /** - * @test - */ - public function shouldRemoveTeamRestrictions() - { - $expectedValue = ['someOutput']; - $data = ['someInput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/teams') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->removeTeamRestrictions('KnpLabs', 'php-github-api', 'master', $data)); - } - - /** - * @test - */ - public function shouldShowUserRestrictions() - { - $expectedValue = ['someOutput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/users') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->showUserRestrictions('KnpLabs', 'php-github-api', 'master')); - } - - /** - * @test - */ - public function shouldReplaceUserRestrictions() - { - $expectedValue = ['someOutput']; - $data = ['someInput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/users') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->replaceUserRestrictions('KnpLabs', 'php-github-api', 'master', $data)); - } - - /** - * @test - */ - public function shouldAddUserRestrictions() - { - $expectedValue = ['someOutput']; - $data = ['someInput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/users') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->addUserRestrictions('KnpLabs', 'php-github-api', 'master', $data)); - } - - /** - * @test - */ - public function shouldRemoveUserRestrictions() - { - $expectedValue = ['someOutput']; - $data = ['someInput']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/branches/master/protection/restrictions/users') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->removeUserRestrictions('KnpLabs', 'php-github-api', 'master', $data)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\Protection::class; - } -} diff --git a/test/Github/Tests/Api/Repository/ReleasesTest.php b/test/Github/Tests/Api/Repository/ReleasesTest.php deleted file mode 100644 index dda8999a163..00000000000 --- a/test/Github/Tests/Api/Repository/ReleasesTest.php +++ /dev/null @@ -1,183 +0,0 @@ -getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/releases/latest') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->latest('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetReleaseByTag() - { - $expectedValue = ['latest_release_data']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/releases/tags/5f078080e01e0365690920d618f12342d2c941c8') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->tag( - 'KnpLabs', - 'php-github-api', - '5f078080e01e0365690920d618f12342d2c941c8' - )); - } - - /** - * @test - */ - public function shouldGetAllRepositoryReleases() - { - $expectedValue = [['release1data'], ['release2data']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/releases') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetSingleRepositoryRelease() - { - $expectedValue = ['releaseData']; - $id = 331; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/releases/'.$id) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', $id)); - } - - /** - * @test - */ - public function shouldGenerateReleaseNotes() - { - $expectedValue = [ - 'name' => 'Release v1.0.0 is now available!', - 'body' => '##Changes in Release v1.0.0 ... ##Contributors @monalisa', - ]; - $data = ['tag_name' => 'some-tag']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/releases/generate-notes') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->generateNotes('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldCreateRepositoryRelease() - { - $expectedValue = ['newReleaseData']; - $data = ['tag_name' => '1.1']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/releases') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', $data)); - } - - /** - * @test - */ - public function shouldNotCreateRepositoryReleaseWithoutTagName() - { - $this->expectException(MissingArgumentException::class); - $data = ['not_a_tag_name' => '1.1']; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', $data); - } - - /** - * @test - */ - public function shouldEditRepositoryRelease() - { - $expectedValue = ['updatedData']; - $id = 332; - $data = ['some' => 'thing']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/releases/'.$id) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->edit('KnpLabs', 'php-github-api', $id, $data)); - } - - /** - * @test - */ - public function shouldRemoveRepositoryRelease() - { - $expectedValue = ['deleted']; - $id = 333; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/repos/KnpLabs/php-github-api/releases/'.$id) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpLabs', 'php-github-api', $id)); - } - - /** - * @test - */ - public function shouldGetAssetsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf('Github\Api\Repository\Assets', $api->assets()); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\Releases::class; - } -} diff --git a/test/Github/Tests/Api/Repository/SecretScanningTest.php b/test/Github/Tests/Api/Repository/SecretScanningTest.php deleted file mode 100644 index e2e98dfa879..00000000000 --- a/test/Github/Tests/Api/Repository/SecretScanningTest.php +++ /dev/null @@ -1,132 +0,0 @@ - 1, 'state' => 'resolved', 'resolution' => 'false_positive'], - ['number' => 2, 'state' => 'open', 'resolution' => null], - ['number' => 3, 'state' => 'resolved', 'resolution' => 'wont_fix'], - ['number' => 4, 'state' => 'resolved', 'resolution' => 'revoked'], - ]; - - /** @var SecretScanning|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/secret-scanning/alerts') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->alerts('KnpLabs', 'php-github-api', [ - 'state' => 'all', - ])); - } - - /** - * @test - */ - public function shouldGetAlert() - { - $expectedArray = ['number' => 1, 'state' => 'resolved', 'resolution' => 'false_positive']; - - /** @var SecretScanning|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/secret-scanning/alerts/1') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->getAlert('KnpLabs', 'php-github-api', 1)); - } - - /** - * @test - */ - public function shouldUpdateAlert() - { - $expectedArray = ['number' => 1, 'state' => 'resolved', 'resolution' => 'false_positive']; - - /** @var SecretScanning|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('patch') - ->with('/repos/KnpLabs/php-github-api/secret-scanning/alerts/2') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->updateAlert('KnpLabs', 'php-github-api', 2, [ - 'state' => 'resolved', - 'resolution' => 'false_positive', - ])); - } - - /** - * @test - */ - public function shouldGetLocations() - { - $expectedArray = [ - [ - 'type' => 'commit', - 'details' => [ - 'path' => '/example/secrets.txt', - 'start_line' => 1, - 'end_line' => 1, - 'start_column' => 1, - 'end_column' => 64, - 'blob_sha' => 'af5626b4a114abcb82d63db7c8082c3c4756e51b', - 'blob_url' => 'https://HOSTNAME/repos/octocat/hello-world/git/blobs/af5626b4a114abcb82d63db7c8082c3c4756e51b', - 'commit_sha' => 'f14d7debf9775f957cf4f1e8176da0786431f72b', - 'commit_url' => 'https://HOSTNAME/repos/octocat/hello-world/git/commits/f14d7debf9775f957cf4f1e8176da0786431f72b', - ], - ], - [ - 'type' => 'commit', - 'details' => [ - 'path' => '/example/secrets.txt', - 'start_line' => 5, - 'end_line' => 5, - 'start_column' => 1, - 'end_column' => 64, - 'blob_sha' => '9def38117ab2d8355b982429aa924e268b4b0065', - 'blob_url' => 'https://HOSTNAME/repos/octocat/hello-world/git/blobs/9def38117ab2d8355b982429aa924e268b4b0065', - 'commit_sha' => '588483b99a46342501d99e3f10630cfc1219ea32', - 'commit_url' => 'https://HOSTNAME/repos/octocat/hello-world/git/commits/588483b99a46342501d99e3f10630cfc1219ea32', - ], - ], - ]; - - /** @var SecretScanning|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/secret-scanning/alerts/2/locations') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->locations('KnpLabs', 'php-github-api', 2, [ - 'per_page' => 10, - ])); - } - - protected function getApiClass() - { - return \Github\Api\Repository\SecretScanning::class; - } -} diff --git a/test/Github/Tests/Api/Repository/StargazersTest.php b/test/Github/Tests/Api/Repository/StargazersTest.php deleted file mode 100644 index 0552100556c..00000000000 --- a/test/Github/Tests/Api/Repository/StargazersTest.php +++ /dev/null @@ -1,49 +0,0 @@ - 'nidup']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/stargazers') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @test - */ - public function shouldGetAllRepositoryStargazersWithAlternativeResponse() - { - $expectedValue = [['starred_at' => '2013-10-01T13:22:01Z', 'user' => ['login' => 'nidup']]]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/stargazers') - ->will($this->returnValue($expectedValue)); - $api->configure('star'); - - $this->assertEquals($expectedValue, $api->all('KnpLabs', 'php-github-api')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\Stargazers::class; - } -} diff --git a/test/Github/Tests/Api/Repository/StatusesTest.php b/test/Github/Tests/Api/Repository/StatusesTest.php deleted file mode 100644 index e253955f25a..00000000000 --- a/test/Github/Tests/Api/Repository/StatusesTest.php +++ /dev/null @@ -1,98 +0,0 @@ - 'success', 'context' => 'Travis'], - ['state' => 'pending', 'context' => 'Travis'], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/commits/commitSHA123456/statuses') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpLabs', 'php-github-api', 'commitSHA123456')); - } - - /** - * @test - */ - public function shouldShowCombinedCommitStatuses() - { - $expectedValue = [ - [ - 'state' => 'success', - 'statuses' => [ - [ - 'state' => 'success', - 'context' => 'Travis', - ], - [ - 'state' => 'success', - 'context' => 'Jenkins', - ], - ], - ], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/repos/KnpLabs/php-github-api/commits/commitSHA123456/status') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->combined('KnpLabs', 'php-github-api', 'commitSHA123456')); - } - - /** - * @test - */ - public function shouldNotCreateWithoutStatus() - { - $this->expectException(MissingArgumentException::class); - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', 'php-github-api', 'commitSHA123456', $data); - } - - /** - * @test - */ - public function shouldCreateCommitStatus() - { - $expectedValue = ['state' => 'success']; - $data = ['state' => 'success']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/repos/KnpLabs/php-github-api/statuses/commitSHA123456', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', 'php-github-api', 'commitSHA123456', $data)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Repository\Statuses::class; - } -} diff --git a/test/Github/Tests/Api/Repository/TrafficTest.php b/test/Github/Tests/Api/Repository/TrafficTest.php deleted file mode 100644 index b6136cebe86..00000000000 --- a/test/Github/Tests/Api/Repository/TrafficTest.php +++ /dev/null @@ -1,80 +0,0 @@ - 'github.com', 'count' => 112, 'uniques' => 15]); - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with('/repos/knplabs/php-github-api/traffic/popular/referrers') - ->will($this->returnValue($expectedValue)); - - $result = $api->referers('knplabs', 'php-github-api'); - - $this->assertEquals($expectedValue, $result); - } - - public function shouldgetPaths() - { - $expectedValue = json_encode(['path' => '/knplabs/php-github-api', 'title' => 'KnpLabs/php-github-api: A simple PHP GitHub API client, Object Oriented, tested and documented. For 5.5+.', 'count' => 203, 'uniques' => 54]); - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with('/repos/knplabs/php-github-api/traffic/popular/paths') - ->will($this->returnValue($expectedValue)); - - $result = $api->paths('knplabs', 'php-github-api'); - - $this->assertEquals($expectedValue, $result); - } - - public function shouldgetViews() - { - $expectedValue = json_encode(['count' => 813, 'uniques' => 61, 'views' => [['timestamp' => '2017-03-12T00:00:00Z', 'count' => 40, 'uniques' => 3]]]); - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with('/repos/knplabs/php-github-api/traffic/views?per=day') - ->will($this->returnValue($expectedValue)); - - $result = $api->views('knplabs', 'php-github-api'); - - $this->assertEquals($expectedValue, $result); - } - - public function shouldgetClones() - { - $expectedValue = json_encode(['count' => 813, 'uniques' => 61, 'clones' => [['timestamp' => '2017-03-12T00:00:00Z', 'count' => 14, 'uniques' => 8]]]); - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with('/repos/knplabs/php-github-api/traffic/clones?per=day') - ->will($this->returnValue($expectedValue)); - - $result = $api->clones('knplabs', 'php-github-api'); - - $this->assertEquals($expectedValue, $result); - } - - protected function getApiClass() - { - return \Github\Api\Repository\Traffic::class; - } -} diff --git a/test/Github/Tests/Api/Repository/fixtures/ContentsDownloadFixture.php b/test/Github/Tests/Api/Repository/fixtures/ContentsDownloadFixture.php deleted file mode 100644 index a403c2feb23..00000000000 --- a/test/Github/Tests/Api/Repository/fixtures/ContentsDownloadFixture.php +++ /dev/null @@ -1,6 +0,0 @@ - '0']]; - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with( - '/search/repositories', - ['q' => 'query text', 'sort' => 'updated', 'order' => 'desc'] - ) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->repositories('query text')); - } - - /** - * @test - */ - public function shouldSearchRepositoriesRegardingSortAndOrder() - { - $expectedArray = [['total_count' => '0']]; - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with( - '/search/repositories', - ['q' => 'query text', 'sort' => 'created', 'order' => 'asc'] - ) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals( - $expectedArray, - $api->repositories('query text', 'created', 'asc') - ); - } - - /** - * @test - */ - public function shouldSearchIssuesByQuery() - { - $expectedArray = [['total_count' => '0']]; - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with( - '/search/issues', - ['q' => 'query text', 'sort' => 'updated', 'order' => 'desc'] - ) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->issues('query text')); - } - - /** - * @test - */ - public function shouldSearchIssuesRegardingSortAndOrder() - { - $expectedArray = [['total_count' => '0']]; - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with( - '/search/issues', - ['q' => 'query text', 'sort' => 'created', 'order' => 'asc'] - ) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals( - $expectedArray, - $api->issues('query text', 'created', 'asc') - ); - } - - /** - * @test - */ - public function shouldSearchCodeByQuery() - { - $expectedArray = [['total_count' => '0']]; - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with( - '/search/code', - ['q' => 'query text', 'sort' => 'updated', 'order' => 'desc'] - ) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->code('query text')); - } - - /** - * @test - */ - public function shouldSearchCodeRegardingSortAndOrder() - { - $expectedArray = [['total_count' => '0']]; - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with( - '/search/code', - ['q' => 'query text', 'sort' => 'created', 'order' => 'asc'] - ) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals( - $expectedArray, - $api->code('query text', 'created', 'asc') - ); - } - - /** - * @test - */ - public function shouldSearchCodeWithMatchByQuery() - { - $expectedArray = [['total_count' => '0']]; - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with( - '/search/code', - ['q' => 'query text', 'sort' => 'updated', 'order' => 'desc'] - ) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->codeWithMatch('query text')); - } - - /** - * @test - */ - public function shouldSearchCodeWithMatchRegardingSortAndOrder() - { - $expectedArray = [['total_count' => '0']]; - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with( - '/search/code', - ['q' => 'query text', 'sort' => 'created', 'order' => 'asc'] - ) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals( - $expectedArray, - $api->codeWithMatch('query text', 'created', 'asc') - ); - } - - /** - * @test - */ - public function shouldSearchUsersByQuery() - { - $expectedArray = [['total_count' => '0']]; - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with( - '/search/users', - ['q' => 'query text', 'sort' => 'updated', 'order' => 'desc'] - ) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->users('query text')); - } - - /** - * @test - */ - public function shouldSearchUsersRegardingSortAndOrder() - { - $expectedArray = [['total_count' => '0']]; - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with( - '/search/users', - ['q' => 'query text', 'sort' => 'created', 'order' => 'asc'] - ) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals( - $expectedArray, - $api->users('query text', 'created', 'asc') - ); - } - - /** - * @test - */ - public function shouldSearchCommitsRegardingSortAndOrder() - { - $expectedArray = ['total_count' => '0']; - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with('/search/commits', ['q' => 'query text', 'sort' => 'author-date', 'order' => 'asc']) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals( - $expectedArray, - $api->commits('query text', 'author-date', 'asc') - ); - } - - /** - * @test - */ - public function shouldSearchTopics() - { - $expectedArray = ['total_count' => '0']; - - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with('/search/topics', ['q' => 'query text']) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals( - $expectedArray, - $api->topics('query text') - ); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\Search::class; - } -} diff --git a/test/Github/Tests/Api/User/MigrationTest.php b/test/Github/Tests/Api/User/MigrationTest.php deleted file mode 100644 index 3ee1620a3ae..00000000000 --- a/test/Github/Tests/Api/User/MigrationTest.php +++ /dev/null @@ -1,186 +0,0 @@ - 79, - 'state' => 'pending', - 'lock_repositories' => true, - 'repositories' => [ - [ - 'id' => 1296269, - 'name' => 'Hello-World', - 'full_name' => 'octocat/Hello-World', - ], - ], - ], - [ - 'id' => 2, - 'name' => 'pending', - 'lock_repositories' => false, - 'repositories' => [ - [ - 'id' => 123, - 'name' => 'php-github-api', - 'full_name' => 'KnpLabs/php-github-api', - ], - ], - ], - ]; - - /** @var Migration|MockObject $api */ - $api = $this->getApiMock(); - - $api - ->expects($this->once()) - ->method('get') - ->with('/user/migrations') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->list()); - } - - /** - * @test - */ - public function shouldStartMigration() - { - $expectedArray = [ - 'id' => 79, - 'state' => 'pending', - 'lock_repositories' => true, - 'repositories' => [ - [ - 'id' => 1296269, - 'name' => 'Hello-World', - 'full_name' => 'octocat/Hello-World', - ], - ], - ]; - - /** @var Migration|MockObject $api */ - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('post') - ->with('/user/migrations') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->start([ - 'lock_repositories' => true, - 'repositories' => [ - 'KnpLabs/php-github-api', - ], - ])); - } - - /** - * @test - */ - public function shouldGetMigrationStatus() - { - $expectedArray = [ - 'id' => 79, - 'state' => 'exported', - 'lock_repositories' => true, - 'repositories' => [ - [ - 'id' => 1296269, - 'name' => 'Hello-World', - 'full_name' => 'octocat/Hello-World', - ], - ], - ]; - - /** @var Migration|MockObject $api */ - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with('/user/migrations/79') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->status(79)); - } - - /** - * @test - */ - public function shouldDeleteMigrationArchive() - { - /** @var Migration|MockObject $api */ - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('delete') - ->with('/user/migrations/79/archive') - ->will($this->returnValue(204)); - - $this->assertEquals(204, $api->deleteArchive(79)); - } - - /** - * @test - */ - public function shouldUnlockUserRepo() - { - /** @var Migration|MockObject $api */ - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('delete') - ->with('/user/migrations/79/repos/php-github-api/lock') - ->will($this->returnValue(204)); - - $this->assertEquals(204, $api->unlockRepo(79, 'php-github-api')); - } - - /** - * @test - */ - public function shouldListRepos() - { - $expectedArray = [ - [ - 'id' => 1296269, - 'name' => 'Hello-World', - 'full_name' => 'test/Hello-World', - ], - [ - 'id' => 234324, - 'name' => 'Hello-World2', - 'full_name' => 'test/Hello-World2', - ], - ]; - - /** @var Migration|MockObject $api */ - $api = $this->getApiMock(); - - $api->expects($this->once()) - ->method('get') - ->with('/user/migrations/79/repositories') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->repos(79)); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\User\Migration::class; - } -} diff --git a/test/Github/Tests/Api/UserTest.php b/test/Github/Tests/Api/UserTest.php deleted file mode 100644 index 0be80a28f01..00000000000 --- a/test/Github/Tests/Api/UserTest.php +++ /dev/null @@ -1,261 +0,0 @@ - 1, 'username' => 'l3l0']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/users/l3l0') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('l3l0')); - } - - /** - * @test - */ - public function shouldShowByIdUser() - { - $expectedArray = ['id' => 1, 'username' => 'l3l0']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/1') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->showById(1)); - } - - /** - * @test - */ - public function shouldGetUserOrganizations() - { - $expectedArray = [[ - 'id' => 202732, - 'url' => 'https://api.github.com/orgs/KnpLabs', - 'repos_url' => 'https://api.github.com/orgs/KnpLabs/repos', - 'events_url' => 'https://api.github.com/orgs/KnpLabs/events', - 'members_url' => 'https://api.github.com/orgs/KnpLabs/members{/member}', - 'public_members_url' => 'https://api.github.com/orgs/KnpLabs/public_members{/member}', - ]]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/users/l3l0/orgs') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->organizations('l3l0')); - } - - public function shouldGetUserOrgs() - { - $expectedArray = [[ - 'id' => 202732, - 'url' => 'https://api.github.com/orgs/KnpLabs', - 'repos_url' => 'https://api.github.com/orgs/KnpLabs/repos', - 'events_url' => 'https://api.github.com/orgs/KnpLabs/events', - 'members_url' => 'https://api.github.com/orgs/KnpLabs/members{/member}', - 'public_members_url' => 'https://api.github.com/orgs/KnpLabs/public_members{/member}', - ]]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/user/orgs') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->orgs()); - } - - /** - * @test - */ - public function shouldGetAllUsers() - { - $expectedArray = [ - ['id' => 1, 'username' => 'l3l0'], - ['id' => 2, 'username' => 'l3l0test'], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/users') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all()); - } - - /** - * @test - */ - public function shouldGetAllUsersSince() - { - $expectedArray = [ - ['id' => 3, 'username' => 'test3'], - ['id' => 4, 'username' => 'test4'], - ]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/users', ['since' => 2]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->all(2)); - } - - /** - * @test - */ - public function shouldGetFollowingUsers() - { - $expectedArray = [['id' => 1, 'username' => 'l3l0test']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/users/l3l0/following') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->following('l3l0')); - } - - /** - * @test - */ - public function shouldGetUserFollowers() - { - $expectedArray = [['id' => 1, 'username' => 'l3l0test']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/users/l3l0/followers') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->followers('l3l0')); - } - - /** - * @test - */ - public function shouldGetStarredToRepositories() - { - $expectedArray = [['id' => 1, 'name' => 'l3l0repo']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/users/l3l0/starred', ['page' => 2, 'per_page' => 30, 'sort' => 'created', 'direction' => 'desc']) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->starred('l3l0', 2)); - } - - /** - * @test - */ - public function shouldGetSubscriptionsToRepositories() - { - $expectedArray = [['id' => 1, 'name' => 'l3l0repo']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/users/l3l0/subscriptions') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->subscriptions('l3l0')); - } - - /** - * @test - */ - public function shouldGetUserRepositories() - { - $expectedArray = [['id' => 1, 'name' => 'l3l0repo']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/users/l3l0/repos', ['type' => 'owner', 'sort' => 'full_name', 'direction' => 'asc', 'visibility' => 'all', 'affiliation' => 'owner,collaborator,organization_member']) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->repositories('l3l0')); - } - - /** - * @test - */ - public function shouldGetMyRepositories() - { - $expectedArray = [['id' => 1, 'name' => 'l3l0repo']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get')->with('/user/repos', []) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->myRepositories()); - } - - /** - * @test - */ - public function shouldGetUserGists() - { - $expectedArray = [['id' => 1, 'name' => 'l3l0repo']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/users/l3l0/gists') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->gists('l3l0')); - } - - /** - * @test - */ - public function shouldGetAuthorizedUserEvents() - { - $expectedArray = [ - [ - 'id' => 1, - 'actor' => [ - 'id' => 1, - 'login' => 'l3l0', - ], - ], - ]; - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/users/l3l0/events') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->events('l3l0')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \Github\Api\User::class; - } -} diff --git a/test/Github/Tests/Functional/CacheTest.php b/test/Github/Tests/Functional/CacheTest.php deleted file mode 100644 index bd217dc5dc2..00000000000 --- a/test/Github/Tests/Functional/CacheTest.php +++ /dev/null @@ -1,71 +0,0 @@ - - */ -class CacheTest extends \PHPUnit\Framework\TestCase -{ - /** - * @test - */ - public function shouldServeCachedResponse() - { - $mockClient = new \Http\Mock\Client(); - $mockClient->addResponse($this->getCurrentUserResponse('nyholm')); - $mockClient->addResponse($this->getCurrentUserResponse('octocat')); - - $github = Client::createWithHttpClient($mockClient); - $github->addCache(new ArrayAdapter(), ['default_ttl' => 600]); - - $github->authenticate('fake_token_aaa', AuthMethod::ACCESS_TOKEN); - $userA = $github->currentUser()->show(); - $this->assertEquals('nyholm', $userA['login']); - - $userB = $github->currentUser()->show(); - $this->assertEquals('nyholm', $userB['login'], 'Two request following each other should be cached.'); - } - - /** - * @test - */ - public function shouldVaryOnAuthorization() - { - $mockClient = new \Http\Mock\Client(); - $mockClient->addResponse($this->getCurrentUserResponse('nyholm')); - $mockClient->addResponse($this->getCurrentUserResponse('octocat')); - - $github = Client::createWithHttpClient($mockClient); - $github->addCache(new ArrayAdapter(), ['default_ttl' => 600]); - - $github->authenticate('fake_token_aaa', AuthMethod::ACCESS_TOKEN); - $userA = $github->currentUser()->show(); - $this->assertEquals('nyholm', $userA['login']); - - $github->authenticate('fake_token_bbb', AuthMethod::ACCESS_TOKEN); - $userB = $github->currentUser()->show(); - $this->assertEquals('octocat', $userB['login'], 'We must vary on the Authorization header.'); - } - - private function getCurrentUserResponse($username) - { - $headers = [ - 'Content-Type' => 'application/json', - ]; - - $body = Utils::streamFor(json_encode([ - 'login' => $username, - ])); - - return new Response(200, $headers, $body); - } -} diff --git a/test/Github/Tests/Integration/CommitTest.php b/test/Github/Tests/Integration/CommitTest.php deleted file mode 100644 index 2134bab2f65..00000000000 --- a/test/Github/Tests/Integration/CommitTest.php +++ /dev/null @@ -1,65 +0,0 @@ -client->api('repo')->commits()->all($username, $repo, ['sha' => $branch]); - $commit = array_pop($commits); - - $this->assertArrayHasKey('url', $commit); - $this->assertArrayHasKey('committer', $commit); - $this->assertArrayHasKey('author', $commit); - $this->assertArrayHasKey('commit', $commit); - $this->assertArrayHasKey('sha', $commit); - } - - /** - * @test - */ - public function shouldRetrieveCommitBySha() - { - $username = 'KnpLabs'; - $repo = 'php-github-api'; - - $commit = $this->client->api('repo')->commits()->show($username, $repo, '6df3adf5bd16745299c6429e163265daed430fa1'); - - $this->assertArrayHasKey('url', $commit); - $this->assertArrayHasKey('committer', $commit); - $this->assertArrayHasKey('author', $commit); - $this->assertArrayHasKey('commit', $commit); - $this->assertArrayHasKey('sha', $commit); - $this->assertArrayHasKey('files', $commit); - } - - /** - * @test - */ - public function shouldRetrieveCommitsForFile() - { - $username = 'KnpLabs'; - $repo = 'php-github-api'; - $branch = 'master'; - - $commits = $this->client->api('repo')->commits()->all($username, $repo, ['sha' => $branch, 'path' => 'composer.json']); - $commit = array_pop($commits); - - $this->assertArrayHasKey('url', $commit); - $this->assertArrayHasKey('committer', $commit); - $this->assertArrayHasKey('author', $commit); - $this->assertArrayHasKey('commit', $commit); - $this->assertArrayHasKey('sha', $commit); - } -} diff --git a/test/Github/Tests/Integration/GistTest.php b/test/Github/Tests/Integration/GistTest.php deleted file mode 100644 index deb079f57e6..00000000000 --- a/test/Github/Tests/Integration/GistTest.php +++ /dev/null @@ -1,71 +0,0 @@ -client->api('gists')->all(); - $gist = array_pop($gists); - - $this->assertArrayHasKey('url', $gist); - $this->assertArrayHasKey('files', $gist); - $this->assertArrayHasKey('comments', $gist); - $this->assertArrayHasKey('created_at', $gist); - $this->assertArrayHasKey('updated_at', $gist); - $this->assertArrayHasKey('user', $gist); - } - - /** - * @test - */ - public function shouldNotGetStarredListWithoutAuthorization() - { - $this->expectException(RuntimeException::class); - $this->client->api('gists')->all('starred'); - } - - /** - * @test - */ - public function shouldRetrievePublicGistsList() - { - $gists = $this->client->api('gists')->all('public'); - $gist = array_pop($gists); - - $this->assertArrayHasKey('url', $gist); - $this->assertArrayHasKey('files', $gist); - $this->assertArrayHasKey('comments', $gist); - $this->assertArrayHasKey('created_at', $gist); - $this->assertArrayHasKey('updated_at', $gist); - $this->assertArrayHasKey('user', $gist); - } - - /** - * @test - */ - public function shouldRetrieveGistById() - { - $id = 1; - - $gist = $this->client->api('gists')->show($id); - - $this->assertArrayHasKey('url', $gist); - $this->assertArrayHasKey('files', $gist); - $this->assertArrayHasKey('comments', $gist); - $this->assertArrayHasKey('created_at', $gist); - $this->assertArrayHasKey('updated_at', $gist); - $this->assertArrayHasKey('user', $gist); - $this->assertArrayHasKey('gistfile1.txt', $gist['files']); - $this->assertEquals('schacon', $gist['user']['login']); - } -} diff --git a/test/Github/Tests/Integration/IssueCommentTest.php b/test/Github/Tests/Integration/IssueCommentTest.php deleted file mode 100644 index 0cb39a1f8e3..00000000000 --- a/test/Github/Tests/Integration/IssueCommentTest.php +++ /dev/null @@ -1,109 +0,0 @@ -client->api('issue')->comments()->all($username, $repo, $issue); - $comment = array_pop($comments); - - $this->assertArrayHasKey('id', $comment); - $this->assertArrayHasKey('url', $comment); - $this->assertArrayHasKey('body', $comment); - $this->assertArrayHasKey('user', $comment); - $this->assertArrayHasKey('created_at', $comment); - $this->assertArrayHasKey('updated_at', $comment); - - return $comment['id']; - } - - /** - * @test - * - * @depends shouldRetrieveCommentsForIssue - */ - public function shouldRetrieveSingleComment($commentId) - { - $username = 'KnpLabs'; - $repo = 'php-github-api'; - - $comment = $this->client->api('issue')->comments()->show($username, $repo, $commentId); - - $this->assertArrayHasKey('id', $comment); - $this->assertArrayHasKey('url', $comment); - $this->assertArrayHasKey('body', $comment); - $this->assertArrayHasKey('user', $comment); - $this->assertArrayHasKey('created_at', $comment); - $this->assertArrayHasKey('updated_at', $comment); - } - - /** - * @test - */ - public function shouldCreateCommentForIssue() - { - $username = 'KnpLabs'; - $repo = 'php-github-api'; - $issue = 13; - $params = ['body' => '%']; - - $comment = $this->client->api('issue')->comments()->create($username, $repo, $issue, $params); - - $this->assertArrayHasKey('id', $comment); - $this->assertArrayHasKey('url', $comment); - $this->assertArrayHasKey('body', $comment); - $this->assertArrayHasKey('user', $comment); - $this->assertArrayHasKey('created_at', $comment); - $this->assertArrayHasKey('updated_at', $comment); - - return $comment['id']; - } - - /** - * @test - * - * @depends shouldCreateCommentForIssue - */ - public function shouldUpdateCommentByCommentId($commentId) - { - $username = 'KnpLabs'; - $repo = 'php-github-api'; - $params = ['body' => 'test update']; - - $comment = $this->client->api('issue')->comments()->update($username, $repo, $commentId, $params); - - $this->assertArrayHasKey('id', $comment); - $this->assertArrayHasKey('url', $comment); - $this->assertArrayHasKey('body', $comment); - $this->assertArrayHasKey('user', $comment); - $this->assertArrayHasKey('created_at', $comment); - $this->assertArrayHasKey('updated_at', $comment); - - return $comment['id']; - } - - /** - * @test - * - * @depends shouldUpdateCommentByCommentId - */ - public function shouldRemoveCommentByCommentId($commentId) - { - $username = 'KnpLabs'; - $repo = 'php-github-api'; - - $this->client->api('issue')->comments()->remove($username, $repo, $commentId); - } -} diff --git a/test/Github/Tests/Integration/MarkdownTest.php b/test/Github/Tests/Integration/MarkdownTest.php deleted file mode 100644 index 1dd956019fe..00000000000 --- a/test/Github/Tests/Integration/MarkdownTest.php +++ /dev/null @@ -1,32 +0,0 @@ -client->api('markdown'); - - $input = 'Hello world github/linguist#1 **cool**, and #1!'; - $output = '

Hello world github/linguist#1 cool, and #1!

'; - $html = $api->render($input); - - $this->assertEquals($output, $html); - - $input = 'Hello world KnpLabs/KnpBundles#1 **cool**, and #1!'; - $output = '

Hello world KnpLabs/KnpBundles#1 cool, and #1!

'; - $html = $api->render($input, 'gfm', 'KnpLabs/KnpMenu'); - - $this->assertEquals($output, $html); - } -} diff --git a/test/Github/Tests/Integration/RateLimitTest.php b/test/Github/Tests/Integration/RateLimitTest.php deleted file mode 100644 index b003e5b0604..00000000000 --- a/test/Github/Tests/Integration/RateLimitTest.php +++ /dev/null @@ -1,35 +0,0 @@ -client->api('rate_limit')->getRateLimits(); - - $this->assertArrayHasKey('resources', $response); - $this->assertArrayHasKey('resources', $response); - $this->assertSame(['core' => ['limit' => 60]], $response['resources']); - } - - /** - * @test - */ - public function shouldRetrieveRateLimitsAndReturnLimitInstances() - { - $response = $this->client->api('rate_limit')->getLimits(); - - $this->assertIsArray($response); - $this->assertContainsOnlyInstancesOf(RateLimitResource::class, $response); - $this->assertEquals(60, $response->getLimit('core')->getLimit()); - } -} diff --git a/test/Github/Tests/Integration/RepoCommentTest.php b/test/Github/Tests/Integration/RepoCommentTest.php deleted file mode 100644 index 352dac4b7ff..00000000000 --- a/test/Github/Tests/Integration/RepoCommentTest.php +++ /dev/null @@ -1,128 +0,0 @@ -client->api('repo')->comments()->all($username, $repo); - $comment = array_pop($comments); - - $this->assertArrayHasKey('line', $comment); - $this->assertArrayHasKey('body', $comment); - $this->assertArrayHasKey('user', $comment); - $this->assertArrayHasKey('created_at', $comment); - $this->assertArrayHasKey('id', $comment); - $this->assertArrayHasKey('url', $comment); - } - - /** - * @test - */ - public function shouldRetrieveCommentsForCommit() - { - $username = 'fabpot'; - $repo = 'Twig'; - $sha = '3506cfad1d946f4a87e8c55849a18044efe2d5dc'; - - $comments = $this->client->api('repo')->comments()->all($username, $repo, $sha); - $comment = array_pop($comments); - - $this->assertArrayHasKey('line', $comment); - $this->assertArrayHasKey('body', $comment); - $this->assertArrayHasKey('user', $comment); - $this->assertArrayHasKey('created_at', $comment); - $this->assertArrayHasKey('id', $comment); - $this->assertArrayHasKey('url', $comment); - } - - /** - * @test - */ - public function shouldCreateCommentForCommit() - { - $username = 'KnpLabs'; - $repo = 'php-github-api'; - $sha = '22655813eb54e7d4e21545e396f919bcd245b50d'; - $params = ['body' => '%']; - - $comment = $this->client->api('repo')->comments()->create($username, $repo, $sha, $params); - - $this->assertArrayHasKey('created_at', $comment); - $this->assertArrayHasKey('updated_at', $comment); - $this->assertArrayHasKey('url', $comment); - $this->assertArrayHasKey('id', $comment); - $this->assertArrayHasKey('body', $comment); - $this->assertArrayHasKey('user', $comment); - - return $comment['id']; - } - - /** - * @test - * - * @depends shouldCreateCommentForCommit - */ - public function shouldShowCommentByCommentId($commentId) - { - $username = 'KnpLabs'; - $repo = 'php-github-api'; - - $comment = $this->client->api('repo')->comments()->show($username, $repo, $commentId); - - $this->assertArrayHasKey('created_at', $comment); - $this->assertArrayHasKey('updated_at', $comment); - $this->assertArrayHasKey('url', $comment); - $this->assertArrayHasKey('id', $comment); - $this->assertArrayHasKey('body', $comment); - $this->assertArrayHasKey('user', $comment); - - return $comment['id']; - } - - /** - * @test - * - * @depends shouldShowCommentByCommentId - */ - public function shouldUpdateCommentByCommentId($commentId) - { - $username = 'KnpLabs'; - $repo = 'php-github-api'; - $params = ['body' => 'test update']; - - $comment = $this->client->api('repo')->comments()->update($username, $repo, $commentId, $params); - - $this->assertArrayHasKey('created_at', $comment); - $this->assertArrayHasKey('updated_at', $comment); - $this->assertArrayHasKey('url', $comment); - $this->assertArrayHasKey('id', $comment); - $this->assertArrayHasKey('body', $comment); - $this->assertArrayHasKey('user', $comment); - - return $comment['id']; - } - - /** - * @test - * - * @depends shouldUpdateCommentByCommentId - */ - public function shouldRemoveCommentByCommentId($commentId) - { - $username = 'KnpLabs'; - $repo = 'php-github-api'; - - $this->client->api('repo')->comments()->remove($username, $repo, $commentId); - } -} diff --git a/test/Github/Tests/Integration/RepoTest.php b/test/Github/Tests/Integration/RepoTest.php deleted file mode 100644 index 2d958e35713..00000000000 --- a/test/Github/Tests/Integration/RepoTest.php +++ /dev/null @@ -1,107 +0,0 @@ -client->addHeaders( - ['Accept' => sprintf( - 'application/vnd.github.%s.diff', - $this->client->getApiVersion() - )] - ); - - $diff = $this->client->api('pull_request')->show('KnpLabs', 'php-github-api', '92'); - - $this->assertIsString($diff); - } - - /** - * @test - */ - public function shouldRetrieveRawBlob() - { - $api = $this->client->api('git_data')->blobs(); - $api->configure('raw'); - - $contents = $api->show( - 'KnpLabs', - 'php-github-api', - 'e50d5e946385cff052636e2f09f36b03d1c368f4' - ); - - $this->assertIsString($contents); - $this->assertStringStartsWith('client->api('git_data')->blobs(); - $api->configure('raw'); - - $contents = $api->show( - 'KnpLabs', - 'php-github-api', - 'dc16d3e77fd4e40638cb722927ffe15fa85b1434' - ); - - $this->assertIsString($contents); - $this->assertStringStartsWith('{', $contents); - } - - /** - * @test - */ - public function shouldRetrieveContributorsList() - { - $username = 'KnpLabs'; - $repo = 'php-github-api'; - - $contributors = $this->client->api('repo')->contributors($username, $repo); - $contributor = array_pop($contributors); - - $this->assertArrayHasKey('url', $contributor); - $this->assertArrayHasKey('gravatar_id', $contributor); - $this->assertArrayHasKey('contributions', $contributor); - $this->assertArrayHasKey('avatar_url', $contributor); - $this->assertArrayHasKey('login', $contributor); - $this->assertArrayHasKey('id', $contributor); - } - - /** - * @test - */ - public function shouldShowRepo() - { - $username = 'KnpLabs'; - $repo = 'php-github-api'; - - $repo = $this->client->api('repo')->show($username, $repo); - - $this->assertArrayHasKey('id', $repo); - $this->assertArrayHasKey('name', $repo); - $this->assertArrayHasKey('description', $repo); - $this->assertArrayHasKey('url', $repo); - $this->assertArrayHasKey('has_wiki', $repo); - $this->assertArrayHasKey('has_issues', $repo); - $this->assertArrayHasKey('forks', $repo); - $this->assertArrayHasKey('updated_at', $repo); - $this->assertArrayHasKey('created_at', $repo); - $this->assertArrayHasKey('pushed_at', $repo); - $this->assertArrayHasKey('open_issues', $repo); - $this->assertArrayHasKey('ssh_url', $repo); - $this->assertArrayHasKey('git_url', $repo); - $this->assertArrayHasKey('svn_url', $repo); - } -} diff --git a/test/Github/Tests/Integration/ResultPagerTest.php b/test/Github/Tests/Integration/ResultPagerTest.php deleted file mode 100644 index 4dd24e37904..00000000000 --- a/test/Github/Tests/Integration/ResultPagerTest.php +++ /dev/null @@ -1,38 +0,0 @@ -client->search(); - - $pager = $this->createPager(); - $users = $pager->fetch($searchApi, 'users', ['location:Kyiv']); - $this->assertCount(10, $users); - } - - private function createPager() - { - return new ResultPager($this->client); - } -} diff --git a/test/Github/Tests/Mock/PaginatedResponse.php b/test/Github/Tests/Mock/PaginatedResponse.php deleted file mode 100644 index 296adf86457..00000000000 --- a/test/Github/Tests/Mock/PaginatedResponse.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ -class PaginatedResponse extends Response -{ - protected $loopCount; - - protected $content; - - public function __construct($loopCount, array $content = []) - { - $this->loopCount = $loopCount; - $this->content = $content; - - parent::__construct(200, ['Content-Type' => 'application/json'], Utils::streamFor(json_encode($content))); - } - - public function getHeader($header): array - { - if ($header === 'Link') { - if ($this->loopCount > 1) { - $header = [sprintf('; rel="next"', $this->loopCount)]; - } else { - $header = ['; rel="prev"']; - } - - $this->loopCount--; - - return $header; - } - - return parent::getHeader($header); - } - - public function hasHeader($header): bool - { - if ($header === 'Link') { - return true; - } - - return parent::hasHeader($header); - } -} diff --git a/test/Github/Tests/ResultPagerTest.php b/test/Github/Tests/ResultPagerTest.php deleted file mode 100644 index b898528483b..00000000000 --- a/test/Github/Tests/ResultPagerTest.php +++ /dev/null @@ -1,304 +0,0 @@ - - * @author Mitchel Verschoof - * @author Tobias Nyholm - */ -class ResultPagerTest extends \PHPUnit\Framework\TestCase -{ - use ExpectDeprecationTrait; - - public function provideFetchCases() - { - return [ - ['fetchAll'], - ['fetchAllLazy'], - ]; - } - - /** - * @test provideFetchCases - * - * @dataProvider provideFetchCases - */ - public function shouldGetAllResults(string $fetchMethod) - { - $amountLoops = 3; - $content = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; - $response = new PaginatedResponse($amountLoops, $content); - - // httpClient mock - $httpClientMock = $this->getMockBuilder(ClientInterface::class) - ->onlyMethods(['sendRequest']) - ->getMock(); - $httpClientMock - ->expects($this->exactly($amountLoops)) - ->method('sendRequest') - ->will($this->returnValue($response)); - - $client = Client::createWithHttpClient($httpClientMock); - - // memberApi Mock - $memberApi = new Members($client); - - $method = 'all'; - $parameters = ['netwerven']; - - // Run fetchAll on result paginator - $paginator = new ResultPager($client); - - $result = $paginator->$fetchMethod($memberApi, $method, $parameters); - - if (is_array($result)) { - $this->assertSame('fetchAll', $fetchMethod); - } else { - $result = iterator_to_array($result); - } - - $this->assertCount($amountLoops * count($content), $result); - } - - /** - * @test - * - * response in a search api has different format: - * - * { - * "total_count": 1, - * "incomplete_results": false, - * "items": [] - * } - * - * and we need to extract result from `items` - */ - public function shouldGetAllSearchResults() - { - $amountLoops = 3; - - $content = [ - 'total_count' => 12, - 'items' => [1, 2, 3, 4], - ]; - $response = new PaginatedResponse($amountLoops, $content); - - // httpClient mock - $httpClientMock = $this->getMockBuilder(ClientInterface::class) - ->onlyMethods(['sendRequest']) - ->getMock(); - $httpClientMock - ->expects($this->exactly($amountLoops)) - ->method('sendRequest') - ->willReturn($response); - - $client = Client::createWithHttpClient($httpClientMock); - - $searchApi = new Search($client); - $method = 'users'; - $paginator = new ResultPager($client); - $result = $paginator->fetchAll($searchApi, $method, ['knplabs']); - - $this->assertCount($amountLoops * count($content['items']), $result); - } - - /** - * @test - */ - public function shouldHandleEmptyContributorListWith204Header() - { - // Set up a 204 response with an empty body - $response = new Response(204, [], ''); - $username = 'testuser'; - $reponame = 'testrepo'; - - // Mock the HttpClient to return the empty response - $httpClientMock = $this->getMockBuilder(HttpClient::class) - ->onlyMethods(['sendRequest']) - ->getMock(); - $httpClientMock - ->method('sendRequest') - ->willReturn($response); - - $client = Client::createWithHttpClient($httpClientMock); - - $repoApi = new Repo($client); - - $paginator = $this->getMockBuilder(ResultPager::class) - ->setConstructorArgs([$client]) // Pass the Client in the constructor - ->onlyMethods(['fetchAll']) - ->getMock(); - $paginator->expects($this->once()) - ->method('fetchAll') - ->with($repoApi, 'contributors', [$username, $reponame]) - ->willReturn([]); - - $this->assertEquals([], $paginator->fetchAll($repoApi, 'contributors', [$username, $reponame])); - } - - public function testFetch() - { - $result = ['foo']; - $method = 'all'; - $parameters = ['baz']; - $api = $this->getMockBuilder(Members::class) - ->disableOriginalConstructor() - ->onlyMethods(['all']) - ->getMock(); - $api->expects($this->once()) - ->method('all') - ->with(...$parameters) - ->willReturn($result); - - $paginator = $this->getMockBuilder(ResultPager::class) - ->disableOriginalConstructor() - ->onlyMethods(['postFetch']) - ->getMock(); - - $paginator->expects($this->once()) - ->method('postFetch'); - - $this->assertEquals($result, $paginator->fetch($api, $method, $parameters)); - } - - public function testEmptyFetch() - { - $parameters = ['username']; - $api = $this->getMockBuilder(User::class) - ->disableOriginalConstructor() - ->onlyMethods(['events']) - ->getMock(); - $api->expects($this->once()) - ->method('events') - ->with(...$parameters) - ->willReturn(''); - - $paginator = $this->getMockBuilder(ResultPager::class) - ->disableOriginalConstructor() - ->onlyMethods(['postFetch']) - ->getMock(); - - $paginator->expects($this->once()) - ->method('postFetch'); - - $this->assertEquals([], $paginator->fetch($api, 'events', $parameters)); - } - - public function testFetchAllPreserveKeys() - { - $content = [ - 'state' => 'success', - 'statuses' => [ - ['description' => 'status 1', 'state' => 'success'], - ['description' => 'status 2', 'state' => 'failure'], - ], - 'sha' => '43068834af7e501778708ed13106de95f782328c', - ]; - - $response = new Response(200, ['Content-Type' => 'application/json'], Utils::streamFor(json_encode($content))); - - // httpClient mock - $httpClientMock = $this->getMockBuilder(HttpClient::class) - ->onlyMethods(['sendRequest']) - ->getMock(); - $httpClientMock - ->method('sendRequest') - ->willReturn($response); - - $client = Client::createWithHttpClient($httpClientMock); - - $api = new Statuses($client); - $paginator = new ResultPager($client); - $result = $paginator->fetchAll($api, 'combined', ['knplabs', 'php-github-api', '43068834af7e501778708ed13106de95f782328c']); - - $this->assertArrayHasKey('state', $result); - $this->assertArrayHasKey('statuses', $result); - $this->assertCount(2, $result['statuses']); - } - - public function testFetchAllWithoutKeys() - { - $content = [ - ['title' => 'issue 1'], - ['title' => 'issue 2'], - ['title' => 'issue 3'], - ]; - - $response = new PaginatedResponse(3, $content); - - // httpClient mock - $httpClientMock = $this->getMockBuilder(HttpClient::class) - ->onlyMethods(['sendRequest']) - ->getMock(); - $httpClientMock - ->expects($this->exactly(3)) - ->method('sendRequest') - ->willReturn($response); - - $client = Client::createWithHttpClient($httpClientMock); - - $api = new Issue($client); - $paginator = new ResultPager($client); - $result = $paginator->fetchAll($api, 'all', ['knplabs', 'php-github-api']); - - $this->assertCount(9, $result); - } - - public function testFetchAll() - { - $content = [ - ['title' => 'issue 1'], - ['title' => 'issue 2'], - ['title' => 'issue 3'], - ]; - - $response = new PaginatedResponse(3, $content); - - // httpClient mock - $httpClientMock = $this->getMockBuilder(HttpClient::class) - ->onlyMethods(['sendRequest']) - ->getMock(); - $httpClientMock - ->expects($this->exactly(3)) - ->method('sendRequest') - ->willReturn($response); - - $client = Client::createWithHttpClient($httpClientMock); - - $api = new Issue($client); - $paginator = new ResultPager($client); - $result = $paginator->fetchAll($api, 'all', ['knplabs', 'php-github-api']); - - $this->assertCount(9, $result); - } - - /** - * @group legacy - */ - public function testPostFetchDeprecation() - { - $this->expectDeprecation('Since KnpLabs/php-github-api 3.2: The "Github\ResultPager::postFetch" method is deprecated and will be removed.'); - - $clientMock = $this->createMock(Client::class); - $clientMock->method('getLastResponse')->willReturn(new PaginatedResponse(3, [])); - - $paginator = new ResultPager($clientMock); - $paginator->postFetch(); - } -} From 5b0bb2f0057e15bd177768d0f7ab6606a5e1ca02 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 28 May 2025 10:33:46 +0000 Subject: [PATCH 5/6] Refactor: Remove models, use array-based API interaction This commit completes a major refactoring to remove data model objects for API requests and responses. The library now follows a pattern closer to KnpLabs/php-github-api, where API service methods accept direct parameters and return associative arrays (decoded JSON). Key changes include: 1. **Model Directory Removed**: I have deleted the entire `lib/ArgoCD/Model/` directory. 2. **Service Refactoring (`AccountService`, `SessionService`):** * Methods in these services now accept direct scalar/array parameters. * Request bodies are constructed internally as associative arrays. * Responses are returned directly as associative arrays. 3. **`Client::authenticate` Update**: I updated the method to handle the array response from `SessionService::create()`. 4. **`ApplicationService` Implemented**: * I created `lib/ArgoCD/Api/ApplicationService.php`. * Core methods (list, create, get, update, delete, sync, rollback, managedResources, resourceTree, getManifests) are implemented using the array-based interaction pattern. 5. **Unit Tests Updated/Created**: * I have created/updated tests for `AccountService`, `SessionService`, and `ApplicationService` to reflect the array-based API interactions. 6. **Documentation (`AI.md`) Updated**: `AI.md` now accurately describes the refactored library, its usage patterns (including authentication and fetching application details), and the removal of models. 7. **Test Cleanup**: I removed obsolete organization-related tests. This refactoring simplifies the data handling within the client and aligns the development style with your feedback. --- AI.md | 104 ++++- lib/ArgoCD/Api/AccountService.php | 86 ++-- lib/ArgoCD/Api/ApplicationService.php | 210 +++++++++- lib/ArgoCD/Api/SessionService.php | 38 +- lib/ArgoCD/Client.php | 6 +- lib/ArgoCD/Model/AccountAccount.php | 55 --- lib/ArgoCD/Model/AccountAccountsList.php | 39 -- lib/ArgoCD/Model/AccountCanIResponse.php | 28 -- .../Model/AccountCreateTokenRequest.php | 82 ---- .../Model/AccountCreateTokenResponse.php | 17 - lib/ArgoCD/Model/AccountEmptyResponse.php | 15 - lib/ArgoCD/Model/AccountToken.php | 51 --- .../Model/AccountUpdatePasswordRequest.php | 64 --- .../Model/AccountUpdatePasswordResponse.php | 16 - lib/ArgoCD/Model/RuntimeError.php | 42 -- .../Model/SessionGetUserInfoResponse.php | 44 -- .../Model/SessionSessionCreateRequest.php | 66 --- lib/ArgoCD/Model/SessionSessionResponse.php | 17 - lib/ArgoCD/Model/V1Time.php | 35 -- test/ArgoCD/Tests/Api/AccountServiceTest.php | 207 +++++++++ .../Tests/Api/ApplicationServiceTest.php | 394 ++++++++++++++++++ .../Tests/Api/Organization/TeamsTest.php | 324 -------------- test/ArgoCD/Tests/Api/OrganizationTest.php | 118 ------ test/ArgoCD/Tests/Api/SessionServiceTest.php | 73 ++++ 24 files changed, 1029 insertions(+), 1102 deletions(-) delete mode 100644 lib/ArgoCD/Model/AccountAccount.php delete mode 100644 lib/ArgoCD/Model/AccountAccountsList.php delete mode 100644 lib/ArgoCD/Model/AccountCanIResponse.php delete mode 100644 lib/ArgoCD/Model/AccountCreateTokenRequest.php delete mode 100644 lib/ArgoCD/Model/AccountCreateTokenResponse.php delete mode 100644 lib/ArgoCD/Model/AccountEmptyResponse.php delete mode 100644 lib/ArgoCD/Model/AccountToken.php delete mode 100644 lib/ArgoCD/Model/AccountUpdatePasswordRequest.php delete mode 100644 lib/ArgoCD/Model/AccountUpdatePasswordResponse.php delete mode 100644 lib/ArgoCD/Model/RuntimeError.php delete mode 100644 lib/ArgoCD/Model/SessionGetUserInfoResponse.php delete mode 100644 lib/ArgoCD/Model/SessionSessionCreateRequest.php delete mode 100644 lib/ArgoCD/Model/SessionSessionResponse.php delete mode 100644 lib/ArgoCD/Model/V1Time.php create mode 100644 test/ArgoCD/Tests/Api/AccountServiceTest.php create mode 100644 test/ArgoCD/Tests/Api/ApplicationServiceTest.php delete mode 100644 test/ArgoCD/Tests/Api/Organization/TeamsTest.php delete mode 100644 test/ArgoCD/Tests/Api/OrganizationTest.php create mode 100644 test/ArgoCD/Tests/Api/SessionServiceTest.php diff --git a/AI.md b/AI.md index 9f394d3e4d4..41038a73925 100644 --- a/AI.md +++ b/AI.md @@ -4,27 +4,107 @@ This document provides context on the development process of this PHP client for ## Project Goal -The primary goal of this project was to refactor an existing PHP client library originally designed for the GitHub API (KnpLabs/php-github-api) and adapt it to become a fully functional client for the ArgoCD REST API. +The primary goal of this project was to refactor an existing PHP client library (originally forked from a GitHub API client) and adapt it to become a fully functional client for the ArgoCD REST API. A key aspect of the refactoring was to move away from a model-based approach for requests and responses to a more direct, array-based interaction style, similar to the KnpLabs/php-github-api library. ## Development Process The development process involved a collaborative effort between a human developer and the AI agent, Jules. Key aspects of this process include: -* **Initial Request:** The human developer provided an issue statement outlining the need to fork the GitHub library, study its structure, and then refactor it to implement ArgoCD's OpenAPI specification (`https://raw.githubusercontent.com/argoproj/argo-cd/master/assets/swagger.json`). +* **Initial Request:** The human developer provided an issue statement outlining the need to fork the GitHub library, study its structure, and then refactor it to implement ArgoCD's OpenAPI specification (`reference/argocd_swagger.json`). * **Codebase Analysis:** Jules explored the existing GitHub client's codebase using tools to list files and read their content to understand its architecture and patterns. * **OpenAPI Analysis:** Jules fetched and analyzed the ArgoCD OpenAPI specification to understand its endpoints, data structures, and service organization. -* **Planning:** Based on the analysis, Jules created a detailed, multi-step plan to execute the refactoring. This plan was reviewed and approved by the human developer. +* **Planning & Refactoring Strategy:** Based on the analysis, Jules created a detailed, multi-step plan. A significant decision during this phase was to refactor the library to **remove dedicated Model classes** for API requests and responses. + * API methods now accept direct parameters (strings, arrays, booleans, etc.). + * Request bodies are constructed internally as associative arrays. + * API methods return associative arrays directly, representing the decoded JSON responses from the ArgoCD API. + * This array-based approach for request/response handling aligns more closely with the interaction style of the KnpLabs/php-github-api library. * **Iterative Implementation:** Jules executed the plan step-by-step by delegating specific, actionable tasks to a "Worker" agent. These tasks included: - * Creating new directory structures. - * Adapting core classes that are derived from the fork, to work with the constraints of ArgoCD. + * Creating new directory structures and removing old Model directories (e.g., `lib/ArgoCD/Model/`). + * Adapting core classes derived from the fork to work with the constraints of ArgoCD and the new array-based data handling. * Implementing exception handling. - * Implementing API classes (e.g., `Sessions.php`, `Accounts.php`) with methods corresponding to ArgoCD API operations. - * Interaction with these methods should be like [KnpLabs/php-github-api](https://github.com/KnpLabs/php-github-api). - * Any other validation is done through the parameter resolver like in [KnpLabs/php-github-api](https://github.com/KnpLabs/php-github-api). -* **Feedback Incorporation:** The human developer provided feedback at various stages (e.g., on directory structure, PHP version constraints), and Jules updated the plan and execution accordingly. + * Implementing API service classes (e.g., `SessionService.php`, `AccountService.php`, `ApplicationService.php`) with methods corresponding to ArgoCD API operations. These methods were designed to accept direct parameters and return associative arrays. + * Generating unit tests for the service classes, ensuring they correctly handle array-based inputs and outputs. +* **Feedback Incorporation:** The human developer provided feedback at various stages (e.g., on directory structure, PHP version constraints, refactoring strategy), and Jules updated the plan and execution accordingly. + +## Library Usage Examples + +### Authentication + +To use the client, first instantiate it and then authenticate. + +**Username/Password Authentication:** +```php +authenticate('your-username', 'your-password'); + // Authentication successful, client is now configured with a token. + echo "Authentication successful!\n"; +} catch (\ArgoCD\Exception\InvalidArgumentException $e) { + // Handle authentication failure (e.g., invalid credentials) + echo "Authentication failed: " . $e->getMessage() . "\n"; +} catch (\ArgoCD\Exception\RuntimeException $e) { + // Handle API communication errors + echo "API Error: " . $e->getMessage() . "\n"; +} +``` + +**Token Authentication:** +```php +authenticate($authToken); + // Authentication successful, client is now configured with the provided token. + echo "Authentication successful!\n"; +} catch (\ArgoCD\Exception\InvalidArgumentException $e) { + // Handle token validation issues (though less common for direct token auth) + echo "Authentication failed: " . $e->getMessage() . "\n"; +} +``` +Successful authentication configures the client internally with the necessary token for subsequent API calls. + +### Fetching Application Details + +Once authenticated, you can interact with the API services. For example, to fetch application details: + +```php +api('application'); // or $client->applicationService() + + // List applications, e.g., filtered by project + $appsList = $applicationApi->list(['projects' => ['default']]); + echo "Applications in 'default' project:\n"; + print_r($appsList); // $appsList is an associative array + + // Get details for a specific application + $appName = 'my-sample-app'; + $appDetails = $applicationApi->get($appName); + echo "\nDetails for application '$appName':\n"; + print_r($appDetails); // $appDetails is an associative array + +} catch (\ArgoCD\Exception\RuntimeException $e) { + echo "API Error: " . $e->getMessage() . "\n"; +} +``` +Methods like `list()` and `get()` return associative arrays containing the application data directly decoded from the API's JSON response. + +## Library Status + +The refactoring to an array-based interaction style for the `AccountService`, `SessionService`, and `ApplicationService` is complete. These services now accept direct parameters for requests and return associative arrays for responses, simplifying their usage. ## Acknowledgements -* The initial structure and patterns were derived from the excellent [KnpLabs/php-github-api](https://github.com/KnpLabs/php-github-api) library. -* The target API is [ArgoCD](https://argo-cd.readthedocs.io/en/stable/), and its OpenAPI specification was used as the blueprint for API implementation. - * You can find the OpenAPI spec in `reference/argocd_swagger.json`. +* The initial structure and patterns were derived from the excellent [KnpLabs/php-github-api](https://github.com/KnpLabs/php-github-api) library. The refactoring aimed to bring the request/response handling closer to this style. +* The target API is [ArgoCD](https://argo-cd.readthedocs.io/en/stable/), and its OpenAPI specification (available in `reference/argocd_swagger.json` in this repository) was used as the blueprint for API implementation. diff --git a/lib/ArgoCD/Api/AccountService.php b/lib/ArgoCD/Api/AccountService.php index b48f83d3cba..f362f3df702 100644 --- a/lib/ArgoCD/Api/AccountService.php +++ b/lib/ArgoCD/Api/AccountService.php @@ -1,14 +1,7 @@ get('/api/v1/account'); - return new AccountAccountsList($responseArray); + return $this->get('/api/v1/account'); } /** @@ -32,43 +24,37 @@ public function listAccounts(): AccountAccountsList * @param string $resource * @param string $action * @param string $subresource - * @return AccountCanIResponse + * @return array * @throws \ArgoCD\Exception\RuntimeException */ - public function canI(string $resource, string $action, string $subresource): AccountCanIResponse + public function canI(string $resource, string $action, string $subresource): array { - // The response for can-i is typically a raw string "yes" or "no". - // The AbstractApi::get method expects JSON. - // We need to handle this: either get() should allow raw responses, - // or this method needs to handle potential JSON decode errors if the response isn't JSON. - // For now, assuming get() returns the raw string if not JSON, - // and AccountCanIResponse constructor can handle it. $response = $this->get(sprintf("/api/v1/account/can-i/%s/%s/%s", rawurlencode($resource), rawurlencode($action), rawurlencode($subresource))); - // If $response is a string from get(), AccountCanIResponse constructor is designed to handle it. - // If $response is an array (e.g. {'value': 'yes'}), it also handles it. - return new AccountCanIResponse(is_array($response) ? $response : ['value' => $response]); + // If $response is a string from get(), convert to array format. + // Otherwise, it's assumed to be already an array (e.g. from JSON response). + return is_array($response) ? $response : ['value' => $response]; } /** * Corresponds to AccountService_UpdatePassword * Updates the password for the current account or a specified account. * - * @param string $name The name of the account to update. If updating the current user's password, this might be the username. + * @param string $name The name of the account to update. * @param string $currentPassword The current password. * @param string $newPassword The new password. - * @return AccountUpdatePasswordResponse + * @return array * @throws \ArgoCD\Exception\RuntimeException */ - public function updatePassword(string $name, string $currentPassword, string $newPassword): AccountUpdatePasswordResponse + public function updatePassword(string $name, string $currentPassword, string $newPassword): array { - $requestModel = new AccountUpdatePasswordRequest(); - $requestModel->setName($name); // Name of the account being updated - $requestModel->setCurrentPassword($currentPassword); - $requestModel->setNewPassword($newPassword); + $body = [ + 'name' => $name, + 'currentPassword' => $currentPassword, + 'newPassword' => $newPassword, + ]; - $responseArray = $this->put('/api/v1/account/password', $requestModel->toArray()); - return new AccountUpdatePasswordResponse($responseArray ?: []); // Response might be empty + return $this->put('/api/v1/account/password', $body); } /** @@ -76,35 +62,34 @@ public function updatePassword(string $name, string $currentPassword, string $ne * Gets information about a specific account. * * @param string $name The name of the account. - * @return AccountAccount + * @return array * @throws \ArgoCD\Exception\RuntimeException */ - public function getAccount(string $name): AccountAccount + public function getAccount(string $name): array { - $responseArray = $this->get(sprintf("/api/v1/account/%s", rawurlencode($name))); - return new AccountAccount($responseArray); + return $this->get(sprintf("/api/v1/account/%s", rawurlencode($name))); } /** * Corresponds to AccountService_CreateToken * Creates a new token for the specified account. * - * @param string $accountName The name of the account. - * @param string $tokenId The desired ID/name for the token. - * @param string $tokenDescription A description for the token. + * @param string $accountName The name of the account (used in URL path). + * @param string $tokenId The desired ID/name for the token (maps to 'id' in request body). + * @param string $tokenNameOrDescription A description for the token (maps to 'name' in request body). * @param string|null $expiresIn Duration string for token expiration (e.g., "30d", "24h", "0" for non-expiring). - * @return AccountCreateTokenResponse + * @return array * @throws \ArgoCD\Exception\RuntimeException */ - public function createToken(string $accountName, string $tokenId, string $tokenDescription, ?string $expiresIn = "0"): AccountCreateTokenResponse + public function createToken(string $accountName, string $tokenId, string $tokenNameOrDescription, ?string $expiresIn = "0"): array { - $requestModel = new AccountCreateTokenRequest(); - $requestModel->setId($tokenId); // This 'id' is the token's identifier - $requestModel->setName($tokenDescription); // This 'name' is the token's description - $requestModel->setExpiresIn($expiresIn); + $body = [ + 'id' => $tokenId, + 'name' => $tokenNameOrDescription, + 'expiresIn' => $expiresIn, + ]; - $responseArray = $this->post(sprintf("/api/v1/account/%s/token", rawurlencode($accountName)), $requestModel->toArray()); - return new AccountCreateTokenResponse($responseArray); + return $this->post(sprintf("/api/v1/account/%s/token", rawurlencode($accountName)), $body); } /** @@ -113,12 +98,11 @@ public function createToken(string $accountName, string $tokenId, string $tokenD * * @param string $accountName The name of the account. * @param string $tokenId The ID of the token to delete. - * @return AccountEmptyResponse + * @return array * @throws \ArgoCD\Exception\RuntimeException */ - public function deleteToken(string $accountName, string $tokenId): AccountEmptyResponse + public function deleteToken(string $accountName, string $tokenId): array { - $responseArray = $this->delete(sprintf("/api/v1/account/%s/token/%s", rawurlencode($accountName), rawurlencode($tokenId))); - return new AccountEmptyResponse($responseArray ?: []); // Response is typically empty + return $this->delete(sprintf("/api/v1/account/%s/token/%s", rawurlencode($accountName), rawurlencode($tokenId))); } } diff --git a/lib/ArgoCD/Api/ApplicationService.php b/lib/ArgoCD/Api/ApplicationService.php index 1ca5658228b..60ddeca7fd9 100644 --- a/lib/ArgoCD/Api/ApplicationService.php +++ b/lib/ArgoCD/Api/ApplicationService.php @@ -3,5 +3,213 @@ class ApplicationService extends AbstractApi { - // Methods will be added later + /** + * Corresponds to ApplicationService_List + * Lists applications. + * + * @param array $queryParameters Optional query parameters: + * - name (string): the application's name. + * - refresh (string): forces application refresh (values: "hard", "normal", "false"). + * - projects (array): filter by project. + * - resourceVersion (string): resource version for watch. + * - selector (string): label selector for applications. + * - repo (string): repository URL. + * - appNamespace (string): application namespace. + * - project (array): legacy, use `projects`. + * @return array + * @throws \ArgoCD\Exception\RuntimeException + */ + public function list(array $queryParameters = []): array + { + return $this->get('/api/v1/applications', $queryParameters); + } + + /** + * Corresponds to ApplicationService_Create + * Creates a new application. + * + * @param array $applicationData Associative array representing the v1alpha1Application schema. + * @param bool|null $upsert Whether to create in upsert mode. + * @param bool|null $validate Whether to validate the application. + * @return array + * @throws \ArgoCD\Exception\RuntimeException + */ + public function create(array $applicationData, ?bool $upsert = null, ?bool $validate = null): array + { + $queryParams = []; + if ($upsert !== null) { + $queryParams['upsert'] = $upsert ? 'true' : 'false'; + } + if ($validate !== null) { + $queryParams['validate'] = $validate ? 'true' : 'false'; + } + $queryString = ''; + if (!empty($queryParams)) { + $queryString = '?' . http_build_query($queryParams); + } + return $this->post('/api/v1/applications' . $queryString, $applicationData); + } + + /** + * Corresponds to ApplicationService_Get + * Gets a specific application. + * + * @param string $name The name of the application. + * @param array $queryParameters Optional query parameters: + * - refresh (string): forces application refresh. + * - projects (array): filter by project. + * - resourceVersion (string): resource version for watch. + * - selector (string): label selector. + * - repo (string): repository URL. + * - appNamespace (string): application namespace. + * - project (array): legacy, use `projects`. + * @return array + * @throws \ArgoCD\Exception\RuntimeException + */ + public function get(string $name, array $queryParameters = []): array + { + $path = sprintf('/api/v1/applications/%s', rawurlencode($name)); + return $this->get($path, $queryParameters); + } + + /** + * Corresponds to ApplicationService_Update + * Updates an application. + * + * @param string $applicationName The name of the application to update. + * @param array $applicationData Associative array representing the v1alpha1Application schema. + * @param bool|null $validate Whether to validate the application. + * @param string|null $project Project of the application. + * @return array + * @throws \ArgoCD\Exception\RuntimeException + */ + public function update(string $applicationName, array $applicationData, ?bool $validate = null, ?string $project = null): array + { + $queryParams = []; + if ($validate !== null) { + $queryParams['validate'] = $validate ? 'true' : 'false'; + } + if ($project !== null) { + $queryParams['project'] = $project; + } + $queryString = ''; + if (!empty($queryParams)) { + $queryString = '?' . http_build_query($queryParams); + } + $path = sprintf('/api/v1/applications/%s', rawurlencode($applicationName)); + return $this->put($path . $queryString, $applicationData); + } + + /** + * Corresponds to ApplicationService_Delete + * Deletes an application. + * + * @param string $name The name of the application. + * @param array $queryParameters Optional query parameters: + * - cascade (bool): whether to delete associated resources. + * - propagationPolicy (string): propagation policy for deletion. + * - appNamespace (string): application namespace. + * - project (string): project name. + * @return array + * @throws \ArgoCD\Exception\RuntimeException + */ + public function delete(string $name, array $queryParameters = []): array + { + $path = sprintf('/api/v1/applications/%s', rawurlencode($name)); + return $this->delete($path, $queryParameters); + } + + /** + * Corresponds to ApplicationService_Sync + * Syncs an application to its target state. + * + * @param string $name The name of the application. + * @param array $syncRequestData Associative array representing the applicationApplicationSyncRequest schema. + * @return array + * @throws \ArgoCD\Exception\RuntimeException + */ + public function sync(string $name, array $syncRequestData): array + { + $path = sprintf('/api/v1/applications/%s/sync', rawurlencode($name)); + return $this->post($path, $syncRequestData); + } + + /** + * Corresponds to ApplicationService_Rollback + * Rolls back an application to a previous deployed version. + * + * @param string $name The name of the application. + * @param array $rollbackRequestData Associative array representing the applicationApplicationRollbackRequest schema. + * @return array + * @throws \ArgoCD\Exception\RuntimeException + */ + public function rollback(string $name, array $rollbackRequestData): array + { + $path = sprintf('/api/v1/applications/%s/rollback', rawurlencode($name)); + return $this->post($path, $rollbackRequestData); + } + + /** + * Corresponds to ApplicationService_ManagedResources + * Lists resources managed by the application. + * + * @param string $applicationName The name of the application. + * @param array $queryParameters Optional query parameters: + * - namespace (string): resource namespace. + * - name (string): resource name. + * - version (string): resource version. + * - group (string): resource group. + * - kind (string): resource kind. + * - appNamespace (string): application namespace. + * - project (string): project name. + * @return array + * @throws \ArgoCD\Exception\RuntimeException + */ + public function managedResources(string $applicationName, array $queryParameters = []): array + { + $path = sprintf('/api/v1/applications/%s/managed-resources', rawurlencode($applicationName)); + return $this->get($path, $queryParameters); + } + + /** + * Corresponds to ApplicationService_ResourceTree + * Gets the resource tree of an application. + * + * @param string $applicationName The name of the application. + * @param array $queryParameters Optional query parameters: + * - namespace (string): resource namespace. + * - name (string): resource name. + * - version (string): resource version. + * - group (string): resource group. + * - kind (string): resource kind. + * - appNamespace (string): application namespace. + * - project (string): project name. + * @return array + * @throws \ArgoCD\Exception\RuntimeException + */ + public function resourceTree(string $applicationName, array $queryParameters = []): array + { + $path = sprintf('/api/v1/applications/%s/resource-tree', rawurlencode($applicationName)); + return $this->get($path, $queryParameters); + } + + /** + * Corresponds to ApplicationService_GetManifests + * Gets the manifests of an application. + * + * @param string $name The name of the application. + * @param array $queryParameters Optional query parameters: + * - revision (string): application revision. + * - appNamespace (string): application namespace. + * - project (string): project name. + * - sourcePositions (bool): include source positions in manifests. + * - revisions (array): revisions to get manifests for. + * @return array + * @throws \ArgoCD\Exception\RuntimeException + */ + public function getManifests(string $name, array $queryParameters = []): array + { + $path = sprintf('/api/v1/applications/%s/manifests', rawurlencode($name)); + return $this->get($path, $queryParameters); + } } diff --git a/lib/ArgoCD/Api/SessionService.php b/lib/ArgoCD/Api/SessionService.php index c8ebae80509..69c52c8bcc9 100644 --- a/lib/ArgoCD/Api/SessionService.php +++ b/lib/ArgoCD/Api/SessionService.php @@ -1,9 +1,7 @@ setUsername($username); - $requestModel->setPassword($password); + $body = [ + 'username' => $username, + 'password' => $password, + ]; - $responseArray = $this->post('/api/v1/session', $requestModel->toArray()); - - return new SessionSessionResponse($responseArray); + return $this->post('/api/v1/session', $body); } /** * Corresponds to SessionService_Delete * Deletes the current session. * - * @return SessionSessionResponse + * @return array * @throws \ArgoCD\Exception\RuntimeException */ - public function delete(): SessionSessionResponse + public function delete(): array { // The OpenAPI spec for delete /api/v1/session indicates a 200 response with sessionSessionResponse. // This is unusual for a DELETE operation (typically 204 No Content or an empty body), // but we will follow the spec. - $responseArray = $this->delete('/api/v1/session'); - - // If the response is truly empty (which is more typical for DELETE), - // instantiating SessionSessionResponse with an empty array will result in a model with a null token. - return new SessionSessionResponse($responseArray ?: []); + // The AbstractApi::delete method should return an array, even if empty. + return $this->delete('/api/v1/session'); } /** * Corresponds to SessionService_GetUserInfo * Gets information about the current user. * - * @return SessionGetUserInfoResponse + * @return array * @throws \ArgoCD\Exception\RuntimeException */ - public function getUserInfo(): SessionGetUserInfoResponse + public function getUserInfo(): array { - $responseArray = $this->get('/api/v1/session/userinfo'); - - return new SessionGetUserInfoResponse($responseArray); + return $this->get('/api/v1/session/userinfo'); } } diff --git a/lib/ArgoCD/Client.php b/lib/ArgoCD/Client.php index 853e950e1e6..86d24b33a64 100644 --- a/lib/ArgoCD/Client.php +++ b/lib/ArgoCD/Client.php @@ -138,8 +138,10 @@ public function authenticate(string $usernameOrToken, ?string $password = null): if ($password !== null) { // Username/password authentication $sessionService = new SessionService($this); - $sessionResponse = $sessionService->create($usernameOrToken, $password); - $this->token = $sessionResponse->getToken(); + $responseArray = $sessionService->create($usernameOrToken, $password); // Returns array now + + // Extract token from array, based on reference/argocd_swagger.json (sessionSessionResponse) + $this->token = $responseArray['token'] ?? null; if (empty($this->token)) { throw new InvalidArgumentException('Authentication failed: Could not retrieve token with the provided username and password.'); diff --git a/lib/ArgoCD/Model/AccountAccount.php b/lib/ArgoCD/Model/AccountAccount.php deleted file mode 100644 index cf035792435..00000000000 --- a/lib/ArgoCD/Model/AccountAccount.php +++ /dev/null @@ -1,55 +0,0 @@ -capabilities = $data['capabilities']; - } - $this->enabled = isset($data['enabled']) ? (bool)$data['enabled'] : null; - $this->name = $data['name'] ?? null; - - if (isset($data['tokens']) && is_array($data['tokens'])) { - foreach ($data['tokens'] as $tokenData) { - if (is_array($tokenData)) { - $this->tokens[] = new AccountToken($tokenData); - } - } - } - } - - /** - * @return string[]|null - */ - public function getCapabilities(): ?array - { - return $this->capabilities; - } - - public function isEnabled(): ?bool - { - return $this->enabled; - } - - public function getName(): ?string - { - return $this->name; - } - - /** - * @return AccountToken[] - */ - public function getTokens(): array - { - return $this->tokens; - } -} diff --git a/lib/ArgoCD/Model/AccountAccountsList.php b/lib/ArgoCD/Model/AccountAccountsList.php deleted file mode 100644 index bca0a47f53f..00000000000 --- a/lib/ArgoCD/Model/AccountAccountsList.php +++ /dev/null @@ -1,39 +0,0 @@ -items[] = new AccountAccount($accountData); - } - } - } - // Initialize metadata if present, e.g.: - // if (isset($data['metadata'])) { - // $this->metadata = new V1ListMeta($data['metadata']); - // } - } - - /** - * @return AccountAccount[] - */ - public function getItems(): array - { - return $this->items; - } - - // Getter for metadata if added - // public function getMetadata(): ?V1ListMeta - // { - // return $this->metadata; - // } -} diff --git a/lib/ArgoCD/Model/AccountCanIResponse.php b/lib/ArgoCD/Model/AccountCanIResponse.php deleted file mode 100644 index 52b96bb77f9..00000000000 --- a/lib/ArgoCD/Model/AccountCanIResponse.php +++ /dev/null @@ -1,28 +0,0 @@ - 'the_string_response'] or the direct string. - if (isset($data['value'])) { - $this->value = (string)$data['value']; - } elseif (is_string($data)) { // Handle direct string response - $this->value = $data; - } else if (count($data) === 1 && is_string(current($data))) { // Handle if wrapped in an array with one string value - $this->value = current($data); - } - - } - - public function getValue(): ?string - { - return $this->value; - } -} diff --git a/lib/ArgoCD/Model/AccountCreateTokenRequest.php b/lib/ArgoCD/Model/AccountCreateTokenRequest.php deleted file mode 100644 index bde59a97eb0..00000000000 --- a/lib/ArgoCD/Model/AccountCreateTokenRequest.php +++ /dev/null @@ -1,82 +0,0 @@ -expiresIn = $data['expiresIn'] ?? null; - $this->id = $data['id'] ?? null; - $this->name = $data['name'] ?? null; - } - - public function setExpiresIn(?string $expiresIn): self - { - $this->expiresIn = $expiresIn; - return $this; - } - - public function setId(string $id): self - { - $this->id = $id; - return $this; - } - - public function setName(string $name): self - { - $this->name = $name; - return $this; - } - - public function getExpiresIn(): ?string - { - return $this->expiresIn; - } - - public function getId(): ?string - { - return $this->id; - } - - public function getName(): ?string - { - return $this->name; - } - - public function toArray(): array - { - $payload = []; - // According to typical ArgoCD API usage for creating tokens, - // 'name' in the path is the account name. - // 'id' in the body is the token's identifier/name. - // 'expiresIn' in the body is the token's expiration duration. - // The 'name' field in the body for this request is often used as the token's description or friendly name. - // The OpenAPI spec has 'name' in the body, which is slightly ambiguous. - // Let's assume 'id' is the token's unique ID, and 'name' (body) is a display name. - // If 'name' from the constructor is meant for the account, it shouldn't be in this payload. - // The method signature for createToken in service will have $accountName for the path. - - if ($this->id !== null) { - // This 'id' in the request body is often used as the token's name or identifier. - // The API might also have a 'name' field for a description. - // The OpenAPI spec is: properties: { expiresIn, id, name } - // Let's assume 'id' is the desired token ID, and 'name' is its description. - $payload['id'] = $this->id; - } - if ($this->name !== null) { - // This 'name' field is for the token's display name/description. - $payload['name'] = $this->name; - } - if ($this->expiresIn !== null) { - $payload['expiresIn'] = $this->expiresIn; - } else { - // Default to non-expiring if not specified, or API might require it - $payload['expiresIn'] = "0"; - } - return $payload; - } -} diff --git a/lib/ArgoCD/Model/AccountCreateTokenResponse.php b/lib/ArgoCD/Model/AccountCreateTokenResponse.php deleted file mode 100644 index 2dd368342cc..00000000000 --- a/lib/ArgoCD/Model/AccountCreateTokenResponse.php +++ /dev/null @@ -1,17 +0,0 @@ -token = $data['token'] ?? null; - } - - public function getToken(): ?string - { - return $this->token; - } -} diff --git a/lib/ArgoCD/Model/AccountEmptyResponse.php b/lib/ArgoCD/Model/AccountEmptyResponse.php deleted file mode 100644 index c871dbf8db9..00000000000 --- a/lib/ArgoCD/Model/AccountEmptyResponse.php +++ /dev/null @@ -1,15 +0,0 @@ -expiresAt = $data['expiresAt'] ?? null; - $this->id = $data['id'] ?? null; - $this->issuedAt = $data['issuedAt'] ?? null; - } - - public function getExpiresAt(): ?string - { - return $this->expiresAt; - } - - public function getId(): ?string - { - return $this->id; - } - - public function getIssuedAt(): ?string - { - return $this->issuedAt; - } - - // Optional: Convert expiresAt to DateTimeImmutable - public function getExpiresAtDateTime(): ?\DateTimeImmutable - { - if ($this->expiresAt === null) { - return null; - } - $dateTime = new \DateTimeImmutable(); - return $dateTime->setTimestamp((int)$this->expiresAt); - } - - // Optional: Convert issuedAt to DateTimeImmutable - public function getIssuedAtDateTime(): ?\DateTimeImmutable - { - if ($this->issuedAt === null) { - return null; - } - $dateTime = new \DateTimeImmutable(); - return $dateTime->setTimestamp((int)$this->issuedAt); - } -} diff --git a/lib/ArgoCD/Model/AccountUpdatePasswordRequest.php b/lib/ArgoCD/Model/AccountUpdatePasswordRequest.php deleted file mode 100644 index 4b01a32297c..00000000000 --- a/lib/ArgoCD/Model/AccountUpdatePasswordRequest.php +++ /dev/null @@ -1,64 +0,0 @@ -currentPassword = $data['currentPassword'] ?? null; - $this->name = $data['name'] ?? null; - $this->newPassword = $data['newPassword'] ?? null; - } - - public function setCurrentPassword(string $currentPassword): self - { - $this->currentPassword = $currentPassword; - return $this; - } - - public function setName(string $name): self - { - $this->name = $name; - return $this; - } - - public function setNewPassword(string $newPassword): self - { - $this->newPassword = $newPassword; - return $this; - } - - public function getCurrentPassword(): ?string - { - return $this->currentPassword; - } - - public function getName(): ?string - { - return $this->name; - } - - public function getNewPassword(): ?string - { - return $this->newPassword; - } - - public function toArray(): array - { - $payload = []; - if ($this->currentPassword !== null) { - $payload['currentPassword'] = $this->currentPassword; - } - if ($this->name !== null) { - $payload['name'] = $this->name; - } - if ($this->newPassword !== null) { - $payload['newPassword'] = $this->newPassword; - } - return $payload; - } -} diff --git a/lib/ArgoCD/Model/AccountUpdatePasswordResponse.php b/lib/ArgoCD/Model/AccountUpdatePasswordResponse.php deleted file mode 100644 index f3765e1166e..00000000000 --- a/lib/ArgoCD/Model/AccountUpdatePasswordResponse.php +++ /dev/null @@ -1,16 +0,0 @@ -code = isset($data['code']) ? (int)$data['code'] : null; - $this->error = $data['error'] ?? null; - $this->message = $data['message'] ?? null; - $this->details = $data['details'] ?? null; - } - - public function getCode(): ?int - { - return $this->code; - } - - public function getError(): ?string - { - return $this->error; - } - - public function getMessage(): ?string - { - return $this->message; - } - - public function getDetails(): ?array - { - return $this->details; - } -} diff --git a/lib/ArgoCD/Model/SessionGetUserInfoResponse.php b/lib/ArgoCD/Model/SessionGetUserInfoResponse.php deleted file mode 100644 index 4e5cebaaef2..00000000000 --- a/lib/ArgoCD/Model/SessionGetUserInfoResponse.php +++ /dev/null @@ -1,44 +0,0 @@ -groups = $data['groups']; - } - $this->iss = $data['iss'] ?? null; - $this->loggedIn = isset($data['loggedIn']) ? (bool)$data['loggedIn'] : null; - $this->username = $data['username'] ?? null; - } - - /** - * @return string[]|null - */ - public function getGroups(): ?array - { - return $this->groups; - } - - public function getIss(): ?string - { - return $this->iss; - } - - public function isLoggedIn(): ?bool - { - return $this->loggedIn; - } - - public function getUsername(): ?string - { - return $this->username; - } -} diff --git a/lib/ArgoCD/Model/SessionSessionCreateRequest.php b/lib/ArgoCD/Model/SessionSessionCreateRequest.php deleted file mode 100644 index 9ca171dacea..00000000000 --- a/lib/ArgoCD/Model/SessionSessionCreateRequest.php +++ /dev/null @@ -1,66 +0,0 @@ -password = $data['password'] ?? null; - $this->token = $data['token'] ?? null; - $this->username = $data['username'] ?? null; - } - - public function getPassword(): ?string - { - return $this->password; - } - - public function getToken(): ?string - { - return $this->token; - } - - public function getUsername(): ?string - { - return $this->username; - } - - // It might be useful to have setters for a request object - // or a method to convert to array for the request body. - public function setPassword(string $password): self - { - $this->password = $password; - return $this; - } - - public function setToken(string $token): self - { - $this->token = $token; - return $this; - } - - public function setUsername(string $username): self - { - $this->username = $username; - return $this; - } - - public function toArray(): array - { - $payload = []; - if ($this->username !== null) { - $payload['username'] = $this->username; - } - if ($this->password !== null) { - $payload['password'] = $this->password; - } - if ($this->token !== null) { - $payload['token'] = $this->token; - } - return $payload; - } -} diff --git a/lib/ArgoCD/Model/SessionSessionResponse.php b/lib/ArgoCD/Model/SessionSessionResponse.php deleted file mode 100644 index 146d6ab7328..00000000000 --- a/lib/ArgoCD/Model/SessionSessionResponse.php +++ /dev/null @@ -1,17 +0,0 @@ -token = $data['token'] ?? null; - } - - public function getToken(): ?string - { - return $this->token; - } -} diff --git a/lib/ArgoCD/Model/V1Time.php b/lib/ArgoCD/Model/V1Time.php deleted file mode 100644 index a9d069325d3..00000000000 --- a/lib/ArgoCD/Model/V1Time.php +++ /dev/null @@ -1,35 +0,0 @@ -seconds = $data['seconds'] ?? null; - $this->nanos = isset($data['nanos']) ? (int)$data['nanos'] : null; - } - - public function getSeconds(): ?string - { - return $this->seconds; - } - - public function getNanos(): ?int - { - return $this->nanos; - } - - public function toDateTime(): ?\DateTimeImmutable - { - if ($this->seconds === null) { - return null; - } - // Assuming seconds is a string that can be cast to int for setTimestamp - $dateTime = new \DateTimeImmutable(); - return $dateTime->setTimestamp((int)$this->seconds); - // Note: Nanos are not easily representable in standard DateTime - } -} diff --git a/test/ArgoCD/Tests/Api/AccountServiceTest.php b/test/ArgoCD/Tests/Api/AccountServiceTest.php new file mode 100644 index 00000000000..c55bb545568 --- /dev/null +++ b/test/ArgoCD/Tests/Api/AccountServiceTest.php @@ -0,0 +1,207 @@ + 'admin', 'enabled' => true], + ['name' => 'user1', 'enabled' => false], + ]; + + /** @var AccountService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo('/api/v1/account')) + ->will($this->returnValue($expectedArray)); + + $result = $api->listAccounts(); + self::assertIsArray($result); + self::assertEquals($expectedArray, $result); + } + + public function testCanIReturnsYesString(): void + { + /** @var AccountService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo('/api/v1/account/can-i/apps/create/my-app')) + ->will($this->returnValue('yes')); // Mock the raw string response + + $result = $api->canI('apps', 'create', 'my-app'); + self::assertIsArray($result); + self::assertEquals(['value' => 'yes'], $result); + } + + public function testCanIReturnsNoString(): void + { + /** @var AccountService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo('/api/v1/account/can-i/apps/delete/my-app')) + ->will($this->returnValue('no')); // Mock the raw string response + + $result = $api->canI('apps', 'delete', 'my-app'); + self::assertIsArray($result); + self::assertEquals(['value' => 'no'], $result); + } + + public function testCanIReturnsJson(): void + { + $expectedResponse = ['value' => 'yes']; + /** @var AccountService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo('/api/v1/account/can-i/apps/get/my-app')) + ->will($this->returnValue($expectedResponse)); // Mock the array response + + $result = $api->canI('apps', 'get', 'my-app'); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + public function testUpdatePassword(): void + { + $expectedResponse = []; // Often empty response + $accountName = 'admin'; + $currentPassword = 'oldPassword'; + $newPassword = 'newPassword'; + + $expectedBody = [ + 'name' => $accountName, + 'currentPassword' => $currentPassword, + 'newPassword' => $newPassword, + ]; + + /** @var AccountService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('put') + ->with( + $this->equalTo('/api/v1/account/password'), + $this->equalTo($expectedBody) + ) + ->will($this->returnValue($expectedResponse)); + + $result = $api->updatePassword($accountName, $currentPassword, $newPassword); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + public function testGetAccount(): void + { + $accountName = 'test-user'; + $expectedAccount = ['name' => $accountName, 'enabled' => true, 'capabilities' => ['login']]; + + /** @var AccountService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo(sprintf('/api/v1/account/%s', rawurlencode($accountName)))) + ->will($this->returnValue($expectedAccount)); + + $result = $api->getAccount($accountName); + self::assertIsArray($result); + self::assertEquals($expectedAccount, $result); + } + + public function testCreateToken(): void + { + $accountName = 'test-user'; + $tokenId = 'new-token-id'; + $tokenNameOrDescription = 'My Test Token'; + $expiresIn = '24h'; + + $expectedRequestBody = [ + 'id' => $tokenId, + 'name' => $tokenNameOrDescription, + 'expiresIn' => $expiresIn, + ]; + $expectedResponseArray = [ + 'token' => 'generated-jwt-string-here', + 'id' => $tokenId, + 'name' => $tokenNameOrDescription, + 'expiresIn' => $expiresIn, + // other fields like 'issuedAt', 'expiresAt' might be present + ]; + + /** @var AccountService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('post') + ->with( + $this->equalTo(sprintf('/api/v1/account/%s/token', rawurlencode($accountName))), + $this->equalTo($expectedRequestBody) + ) + ->will($this->returnValue($expectedResponseArray)); + + $result = $api->createToken($accountName, $tokenId, $tokenNameOrDescription, $expiresIn); + self::assertIsArray($result); + self::assertEquals($expectedResponseArray, $result); + } + + public function testCreateTokenWithDefaultExpiry(): void + { + $accountName = 'test-user-default-expiry'; + $tokenId = 'default-exp-token'; + $tokenNameOrDescription = 'Token with default expiry'; + // expiresIn is omitted, should default to "0" in the service method + + $expectedRequestBody = [ + 'id' => $tokenId, + 'name' => $tokenNameOrDescription, + 'expiresIn' => "0", // Default value + ]; + $expectedResponseArray = [ + 'token' => 'another-jwt-string', + 'id' => $tokenId, + 'name' => $tokenNameOrDescription, + 'expiresIn' => "0", + ]; + + /** @var AccountService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('post') + ->with( + $this->equalTo(sprintf('/api/v1/account/%s/token', rawurlencode($accountName))), + $this->equalTo($expectedRequestBody) + ) + ->will($this->returnValue($expectedResponseArray)); + + // Call without the expiresIn parameter + $result = $api->createToken($accountName, $tokenId, $tokenNameOrDescription); + self::assertIsArray($result); + self::assertEquals($expectedResponseArray, $result); + } + + public function testDeleteToken(): void + { + $expectedResponse = []; // Often empty response + $accountName = 'test-user'; + $tokenId = 'token-to-delete'; + + /** @var AccountService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('delete') + ->with($this->equalTo(sprintf('/api/v1/account/%s/token/%s', rawurlencode($accountName), rawurlencode($tokenId)))) + ->will($this->returnValue($expectedResponse)); + + $result = $api->deleteToken($accountName, $tokenId); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } +} diff --git a/test/ArgoCD/Tests/Api/ApplicationServiceTest.php b/test/ArgoCD/Tests/Api/ApplicationServiceTest.php new file mode 100644 index 00000000000..09a27d7a3eb --- /dev/null +++ b/test/ArgoCD/Tests/Api/ApplicationServiceTest.php @@ -0,0 +1,394 @@ + []]; + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo('/api/v1/applications'), $this->equalTo([])) + ->will($this->returnValue($expectedResponse)); + + $result = $api->list(); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + public function testListApplicationsWithParams(): void + { + $expectedResponse = ['items' => [['metadata' => ['name' => 'app1']]]]; + $queryParams = ['selector' => 'env=prod', 'projects' => ['proj1', 'proj2']]; + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo('/api/v1/applications'), $this->equalTo($queryParams)) + ->will($this->returnValue($expectedResponse)); + + $result = $api->list($queryParams); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + // --- Test Cases for create --- + public function testCreateApplication(): void + { + $appData = ['metadata' => ['name' => 'new-app'], 'spec' => ['project' => 'default']]; + $expectedResponse = ['metadata' => ['name' => 'new-app'], 'spec' => ['project' => 'default']]; + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('post') + ->with( + $this->equalTo('/api/v1/applications'), + $this->equalTo($appData) + ) + ->will($this->returnValue($expectedResponse)); + + $result = $api->create($appData); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + public function testCreateApplicationWithUpsertAndValidate(): void + { + $appData = ['metadata' => ['name' => 'new-app-upsert'], 'spec' => ['project' => 'default']]; + $expectedResponse = $appData; + $upsert = true; + $validate = true; + // Note: http_build_query sorts params by name, so validate=true comes before upsert=true + $expectedPath = '/api/v1/applications?validate=true&upsert=true'; + + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('post') + ->with( + $this->equalTo($expectedPath), + $this->equalTo($appData) + ) + ->will($this->returnValue($expectedResponse)); + + $result = $api->create($appData, $upsert, $validate); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + public function testCreateApplicationWithUpsertOnly(): void + { + $appData = ['metadata' => ['name' => 'new-app-upsert-only'], 'spec' => ['project' => 'default']]; + $expectedResponse = $appData; + $upsert = true; + $validate = null; + $expectedPath = '/api/v1/applications?upsert=true'; + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('post') + ->with( + $this->equalTo($expectedPath), + $this->equalTo($appData) + ) + ->will($this->returnValue($expectedResponse)); + + $result = $api->create($appData, $upsert, $validate); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + + // --- Test Cases for get --- + public function testGetApplication(): void + { + $appName = 'test-app'; + $expectedResponse = ['metadata' => ['name' => $appName]]; + $expectedPath = sprintf('/api/v1/applications/%s', rawurlencode($appName)); + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo($expectedPath), $this->equalTo([])) + ->will($this->returnValue($expectedResponse)); + + $result = $api->get($appName); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + public function testGetApplicationWithParams(): void + { + $appName = 'test-app-params'; + $queryParams = ['refresh' => 'hard', 'project' => ['proj-A']]; + $expectedResponse = ['metadata' => ['name' => $appName]]; + $expectedPath = sprintf('/api/v1/applications/%s', rawurlencode($appName)); + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo($expectedPath), $this->equalTo($queryParams)) + ->will($this->returnValue($expectedResponse)); + + $result = $api->get($appName, $queryParams); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + // --- Test Cases for update --- + public function testUpdateApplication(): void + { + $appName = 'app-to-update'; + $appData = ['spec' => ['description' => 'new description']]; + $expectedResponse = ['metadata' => ['name' => $appName], 'spec' => $appData['spec']]; + $expectedPath = sprintf('/api/v1/applications/%s', rawurlencode($appName)); + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('put') + ->with( + $this->equalTo($expectedPath), // Path without query params + $this->equalTo($appData) + ) + ->will($this->returnValue($expectedResponse)); + + $result = $api->update($appName, $appData); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + public function testUpdateApplicationWithValidateAndProject(): void + { + $appName = 'app-to-update-complex'; + $appData = ['spec' => ['description' => 'another description']]; + $expectedResponse = $appData; + $validate = true; + $project = 'my-special-project'; + // http_build_query sorts params, project comes before validate + $expectedPath = sprintf('/api/v1/applications/%s?project=%s&validate=true', rawurlencode($appName), rawurlencode($project)); + + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('put') + ->with( + $this->equalTo($expectedPath), + $this->equalTo($appData) + ) + ->will($this->returnValue($expectedResponse)); + + $result = $api->update($appName, $appData, $validate, $project); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + // --- Test Cases for delete --- + public function testDeleteApplication(): void + { + $appName = 'app-to-delete'; + $expectedResponse = []; // Delete often returns empty or minimal response + $expectedPath = sprintf('/api/v1/applications/%s', rawurlencode($appName)); + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('delete') + ->with($this->equalTo($expectedPath), $this->equalTo([])) + ->will($this->returnValue($expectedResponse)); + + $result = $api->delete($appName); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + public function testDeleteApplicationWithParams(): void + { + $appName = 'app-to-delete-cascade'; + $queryParams = ['cascade' => 'true', 'propagationPolicy' => 'foreground']; // Note: bools as strings + $expectedResponse = []; + $expectedPath = sprintf('/api/v1/applications/%s', rawurlencode($appName)); + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('delete') + ->with($this->equalTo($expectedPath), $this->equalTo($queryParams)) + ->will($this->returnValue($expectedResponse)); + + $result = $api->delete($appName, $queryParams); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + // --- Test Cases for sync --- + public function testSyncApplication(): void + { + $appName = 'app-to-sync'; + $syncData = ['revision' => 'HEAD', 'prune' => true]; + $expectedResponse = ['status' => 'Sync initiated']; + $expectedPath = sprintf('/api/v1/applications/%s/sync', rawurlencode($appName)); + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('post') + ->with($this->equalTo($expectedPath), $this->equalTo($syncData)) + ->will($this->returnValue($expectedResponse)); + + $result = $api->sync($appName, $syncData); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + // --- Test Cases for rollback --- + public function testRollbackApplication(): void + { + $appName = 'app-to-rollback'; + $rollbackData = ['id' => 123, 'prune' => false, 'dryRun' => true]; + $expectedResponse = ['status' => 'Rollback initiated']; + $expectedPath = sprintf('/api/v1/applications/%s/rollback', rawurlencode($appName)); + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('post') + ->with($this->equalTo($expectedPath), $this->equalTo($rollbackData)) + ->will($this->returnValue($expectedResponse)); + + $result = $api->rollback($appName, $rollbackData); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + // --- Test Cases for managedResources --- + public function testManagedResources(): void + { + $appName = 'app-managed'; + $expectedResponse = ['items' => [['kind' => 'Pod', 'name' => 'p1']]]; + $expectedPath = sprintf('/api/v1/applications/%s/managed-resources', rawurlencode($appName)); + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo($expectedPath), $this->equalTo([])) + ->will($this->returnValue($expectedResponse)); + + $result = $api->managedResources($appName); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + public function testManagedResourcesWithParams(): void + { + $appName = 'app-managed-params'; + $queryParams = ['namespace' => 'ns1', 'kind' => 'Service']; + $expectedResponse = ['items' => [['kind' => 'Service', 'name' => 's1']]]; + $expectedPath = sprintf('/api/v1/applications/%s/managed-resources', rawurlencode($appName)); + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo($expectedPath), $this->equalTo($queryParams)) + ->will($this->returnValue($expectedResponse)); + + $result = $api->managedResources($appName, $queryParams); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + // --- Test Cases for resourceTree --- + public function testResourceTree(): void + { + $appName = 'app-tree'; + $expectedResponse = ['nodes' => [['kind' => 'Application']]]; + $expectedPath = sprintf('/api/v1/applications/%s/resource-tree', rawurlencode($appName)); + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo($expectedPath), $this->equalTo([])) + ->will($this->returnValue($expectedResponse)); + + $result = $api->resourceTree($appName); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + public function testResourceTreeWithParams(): void + { + $appName = 'app-tree-params'; + $queryParams = ['namespace' => 'default', 'group' => 'apps', 'kind' => 'Deployment']; + $expectedResponse = ['nodes' => [['kind' => 'Deployment']]]; + $expectedPath = sprintf('/api/v1/applications/%s/resource-tree', rawurlencode($appName)); + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo($expectedPath), $this->equalTo($queryParams)) + ->will($this->returnValue($expectedResponse)); + + $result = $api->resourceTree($appName, $queryParams); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + // --- Test Cases for getManifests --- + public function testGetManifests(): void + { + $appName = 'app-manifests'; + $expectedResponse = ['manifests' => ["---apiVersion: v1...", "---apiVersion: apps/v1..."]]; + $expectedPath = sprintf('/api/v1/applications/%s/manifests', rawurlencode($appName)); + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo($expectedPath), $this->equalTo([])) + ->will($this->returnValue($expectedResponse)); + + $result = $api->getManifests($appName); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + public function testGetManifestsWithParams(): void + { + $appName = 'app-manifests-params'; + $queryParams = ['revision' => 'my-branch', 'sourcePositions' => 'true']; + $expectedResponse = ['manifests' => ["---apiVersion: v1..."]]; + $expectedPath = sprintf('/api/v1/applications/%s/manifests', rawurlencode($appName)); + + /** @var ApplicationService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo($expectedPath), $this->equalTo($queryParams)) + ->will($this->returnValue($expectedResponse)); + + $result = $api->getManifests($appName, $queryParams); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } +} diff --git a/test/ArgoCD/Tests/Api/Organization/TeamsTest.php b/test/ArgoCD/Tests/Api/Organization/TeamsTest.php deleted file mode 100644 index aa586ae89ef..00000000000 --- a/test/ArgoCD/Tests/Api/Organization/TeamsTest.php +++ /dev/null @@ -1,324 +0,0 @@ - 'KnpWorld'], ['name' => 'KnpFrance'], ['name' => 'KnpMontreal']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/teams') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all('KnpLabs')); - } - - /** - * @test - */ - public function shouldCheckIfMemberIsInOrganizationTeam() - { - $expectedValue = 'response'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/teams/KnpWorld/memberships/l3l0') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->check('KnpWorld', 'l3l0', 'KnpLabs')); - } - - /** - * @test - */ - public function shouldRemoveOrganizationTeam() - { - $expectedValue = 'response'; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/orgs/KnpLabs/teams/KnpWorld') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->remove('KnpWorld', 'KnpLabs')); - } - - /** - * @test - */ - public function shouldShowOrganizationTeam() - { - $expectedValue = ['username' => 'l3l0']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/teams/KnpWorld') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->show('KnpWorld', 'KnpLabs')); - } - - /** - * @test - */ - public function shouldGetTeamMembers() - { - $expectedValue = [['username' => 'l3l0']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/teams/KnpWorld/members') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->members('KnpWorld', 'KnpLabs')); - } - - /** - * @test - */ - public function shouldAddTeamMembers() - { - $expectedValue = ['username' => 'l3l0']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/orgs/KnpLabs/teams/KnpWorld/memberships/l3l0') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->addMember('KnpWorld', 'l3l0', 'KnpLabs')); - } - - /** - * @test - */ - public function shouldRemoveTeamMembers() - { - $expectedValue = ['username' => 'l3l0']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/orgs/KnpLabs/teams/KnpWorld/memberships/l3l0') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->removeMember('KnpWorld', 'l3l0', 'KnpLabs')); - } - - /** - * @test - */ - public function shouldGetTeamRepositories() - { - $expectedValue = [['name' => 'l3l0repo']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/teams/KnpWorld/repos') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->repositories('KnpWorld', 'KnpLabs')); - } - - /** - * @test - */ - public function shouldGetTeamRepositoriesViaLegacy() - { - $expectedValue = [['name' => 'l3l0repo']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/teams/KnpWorld/repos') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->repositories('KnpWorld')); - } - - /** - * @test - */ - public function shouldGetTeamRepository() - { - $expectedValue = ['name' => 'l3l0repo']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/teams/KnpWorld/repos/l3l0/l3l0Repo') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->repository('KnpWorld', 'l3l0', 'l3l0Repo')); - } - - /** - * @test - */ - public function shouldAddTeamRepository() - { - $expectedValue = ['name' => 'l3l0repo']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('put') - ->with('/orgs/l3l0/teams/KnpWorld/repos/l3l0/l3l0Repo') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->addRepository('KnpWorld', 'l3l0', 'l3l0Repo')); - } - - /** - * @test - */ - public function shouldRemoveTeamRepository() - { - $expectedValue = ['name' => 'l3l0repo']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('delete') - ->with('/orgs/l3l0/teams/KnpWorld/repos/l3l0/l3l0Repo') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->removeRepository('KnpWorld', 'l3l0', 'l3l0Repo')); - } - - /** - * @test - */ - public function shouldNotCreateTeamWithoutName() - { - $this->expectException(MissingArgumentException::class); - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('post'); - - $api->create('KnpLabs', $data); - } - - /** - * @test - */ - public function shouldCreateOrganizationTeam() - { - $expectedValue = ['name' => 'KnpWorld']; - $data = ['name' => 'KnpWorld']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/orgs/KnpLabs/teams', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', $data)); - } - - /** - * @test - */ - public function shouldCreateOrganizationTeamWithRepoName() - { - $expectedValue = ['name' => 'KnpWorld']; - $data = ['name' => 'KnpWorld', 'repo_names' => 'somerepo']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/orgs/KnpLabs/teams', ['name' => 'KnpWorld', 'repo_names' => ['somerepo']]) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', $data)); - } - - /** - * @test - */ - public function shouldCreateWithPullPermissionWhenPermissionParamNotRecognized() - { - $expectedValue = ['name' => 'KnpWorld']; - $data = ['name' => 'KnpWorld', 'permission' => 'someinvalid']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('post') - ->with('/orgs/KnpLabs/teams', ['name' => 'KnpWorld', 'permission' => 'pull']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->create('KnpLabs', $data)); - } - - /** - * @test - */ - public function shouldNotUpdateTeamWithoutName() - { - $this->expectException(MissingArgumentException::class); - $data = []; - - $api = $this->getApiMock(); - $api->expects($this->never()) - ->method('patch'); - - $api->update('KnpWorld', $data, 'KnpLabs'); - } - - /** - * @test - */ - public function shouldUpdateOrganizationTeam() - { - $expectedValue = ['name' => 'KnpWorld']; - $data = ['name' => 'KnpWorld']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/orgs/KnpLabs/teams/KnpWorld', $data) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpWorld', $data, 'KnpLabs')); - } - - /** - * @test - */ - public function shouldUpdateWithPullPermissionWhenPermissionParamNotRecognized() - { - $expectedValue = ['name' => 'KnpWorld']; - $data = ['name' => 'KnpWorld', 'permission' => 'someinvalid']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/orgs/KnpLabs/teams/KnpWorld', ['name' => 'KnpWorld', 'permission' => 'pull']) - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->update('KnpWorld', $data, 'KnpLabs')); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \ArgoCD\Api\Organization\Teams::class; - } -} diff --git a/test/ArgoCD/Tests/Api/OrganizationTest.php b/test/ArgoCD/Tests/Api/OrganizationTest.php deleted file mode 100644 index 2d39774b68e..00000000000 --- a/test/ArgoCD/Tests/Api/OrganizationTest.php +++ /dev/null @@ -1,118 +0,0 @@ - 'KnpLabs']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/organizations?since=1') - ->will($this->returnValue($expectedValue)); - - $this->assertEquals($expectedValue, $api->all(1)); - } - - /** - * @test - */ - public function shouldShowOrganization() - { - $expectedArray = ['id' => 1, 'name' => 'KnpLabs']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs') - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->show('KnpLabs')); - } - - /** - * @test - */ - public function shouldUpdateOrganization() - { - $expectedArray = ['id' => 1, 'name' => 'KnpLabs']; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('patch') - ->with('/orgs/KnpLabs', ['value' => 'toUpdate']) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->update('KnpLabs', ['value' => 'toUpdate'])); - } - - /** - * @test - */ - public function shouldGetOrganizationRepositories() - { - $expectedArray = [['id' => 1, 'username' => 'KnpLabs', 'name' => 'php-github-api']]; - - $api = $this->getApiMock(); - $api->expects($this->once()) - ->method('get') - ->with('/orgs/KnpLabs/repos', ['type' => 'all', 'page' => 1]) - ->will($this->returnValue($expectedArray)); - - $this->assertEquals($expectedArray, $api->repositories('KnpLabs')); - } - - /** - * @test - */ - public function shouldGetMembersApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\ArgoCD\Api\Organization\Members::class, $api->members()); - } - - /** - * @test - */ - public function shouldGetTeamsApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\ArgoCD\Api\Organization\Teams::class, $api->teams()); - } - - /** - * @test - */ - public function shouldGetSelfHostedRunnersApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\ArgoCD\Api\Organization\Actions\SelfHostedRunners::class, $api->runners()); - } - - /** - * @test - */ - public function shouldGetVariablesApiObject() - { - $api = $this->getApiMock(); - - $this->assertInstanceOf(\ArgoCD\Api\Organization\Actions\Variables::class, $api->variables()); - } - - /** - * @return string - */ - protected function getApiClass() - { - return \ArgoCD\Api\Organization::class; - } -} diff --git a/test/ArgoCD/Tests/Api/SessionServiceTest.php b/test/ArgoCD/Tests/Api/SessionServiceTest.php new file mode 100644 index 00000000000..b14114c38db --- /dev/null +++ b/test/ArgoCD/Tests/Api/SessionServiceTest.php @@ -0,0 +1,73 @@ + 'mocked-jwt-token']; + $username = 'testuser'; + $password = 'testpass'; + + /** @var SessionService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('post') + ->with( + $this->equalTo('/api/v1/session'), + $this->equalTo(['username' => $username, 'password' => $password]) + ) + ->will($this->returnValue($expectedResponse)); + + $result = $api->create($username, $password); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + public function testDeleteSession(): void + { + // The Swagger spec indicates SessionSessionResponse, which has a 'token' field. + // A real delete might return an empty body, but our AbstractApi::delete + // usually decodes JSON or returns empty array if decode fails or body is empty. + $expectedResponse = []; // Or ['token' => null] if AbstractApi guarantees field presence + + /** @var SessionService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('delete') + ->with($this->equalTo('/api/v1/session')) + ->will($this->returnValue($expectedResponse)); + + $result = $api->delete(); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } + + public function testGetUserInfo(): void + { + $expectedResponse = [ + 'loggedIn' => true, + 'username' => 'testuser', + 'iss' => 'argocd', + 'groups' => ['my-group'], + ]; + + /** @var SessionService $api */ + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with($this->equalTo('/api/v1/session/userinfo')) + ->will($this->returnValue($expectedResponse)); + + $result = $api->getUserInfo(); + self::assertIsArray($result); + self::assertEquals($expectedResponse, $result); + } +} From 7915754ffa22bd509989db0113f325e8980d78c7 Mon Sep 17 00:00:00 2001 From: Michael Roterman Date: Wed, 28 May 2025 12:35:33 +0200 Subject: [PATCH 6/6] Remove styleci for now --- .styleci.yml | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .styleci.yml diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index 4187da89396..00000000000 --- a/.styleci.yml +++ /dev/null @@ -1,8 +0,0 @@ -preset: recommended - -enabled: - - return_assignment - -disabled: - - align_double_arrow - - no_multiline_whitespace_before_semicolons