Fix the update server #978 issue. Fixed the change log to load all entries, not just the last one. Fixed #983 so that database updates are created when adding a new adminview. Moved a few builder arrays to the Compiler Registry. Adds super powers to JCB. Adds Gitea API library. Improves Power filters. Fix #991 to add the Utilities service class. Adds Superpower Key (SPK) replacement feature. Adds Superpower search (GREP) feature. Adds Power Insert/Update Classe. Fix #995 that all update sites are using the correct URL.
This commit is contained in:
166
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Applications.php
Normal file
166
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Applications.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\User;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea User Applications
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Applications extends Api
|
||||
{
|
||||
/**
|
||||
* List the authenticated user's oauth2 applications.
|
||||
*
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/applications/oauth2';
|
||||
|
||||
// Build the URI with query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an OAuth2 application by ID.
|
||||
*
|
||||
* @param int $id The OAuth2 application ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function id(int $id): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/user/applications/oauth2/{$id}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new OAuth2 application.
|
||||
*
|
||||
* @param string $appName The application name.
|
||||
* @param array $redirectUris The application redirect URIs.
|
||||
* @param bool $confidentialClient The confidentiality of the client (default: true).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $appName,
|
||||
array $redirectUris,
|
||||
bool $confidentialClient = true
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/applications/oauth2';
|
||||
|
||||
// Set the application data.
|
||||
$data = new \stdClass();
|
||||
$data->name = $appName;
|
||||
$data->redirect_uris = $redirectUris;
|
||||
$data->confidential_client = $confidentialClient;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an OAuth2 application by ID.
|
||||
*
|
||||
* @param int $id The OAuth2 application ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(int $id): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/user/applications/oauth2/{$id}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an OAuth2 application by ID, this includes regenerating the client secret.
|
||||
*
|
||||
* @param int $appId The OAuth2 application ID.
|
||||
* @param string $appName The application name.
|
||||
* @param array $redirectUris The application redirect URIs.
|
||||
* @param bool $confidentialClient The confidentiality of the client (default: true).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function update(
|
||||
int $appId,
|
||||
string $appName,
|
||||
array $redirectUris,
|
||||
bool $confidentialClient = true
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/user/applications/oauth2/{$appId}";
|
||||
|
||||
// Set the application data.
|
||||
$data = new \stdClass();
|
||||
$data->name = $appName;
|
||||
$data->redirect_uris = $redirectUris;
|
||||
$data->confidential_client = $confidentialClient;
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
94
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Emails.php
Normal file
94
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Emails.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\User;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea User Emails
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Emails extends Api
|
||||
{
|
||||
/**
|
||||
* List the authenticated user's email addresses.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/emails';
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add email addresses for the authenticated user.
|
||||
*
|
||||
* @param array $emails An array of email addresses to add.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function add(array $emails): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/emails';
|
||||
|
||||
// Create the request body.
|
||||
$body = new \stdClass();
|
||||
$body->emails = $emails;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($body)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete email addresses for the authenticated user.
|
||||
*
|
||||
* @param array $$emails An array of email addresses to delete.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(array $emails): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/emails';
|
||||
|
||||
// Build the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('emails', json_encode($emails));
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete($uri), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
54
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Followers.php
Normal file
54
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Followers.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\User;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea User Followers
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Followers extends Api
|
||||
{
|
||||
/**
|
||||
* List the authenticated user's followers.
|
||||
*
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/followers';
|
||||
|
||||
// Build the URL
|
||||
$url = $this->uri->get($path);
|
||||
$url->setVar('page', $page);
|
||||
$url->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($url)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
122
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Following.php
Normal file
122
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Following.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\User;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea User Following
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Following extends Api
|
||||
{
|
||||
/**
|
||||
* List the users that the authenticated user is following.
|
||||
*
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/following';
|
||||
|
||||
// Build the URL
|
||||
$url = $this->uri->get($path);
|
||||
$url->setVar('page', $page);
|
||||
$url->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($url)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a user is followed by the authenticated user.
|
||||
*
|
||||
* @param string $username The username to check.
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function check(string $username): bool
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/user/following/{$username}";
|
||||
|
||||
// Send the get request.
|
||||
$response = $this->http->get(
|
||||
$this->uri->get($path)
|
||||
);
|
||||
|
||||
// Check if the user is followed by the authenticated user.
|
||||
if ($response->code === 204)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow a user.
|
||||
*
|
||||
* @param string $username The username to follow.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function follow(string $username): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/user/following/{$username}";
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put(
|
||||
$this->uri->get($path), ''
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unfollow a user.
|
||||
*
|
||||
* @param string $username The username to unfollow.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function unfollow(string $username): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/user/following/{$username}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
173
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Gpg.php
Normal file
173
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Gpg.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\User;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea User Gpg
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Gpg extends Api
|
||||
{
|
||||
/**
|
||||
* Create a GPG key for the authenticated user.
|
||||
*
|
||||
* @param string $armoredPublicKey The armored public GPG key.
|
||||
* @param string|null $armoredSignature The armored signature (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function createGPGKey(
|
||||
string $armoredPublicKey,
|
||||
?string $armoredSignature = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/gpg_keys';
|
||||
|
||||
// Set the GPG key data.
|
||||
$data = array_filter([
|
||||
'armored_public_key' => $armoredPublicKey,
|
||||
'armored_signature' => $armoredSignature
|
||||
]);
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a GPG key for the authenticated user.
|
||||
*
|
||||
* @param int $id The GPG key ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(int $id): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/user/gpg_keys/{$id}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a token to verify.
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function token(): ?string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/gpg_key_token';
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify a GPG key.
|
||||
*
|
||||
* @param string $armoredPublicKey The armored public GPG key.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function verify(string $armoredPublicKey): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/gpg_key_verify';
|
||||
|
||||
// Set the GPG key data.
|
||||
$data = new \stdClass();
|
||||
$data->armoredPublicKey = $armoredPublicKey;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the authenticated user's GPG keys.
|
||||
*
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/gpg_keys';
|
||||
|
||||
// Build the URL
|
||||
$url = $this->uri->get($path);
|
||||
$url->setVar('page', $page);
|
||||
$url->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($url)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a GPG key for the authenticated user.
|
||||
*
|
||||
* @param int $id The GPG key ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function remove(int $id): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/user/gpg_keys/{$id}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
135
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Keys.php
Normal file
135
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Keys.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\User;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea User Keys
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Keys extends Api
|
||||
{
|
||||
/**
|
||||
* Create a public key for the authenticated user.
|
||||
*
|
||||
* @param string $title The title of the public key.
|
||||
* @param string $key The content of the public key.
|
||||
* @param bool $readOnly Optional. True if the key has only read access, false for read/write access.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $title,
|
||||
string $key,
|
||||
bool $readOnly = false
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/keys';
|
||||
|
||||
// Set the public key data.
|
||||
$data = new \stdClass();
|
||||
$data->title = $title;
|
||||
$data->key = $key;
|
||||
$data->read_only = $readOnly;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the authenticated user's public keys.
|
||||
*
|
||||
* @param string|null $fingerprint Optional. The fingerprint of the key.
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
?string $fingerprint = null,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/keys';
|
||||
|
||||
// Build the URI with query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
if ($fingerprint !== null) {
|
||||
$uri->setVar('fingerprint', $fingerprint);
|
||||
}
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a public key for the authenticated user.
|
||||
*
|
||||
* @param int $id The public key ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(int $id): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/user/keys/{$id}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a public key for the authenticated user.
|
||||
*
|
||||
* @param int $id The public key ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(int $id): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/user/keys/{$id}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
188
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Repos.php
Normal file
188
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Repos.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\User;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea User Repos
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Repos extends Api
|
||||
{
|
||||
/**
|
||||
* Create a repository for the authenticated user.
|
||||
*
|
||||
* @param string $name The name of the repository.
|
||||
* @param string|null $description Optional. The description of the repository.
|
||||
* @param bool $private Optional. Indicates whether the repository should be private or not.
|
||||
* @param bool $autoInit Optional. Indicates whether the repository should be auto-initialized.
|
||||
* @param string|null $defaultBranch Optional. The default branch of the repository.
|
||||
* @param string|null $gitignores Optional. Gitignores to use.
|
||||
* @param string|null $issueLabels Optional. Label-Set to use.
|
||||
* @param string|null $license Optional. License to use.
|
||||
* @param string|null $readme Optional. Readme of the repository to create.
|
||||
* @param bool|null $template Optional. Whether the repository is a template.
|
||||
* @param string|null $trustModel Optional. TrustModel of the repository.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $name,
|
||||
?string $description = null,
|
||||
bool $private = false,
|
||||
bool $autoInit = false,
|
||||
?string $defaultBranch = null,
|
||||
?string $gitignores = null,
|
||||
?string $issueLabels = null,
|
||||
?string $license = null,
|
||||
?string $readme = null,
|
||||
?bool $template = null,
|
||||
?string $trustModel = null
|
||||
): ?object {
|
||||
// Build the request path.
|
||||
$path = '/user/repos';
|
||||
|
||||
// Set the repository data.
|
||||
$data = new \stdClass();
|
||||
$data->name = $name;
|
||||
|
||||
if ($description !== null)
|
||||
{
|
||||
$data->description = $description;
|
||||
}
|
||||
|
||||
$data->private = $private;
|
||||
$data->auto_init = $autoInit;
|
||||
|
||||
if ($defaultBranch !== null)
|
||||
{
|
||||
$data->default_branch = $defaultBranch;
|
||||
}
|
||||
|
||||
if ($gitignores !== null)
|
||||
{
|
||||
$data->gitignores = $gitignores;
|
||||
}
|
||||
|
||||
if ($issueLabels !== null)
|
||||
{
|
||||
$data->issue_labels = $issueLabels;
|
||||
}
|
||||
|
||||
if ($license !== null)
|
||||
{
|
||||
$data->license = $license;
|
||||
}
|
||||
|
||||
if ($readme !== null)
|
||||
{
|
||||
$data->readme = $readme;
|
||||
}
|
||||
|
||||
if ($template !== null)
|
||||
{
|
||||
$data->template = $template;
|
||||
}
|
||||
|
||||
if ($trustModel !== null)
|
||||
{
|
||||
$data->trust_model = $trustModel;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the repos that the authenticated user owns.
|
||||
*
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/repos';
|
||||
|
||||
// Build the URI with query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Star the given repo for the authenticated user.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function star(string $owner, string $repo): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/user/starred/{$owner}/{$repo}";
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put(
|
||||
$this->uri->get($path), ''
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unstar the given repo for the authenticated user.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function unstar(string $owner, string $repo): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/user/starred/{$owner}/{$repo}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
124
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Settings.php
Normal file
124
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Settings.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\User;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea User Settings
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Settings extends Api
|
||||
{
|
||||
/**
|
||||
* Get user settings for the authenticated user.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/settings';
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update user settings for the authenticated user.
|
||||
*
|
||||
* @param string|null $description Optional. The description to update.
|
||||
* @param string|null $diffViewStyle Optional. The diff view style to update.
|
||||
* @param string|null $fullName Optional. The full name to update.
|
||||
* @param bool|null $hideActivity Optional. Whether to hide activity or not.
|
||||
* @param bool|null $hideEmail Optional. Whether to hide email or not.
|
||||
* @param string|null $language Optional. The language to update.
|
||||
* @param string|null $location Optional. The location to update.
|
||||
* @param string|null $theme Optional. The theme to update.
|
||||
* @param string|null $website Optional. The website to update.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function update(
|
||||
?string $description = null,
|
||||
?string $diffViewStyle = null,
|
||||
?string $fullName = null,
|
||||
?bool $hideActivity = null,
|
||||
?bool $hideEmail = null,
|
||||
?string $language = null,
|
||||
?string $location = null,
|
||||
?string $theme = null,
|
||||
?string $website = null
|
||||
): ?array
|
||||
{
|
||||
// Prepare settings data
|
||||
$settings = [];
|
||||
if ($description !== null)
|
||||
{
|
||||
$settings['description'] = $description;
|
||||
}
|
||||
if ($diffViewStyle !== null)
|
||||
{
|
||||
$settings['diff_view_style'] = $diffViewStyle;
|
||||
}
|
||||
if ($fullName !== null)
|
||||
{
|
||||
$settings['full_name'] = $fullName;
|
||||
}
|
||||
if ($hideActivity !== null)
|
||||
{
|
||||
$settings['hide_activity'] = $hideActivity;
|
||||
}
|
||||
if ($hideEmail !== null)
|
||||
{
|
||||
$settings['hide_email'] = $hideEmail;
|
||||
}
|
||||
if ($language !== null)
|
||||
{
|
||||
$settings['language'] = $language;
|
||||
}
|
||||
if ($location !== null)
|
||||
{
|
||||
$settings['location'] = $location;
|
||||
}
|
||||
if ($theme !== null)
|
||||
{
|
||||
$settings['theme'] = $theme;
|
||||
}
|
||||
if ($website !== null)
|
||||
{
|
||||
$settings['website'] = $website;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = '/user/settings';
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path),
|
||||
json_encode($settings)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
76
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Starred.php
Normal file
76
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Starred.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\User;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea User Starred
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Starred extends Api
|
||||
{
|
||||
/**
|
||||
* List the repos that the authenticated user has starred.
|
||||
*
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/starred';
|
||||
|
||||
// Build the URL
|
||||
$url = $this->uri->get($path);
|
||||
$url->setVar('page', $page);
|
||||
$url->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($url)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the authenticated user is starring the repo.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function check(string $owner, string $repo): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/user/starred/{$owner}/{$repo}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\User;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea User Subscriptions
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Subscriptions extends Api
|
||||
{
|
||||
/**
|
||||
* List repositories watched by the authenticated user.
|
||||
*
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/subscriptions';
|
||||
|
||||
// Build the URL
|
||||
$url = $this->uri->get($path);
|
||||
$url->setVar('page', $page);
|
||||
$url->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($url)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
54
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Teams.php
Normal file
54
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Teams.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\User;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea User Teams
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Teams extends Api
|
||||
{
|
||||
/**
|
||||
* List all the teams a user belongs to.
|
||||
*
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/teams';
|
||||
|
||||
// Build the URL
|
||||
$url = $this->uri->get($path);
|
||||
$url->setVar('page', $page);
|
||||
$url->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($url)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
96
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Times.php
Normal file
96
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Times.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\User;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea User Times
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Times extends Api
|
||||
{
|
||||
/**
|
||||
* List the current user's tracked times.
|
||||
*
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
* @param string|null $since Optional. Only show times updated after the given time (RFC 3339 format).
|
||||
* @param string|null $before Optional. Only show times updated before the given time (RFC 3339 format).
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
int $page = 1,
|
||||
int $limit = 10,
|
||||
?string $since = null,
|
||||
?string $before = null
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/times';
|
||||
|
||||
// Build the URL
|
||||
$url = $this->uri->get($path);
|
||||
$url->setVar('page', $page);
|
||||
$url->setVar('limit', $limit);
|
||||
|
||||
if ($since !== null)
|
||||
{
|
||||
$url->setVar('since', $since);
|
||||
}
|
||||
|
||||
if ($before !== null)
|
||||
{
|
||||
$url->setVar('before', $before);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($url)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of all existing stopwatches for the authenticated user.
|
||||
*
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function stopwatches(
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/user/stopwatches';
|
||||
|
||||
// Build the URL
|
||||
$url = $this->uri->get($path);
|
||||
$url->setVar('page', $page);
|
||||
$url->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($url)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
111
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Tokens.php
Normal file
111
libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Tokens.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Gitea\User;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea User Tokens
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Tokens extends Api
|
||||
{
|
||||
/**
|
||||
* List the authenticated user's access tokens.
|
||||
*
|
||||
* @param string $username The username of the authenticated user to retrieve access tokens for.
|
||||
* @param int|null $page Optional. Page number of results to return (1-based).
|
||||
* @param int|null $limit Optional. Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $username,
|
||||
?int $page = null,
|
||||
?int $limit = null
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/users/{$username}/tokens";
|
||||
|
||||
// Build the URL
|
||||
$url = $this->uri->get($path);
|
||||
if ($page !== null)
|
||||
{
|
||||
$url->setVar('page', $page);
|
||||
}
|
||||
if ($limit !== null)
|
||||
{
|
||||
$url->setVar('limit', $limit);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($url)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an access token for a user.
|
||||
*
|
||||
* @param string $username The username of the user to create the access token for.
|
||||
* @param string $name The name of the access token.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(string $username, string $name): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/users/{$username}/tokens";
|
||||
|
||||
// Set the token data
|
||||
$data = new \stdClass();
|
||||
$data->name = $name;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an access token for a user.
|
||||
*
|
||||
* @param string $username The username of the user to delete the access token for.
|
||||
* @param string $token The token to delete.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(string $username, string $token): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/users/{$username}/tokens/{$token}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
Reference in New Issue
Block a user