Release of v3.2.1-alpha1
Add power path override option on component level. Fix the sql build feature. #1032.
This commit is contained in:
9
libraries/vendor_jcb/.htaccess
Normal file
9
libraries/vendor_jcb/.htaccess
Normal file
@@ -0,0 +1,9 @@
|
||||
# Apache 2.4+
|
||||
<IfModule mod_authz_core.c>
|
||||
Require all denied
|
||||
</IfModule>
|
||||
|
||||
# Apache 2.0-2.2
|
||||
<IfModule !mod_authz_core.c>
|
||||
Deny from all
|
||||
</IfModule>
|
1
libraries/vendor_jcb/VDM.Joomla.FOF/index.html
Normal file
1
libraries/vendor_jcb/VDM.Joomla.FOF/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
300
libraries/vendor_jcb/VDM.Joomla.FOF/src/Encrypt/AES.php
Normal file
300
libraries/vendor_jcb/VDM.Joomla.FOF/src/Encrypt/AES.php
Normal file
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Encryption
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
* - Do not use this in new projects.
|
||||
* - Expect no updates.
|
||||
* - This is outdated.
|
||||
* - Not best choice for encryption.
|
||||
* - Use phpseclib/phpseclib version 3 Instead.
|
||||
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Encrypt;
|
||||
|
||||
|
||||
use VDM\Joomla\FOF\Encrypt\AES\AesInterface;
|
||||
use VDM\Joomla\FOF\Encrypt\AES\Mcrypt;
|
||||
use VDM\Joomla\FOF\Encrypt\AES\Openssl;
|
||||
use VDM\Joomla\FOF\Utils\Phpfunc;
|
||||
|
||||
|
||||
/**
|
||||
* AES encryption class
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
*/
|
||||
class AES
|
||||
{
|
||||
/**
|
||||
* The cipher key.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $key = '';
|
||||
|
||||
/**
|
||||
* The AES encryption adapter in use.
|
||||
*
|
||||
* @var AesInterface
|
||||
*/
|
||||
protected $adapter;
|
||||
|
||||
/**
|
||||
* Initialise the AES encryption object.
|
||||
*
|
||||
* Note: If the key is not 16 bytes this class will do a stupid key expansion for legacy reasons (produce the
|
||||
* SHA-256 of the key string and throw away half of it).
|
||||
*
|
||||
* @param string $key The encryption key (password). It can be a raw key (16 bytes) or a passphrase.
|
||||
* @param int $strength Bit strength (128, 192 or 256) – ALWAYS USE 128 BITS. THIS PARAMETER IS DEPRECATED.
|
||||
* @param string $mode Encryption mode. Can be ebc or cbc. We recommend using cbc.
|
||||
* @param Phpfunc $phpfunc For testing
|
||||
* @param string $priority Priority which adapter we should try first
|
||||
*/
|
||||
public function __construct($key, $strength = 128, $mode = 'cbc', Phpfunc $phpfunc = null, $priority = 'openssl')
|
||||
{
|
||||
if ($priority == 'openssl')
|
||||
{
|
||||
$this->adapter = new Openssl();
|
||||
|
||||
if (!$this->adapter->isSupported($phpfunc))
|
||||
{
|
||||
$this->adapter = new Mcrypt();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->adapter = new Mcrypt();
|
||||
|
||||
if (!$this->adapter->isSupported($phpfunc))
|
||||
{
|
||||
$this->adapter = new Openssl();
|
||||
}
|
||||
}
|
||||
|
||||
$this->adapter->setEncryptionMode($mode, $strength);
|
||||
$this->setPassword($key, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the password for this instance.
|
||||
*
|
||||
* WARNING: Do not use the legacy mode, it's insecure
|
||||
*
|
||||
* @param string $password The password (either user-provided password or binary encryption key) to use
|
||||
* @param bool $legacyMode True to use the legacy key expansion. We recommend against using it.
|
||||
*/
|
||||
public function setPassword($password, $legacyMode = false)
|
||||
{
|
||||
$this->key = $password;
|
||||
|
||||
$passLength = strlen($password);
|
||||
|
||||
if (function_exists('mb_strlen'))
|
||||
{
|
||||
$passLength = mb_strlen($password, 'ASCII');
|
||||
}
|
||||
|
||||
// Legacy mode was doing something stupid, requiring a key of 32 bytes. DO NOT USE LEGACY MODE!
|
||||
if ($legacyMode && ($passLength != 32))
|
||||
{
|
||||
// Legacy mode: use the sha256 of the password
|
||||
$this->key = hash('sha256', $password, true);
|
||||
// We have to trim or zero pad the password (we end up throwing half of it away in Rijndael-128 / AES...)
|
||||
$this->key = $this->adapter->resizeKey($this->key, $this->adapter->getBlockSize());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts a string using AES
|
||||
*
|
||||
* @param string $stringToEncrypt The plaintext to encrypt
|
||||
* @param bool $base64encoded Should I Base64-encode the result?
|
||||
*
|
||||
* @return string The cryptotext. Please note that the first 16 bytes of
|
||||
* the raw string is the IV (initialisation vector) which
|
||||
* is necessary for decoding the string.
|
||||
*/
|
||||
public function encryptString($stringToEncrypt, $base64encoded = true)
|
||||
{
|
||||
$blockSize = $this->adapter->getBlockSize();
|
||||
$randVal = new Randval();
|
||||
$iv = $randVal->generate($blockSize);
|
||||
|
||||
$key = $this->getExpandedKey($blockSize, $iv);
|
||||
$cipherText = $this->adapter->encrypt($stringToEncrypt, $key, $iv);
|
||||
|
||||
// Optionally pass the result through Base64 encoding
|
||||
if ($base64encoded)
|
||||
{
|
||||
$cipherText = base64_encode((string) $cipherText);
|
||||
}
|
||||
|
||||
// Return the result
|
||||
return $cipherText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypts a ciphertext into a plaintext string using AES
|
||||
*
|
||||
* @param string $stringToDecrypt The ciphertext to decrypt. The first 16 bytes of the raw string must contain
|
||||
* the IV (initialisation vector).
|
||||
* @param bool $base64encoded Should I Base64-decode the data before decryption?
|
||||
*
|
||||
* @return string The plain text string
|
||||
*/
|
||||
public function decryptString($stringToDecrypt, $base64encoded = true)
|
||||
{
|
||||
if ($base64encoded)
|
||||
{
|
||||
$stringToDecrypt = base64_decode($stringToDecrypt);
|
||||
}
|
||||
|
||||
// Extract IV
|
||||
$iv_size = $this->adapter->getBlockSize();
|
||||
$iv = substr($stringToDecrypt, 0, $iv_size);
|
||||
$key = $this->getExpandedKey($iv_size, $iv);
|
||||
|
||||
// Decrypt the data
|
||||
$plainText = $this->adapter->decrypt($stringToDecrypt, $key);
|
||||
|
||||
return $plainText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is AES encryption supported by this PHP installation?
|
||||
*
|
||||
* @param Phpfunc $phpfunc
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isSupported(Phpfunc $phpfunc = null)
|
||||
{
|
||||
if (!is_object($phpfunc) || !($phpfunc instanceof $phpfunc))
|
||||
{
|
||||
$phpfunc = new Phpfunc();
|
||||
}
|
||||
|
||||
$adapter = new Openssl();
|
||||
|
||||
if (!$adapter->isSupported($phpfunc))
|
||||
{
|
||||
$adapter = new Mcrypt();
|
||||
|
||||
if (!$adapter->isSupported($phpfunc))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('base64_encode'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('base64_decode'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('hash_algos'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$algorightms = $phpfunc->hash_algos();
|
||||
|
||||
if (!in_array('sha256', $algorightms))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $blockSize
|
||||
* @param $iv
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExpandedKey($blockSize, $iv)
|
||||
{
|
||||
$key = $this->key;
|
||||
$passLength = strlen($key);
|
||||
|
||||
if (function_exists('mb_strlen'))
|
||||
{
|
||||
$passLength = mb_strlen($key, 'ASCII');
|
||||
}
|
||||
|
||||
if ($passLength != $blockSize)
|
||||
{
|
||||
$iterations = 1000;
|
||||
$salt = $this->adapter->resizeKey($iv, 16);
|
||||
$key = hash_pbkdf2('sha256', $this->key, $salt, $iterations, $blockSize, true);
|
||||
}
|
||||
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('hash_pbkdf2'))
|
||||
{
|
||||
function hash_pbkdf2($algo, $password, $salt, $count, $length = 0, $raw_output = false)
|
||||
{
|
||||
if (!in_array(strtolower((string) $algo), hash_algos()))
|
||||
{
|
||||
trigger_error(__FUNCTION__ . '(): Unknown hashing algorithm: ' . $algo, E_USER_WARNING);
|
||||
}
|
||||
|
||||
if (!is_numeric($count))
|
||||
{
|
||||
trigger_error(__FUNCTION__ . '(): expects parameter 4 to be long, ' . gettype($count) . ' given', E_USER_WARNING);
|
||||
}
|
||||
|
||||
if (!is_numeric($length))
|
||||
{
|
||||
trigger_error(__FUNCTION__ . '(): expects parameter 5 to be long, ' . gettype($length) . ' given', E_USER_WARNING);
|
||||
}
|
||||
|
||||
if ($count <= 0)
|
||||
{
|
||||
trigger_error(__FUNCTION__ . '(): Iterations must be a positive integer: ' . $count, E_USER_WARNING);
|
||||
}
|
||||
|
||||
if ($length < 0)
|
||||
{
|
||||
trigger_error(__FUNCTION__ . '(): Length must be greater than or equal to 0: ' . $length, E_USER_WARNING);
|
||||
}
|
||||
|
||||
$output = '';
|
||||
$block_count = $length ? ceil($length / strlen(hash((string) $algo, '', $raw_output))) : 1;
|
||||
|
||||
for ($i = 1; $i <= $block_count; $i++)
|
||||
{
|
||||
$last = $xorsum = hash_hmac((string) $algo, $salt . pack('N', $i), (string) $password, true);
|
||||
|
||||
for ($j = 1; $j < $count; $j++)
|
||||
{
|
||||
$xorsum ^= ($last = hash_hmac((string) $algo, $last, (string) $password, true));
|
||||
}
|
||||
|
||||
$output .= $xorsum;
|
||||
}
|
||||
|
||||
if (!$raw_output)
|
||||
{
|
||||
$output = bin2hex($output);
|
||||
}
|
||||
|
||||
return $length ? substr($output, 0, $length) : $output;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Encryption
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
* - Do not use this in new projects.
|
||||
* - Expect no updates.
|
||||
* - This is outdated.
|
||||
* - Not best choice for encryption.
|
||||
* - Use phpseclib/phpseclib version 3 Instead.
|
||||
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Encrypt\AES;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract AES encryption class
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
*/
|
||||
abstract class Abstraction
|
||||
{
|
||||
/**
|
||||
* Trims or zero-pads a key / IV
|
||||
*
|
||||
* @param string $key The key or IV to treat
|
||||
* @param int $size The block size of the currently used algorithm
|
||||
*
|
||||
* @return null|string Null if $key is null, treated string of $size byte length otherwise
|
||||
*/
|
||||
public function resizeKey($key, $size)
|
||||
{
|
||||
if (empty($key))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$keyLength = strlen($key);
|
||||
|
||||
if (function_exists('mb_strlen'))
|
||||
{
|
||||
$keyLength = mb_strlen($key, 'ASCII');
|
||||
}
|
||||
|
||||
if ($keyLength == $size)
|
||||
{
|
||||
return $key;
|
||||
}
|
||||
|
||||
if ($keyLength > $size)
|
||||
{
|
||||
if (function_exists('mb_substr'))
|
||||
{
|
||||
return mb_substr($key, 0, $size, 'ASCII');
|
||||
}
|
||||
|
||||
return substr($key, 0, $size);
|
||||
}
|
||||
|
||||
return $key . str_repeat("\0", ($size - $keyLength));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns null bytes to append to the string so that it's zero padded to the specified block size
|
||||
*
|
||||
* @param string $string The binary string which will be zero padded
|
||||
* @param int $blockSize The block size
|
||||
*
|
||||
* @return string The zero bytes to append to the string to zero pad it to $blockSize
|
||||
*/
|
||||
protected function getZeroPadding($string, $blockSize)
|
||||
{
|
||||
$stringSize = strlen($string);
|
||||
|
||||
if (function_exists('mb_strlen'))
|
||||
{
|
||||
$stringSize = mb_strlen($string, 'ASCII');
|
||||
}
|
||||
|
||||
if ($stringSize == $blockSize)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($stringSize < $blockSize)
|
||||
{
|
||||
return str_repeat("\0", $blockSize - $stringSize);
|
||||
}
|
||||
|
||||
$paddingBytes = $stringSize % $blockSize;
|
||||
|
||||
return str_repeat("\0", $blockSize - $paddingBytes);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Encryption
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
* - Do not use this in new projects.
|
||||
* - Expect no updates.
|
||||
* - This is outdated.
|
||||
* - Not best choice for encryption.
|
||||
* - Use phpseclib/phpseclib version 3 Instead.
|
||||
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Encrypt\AES;
|
||||
|
||||
|
||||
use VDM\Joomla\FOF\Utils\Phpfunc;
|
||||
|
||||
|
||||
/**
|
||||
* Interface for AES encryption adapters
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
*/
|
||||
interface AesInterface
|
||||
{
|
||||
/**
|
||||
* Sets the AES encryption mode.
|
||||
*
|
||||
* WARNING: The strength is deprecated as it has a different effect in MCrypt and OpenSSL. MCrypt was abandoned in
|
||||
* 2003 before the Rijndael-128 algorithm was officially the Advanced Encryption Standard (AES). MCrypt also offered
|
||||
* Rijndael-192 and Rijndael-256 algorithms with different block sizes. These are NOT used in AES. OpenSSL, however,
|
||||
* implements AES correctly. It always uses a 128-bit (16 byte) block. The 192 and 256 bit strengths refer to the
|
||||
* key size, not the block size. Therefore using different strengths in MCrypt and OpenSSL will result in different
|
||||
* and incompatible ciphertexts.
|
||||
*
|
||||
* TL;DR: Always use $strength = 128!
|
||||
*
|
||||
* @param string $mode Choose between CBC (recommended) or ECB
|
||||
* @param int $strength Bit strength of the key (128, 192 or 256 bits). DEPRECATED. READ NOTES ABOVE.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function setEncryptionMode($mode = 'cbc', $strength = 128);
|
||||
|
||||
/**
|
||||
* Encrypts a string. Returns the raw binary ciphertext.
|
||||
*
|
||||
* WARNING: The plaintext is zero-padded to the algorithm's block size. You are advised to store the size of the
|
||||
* plaintext and trim the string to that length upon decryption.
|
||||
*
|
||||
* @param string $plainText The plaintext to encrypt
|
||||
* @param string $key The raw binary key (will be zero-padded or chopped if its size is different than the block size)
|
||||
* @param null|string $iv The initialization vector (for CBC mode algorithms)
|
||||
*
|
||||
* @return string The raw encrypted binary string.
|
||||
*/
|
||||
public function encrypt($plainText, $key, $iv = null);
|
||||
|
||||
/**
|
||||
* Decrypts a string. Returns the raw binary plaintext.
|
||||
*
|
||||
* $ciphertext MUST start with the IV followed by the ciphertext, even for EBC data (the first block of data is
|
||||
* dropped in EBC mode since there is no concept of IV in EBC).
|
||||
*
|
||||
* WARNING: The returned plaintext is zero-padded to the algorithm's block size during encryption. You are advised
|
||||
* to trim the string to the original plaintext's length upon decryption. While rtrim($decrypted, "\0") sounds
|
||||
* appealing it's NOT the correct approach for binary data (zero bytes may actually be part of your plaintext, not
|
||||
* just padding!).
|
||||
*
|
||||
* @param string $cipherText The ciphertext to encrypt
|
||||
* @param string $key The raw binary key (will be zero-padded or chopped if its size is different than the block size)
|
||||
*
|
||||
* @return string The raw unencrypted binary string.
|
||||
*/
|
||||
public function decrypt($cipherText, $key);
|
||||
|
||||
/**
|
||||
* Returns the encryption block size in bytes
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getBlockSize();
|
||||
|
||||
/**
|
||||
* Is this adapter supported?
|
||||
*
|
||||
* @param Phpfunc $phpfunc
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSupported(Phpfunc $phpfunc = null);
|
||||
}
|
||||
|
178
libraries/vendor_jcb/VDM.Joomla.FOF/src/Encrypt/AES/Mcrypt.php
Normal file
178
libraries/vendor_jcb/VDM.Joomla.FOF/src/Encrypt/AES/Mcrypt.php
Normal file
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Encryption
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
* - Do not use this in new projects.
|
||||
* - Expect no updates.
|
||||
* - This is outdated.
|
||||
* - Not best choice for encryption.
|
||||
* - Use phpseclib/phpseclib version 3 Instead.
|
||||
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Encrypt\AES;
|
||||
|
||||
|
||||
use VDM\Joomla\FOF\Encrypt\Randval;
|
||||
use VDM\Joomla\FOF\Utils\Phpfunc;
|
||||
use VDM\Joomla\FOF\Encrypt\AES\AesInterface;
|
||||
use VDM\Joomla\FOF\Encrypt\AES\Abstraction;
|
||||
|
||||
|
||||
/**
|
||||
* Mcrypt AES encryption class
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
*/
|
||||
class Mcrypt extends Abstraction implements AesInterface
|
||||
{
|
||||
protected $cipherType = MCRYPT_RIJNDAEL_128;
|
||||
|
||||
protected $cipherMode = MCRYPT_MODE_CBC;
|
||||
|
||||
public function setEncryptionMode($mode = 'cbc', $strength = 128)
|
||||
{
|
||||
switch ((int) $strength)
|
||||
{
|
||||
default:
|
||||
case '128':
|
||||
$this->cipherType = MCRYPT_RIJNDAEL_128;
|
||||
break;
|
||||
|
||||
case '192':
|
||||
$this->cipherType = MCRYPT_RIJNDAEL_192;
|
||||
break;
|
||||
|
||||
case '256':
|
||||
$this->cipherType = MCRYPT_RIJNDAEL_256;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (strtolower($mode))
|
||||
{
|
||||
case 'ecb':
|
||||
$this->cipherMode = MCRYPT_MODE_ECB;
|
||||
break;
|
||||
|
||||
default:
|
||||
case 'cbc':
|
||||
$this->cipherMode = MCRYPT_MODE_CBC;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function encrypt($plainText, $key, $iv = null)
|
||||
{
|
||||
$iv_size = $this->getBlockSize();
|
||||
$key = $this->resizeKey($key, $iv_size);
|
||||
$iv = $this->resizeKey($iv, $iv_size);
|
||||
|
||||
if (empty($iv))
|
||||
{
|
||||
$randVal = new Randval();
|
||||
$iv = $randVal->generate($iv_size);
|
||||
}
|
||||
|
||||
$cipherText = mcrypt_encrypt($this->cipherType, $key, $plainText, $this->cipherMode, $iv);
|
||||
$cipherText = $iv . $cipherText;
|
||||
|
||||
return $cipherText;
|
||||
}
|
||||
|
||||
public function decrypt($cipherText, $key)
|
||||
{
|
||||
$iv_size = $this->getBlockSize();
|
||||
$key = $this->resizeKey($key, $iv_size);
|
||||
$iv = substr($cipherText, 0, $iv_size);
|
||||
$cipherText = substr($cipherText, $iv_size);
|
||||
$plainText = mcrypt_decrypt($this->cipherType, $key, $cipherText, $this->cipherMode, $iv);
|
||||
|
||||
return $plainText;
|
||||
}
|
||||
|
||||
public function isSupported(Phpfunc $phpfunc = null)
|
||||
{
|
||||
if (!is_object($phpfunc) || !($phpfunc instanceof $phpfunc))
|
||||
{
|
||||
$phpfunc = new Phpfunc();
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('mcrypt_get_key_size'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('mcrypt_get_iv_size'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('mcrypt_create_iv'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('mcrypt_encrypt'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('mcrypt_decrypt'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('mcrypt_list_algorithms'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('hash'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('hash_algos'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$algorightms = $phpfunc->mcrypt_list_algorithms();
|
||||
|
||||
if (!in_array('rijndael-128', $algorightms))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!in_array('rijndael-192', $algorightms))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!in_array('rijndael-256', $algorightms))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$algorightms = $phpfunc->hash_algos();
|
||||
|
||||
if (!in_array('sha256', $algorightms))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getBlockSize()
|
||||
{
|
||||
return mcrypt_get_iv_size($this->cipherType, $this->cipherMode);
|
||||
}
|
||||
}
|
||||
|
193
libraries/vendor_jcb/VDM.Joomla.FOF/src/Encrypt/AES/Openssl.php
Normal file
193
libraries/vendor_jcb/VDM.Joomla.FOF/src/Encrypt/AES/Openssl.php
Normal file
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Encryption
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
* - Do not use this in new projects.
|
||||
* - Expect no updates.
|
||||
* - This is outdated.
|
||||
* - Not best choice for encryption.
|
||||
* - Use phpseclib/phpseclib version 3 Instead.
|
||||
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Encrypt\AES;
|
||||
|
||||
|
||||
use VDM\Joomla\FOF\Encrypt\Randval;
|
||||
use VDM\Joomla\FOF\Utils\Phpfunc;
|
||||
use VDM\Joomla\FOF\Encrypt\AES\AesInterface;
|
||||
use VDM\Joomla\FOF\Encrypt\AES\Abstraction;
|
||||
|
||||
|
||||
/**
|
||||
* Openssl AES encryption class
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
*/
|
||||
class Openssl extends Abstraction implements AesInterface
|
||||
{
|
||||
/**
|
||||
* The OpenSSL options for encryption / decryption
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $openSSLOptions = 0;
|
||||
|
||||
/**
|
||||
* The encryption method to use
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $method = 'aes-128-cbc';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->openSSLOptions = OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING;
|
||||
}
|
||||
|
||||
public function setEncryptionMode($mode = 'cbc', $strength = 128)
|
||||
{
|
||||
static $availableAlgorithms = null;
|
||||
static $defaultAlgo = 'aes-128-cbc';
|
||||
|
||||
if (!is_array($availableAlgorithms))
|
||||
{
|
||||
$availableAlgorithms = openssl_get_cipher_methods();
|
||||
|
||||
foreach (array('aes-256-cbc', 'aes-256-ecb', 'aes-192-cbc',
|
||||
'aes-192-ecb', 'aes-128-cbc', 'aes-128-ecb') as $algo)
|
||||
{
|
||||
if (in_array($algo, $availableAlgorithms))
|
||||
{
|
||||
$defaultAlgo = $algo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$strength = (int) $strength;
|
||||
$mode = strtolower($mode);
|
||||
|
||||
if (!in_array($strength, array(128, 192, 256)))
|
||||
{
|
||||
$strength = 256;
|
||||
}
|
||||
|
||||
if (!in_array($mode, array('cbc', 'ebc')))
|
||||
{
|
||||
$mode = 'cbc';
|
||||
}
|
||||
|
||||
$algo = 'aes-' . $strength . '-' . $mode;
|
||||
|
||||
if (!in_array($algo, $availableAlgorithms))
|
||||
{
|
||||
$algo = $defaultAlgo;
|
||||
}
|
||||
|
||||
$this->method = $algo;
|
||||
}
|
||||
|
||||
public function encrypt($plainText, $key, $iv = null)
|
||||
{
|
||||
$iv_size = $this->getBlockSize();
|
||||
$key = $this->resizeKey($key, $iv_size);
|
||||
$iv = $this->resizeKey($iv, $iv_size);
|
||||
|
||||
if (empty($iv))
|
||||
{
|
||||
$randVal = new Randval();
|
||||
$iv = $randVal->generate($iv_size);
|
||||
}
|
||||
|
||||
$plainText .= $this->getZeroPadding($plainText, $iv_size);
|
||||
$cipherText = openssl_encrypt($plainText, $this->method, $key, $this->openSSLOptions, $iv);
|
||||
$cipherText = $iv . $cipherText;
|
||||
|
||||
return $cipherText;
|
||||
}
|
||||
|
||||
public function decrypt($cipherText, $key)
|
||||
{
|
||||
$iv_size = $this->getBlockSize();
|
||||
$key = $this->resizeKey($key, $iv_size);
|
||||
$iv = substr($cipherText, 0, $iv_size);
|
||||
$cipherText = substr($cipherText, $iv_size);
|
||||
$plainText = openssl_decrypt($cipherText, $this->method, $key, $this->openSSLOptions, $iv);
|
||||
|
||||
return $plainText;
|
||||
}
|
||||
|
||||
public function isSupported(Phpfunc $phpfunc = null)
|
||||
{
|
||||
if (!is_object($phpfunc) || !($phpfunc instanceof $phpfunc))
|
||||
{
|
||||
$phpfunc = new Phpfunc();
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('openssl_get_cipher_methods'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('openssl_random_pseudo_bytes'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('openssl_cipher_iv_length'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('openssl_encrypt'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('openssl_decrypt'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('hash'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$phpfunc->function_exists('hash_algos'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$algorightms = $phpfunc->openssl_get_cipher_methods();
|
||||
|
||||
if (!in_array('aes-128-cbc', $algorightms))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$algorightms = $phpfunc->hash_algos();
|
||||
|
||||
if (!in_array('sha256', $algorightms))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBlockSize()
|
||||
{
|
||||
return openssl_cipher_iv_length($this->method);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
69
libraries/vendor_jcb/VDM.Joomla.FOF/src/Encrypt/Randval.php
Normal file
69
libraries/vendor_jcb/VDM.Joomla.FOF/src/Encrypt/Randval.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Encryption
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
* - Do not use this in new projects.
|
||||
* - Expect no updates.
|
||||
* - This is outdated.
|
||||
* - Not best choice for encryption.
|
||||
* - Use phpseclib/phpseclib version 3 Instead.
|
||||
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Encrypt;
|
||||
|
||||
|
||||
use VDM\Joomla\FOF\Encrypt\Randvalinterface;
|
||||
|
||||
|
||||
/**
|
||||
* Generates cryptographically-secure random values.
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
*/
|
||||
class Randval implements Randvalinterface
|
||||
{
|
||||
/**
|
||||
* Returns a cryptographically secure random value.
|
||||
*
|
||||
* Since we only run on PHP 7+ we can use random_bytes(), which internally uses a crypto safe PRNG. If the function
|
||||
* doesn't exist, Joomla already loads a secure polyfill.
|
||||
*
|
||||
* The reason this method exists is backwards compatibility with older versions of FOF. It also allows us to quickly
|
||||
* address any future issues if Joomla drops the polyfill or otherwise find problems with PHP's random_bytes() on
|
||||
* some weird host (you can't be too careful when releasing mass-distributed software).
|
||||
*
|
||||
* @param integer $bytes How many bytes to return
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generate($bytes = 32)
|
||||
{
|
||||
return random_bytes($bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate random bytes. Adapted from Joomla! 3.2.
|
||||
*
|
||||
* Since we only run on PHP 7+ we can use random_bytes(), which internally uses a crypto safe PRNG. If the function
|
||||
* doesn't exist, Joomla already loads a secure polyfill.
|
||||
*
|
||||
* The reason this method exists is backwards compatibility with older versions of FOF. It also allows us to quickly
|
||||
* address any future issues if Joomla drops the polyfill or otherwise find problems with PHP's random_bytes() on
|
||||
* some weird host (you can't be too careful when releasing mass-distributed software).
|
||||
*
|
||||
* @param integer $length Length of the random data to generate
|
||||
*
|
||||
* @return string Random binary data
|
||||
*/
|
||||
public function genRandomBytes($length = 32)
|
||||
{
|
||||
return random_bytes($length);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Encryption
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
* - Do not use this in new projects.
|
||||
* - Expect no updates.
|
||||
* - This is outdated.
|
||||
* - Not best choice for encryption.
|
||||
* - Use phpseclib/phpseclib version 3 Instead.
|
||||
* - Checkout the JCB Crypt Suite. <https://git.vdm.dev/joomla/phpseclib>
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Encrypt;
|
||||
|
||||
|
||||
/**
|
||||
* Randvalinterface
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
* @deprecated Use phpseclib/phpseclib version 3 Instead.
|
||||
*/
|
||||
interface Randvalinterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* Returns a cryptographically secure random value.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function generate();
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
44
libraries/vendor_jcb/VDM.Joomla.FOF/src/Utils/Phpfunc.php
Normal file
44
libraries/vendor_jcb/VDM.Joomla.FOF/src/Utils/Phpfunc.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* @package FrameworkOnFramework
|
||||
* @subpackage Utilities
|
||||
* @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
* @note This file has been modified by the Joomla! Project (and VDM) and no longer reflects the original work of its author.
|
||||
* @depreciation This was ported for the sake of those who have stuff encrypted with the FOF encryption suite.
|
||||
*/
|
||||
namespace VDM\Joomla\FOF\Utils;
|
||||
|
||||
|
||||
/**
|
||||
* Intercept calls to PHP functions.
|
||||
*
|
||||
* @method function_exists(string $function)
|
||||
* @method mcrypt_list_algorithms()
|
||||
* @method hash_algos()
|
||||
* @method extension_loaded(string $ext)
|
||||
* @method mcrypt_create_iv(int $bytes, int $source)
|
||||
* @method openssl_get_cipher_methods()
|
||||
*
|
||||
* @package FrameworkOnFramework
|
||||
* @since 1.0
|
||||
*/
|
||||
class Phpfunc
|
||||
{
|
||||
/**
|
||||
*
|
||||
* Magic call to intercept any function pass to it.
|
||||
*
|
||||
* @param string $func The function to call.
|
||||
*
|
||||
* @param array $args Arguments passed to the function.
|
||||
*
|
||||
* @return mixed The result of the function call.
|
||||
*
|
||||
*/
|
||||
public function __call($func, $args)
|
||||
{
|
||||
return call_user_func_array($func, $args);
|
||||
}
|
||||
}
|
||||
|
1
libraries/vendor_jcb/VDM.Joomla.FOF/src/Utils/index.html
Normal file
1
libraries/vendor_jcb/VDM.Joomla.FOF/src/Utils/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
1
libraries/vendor_jcb/VDM.Joomla.Gitea/index.html
Normal file
1
libraries/vendor_jcb/VDM.Joomla.Gitea/index.html
Normal file
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
154
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Abstraction/Api.php
Normal file
154
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Abstraction/Api.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?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\Abstraction;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Utilities\Http;
|
||||
use VDM\Joomla\Gitea\Utilities\Uri;
|
||||
use VDM\Joomla\Gitea\Utilities\Response;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Api
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class Api
|
||||
{
|
||||
/**
|
||||
* The Http class
|
||||
*
|
||||
* @var Http
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Http $http;
|
||||
|
||||
/**
|
||||
* The Uri class
|
||||
*
|
||||
* @var Uri
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Uri $uri;
|
||||
|
||||
/**
|
||||
* The Response class
|
||||
*
|
||||
* @var Response
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Response $response;
|
||||
|
||||
/**
|
||||
* The Url string
|
||||
*
|
||||
* @var string|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected ?string $url = null;
|
||||
|
||||
/**
|
||||
* The token string
|
||||
*
|
||||
* @var string|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected ?string $token = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Http $http The http class.
|
||||
* @param Uri $uri The uri class.
|
||||
* @param Response $response The response class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function __construct(Http $http, Uri $uri, Response $response)
|
||||
{
|
||||
$this->http = $http;
|
||||
$this->uri = $uri;
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load/Reload API.
|
||||
*
|
||||
* @param string|null $url The url.
|
||||
* @param token|null $token The token.
|
||||
* @param bool $backup The backup swapping switch.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function load_(?string $url = null, ?string $token = null, bool $backup = true): void
|
||||
{
|
||||
// we keep the old values
|
||||
// so we can reset after our call
|
||||
// for the rest of the container
|
||||
if ($backup)
|
||||
{
|
||||
if ($url !== null)
|
||||
{
|
||||
$this->url = $this->uri->getUrl();
|
||||
}
|
||||
|
||||
if ($token !== null)
|
||||
{
|
||||
$this->token = $this->http->getToken();
|
||||
}
|
||||
}
|
||||
|
||||
if ($url !== null)
|
||||
{
|
||||
$this->uri->setUrl($url);
|
||||
}
|
||||
|
||||
if ($token !== null)
|
||||
{
|
||||
$this->http->setToken($token);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset to previous toke, url it set
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function reset_(): void
|
||||
{
|
||||
if ($this->url !== null)
|
||||
{
|
||||
$this->uri->setUrl($this->url);
|
||||
$this->url = null;
|
||||
}
|
||||
|
||||
if ($this->token !== null)
|
||||
{
|
||||
$this->http->setToken($this->token);
|
||||
$this->token = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the API url
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function api()
|
||||
{
|
||||
return $this->uri->api();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
72
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Admin/Cron.php
Normal file
72
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Admin/Cron.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?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\Admin;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Admin Cron
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Cron extends Api
|
||||
{
|
||||
/**
|
||||
* List cron tasks.
|
||||
*
|
||||
* @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 = "/admin/cron";
|
||||
|
||||
// Set the 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)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run cron task.
|
||||
*
|
||||
* @param string $task The cron task to run.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function run(string $task): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/admin/cron/{$task}";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,51 @@
|
||||
<?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\Admin;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Admin Organizations
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Organizations extends Api
|
||||
{
|
||||
/**
|
||||
* List all organizations.
|
||||
*
|
||||
* @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 = "/admin/orgs";
|
||||
|
||||
// Set the 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)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
101
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Admin/Unadopted.php
Normal file
101
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Admin/Unadopted.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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\Admin;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Admin Unadopted
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Unadopted extends Api
|
||||
{
|
||||
/**
|
||||
* List unadopted repositories.
|
||||
*
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
* @param string $pattern Pattern of repositories to search for.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(int $page = 1, int $limit = 10, string $pattern = ''): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/admin/unadopted";
|
||||
|
||||
// Set the query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
if (!empty($pattern))
|
||||
{
|
||||
$uri->setVar('pattern', $pattern);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adopt unadopted files as a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function adopt(string $owner, string $repo): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/admin/unadopted/{$owner}/{$repo}";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), ''
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete unadopted files.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(string $owner, string $repo): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/admin/unadopted/{$owner}/{$repo}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
207
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Admin/Users.php
Normal file
207
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Admin/Users.php
Normal file
@@ -0,0 +1,207 @@
|
||||
<?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\Admin;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Admin Users
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Users extends Api
|
||||
{
|
||||
/**
|
||||
* List all users.
|
||||
*
|
||||
* @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 = "/admin/users";
|
||||
|
||||
// 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)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a user with extended options.
|
||||
*
|
||||
* @param string $loginName The user's login name.
|
||||
* @param string $email The user's email address.
|
||||
* @param string $password The user's password.
|
||||
* @param string|null $username The username.
|
||||
* @param string|null $fullName The user's full name (optional).
|
||||
* @param bool|null $mustChangePassword User must change password on next login (optional).
|
||||
* @param bool|null $restricted Restrict the user (optional).
|
||||
* @param bool|null $sendNotify Send a notification email to the user (optional).
|
||||
* @param int|null $sourceId Source ID (optional).
|
||||
* @param string|null $visibility The user's visibility (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $loginName,
|
||||
string $email,
|
||||
string $password,
|
||||
string $username,
|
||||
?string $fullName = null,
|
||||
?bool $mustChangePassword = null,
|
||||
?bool $restricted = null,
|
||||
?bool $sendNotify = null,
|
||||
?int $sourceId = null,
|
||||
?string $visibility = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/admin/users";
|
||||
|
||||
// Set the user data.
|
||||
$data = new \stdClass();
|
||||
$data->login_name = $loginName;
|
||||
$data->email = $email;
|
||||
$data->password = $password;
|
||||
$data->username = $username;
|
||||
$data->full_name = $fullName;
|
||||
$data->must_change_password = $mustChangePassword;
|
||||
$data->restricted = $restricted;
|
||||
$data->send_notify = $sendNotify;
|
||||
$data->source_id = $sourceId;
|
||||
$data->visibility = $visibility;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a user.
|
||||
*
|
||||
* @param string $username The user's display name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(string $username): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/admin/users/{$username}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit an existing user.
|
||||
*
|
||||
* @param string $username The user's display name.
|
||||
* @param string $loginName The user's login name.
|
||||
* @param int $sourceId The user's source ID.
|
||||
* @param bool $active Optional. Is the user active? Default: false.
|
||||
* @param bool $admin Optional. Is the user an admin? Default: false.
|
||||
* @param bool $allowCreateOrganization Optional. Can the user create an organization? Default: false.
|
||||
* @param bool $allowGitHook Optional. Can the user create Git hooks? Default: false.
|
||||
* @param bool $allowImportLocal Optional. Can the user import local repositories? Default: false.
|
||||
* @param string $description Optional. The user's description. Default: ''.
|
||||
* @param string $email Optional. The user's email address. Default: ''.
|
||||
* @param string $fullName Optional. The user's full name. Default: ''.
|
||||
* @param string $location Optional. The user's location. Default: ''.
|
||||
* @param int $maxRepoCreation Optional. Maximum repositories the user can create. Default: 0.
|
||||
* @param bool $mustChangePassword Optional. Must the user change their password? Default: false.
|
||||
* @param string $password Optional. The user's password. Default: ''.
|
||||
* @param bool $prohibitLogin Optional. Is the user's login prohibited? Default: false.
|
||||
* @param bool $restricted Optional. Is the user restricted? Default: false.
|
||||
* @param string $visibility Optional. The user's visibility setting. Default: ''.
|
||||
* @param string $website Optional. The user's website. Default: ''.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(
|
||||
string $username,
|
||||
string $loginName,
|
||||
int $sourceId,
|
||||
bool $active = false,
|
||||
bool $admin = false,
|
||||
bool $allowCreateOrganization = false,
|
||||
bool $allowGitHook = false,
|
||||
bool $allowImportLocal = false,
|
||||
string $description = '',
|
||||
string $email = '',
|
||||
string $fullName = '',
|
||||
string $location = '',
|
||||
int $maxRepoCreation = 0,
|
||||
bool $mustChangePassword = false,
|
||||
string $password = '',
|
||||
bool $prohibitLogin = false,
|
||||
bool $restricted = false,
|
||||
string $visibility = '',
|
||||
string $website = ''
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/admin/users/{$username}";
|
||||
|
||||
// Set the data.
|
||||
$data = [
|
||||
'login_name' => $loginName,
|
||||
'source_id' => $sourceId,
|
||||
'active' => $active,
|
||||
'admin' => $admin,
|
||||
'allow_create_organization' => $allowCreateOrganization,
|
||||
'allow_git_hook' => $allowGitHook,
|
||||
'allow_import_local' => $allowImportLocal,
|
||||
'description' => $description,
|
||||
'email' => $email,
|
||||
'full_name' => $fullName,
|
||||
'location' => $location,
|
||||
'max_repo_creation' => $maxRepoCreation,
|
||||
'must_change_password' => $mustChangePassword,
|
||||
'password' => $password,
|
||||
'prohibit_login' => $prohibitLogin,
|
||||
'restricted' => $restricted,
|
||||
'visibility' => $visibility,
|
||||
'website' => $website
|
||||
];
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,86 @@
|
||||
<?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\Admin\Users;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Admin Users Keys
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Keys extends Api
|
||||
{
|
||||
/**
|
||||
* Add a public key on behalf of a user.
|
||||
*
|
||||
* @param string $userName The user's display name.
|
||||
* @param string $publicKey The public key to add.
|
||||
* @param string $keyTitle Title of the key to add.
|
||||
* @param bool $readOnly Whether the key has only read access or read/write (optional).
|
||||
* @param string|null $description Description of the key (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function add(
|
||||
string $userName,
|
||||
string $publicKey,
|
||||
string $keyTitle,
|
||||
bool $readOnly = false,
|
||||
?string $description = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/admin/users/{$userName}/keys";
|
||||
|
||||
// Set the key data.
|
||||
$data = new \stdClass();
|
||||
$data->key = $publicKey;
|
||||
$data->title = $keyTitle;
|
||||
$data->read_only = $readOnly;
|
||||
$data->description = $description;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a user's public key.
|
||||
*
|
||||
* @param string $username The user's display name.
|
||||
* @param int $id The public key ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(string $username, int $id): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/admin/users/{$username}/keys/{$id}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,70 @@
|
||||
<?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\Admin\Users;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Admin Users Organization
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Organization extends Api
|
||||
{
|
||||
/**
|
||||
* Create an organization on behalf of a user.
|
||||
*
|
||||
* @param string $username The user's display name.
|
||||
* @param string $fullName The organization full name.
|
||||
* @param string|null $description The organization description (optional).
|
||||
* @param string|null $location The organization location (optional).
|
||||
* @param bool $repoAdminChangeTeamAccess Whether repo admin can change team access (optional).
|
||||
* @param string $visibility The organization visibility (optional).
|
||||
* @param string|null $website The organization website (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $username,
|
||||
string $fullName,
|
||||
?string $description = null,
|
||||
?string $location = null,
|
||||
bool $repoAdminChangeTeamAccess = false,
|
||||
string $visibility = 'public',
|
||||
?string $website = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/admin/users/{$username}/orgs";
|
||||
|
||||
// Set the organization data.
|
||||
$data = new \stdClass();
|
||||
$data->full_name = $fullName;
|
||||
$data->description = $description;
|
||||
$data->location = $location;
|
||||
$data->repo_admin_change_team_access = $repoAdminChangeTeamAccess;
|
||||
$data->visibility = $visibility;
|
||||
$data->website = $website;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,85 @@
|
||||
<?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\Admin\Users;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Admin Users Repository
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Repository extends Api
|
||||
{
|
||||
/**
|
||||
* Create a repository on behalf of a user.
|
||||
*
|
||||
* @param string $username The user's display name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string|null $description The repository description (optional).
|
||||
* @param bool $auto_init Whether the repository should be auto-initialized? (optional).
|
||||
* @param string|null $default_branch Default branch of the repository (optional).
|
||||
* @param string|null $gitignores Gitignores to use (optional).
|
||||
* @param string|null $issue_labels Label-Set to use (optional).
|
||||
* @param string|null $license License to use (optional).
|
||||
* @param bool $private Whether the repository is private (optional).
|
||||
* @param string|null $readme Readme of the repository to create (optional).
|
||||
* @param bool $template Whether the repository is template (optional).
|
||||
* @param string|null $trust_model TrustModel of the repository (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $username,
|
||||
string $repoName,
|
||||
?string $description = null,
|
||||
bool $auto_init = false,
|
||||
?string $default_branch = null,
|
||||
?string $gitignores = null,
|
||||
?string $issue_labels = null,
|
||||
?string $license = null,
|
||||
bool $private = false,
|
||||
?string $readme = null,
|
||||
bool $template = false,
|
||||
?string $trust_model = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/admin/users/{$username}/repos";
|
||||
|
||||
// Set the repository data.
|
||||
$data = new \stdClass();
|
||||
$data->name = $repoName;
|
||||
$data->description = $description;
|
||||
$data->auto_init = $auto_init;
|
||||
$data->default_branch = $default_branch;
|
||||
$data->gitignores = $gitignores;
|
||||
$data->issue_labels = $issue_labels;
|
||||
$data->license = $license;
|
||||
$data->private = $private;
|
||||
$data->readme = $readme;
|
||||
$data->template = $template;
|
||||
$data->trust_model = $trust_model;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
97
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Factory.php
Normal file
97
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Factory.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use VDM\Joomla\Gitea\Service\Utilities;
|
||||
use VDM\Joomla\Gitea\Service\Jcb;
|
||||
use VDM\Joomla\Gitea\Service\Settings;
|
||||
use VDM\Joomla\Gitea\Service\Organization;
|
||||
use VDM\Joomla\Gitea\Service\User;
|
||||
use VDM\Joomla\Gitea\Service\Repository;
|
||||
use VDM\Joomla\Gitea\Service\Package;
|
||||
use VDM\Joomla\Gitea\Service\Issue;
|
||||
use VDM\Joomla\Gitea\Service\Notifications;
|
||||
use VDM\Joomla\Gitea\Service\Miscellaneous;
|
||||
use VDM\Joomla\Gitea\Service\Admin;
|
||||
use VDM\Joomla\Interfaces\FactoryInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Gitea Factory
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class Factory implements FactoryInterface
|
||||
{
|
||||
/**
|
||||
* Global Package Container
|
||||
*
|
||||
* @var Container
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected static $container = null;
|
||||
|
||||
/**
|
||||
* Get any class from the package container
|
||||
*
|
||||
* @param string $key The container class key
|
||||
*
|
||||
* @return Mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static function _($key)
|
||||
{
|
||||
return self::getContainer()->get($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the global package container
|
||||
*
|
||||
* @return Container
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public static function getContainer(): Container
|
||||
{
|
||||
if (!self::$container)
|
||||
{
|
||||
self::$container = self::createContainer();
|
||||
}
|
||||
|
||||
return self::$container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a container object
|
||||
*
|
||||
* @return Container
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected static function createContainer(): Container
|
||||
{
|
||||
return (new Container())
|
||||
->registerServiceProvider(new Utilities())
|
||||
->registerServiceProvider(new Jcb())
|
||||
->registerServiceProvider(new Settings())
|
||||
->registerServiceProvider(new Organization())
|
||||
->registerServiceProvider(new User())
|
||||
->registerServiceProvider(new Repository())
|
||||
->registerServiceProvider(new Package())
|
||||
->registerServiceProvider(new Issue())
|
||||
->registerServiceProvider(new Notifications())
|
||||
->registerServiceProvider(new Miscellaneous())
|
||||
->registerServiceProvider(new Admin());
|
||||
}
|
||||
|
||||
}
|
||||
|
406
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue.php
Normal file
406
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue.php
Normal file
@@ -0,0 +1,406 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Issue
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Issue extends Api
|
||||
{
|
||||
/**
|
||||
* List a repository's issues.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param string $state The state of the issues to get, defaults to 'open'.
|
||||
* @param int $page The page to get, defaults to null.
|
||||
* @param int $limit The number of issues per page, defaults to null.
|
||||
* @param string|null $labels Comma-separated list of labels, defaults to null.
|
||||
* @param string|null $q The search string, defaults to null.
|
||||
* @param string|null $type The type to filter by (issues/pulls), defaults to null.
|
||||
* @param string|null $milestones Comma-separated list of milestone names or IDs, defaults to null.
|
||||
* @param string|null $since Only show items updated after the given time, defaults to null.
|
||||
* @param string|null $before Only show items updated before the given time, defaults to null.
|
||||
* @param string|null $createdBy Only show items created by the given user, defaults to null.
|
||||
* @param string|null $assignedBy Only show items assigned to the given user, defaults to null.
|
||||
* @param string|null $mentionedBy Only show items where the given user is mentioned, defaults to null.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $state = 'open',
|
||||
int $page = 1,
|
||||
int $limit = 10,
|
||||
?string $labels = null,
|
||||
?string $q = null,
|
||||
?string $type = null,
|
||||
?string $milestones = null,
|
||||
?string $since = null,
|
||||
?string $before = null,
|
||||
?string $createdBy = null,
|
||||
?string $assignedBy = null,
|
||||
?string $mentionedBy = null
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues";
|
||||
|
||||
// Build the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set the query parameters
|
||||
$uri->setVar('state', $state);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
$uri->setVar('labels', $labels);
|
||||
$uri->setVar('q', $q);
|
||||
$uri->setVar('type', $type);
|
||||
$uri->setVar('milestones', $milestones);
|
||||
$uri->setVar('since', $since);
|
||||
$uri->setVar('before', $before);
|
||||
$uri->setVar('created_by', $createdBy);
|
||||
$uri->setVar('assigned_by', $assignedBy);
|
||||
$uri->setVar('mentioned_by', $mentionedBy);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo, int $index): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an issue. If using deadline only the date will be taken into account, and time of day ignored.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param string $issueTitle The issue title.
|
||||
* @param array|null $assignees The array of assignees, defaults to null.
|
||||
* @param string|null $issueBody The issue body, defaults to null.
|
||||
* @param bool|null $closed If the issue is closed, defaults to null.
|
||||
* @param string|null $dueDate The deadline for the issue, format: "YYYY-MM-DD", defaults to null.
|
||||
* @param array|null $labelIds The array of label IDs to attach to the issue, defaults to null.
|
||||
* @param int|null $milestoneId The milestone ID, defaults to null.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $issueTitle,
|
||||
?array $assignees = null,
|
||||
?string $issueBody = null,
|
||||
?bool $closed = null,
|
||||
?string $dueDate = null,
|
||||
?array $labelIds = null,
|
||||
?int $milestoneId = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues";
|
||||
|
||||
// Build the request data.
|
||||
$data = new \stdClass();
|
||||
$data->title = $issueTitle;
|
||||
$data->body = $issueBody;
|
||||
$data->assignees = $assignees;
|
||||
$data->closed = $closed;
|
||||
$data->due_date = $dueDate;
|
||||
$data->labels = $labelIds;
|
||||
$data->milestone = $milestoneId;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for issues across the repositories that the user has access to.
|
||||
*
|
||||
* @param string $q Search query.
|
||||
* @param int $page Page number (default 1).
|
||||
* @param int $limit Page size (default 10, max 50).
|
||||
* @param string|null $state Issue state (default open).
|
||||
* @param string|null $labels Label filter, comma-separated.
|
||||
* @param string|null $milestones Milestone filter, comma-separated.
|
||||
* @param int|null $priorityRepoId Repository to prioritize in the results.
|
||||
* @param string|null $type Filter by type (issues/pulls).
|
||||
* @param string|null $since Only show notifications updated after the given time (RFC 3339 format).
|
||||
* @param string|null $before Only show notifications updated before the given time (RFC 3339 format).
|
||||
* @param bool|null $assigned Filter assigned to you (default false).
|
||||
* @param bool|null $created Filter created by you (default false).
|
||||
* @param bool|null $mentioned Filter mentioning you (default false).
|
||||
* @param bool|null $reviewRequested Filter pulls requesting your review (default false).
|
||||
* @param string|null $owner Filter by owner.
|
||||
* @param string|null $team Filter by team (requires organization owner parameter).
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function search(
|
||||
string $q,
|
||||
int $page = 1,
|
||||
int $limit = 10,
|
||||
?string $state = 'open',
|
||||
?string $labels = null,
|
||||
?string $milestones = null,
|
||||
?int $priorityRepoId = null,
|
||||
?string $type = null,
|
||||
?string $since = null,
|
||||
?string $before = null,
|
||||
?bool $assigned = null,
|
||||
?bool $created = null,
|
||||
?bool $mentioned = null,
|
||||
?bool $reviewRequested = null,
|
||||
?string $owner = null,
|
||||
?string $team = null
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/issues/search";
|
||||
|
||||
// Set the URL parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('q', $q);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
$uri->setVar('state', $state);
|
||||
|
||||
if ($labels !== null)
|
||||
{
|
||||
$uri->setVar('labels', $labels);
|
||||
}
|
||||
|
||||
if ($milestones !== null)
|
||||
{
|
||||
$uri->setVar('milestones', $milestones);
|
||||
}
|
||||
|
||||
if ($priorityRepoId !== null)
|
||||
{
|
||||
$uri->setVar('priority_repo_id', $priorityRepoId);
|
||||
}
|
||||
|
||||
if ($type !== null)
|
||||
{
|
||||
$uri->setVar('type', $type);
|
||||
}
|
||||
|
||||
if ($since !== null)
|
||||
{
|
||||
$uri->setVar('since', $since);
|
||||
}
|
||||
|
||||
if ($before !== null)
|
||||
{
|
||||
$uri->setVar('before', $before);
|
||||
}
|
||||
|
||||
if ($assigned !== null)
|
||||
{
|
||||
$uri->setVar('assigned', $assigned);
|
||||
}
|
||||
|
||||
if ($created !== null)
|
||||
{
|
||||
$uri->setVar('created', $created);
|
||||
}
|
||||
|
||||
if ($mentioned !== null)
|
||||
{
|
||||
$uri->setVar('mentioned', $mentioned);
|
||||
}
|
||||
|
||||
if ($reviewRequested !== null)
|
||||
{
|
||||
$uri->setVar('review_requested', $reviewRequested);
|
||||
}
|
||||
|
||||
if ($owner !== null)
|
||||
{
|
||||
$uri->setVar('owner', $owner);
|
||||
}
|
||||
|
||||
if ($team !== null)
|
||||
{
|
||||
$uri->setVar('team', $team);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param string|null $assignee The assignee, defaults to null.
|
||||
* @param array|null $assignees The assignees, defaults to null.
|
||||
* @param string|null $body The issue body, defaults to null.
|
||||
* @param string|null $dueDate The due date, defaults to null.
|
||||
* @param int|null $milestone The milestone, defaults to null.
|
||||
* @param string|null $ref The reference, defaults to null.
|
||||
* @param string|null $state The issue state, defaults to null.
|
||||
* @param string|null $title The issue title, defaults to null.
|
||||
* @param bool|null $unsetDueDate The flag to unset due date, defaults to null.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
?string $assignee = null,
|
||||
?array $assignees = null,
|
||||
?string $body = null,
|
||||
?string $dueDate = null,
|
||||
?int $milestone = null,
|
||||
?string $ref = null,
|
||||
?string $state = null,
|
||||
?string $title = null,
|
||||
?bool $unsetDueDate = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}";
|
||||
|
||||
// Prepare the issue data.
|
||||
$editIssueData = new \stdClass();
|
||||
|
||||
if ($assignee !== null || $assignees !== null)
|
||||
{
|
||||
$editIssueData->assignee = new \stdClass();
|
||||
|
||||
if ($assignee !== null)
|
||||
{
|
||||
$editIssueData->assignee->name = $assignee;
|
||||
}
|
||||
|
||||
if ($assignees !== null)
|
||||
{
|
||||
$editIssueData->assignee->names = $assignees;
|
||||
}
|
||||
}
|
||||
|
||||
if ($body !== null)
|
||||
{
|
||||
$editIssueData->body = $body;
|
||||
}
|
||||
|
||||
if ($dueDate !== null || $unsetDueDate !== null)
|
||||
{
|
||||
$editIssueData->dueDate = new \stdClass();
|
||||
|
||||
if ($dueDate !== null)
|
||||
{
|
||||
$editIssueData->dueDate->date = $dueDate;
|
||||
}
|
||||
|
||||
if ($unsetDueDate !== null)
|
||||
{
|
||||
$editIssueData->dueDate->unset = $unsetDueDate;
|
||||
}
|
||||
}
|
||||
|
||||
if ($milestone !== null)
|
||||
{
|
||||
$editIssueData->milestone = $milestone;
|
||||
}
|
||||
|
||||
if ($ref !== null)
|
||||
{
|
||||
$editIssueData->ref = $ref;
|
||||
}
|
||||
|
||||
if ($state !== null)
|
||||
{
|
||||
$editIssueData->state = $state;
|
||||
}
|
||||
|
||||
if ($title !== null)
|
||||
{
|
||||
$editIssueData->title = $title;
|
||||
}
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path), json_encode($editIssueData)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(string $owner, string $repo, int $index): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
176
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue/Comments.php
Normal file
176
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue/Comments.php
Normal file
@@ -0,0 +1,176 @@
|
||||
<?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\Issue;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Issue Comments
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Comments extends Api
|
||||
{
|
||||
/**
|
||||
* List all comments on an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param int $page The page number to get, defaults to 1.
|
||||
* @param int $limit The number of comments per page, defaults to 10.
|
||||
* @param string|null $since The date-time since when to get comments, defaults to null.
|
||||
* @param string|null $before The date-time before when to get comments, defaults to null.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $page = 1,
|
||||
int $limit = 10,
|
||||
?string $since = null,
|
||||
?string $before = null
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/comments";
|
||||
|
||||
// Build the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Set the 'since' and 'before' parameters if not null.
|
||||
if ($since !== null)
|
||||
{
|
||||
$uri->setVar('since', $since);
|
||||
}
|
||||
if ($before !== null)
|
||||
{
|
||||
$uri->setVar('before', $before);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a comment.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $commentId The comment ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo, int $commentId): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/comments/{$commentId}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a comment.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $commentId The comment ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(string $owner, string $repo, int $commentId): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/comments/{$commentId}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a comment.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $commentId The comment ID.
|
||||
* @param string $commentBody The new comment body.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(string $owner, string $repo, int $commentId, string $commentBody): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/comments/{$commentId}";
|
||||
|
||||
// Build the request data.
|
||||
$data = new \stdClass();
|
||||
$data->body = $commentBody;
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a comment to an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $issueIndex The issue index.
|
||||
* @param string $commentBody The comment body.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function add(string $owner, string $repo, int $issueIndex, string $commentBody): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$issueIndex}/comments";
|
||||
|
||||
// Build the request data.
|
||||
$data = new \stdClass();
|
||||
$data->body = $commentBody;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
54
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue/Deadline.php
Normal file
54
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue/Deadline.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\Issue;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Issue Deadline
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Deadline extends Api
|
||||
{
|
||||
/**
|
||||
* Set an issue deadline.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param string|null $dueDate The deadline date string in the format YYYY-MM-DD or null to delete the deadline.
|
||||
*
|
||||
* @return object
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function set(string $owner, string $repo, int $index, ?string $dueDate): object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/deadline";
|
||||
|
||||
// Build the request data.
|
||||
$data = new \stdClass();
|
||||
$data->due_date = $dueDate;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
181
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue/Labels.php
Normal file
181
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue/Labels.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?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\Issue;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Issue Labels
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Labels extends Api
|
||||
{
|
||||
/**
|
||||
* Get all of a repository's labels.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(string $owner, string $repo, int $page = 1, int $limit = 10): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/labels";
|
||||
|
||||
// Get the URI object with the request path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the page and limit query parameters if provided.
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an issue's labels.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo, int $index): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/labels";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace an issue's labels.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param array $labels An array of labels to replace the current issue labels.
|
||||
*
|
||||
* @return object
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function replace(string $owner, string $repo, int $index, array $labels): object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/labels";
|
||||
|
||||
// Build the request data.
|
||||
$data = new \stdClass();
|
||||
$data->labels = $labels;
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a label to an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param array $labels An array of label IDs to add.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function add(string $owner, string $repo, int $index, array $labels): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/labels";
|
||||
|
||||
// Build the request data.
|
||||
$data = new \stdClass();
|
||||
$data->labels = $labels;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a label from an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param int $labelId The ID of the label to remove.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function remove(string $owner, string $repo, int $index, int $labelId): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/labels/{$labelId}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all labels from an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function clear(string $owner, string $repo, int $index): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/labels";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
230
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue/Milestones.php
Normal file
230
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue/Milestones.php
Normal file
@@ -0,0 +1,230 @@
|
||||
<?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\Issue;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Issue Milestones
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Milestones extends Api
|
||||
{
|
||||
/**
|
||||
* Create a milestone.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param string $title The title of the milestone.
|
||||
* @param string|null $description Optional. The description of the milestone.
|
||||
* @param string|null $dueOn Optional. The due date of the milestone.
|
||||
* @param string|null $state Optional. The state of the milestone. Default is 'open'.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $title,
|
||||
?string $description = null,
|
||||
?string $dueOn = null,
|
||||
?string $state = 'open'
|
||||
): ?object
|
||||
{
|
||||
// Set the lines data
|
||||
$data = new \stdClass();
|
||||
|
||||
// Set all the required data.
|
||||
$data->title = $title;
|
||||
|
||||
// Set all the optional data that has been provided.
|
||||
if ($description !== null)
|
||||
{
|
||||
$data->description = $description;
|
||||
}
|
||||
if ($dueOn !== null)
|
||||
{
|
||||
$data->due_on = $dueOn;
|
||||
}
|
||||
if ($state !== null)
|
||||
{
|
||||
$data->state = $state;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/milestones";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of a repository's opened milestones.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param string|null $state Optional. Milestone state. Recognized values are open, closed, and all. Defaults to "open".
|
||||
* @param string|null $name Optional. Filter by milestone name.
|
||||
* @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 $owner,
|
||||
string $repo,
|
||||
?string $state = 'open',
|
||||
?string $name = null,
|
||||
?int $page = null,
|
||||
?int $limit = null
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/milestones";
|
||||
|
||||
// Build the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('state', $state);
|
||||
if ($name !== null)
|
||||
{
|
||||
$uri->setVar('name', $name);
|
||||
}
|
||||
if ($page !== null)
|
||||
{
|
||||
$uri->setVar('page', $page);
|
||||
}
|
||||
if ($limit !== null)
|
||||
{
|
||||
$uri->setVar('limit', $limit);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a milestone.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param string $milestoneId The ID of the milestone.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo, string $milestoneId): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/milestones/{$milestoneId}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a milestone.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param string $milestoneId The ID of the milestone to delete.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(string $owner, string $repo, string $milestoneId): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/milestones/{$milestoneId}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a milestone.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param string $milestoneId The ID of the milestone to update.
|
||||
* @param string $title Optional. The new title of the milestone.
|
||||
* @param string $description Optional. The new description of the milestone.
|
||||
* @param string $dueOn Optional. The new due date of the milestone.
|
||||
* @param string $state Optional. The new state of the milestone.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function update(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $milestoneId,
|
||||
string $title = null,
|
||||
string $description = null,
|
||||
string $dueOn = null,
|
||||
string $state = null
|
||||
): ?object
|
||||
{
|
||||
// Set the lines data
|
||||
$data = new \stdClass();
|
||||
|
||||
// Set all the optional data that has been provided.
|
||||
if ($title !== null)
|
||||
{
|
||||
$data->title = $title;
|
||||
}
|
||||
if ($description !== null)
|
||||
{
|
||||
$data->description = $description;
|
||||
}
|
||||
if ($dueOn !== null)
|
||||
{
|
||||
$data->due_on = $dueOn;
|
||||
}
|
||||
if ($state !== null)
|
||||
{
|
||||
$data->state = $state;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/milestones/{$milestoneId}";
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
110
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue/Reactions.php
Normal file
110
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue/Reactions.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?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\Issue;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Issue Reactions
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Reactions extends Api
|
||||
{
|
||||
/**
|
||||
* Get a list reactions of an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param int $page The page to get, defaults to 1.
|
||||
* @param int $limit The number of reactions per page, defaults to 10.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(string $owner, string $repo, int $index, int $page = 1, int $limit = 10): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/reactions";
|
||||
|
||||
// Build the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set the URI variables.
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a reaction to an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param string $content The name of the reaction to add.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function add(string $owner, string $repo, int $index, string $content): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/reactions";
|
||||
|
||||
// Build the request data.
|
||||
$data = new \stdClass();
|
||||
$data->content = $content;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a reaction from an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param string $content The name of the reaction to remove.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function remove(string $owner, string $repo, int $index, string $content): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/reactions";
|
||||
|
||||
// Build the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('content', $content);
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete($uri), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,103 @@
|
||||
<?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\Issue\Reactions;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Issue Reactions Comment
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Comment extends Api
|
||||
{
|
||||
/**
|
||||
* Get a list of reactions from a comment of an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $commentId The comment ID.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(string $owner, string $repo, int $commentId): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/comments/{$commentId}/reactions";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a reaction to a comment of an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $commentId The comment ID.
|
||||
* @param string $content The reaction to add, e.g. "+1".
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function add(string $owner, string $repo, int $commentId, string $content): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/comments/{$commentId}/reactions";
|
||||
|
||||
// Build the request data.
|
||||
$data = new \stdClass();
|
||||
$data->content = $content;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a reaction from a comment of an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $commentId The comment ID.
|
||||
* @param string $content The reaction to remove, e.g. "+1".
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function remove(string $owner, string $repo, int $commentId, string $content): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/comments/{$commentId}/reactions";
|
||||
|
||||
// Build the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('content', $content);
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete($uri), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,67 @@
|
||||
<?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\Issue\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Issue Repository Comments
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Comments extends Api
|
||||
{
|
||||
/**
|
||||
* List all comments in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $page The page to get, defaults to 1.
|
||||
* @param int $limit The number of comments per page, defaults to 10.
|
||||
* @param string|null $since The date-time string to filter updated comments since, defaults to null.
|
||||
* @param string|null $before The date-time string to filter updated comments before, defaults to null.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(string $owner, string $repo, int $page = 1, int $limit = 10, ?string $since = null, ?string $before = null): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/comments";
|
||||
|
||||
// Build the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set the URI variables.
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
if ($since !== null)
|
||||
{
|
||||
$uri->setVar('since', $since);
|
||||
}
|
||||
|
||||
if ($before !== null)
|
||||
{
|
||||
$uri->setVar('before', $before);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,95 @@
|
||||
<?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\Issue;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Issue Stopwatch
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Stopwatch extends Api
|
||||
{
|
||||
/**
|
||||
* Start stopwatch on an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function start(string $owner, string $repo, int $index): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/stopwatch/start";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), ''
|
||||
), 201, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop an issue's existing stopwatch.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function stop(string $owner, string $repo, int $index): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/stopwatch/stop";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), ''
|
||||
), 201, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an issue's existing stopwatch.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(string $owner, string $repo, int $index): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/stopwatch/delete";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,137 @@
|
||||
<?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\Issue;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Issue Subscriptions
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Subscriptions extends Api
|
||||
{
|
||||
/**
|
||||
* Get users who subscribed on an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param int|null $page Optional. Page number of results to return (1-based).
|
||||
* @param int|null $limit Optional. Page size of results.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
?int $page = null,
|
||||
?int $limit = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/subscriptions";
|
||||
|
||||
// Set the query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
if ($page !== null)
|
||||
{
|
||||
$uri->setVar('page', $page);
|
||||
}
|
||||
if ($limit !== null)
|
||||
{
|
||||
$uri->setVar('limit', $limit);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user is subscribed to an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function check(string $owner, string $repo, int $index): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/subscriptions/check";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe user to issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param string $user The username to subscribe.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function subscribe(string $owner, string $repo, int $index, string $user): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/subscriptions/{$user}";
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get_(
|
||||
$this->http->put(
|
||||
$this->uri->get($path), ''
|
||||
), [200 => 'already subscribed', 201 => 'success']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe user from issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param string $user The username to unsubscribe.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function unsubscribe(string $owner, string $repo, int $index, string $user): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/subscriptions/{$user}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get_(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), [200 => 'already unsubscribed', 201 => 'success']
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
78
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue/Timeline.php
Normal file
78
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue/Timeline.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?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\Issue;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Issue Timeline
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Timeline extends Api
|
||||
{
|
||||
/**
|
||||
* List all comments and events on an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param string|null $since Optional. If provided, only comments updated since the specified time are returned.
|
||||
* @param int|null $page Optional. Page number of results to return (1-based).
|
||||
* @param int|null $limit Optional. Page size of results.
|
||||
* @param string|null $before Optional. If provided, only comments updated before the provided time are returned.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
?string $since = null,
|
||||
?int $page = null,
|
||||
?int $limit = null,
|
||||
?string $before = null
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/timeline";
|
||||
|
||||
// Set the query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
if ($since !== null)
|
||||
{
|
||||
$uri->setVar('since', $since);
|
||||
}
|
||||
if ($page !== null)
|
||||
{
|
||||
$uri->setVar('page', $page);
|
||||
}
|
||||
if ($limit !== null)
|
||||
{
|
||||
$uri->setVar('limit', $limit);
|
||||
}
|
||||
if ($before !== null)
|
||||
{
|
||||
$uri->setVar('before', $before);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
179
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue/Times.php
Normal file
179
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Issue/Times.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?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\Issue;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Issue Times
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Times extends Api
|
||||
{
|
||||
/**
|
||||
* List an issue's tracked times.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param string $user Optional. Filter by user.
|
||||
* @param string $since Optional. Show times updated after the given time.
|
||||
* @param string $before Optional. Show times updated before the given time.
|
||||
* @param int $page Optional. Page number of results to return (1-based).
|
||||
* @param int $limit Optional. Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
string $user = null,
|
||||
string $since = null,
|
||||
string $before = null,
|
||||
int $page = null,
|
||||
int $limit = null
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/times";
|
||||
|
||||
// Prepare the query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
if ($user !== null)
|
||||
{
|
||||
$uri->setVar('user', $user);
|
||||
}
|
||||
if ($since !== null)
|
||||
{
|
||||
$uri->setVar('since', $since);
|
||||
}
|
||||
if ($before !== null)
|
||||
{
|
||||
$uri->setVar('before', $before);
|
||||
}
|
||||
if ($page !== null)
|
||||
{
|
||||
$uri->setVar('page', $page);
|
||||
}
|
||||
if ($limit !== null)
|
||||
{
|
||||
$uri->setVar('limit', $limit);
|
||||
}
|
||||
|
||||
// Send the get request with the query parameters.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add tracked time to an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param int $time The tracked time in seconds.
|
||||
* @param string $created Optional. The date and time of the tracked time in RFC 3339 format.
|
||||
* @param string $userName Optional. User who spent the time.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function add(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $time,
|
||||
string $created = null,
|
||||
string $userName = null
|
||||
): ?object
|
||||
{
|
||||
// Set the lines data
|
||||
$data = new \stdClass();
|
||||
|
||||
// Set all the needed data.
|
||||
$data->time = $time;
|
||||
if ($created !== null)
|
||||
{
|
||||
$data->created = $created;
|
||||
}
|
||||
if ($userName !== null)
|
||||
{
|
||||
$data->user_name = $userName;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/times";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset a tracked time of an issue.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function reset(string $owner, string $repo, int $index): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/times";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete specific tracked time.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param int $index The issue index.
|
||||
* @param int $id The ID of the tracked time to delete.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(string $owner, string $repo, int $index, int $id): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/issues/{$index}/times/{$id}";
|
||||
|
||||
// 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>
|
162
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Labels.php
Normal file
162
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Labels.php
Normal file
@@ -0,0 +1,162 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Labels
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Labels extends Api
|
||||
{
|
||||
/**
|
||||
* Create a label.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param string $labelName The name of the label.
|
||||
* @param string $labelColor The color of the label, in hexadecimal format with the leading '#'.
|
||||
* @param string $labelDescription Optional. The description of the label.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(string $owner, string $repo, string $labelName, string $labelColor, string $labelDescription = ''): ?object
|
||||
{
|
||||
// Set the lines data
|
||||
$data = new \stdClass();
|
||||
|
||||
// Set all the needed data.
|
||||
$data->name = $labelName;
|
||||
$data->color = $labelColor;
|
||||
if (!empty($labelDescription))
|
||||
{
|
||||
$data->description = $labelDescription;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/labels";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single label.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param string $id The ID of the label to retrieve.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo, string $id): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/labels/{$id}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a label.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param string $id The ID of the label to delete.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(string $owner, string $repo, string $id): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/labels/{$id}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a label.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repo name.
|
||||
* @param string $id The ID of the label to update.
|
||||
* @param string $labelName Optional. The new name of the label.
|
||||
* @param string $labelColor Optional. The new color of the label, in hexadecimal format without the leading '#'.
|
||||
* @param string $labelDescription Optional. The new description of the label.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function update(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $id,
|
||||
string $labelName = '',
|
||||
string $labelColor = '',
|
||||
string $labelDescription = ''
|
||||
): ?object
|
||||
{
|
||||
// Set the lines data
|
||||
$data = new \stdClass();
|
||||
|
||||
// Set all the optional data that has been provided.
|
||||
if (!empty($labelName))
|
||||
{
|
||||
$data->name = $labelName;
|
||||
}
|
||||
|
||||
if (!empty($labelColor))
|
||||
{
|
||||
$data->color = $labelColor;
|
||||
}
|
||||
|
||||
if (!empty($labelDescription))
|
||||
{
|
||||
$data->description = $labelDescription;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/labels/{$id}";
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,69 @@
|
||||
<?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\Miscellaneous;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Miscellaneous Activitypub
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Activitypub extends Api
|
||||
{
|
||||
/**
|
||||
* Returns the Person actor for a user.
|
||||
*
|
||||
* @param string $username The user's username.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $username): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/activitypub/user/{$username}";
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send to the user's inbox.
|
||||
*
|
||||
* @param string $username The user's username.
|
||||
* @param object $postData The post data.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function send(string $username, object $postData): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/activitypub/user/{$username}/inbox";
|
||||
|
||||
// Send the POST request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($postData)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,45 @@
|
||||
<?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\Miscellaneous;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Miscellaneous Gpg
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Gpg extends Api
|
||||
{
|
||||
/**
|
||||
* Get default signing-key.gpg.
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(): ?string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/signing-key.gpg";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,87 @@
|
||||
<?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\Miscellaneous;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Miscellaneous Markdown
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Markdown extends Api
|
||||
{
|
||||
/**
|
||||
* Render a markdown document as HTML.
|
||||
*
|
||||
* @param string $markdownText The markdown text to render.
|
||||
* @param bool $isWikiPage Is it a wiki page?
|
||||
* @param string $context Context to render.
|
||||
* @param string $mode Mode to render.
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function render(
|
||||
string $markdownText,
|
||||
bool $isWikiPage = false,
|
||||
string $context = 'string',
|
||||
string $mode = 'string'
|
||||
): ?string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/markdown";
|
||||
|
||||
// Set the markdown data.
|
||||
$data = new \stdClass();
|
||||
$data->Text = $markdownText;
|
||||
$data->Wiki = $isWikiPage;
|
||||
$data->Context = $context;
|
||||
$data->Mode = $mode;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data),
|
||||
['accept' => 'text/html']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render raw markdown as HTML.
|
||||
*
|
||||
* @param string $rawMarkdown The raw markdown text to render.
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function raw(string $rawMarkdown): ?string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/markdown/raw";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
$rawMarkdown,
|
||||
['Content-Type' => 'text/plain', 'accept' => 'text/html']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,45 @@
|
||||
<?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\Miscellaneous;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Miscellaneous NodeInfo
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class NodeInfo extends Api
|
||||
{
|
||||
/**
|
||||
* Returns the nodeinfo of the Gitea application.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/nodeinfo";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,45 @@
|
||||
<?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\Miscellaneous;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Miscellaneous Version
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Version extends Api
|
||||
{
|
||||
/**
|
||||
* Returns the version of the Gitea application.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/version";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
149
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Notifications.php
Normal file
149
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Notifications.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Notifications
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Notifications extends Api
|
||||
{
|
||||
/**
|
||||
* List user's notification threads.
|
||||
*
|
||||
* @param bool|null $all Show notifications marked as read (optional).
|
||||
* @param array|null $statusTypes Show notifications with the provided status types (optional).
|
||||
* @param array|null $subjectType Filter notifications by subject type (optional).
|
||||
* @param string|null $since Show notifications updated after the given time (optional).
|
||||
* @param string|null $before Show notifications updated before the given time (optional).
|
||||
* @param int $page Page number of results to return (optional).
|
||||
* @param int $limit Page size of results (optional).
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
?bool $all = null,
|
||||
?array $statusTypes = null,
|
||||
?array $subjectType = null,
|
||||
?string $since = null,
|
||||
?string $before = null,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/notifications";
|
||||
|
||||
// Configure the URI with query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
if ($all !== null)
|
||||
{
|
||||
$uri->setVar('all', $all);
|
||||
}
|
||||
if ($statusTypes !== null)
|
||||
{
|
||||
$uri->setVar('status-types', implode(',', $statusTypes));
|
||||
}
|
||||
if ($subjectType !== null)
|
||||
{
|
||||
$uri->setVar('subject-type', implode(',', $subjectType));
|
||||
}
|
||||
if ($since !== null)
|
||||
{
|
||||
$uri->setVar('since', $since);
|
||||
}
|
||||
if ($before !== null)
|
||||
{
|
||||
$uri->setVar('before', $before);
|
||||
}
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark notification threads as read, pinned, or unread.
|
||||
*
|
||||
* @param string|null $lastReadAt Describes the last point that notifications were checked (optional).
|
||||
* @param bool|null $all If true, mark all notifications on this repo (optional).
|
||||
* @param array|null $statusTypes Mark notifications with the provided status types (optional).
|
||||
* @param string|null $toStatus Status to mark notifications as (optional).
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function update(
|
||||
?string $lastReadAt = null,
|
||||
?bool $all = null,
|
||||
?array $statusTypes = null,
|
||||
?string $toStatus = null
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/notifications";
|
||||
|
||||
// Configure the URI with query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
if ($lastReadAt !== null)
|
||||
{
|
||||
$uri->setVar('last_read_at', $lastReadAt);
|
||||
}
|
||||
if ($all !== null)
|
||||
{
|
||||
$uri->setVar('all', $all);
|
||||
}
|
||||
if ($statusTypes !== null)
|
||||
{
|
||||
$uri->setVar('status-types', implode(',', $statusTypes));
|
||||
}
|
||||
if ($toStatus !== null)
|
||||
{
|
||||
$uri->setVar('to-status', $toStatus);
|
||||
}
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put($uri, ''), 205
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if unread notifications exist.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function check(): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/notifications/new";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,144 @@
|
||||
<?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\Notifications;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Notifications Repository
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Repository extends Api
|
||||
{
|
||||
/**
|
||||
* List user's notification threads on a specific repo.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param bool $all Show notifications marked as read.
|
||||
* @param array $statusTypes Show notifications with the provided status types.
|
||||
* @param array $subjectTypes Filter notifications by subject type.
|
||||
* @param string $since Show notifications updated after the given time.
|
||||
* @param string $before Show notifications updated before the given time.
|
||||
* @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(
|
||||
string $owner,
|
||||
string $repo,
|
||||
bool $all = false,
|
||||
array $statusTypes = [],
|
||||
array $subjectTypes = [],
|
||||
string $since = '',
|
||||
string $before = '',
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/notifications";
|
||||
|
||||
// Configure the URI with query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
if ($all)
|
||||
{
|
||||
$uri->setVar('all', $all);
|
||||
}
|
||||
|
||||
if (!empty($statusTypes))
|
||||
{
|
||||
$uri->setVar('status-types', implode(',', $statusTypes));
|
||||
}
|
||||
|
||||
if (!empty($subjectTypes))
|
||||
{
|
||||
$uri->setVar('subject-type', implode(',', $subjectTypes));
|
||||
}
|
||||
|
||||
if (!empty($since))
|
||||
{
|
||||
$uri->setVar('since', $since);
|
||||
}
|
||||
|
||||
if (!empty($before))
|
||||
{
|
||||
$uri->setVar('before', $before);
|
||||
}
|
||||
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark notification threads as read, pinned, or unread on a specific repo.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param bool|null $all Mark all notifications on this repo (optional).
|
||||
* @param array|null $statusTypes Mark notifications with the provided status types (optional).
|
||||
* @param string|null $toStatus Status to mark notifications as (optional).
|
||||
* @param string|null $lastReadAt Last point that notifications were checked (optional).
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function update(
|
||||
string $owner,
|
||||
string $repo,
|
||||
?bool $all = null,
|
||||
?array $statusTypes = null,
|
||||
?string $toStatus = null,
|
||||
?string $lastReadAt = null
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/notifications";
|
||||
|
||||
// Configure the URI with query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
if ($all !== null)
|
||||
{
|
||||
$uri->setVar('all', $all);
|
||||
}
|
||||
if ($statusTypes !== null)
|
||||
{
|
||||
$uri->setVar('status-types', implode(',', $statusTypes));
|
||||
}
|
||||
if ($toStatus !== null)
|
||||
{
|
||||
$uri->setVar('to-status', $toStatus);
|
||||
}
|
||||
if ($lastReadAt !== null)
|
||||
{
|
||||
$uri->setVar('last_read_at', $lastReadAt);
|
||||
}
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put($uri, ''), 205
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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\Notifications;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Notifications Thread
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Thread extends Api
|
||||
{
|
||||
/**
|
||||
* Get notification thread by ID.
|
||||
*
|
||||
* @param int $id The notification thread ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(int $id): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/notifications/threads/{$id}";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark notification threads as read, pinned, or unread by ID.
|
||||
*
|
||||
* @param int $id The notification thread ID.
|
||||
* @param string|null $lastReadAt Last point that notifications were checked (optional).
|
||||
* @param bool|null $all Mark all notifications on this repo (optional).
|
||||
* @param array|null $statusTypes Mark notifications with the provided status types (optional).
|
||||
* @param string|null $toStatus Status to mark notifications as (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function mark(
|
||||
int $id,
|
||||
?string $lastReadAt = null,
|
||||
?bool $all = null,
|
||||
?array $statusTypes = null,
|
||||
?string $toStatus = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/notifications/threads/{$id}";
|
||||
|
||||
// Configure the URI with query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
if ($lastReadAt !== null)
|
||||
{
|
||||
$uri->setVar('last_read_at', $lastReadAt);
|
||||
}
|
||||
if ($all !== null)
|
||||
{
|
||||
$uri->setVar('all', $all);
|
||||
}
|
||||
if ($statusTypes !== null)
|
||||
{
|
||||
$uri->setVar('status-types', implode(',', $statusTypes));
|
||||
}
|
||||
if ($toStatus !== null)
|
||||
{
|
||||
$uri->setVar('to-status', $toStatus);
|
||||
}
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put($uri, ''), 205
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
209
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Organization.php
Normal file
209
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Organization.php
Normal file
@@ -0,0 +1,209 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Organization
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Organization extends Api
|
||||
{
|
||||
/**
|
||||
* Create an organization.
|
||||
*
|
||||
* @param string $login Required. The organization's username.
|
||||
* @param string $fullName Required. The full name of the organization.
|
||||
* @param string $email Required. The email of the organization.
|
||||
* @param string $description Optional. The description of the organization.
|
||||
* @param bool $repoAdmin Optional. Whether the user has repository admin access.
|
||||
* @param bool $teamAdmin Optional. Whether the user has team admin access.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $login,
|
||||
string $fullName,
|
||||
string $email,
|
||||
string $description = '',
|
||||
bool $repoAdmin = false,
|
||||
bool $teamAdmin = false
|
||||
): ?object
|
||||
{
|
||||
// Set the lines data
|
||||
$data = new \stdClass();
|
||||
$data->username = $login;
|
||||
$data->full_name = $fullName;
|
||||
$data->email = $email;
|
||||
$data->description = $description;
|
||||
$data->repo_admin_change_team_access = $repoAdmin;
|
||||
$data->team_admin_change_team_access = $teamAdmin;
|
||||
|
||||
// Build the request path.
|
||||
$path = '/orgs';
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an organization.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $org): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of organizations.
|
||||
*
|
||||
* @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 = '/orgs';
|
||||
|
||||
// Get the URI and set 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)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an organization.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(string $org): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit an organization.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
* @param string $fullName Optional. The full name of the organization.
|
||||
* @param string $location Optional. The location of the organization.
|
||||
* @param string $description Optional. The description of the organization.
|
||||
* @param bool $repoAdmin Optional. Whether the user has repository admin access.
|
||||
* @param string $visibility Optional. The visibility of the organization (public, limited, or private).
|
||||
* @param string $website Optional. The website of the organization.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(
|
||||
string $org,
|
||||
?string $fullName = null,
|
||||
?string $email = null,
|
||||
?string $location = null,
|
||||
?string $description = null,
|
||||
?bool $repoAdmin = null,
|
||||
?string $visibility = null,
|
||||
?string $website = null
|
||||
): ?object
|
||||
{
|
||||
// Set the lines data
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($fullName !== null)
|
||||
{
|
||||
$data->full_name = $fullName;
|
||||
}
|
||||
|
||||
if ($location !== null)
|
||||
{
|
||||
$data->location = $location;
|
||||
}
|
||||
|
||||
if ($description !== null)
|
||||
{
|
||||
$data->description = $description;
|
||||
}
|
||||
|
||||
if ($repoAdmin !== null)
|
||||
{
|
||||
$data->repo_admin_change_team_access = $repoAdmin;
|
||||
}
|
||||
|
||||
if ($visibility !== null)
|
||||
{
|
||||
$data->visibility = $visibility;
|
||||
}
|
||||
|
||||
if ($website !== null)
|
||||
{
|
||||
$data->website = $website;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}";
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
200
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Organization/Hooks.php
Normal file
200
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Organization/Hooks.php
Normal file
@@ -0,0 +1,200 @@
|
||||
<?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\Organization;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Organization Hooks
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Hooks extends Api
|
||||
{
|
||||
/**
|
||||
* List an organization's webhooks.
|
||||
*
|
||||
* @param string $orgName The organization name.
|
||||
* @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 $orgName,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$orgName}/hooks";
|
||||
|
||||
// Get the URI and set 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)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a hook for an organization.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
* @param string $type The type of hook (e.g. "gitea", "slack", "discord", etc.).
|
||||
* @param string $url The URL of the hook.
|
||||
* @param string $secret Optional. The secret for the hook.
|
||||
* @param bool $events Optional. The events that trigger the hook.
|
||||
* @param bool $active Optional. Whether the hook is active.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $org,
|
||||
string $type,
|
||||
string $url,
|
||||
string $secret = '',
|
||||
bool $events = true,
|
||||
bool $active = true
|
||||
): ?object
|
||||
{
|
||||
// Set the lines data
|
||||
$data = new \stdClass();
|
||||
$data->type = $type;
|
||||
$data->config = new \stdClass();
|
||||
$data->config->url = $url;
|
||||
$data->config->secret = $secret;
|
||||
$data->events = [];
|
||||
$data->active = $active;
|
||||
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}/hooks";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a hook for an organization.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
* @param int $id The ID of the hook.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $org, int $id): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}/hooks/{$id}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a hook for an organization.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
* @param int $id The hook ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(string $org, int $id): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}/hooks/{$id}";
|
||||
|
||||
// Send the DELETE request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a hook for an organization.
|
||||
*
|
||||
* @param string $orgName The organization name.
|
||||
* @param int $hookId The ID of the hook.
|
||||
* @param bool|null $active Optional. Whether the hook is active.
|
||||
* @param string|null $branchFilter Optional. Branch filter for the hook.
|
||||
* @param array|null $config Optional. Configuration for the hook.
|
||||
* @param array|null $events Optional. Events for the hook.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function update(
|
||||
string $orgName,
|
||||
int $hookId,
|
||||
?bool $active = null,
|
||||
?string $branchFilter = null,
|
||||
?array $config = null,
|
||||
?array $events = null
|
||||
): ?object
|
||||
{
|
||||
// Set the lines data
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($active !== null)
|
||||
{
|
||||
$data->active = $active;
|
||||
}
|
||||
|
||||
if ($branchFilter !== null)
|
||||
{
|
||||
$data->branch_filter = $branchFilter;
|
||||
}
|
||||
|
||||
if ($config !== null)
|
||||
{
|
||||
$data->config = (object) $config;
|
||||
}
|
||||
|
||||
if ($events !== null)
|
||||
{
|
||||
$data->events = $events;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$orgName}/hooks/{$hookId}";
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,183 @@
|
||||
<?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\Organization;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Organization Labels
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Labels extends Api
|
||||
{
|
||||
/**
|
||||
* List an organization's labels.
|
||||
*
|
||||
* @param string $orgName The organization name.
|
||||
* @param int $pageNum Page number of results to return (1-based).
|
||||
* @param int $pageSize Page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $orgName,
|
||||
int $pageNum = 1,
|
||||
int $pageSize = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$orgName}/labels";
|
||||
|
||||
// Build the URL
|
||||
$url = $this->uri->get($path);
|
||||
$url->setVar('page', $pageNum);
|
||||
$url->setVar('limit', $pageSize);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($url)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a label for an organization.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
* @param string $name The name of the label.
|
||||
* @param string $color The color of the label.
|
||||
* @param string $description Optional. The description of the label.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $org,
|
||||
string $name,
|
||||
string $color,
|
||||
string $description = ''
|
||||
): ?object
|
||||
{
|
||||
// Set the lines data
|
||||
$data = new \stdClass();
|
||||
$data->name = $name;
|
||||
$data->color = $color;
|
||||
$data->description = $description;
|
||||
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}/labels";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single label for an organization.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
* @param int $id The ID of the label.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $org, int $id): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}/labels/{$id}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a label for an organization.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
* @param int $id The ID of the label.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(string $org, int $id): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}/labels/{$id}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a label for an organization.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
* @param int $id The ID of the label.
|
||||
* @param string $name Optional. The name of the label.
|
||||
* @param string $color Optional. The color of the label.
|
||||
* @param string $description Optional. The description of the label.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function update(
|
||||
string $org,
|
||||
int $id,
|
||||
string $name = '',
|
||||
string $color = '',
|
||||
string $description = ''
|
||||
): ?object
|
||||
{
|
||||
// Set the lines data
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($name) {
|
||||
$data->name = $name;
|
||||
}
|
||||
|
||||
if ($color) {
|
||||
$data->color = $color;
|
||||
}
|
||||
|
||||
if ($description) {
|
||||
$data->description = $description;
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}/labels/{$id}";
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,100 @@
|
||||
<?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\Organization;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Organization Members
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Members extends Api
|
||||
{
|
||||
/**
|
||||
* Get a list of members of an organization.
|
||||
*
|
||||
* @param string $orgName The organization name.
|
||||
* @param int $page The page number.
|
||||
* @param int $limit The number of members per page.
|
||||
*
|
||||
* @return array|null The organization members.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function list(
|
||||
string $orgName,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$orgName}/members";
|
||||
|
||||
// Get the URI and set query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user is a member of an organization.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
* @param string $username The username.
|
||||
*
|
||||
* @return string Whether the user is a member of the organization.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function check(string $org, string $username): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}/members/{$username}";
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a member from an organization.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
* @param string $username The username of the user to remove.
|
||||
*
|
||||
* @return string Whether the user was successfully removed from the organization.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function remove(string $org, string $username): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}/members/{$username}";
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,119 @@
|
||||
<?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\Organization;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Organization Public Members
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class PublicMembers extends Api
|
||||
{
|
||||
/**
|
||||
* List an organization's public members.
|
||||
*
|
||||
* @param string $orgName The organization name.
|
||||
* @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 $orgName, int $page = 1, int $limit = 10): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$orgName}/public_members";
|
||||
|
||||
// Configure the request URI.
|
||||
$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)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a user is a public member of an organization.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
* @param string $username The user's username.
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function check(string $org, string $username): ?string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}/public_members/{$username}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
), 204
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publicize a user's membership.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
* @param string $username The user's username.
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function publicize(string $org, string $username): ?string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}/public_members/{$username}";
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put(
|
||||
$this->uri->get($path), ''
|
||||
), 204
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Conceal a user's membership.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
* @param string $username The user's username.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function conceal(string $org, string $username): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}/public_members/{$username}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,145 @@
|
||||
<?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\Organization;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Organization Repository
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Repository extends Api
|
||||
{
|
||||
/**
|
||||
* List an organization's repos.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
* @param int $pageNumber The page number.
|
||||
* @param int $pageSize The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $org,
|
||||
int $pageNumber = 1,
|
||||
int $pageSize = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}/repos";
|
||||
|
||||
// Configure the request URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('page', $pageNumber);
|
||||
$uri->setVar('limit', $pageSize);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a repository in an organization.
|
||||
*
|
||||
* @param string $org The organization name.
|
||||
* @param string $repoName The name of the repository.
|
||||
* @param string|null $description The description of the repository (optional).
|
||||
* @param bool|null $autoInit Whether the repository should be auto-initialized (optional).
|
||||
* @param string|null $defaultBranch Default branch of the repository (optional).
|
||||
* @param string|null $gitignores Gitignores to use (optional).
|
||||
* @param string|null $issueLabels Label-set to use (optional).
|
||||
* @param string|null $license License to use (optional).
|
||||
* @param bool|null $private Whether the repository is private (optional).
|
||||
* @param string|null $readme Readme of the repository to create (optional).
|
||||
* @param bool|null $template Whether the repository is a template (optional).
|
||||
* @param string|null $trustModel Trust model of the repository (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $org,
|
||||
string $repoName,
|
||||
?string $description = null,
|
||||
?bool $autoInit = null,
|
||||
?string $defaultBranch = null,
|
||||
?string $gitignores = null,
|
||||
?string $issueLabels = null,
|
||||
?string $license = null,
|
||||
?bool $private = null,
|
||||
?string $readme = null,
|
||||
?bool $template = null,
|
||||
?string $trustModel = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$org}/repos";
|
||||
|
||||
// Set the repository data.
|
||||
$data = new \stdClass();
|
||||
$data->name = $repoName;
|
||||
if ($description !== null)
|
||||
{
|
||||
$data->description = $description;
|
||||
}
|
||||
if ($autoInit !== null)
|
||||
{
|
||||
$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 ($private !== null)
|
||||
{
|
||||
$data->private = $private;
|
||||
}
|
||||
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)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
274
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Organization/Teams.php
Normal file
274
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Organization/Teams.php
Normal file
@@ -0,0 +1,274 @@
|
||||
<?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\Organization;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Organization Teams
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Teams extends Api
|
||||
{
|
||||
/**
|
||||
* List an organization's teams.
|
||||
*
|
||||
* @param string $organization The organization name.
|
||||
* @param int $pageNumber The page number of results to return (1-based).
|
||||
* @param int $pageSize The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $organization,
|
||||
int $pageNumber = 1,
|
||||
int $pageSize = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$organization}/teams";
|
||||
|
||||
// Get the URI object.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the query parameters for page number and page size.
|
||||
$uri->setVar('page', $pageNumber);
|
||||
$uri->setVar('limit', $pageSize);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a team.
|
||||
*
|
||||
* @param int $id The team ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(int $id): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/teams/{$id}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a team.
|
||||
*
|
||||
* @param string $organization The organization name.
|
||||
* @param string $name The name of the team.
|
||||
* @param string $description The description of the team.
|
||||
* @param array $repoNames An array of repository names for the team (optional).
|
||||
* @param string $permission The team's permission level (optional).
|
||||
* @param array $units Units for the team (optional).
|
||||
* @param array $unitsMap Units map for the team (optional).
|
||||
* @param bool $canCreateOrgRepo Can create organization repository flag (optional).
|
||||
* @param bool $includesAllRepositories Includes all repositories flag (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $organization,
|
||||
string $name,
|
||||
string $description,
|
||||
array $repoNames = [],
|
||||
string $permission = 'read',
|
||||
array $units = [],
|
||||
array $unitsMap = [],
|
||||
bool $canCreateOrgRepo = null,
|
||||
bool $includesAllRepositories = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$organization}/teams";
|
||||
|
||||
// Set the team data.
|
||||
$data = new \stdClass();
|
||||
$data->name = $name;
|
||||
$data->description = $description;
|
||||
$data->permission = $permission;
|
||||
|
||||
if (!empty($repoNames))
|
||||
{
|
||||
$data->repo_names = $repoNames;
|
||||
}
|
||||
|
||||
if (!empty($units))
|
||||
{
|
||||
$data->units = $units;
|
||||
}
|
||||
|
||||
if (!empty($unitsMap))
|
||||
{
|
||||
$data->units_map = (object)$unitsMap;
|
||||
}
|
||||
|
||||
if ($canCreateOrgRepo !== null)
|
||||
{
|
||||
$data->can_create_org_repo = $canCreateOrgRepo;
|
||||
}
|
||||
|
||||
if ($includesAllRepositories !== null)
|
||||
{
|
||||
$data->includes_all_repositories = $includesAllRepositories;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for teams within an organization.
|
||||
*
|
||||
* @param string $organization The organization name.
|
||||
* @param string $keywords The search keywords.
|
||||
* @param bool $includeDesc Include search within team description (defaults to true).
|
||||
* @param int $page The page number.
|
||||
* @param int $limit The number of results per page.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function search(
|
||||
string $organization,
|
||||
string $keywords,
|
||||
bool $includeDesc = true,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/orgs/{$organization}/teams/search";
|
||||
|
||||
// Configure the request URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('q', $keywords);
|
||||
$uri->setVar('include_desc', $includeDesc);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a team.
|
||||
*
|
||||
* @param int $id The team ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(int $id): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/teams/{$id}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a team.
|
||||
*
|
||||
* @param int $teamId The team ID.
|
||||
* @param string|null $teamName The team name (optional).
|
||||
* @param string|null $teamDescription The team description (optional).
|
||||
* @param string|null $teamPermission The team's permission level (optional).
|
||||
* @param bool|null $canCreateOrgRepo Can team create organization repositories (optional).
|
||||
* @param bool|null $includesAllRepositories Include all repositories (optional).
|
||||
* @param array|null $units List of units (optional).
|
||||
* @param array|null $unitsMap Units map (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(
|
||||
int $teamId,
|
||||
?string $teamName = null,
|
||||
?string $teamDescription = null,
|
||||
?string $teamPermission = null,
|
||||
?bool $canCreateOrgRepo = null,
|
||||
?bool $includesAllRepositories = null,
|
||||
?array $units = null,
|
||||
?array $unitsMap = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/teams/{$teamId}";
|
||||
|
||||
// Set the team data.
|
||||
$data = new \stdClass();
|
||||
if ($teamName !== null)
|
||||
{
|
||||
$data->name = $teamName;
|
||||
}
|
||||
if ($teamDescription !== null)
|
||||
{
|
||||
$data->description = $teamDescription;
|
||||
}
|
||||
if ($teamPermission !== null)
|
||||
{
|
||||
$data->permission = $teamPermission;
|
||||
}
|
||||
if ($canCreateOrgRepo !== null)
|
||||
{
|
||||
$data->can_create_org_repo = $canCreateOrgRepo;
|
||||
}
|
||||
if ($includesAllRepositories !== null)
|
||||
{
|
||||
$data->includes_all_repositories = $includesAllRepositories;
|
||||
}
|
||||
if ($units !== null)
|
||||
{
|
||||
$data->units = $units;
|
||||
}
|
||||
if ($unitsMap !== null)
|
||||
{
|
||||
$data->units_map = $unitsMap;
|
||||
}
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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\Organization\Teams;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Organization Teams Members
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Members extends Api
|
||||
{
|
||||
/**
|
||||
* List a team's members.
|
||||
*
|
||||
* @param int $teamId The team ID.
|
||||
* @param int $pageNumber The page number of results to return (1-based).
|
||||
* @param int $pageSize The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
int $teamId,
|
||||
int $pageNumber = 1,
|
||||
int $pageSize = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/teams/{$teamId}/members";
|
||||
|
||||
// Get the URI object.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the query parameters for page number and page size.
|
||||
$uri->setVar('page', $pageNumber);
|
||||
$uri->setVar('limit', $pageSize);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List a particular member of the team.
|
||||
*
|
||||
* @param int $id The team ID.
|
||||
* @param string $username The user's username.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(int $id, string $username): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/teams/{$id}/members/{$username}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a team member.
|
||||
*
|
||||
* @param int $id The team ID.
|
||||
* @param string $username The user's username.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function add(int $id, string $username): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/teams/{$id}/members/{$username}";
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put(
|
||||
$this->uri->get($path), ''
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a team member.
|
||||
*
|
||||
* @param int $id The team ID.
|
||||
* @param string $username The user's username.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function remove(int $id, string $username): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/teams/{$id}/members/{$username}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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\Organization\Teams;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Organization Teams Repository
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Repository extends Api
|
||||
{
|
||||
/**
|
||||
* List a team's repos.
|
||||
*
|
||||
* @param int $teamId The team ID.
|
||||
* @param int $pageNumber The page number of results to return (1-based).
|
||||
* @param int $pageSize The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
int $teamId,
|
||||
int $pageNumber = 1,
|
||||
int $pageSize = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/teams/{$teamId}/repos";
|
||||
|
||||
// Get the URI object.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the query parameters for page number and page size.
|
||||
$uri->setVar('page', $pageNumber);
|
||||
$uri->setVar('limit', $pageSize);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List a particular repo of the team.
|
||||
*
|
||||
* @param int $teamId The team ID.
|
||||
* @param string $organization The organization name.
|
||||
* @param string $repository The repository name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
int $teamId,
|
||||
string $organization,
|
||||
string $repository
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/teams/{$teamId}/repos/{$organization}/{$repository}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a repository to a team.
|
||||
*
|
||||
* @param int $id The team ID.
|
||||
* @param string $org The organization name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function add(
|
||||
int $id,
|
||||
string $org,
|
||||
string $repo
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/teams/{$id}/repos/{$org}/{$repo}";
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put(
|
||||
$this->uri->get($path), ''
|
||||
),204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a repository from a team.
|
||||
*
|
||||
* @param int $id The team ID.
|
||||
* @param string $org The organization name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function remove(int $id, string $org, string $repo): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/teams/{$id}/repos/{$org}/{$repo}";
|
||||
|
||||
// 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>
|
111
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Organization/User.php
Normal file
111
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Organization/User.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\Organization;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Organization User
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class User extends Api
|
||||
{
|
||||
/**
|
||||
* List the current user's organizations.
|
||||
*
|
||||
* @param int $pageNumber The page number of results to return (1-based).
|
||||
* @param int $pageSize The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
int $pageNumber = 1,
|
||||
int $pageSize = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/user/orgs";
|
||||
|
||||
// Get the URI object.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the query parameters for page number and page size.
|
||||
$uri->setVar('page', $pageNumber);
|
||||
$uri->setVar('limit', $pageSize);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List a user's organizations.
|
||||
*
|
||||
* @param string $username The user's username.
|
||||
* @param int $pageNumber The page number of results to return (1-based).
|
||||
* @param int $pageSize The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $username,
|
||||
int $pageNumber = 1,
|
||||
int $pageSize = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/users/{$username}/orgs";
|
||||
|
||||
// Get the URI object.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the query parameters for page number and page size.
|
||||
$uri->setVar('page', $pageNumber);
|
||||
$uri->setVar('limit', $pageSize);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user permissions in an organization.
|
||||
*
|
||||
* @param string $username The user's username.
|
||||
* @param string $org The organization name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function permissions(string $username, string $org): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/users/{$username}/orgs/{$org}/permissions";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
84
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Package.php
Normal file
84
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Package.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Package
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Package extends Api
|
||||
{
|
||||
/**
|
||||
* Gets a package.
|
||||
*
|
||||
* @param string $owner The owner of the package.
|
||||
* @param string $type The type of the package.
|
||||
* @param string $name The name of the package.
|
||||
* @param string $version The version of the package.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $type,
|
||||
string $name,
|
||||
string $version
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/packages/{$owner}/{$type}/{$name}/{$version}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a package.
|
||||
*
|
||||
* @param string $owner The owner of the package.
|
||||
* @param string $type The type of the package.
|
||||
* @param string $name The name of the package.
|
||||
* @param string $version The version of the package.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $type,
|
||||
string $name,
|
||||
string $version
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/packages/{$owner}/{$type}/{$name}/{$version}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
55
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Package/Files.php
Normal file
55
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Package/Files.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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\Package;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Package Files
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Files extends Api
|
||||
{
|
||||
/**
|
||||
* Gets all files of a package.
|
||||
*
|
||||
* @param string $owner The owner of the package.
|
||||
* @param string $type The type of the package.
|
||||
* @param string $name The name of the package.
|
||||
* @param string $version The version of the package.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $type,
|
||||
string $name,
|
||||
string $version
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/packages/{$owner}/{$type}/{$name}/{$version}/files";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
68
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Package/Owner.php
Normal file
68
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Package/Owner.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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\Package;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Package Owner
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Owner extends Api
|
||||
{
|
||||
/**
|
||||
* Gets all packages of an owner.
|
||||
*
|
||||
* @param string $owner The owner of the packages.
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
* @param string|null $type Package type filter (optional).
|
||||
* @param string|null $name Filter Name filter (optional).
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
int $page = 1,
|
||||
int $limit = 10,
|
||||
?string $type = null,
|
||||
?string $nameFilter = null
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/packages/{$owner}";
|
||||
|
||||
// Configure the URI with query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
if ($type !== null)
|
||||
{
|
||||
$uri->setVar('type', $type);
|
||||
}
|
||||
if ($nameFilter !== null)
|
||||
{
|
||||
$uri->setVar('q', $nameFilter);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
439
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository.php
Normal file
439
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository.php
Normal file
@@ -0,0 +1,439 @@
|
||||
<?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;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Repository extends Api
|
||||
{
|
||||
/**
|
||||
* Search for repositories.
|
||||
*
|
||||
* @param string $q The search query.
|
||||
* @param array $options Additional search options (optional).
|
||||
* @param int $page The page number (optional).
|
||||
* @param int $limit The number of items per page (optional).
|
||||
* @param string $sort The sort order (optional).
|
||||
* @param string $order The order direction (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function search(
|
||||
string $q,
|
||||
array $options = [],
|
||||
int $page = 1,
|
||||
int $limit = 10,
|
||||
string $sort = 'alpha',
|
||||
string $order = 'asc'
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = '/repos/search';
|
||||
|
||||
// Create the URI object and set URL values.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('q', $q);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
$uri->setVar('sort', $sort);
|
||||
$uri->setVar('order', $order);
|
||||
|
||||
foreach ($options as $key => $val)
|
||||
{
|
||||
$uri->setVar($key, $val);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a repository by owner and repo name.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function id(string $owner, string $repo): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(string $owner, string $repo): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a repository's properties.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string|null $description The repository description (optional).
|
||||
* @param string|null $website The repository website (optional).
|
||||
* @param bool|null $private Set the repository to private (optional).
|
||||
* @param bool|null $hasIssues Set the repository to have issues (optional).
|
||||
* @param bool|null $hasWiki Set the repository to have a wiki (optional).
|
||||
* @param bool|null $hasProjects Set the repository to have projects (optional).
|
||||
* @param bool|null $allowManualMerge Allow manual merge of pull requests (optional).
|
||||
* @param bool|null $allowMergeCommits Allow merge commits for pull requests (optional).
|
||||
* @param bool|null $allowRebase Allow rebase-merging pull requests (optional).
|
||||
* @param bool|null $allowRebaseExplicit Allow rebase with explicit merge commits (optional).
|
||||
* @param bool|null $allowRebaseUpdate Allow updating pull request branch by rebase (optional).
|
||||
* @param bool|null $allowSquashMerge Allow squash-merging pull requests (optional).
|
||||
* @param bool|null $archived
|
||||
* @param bool|null $archived Set to true to archive this repository (optional).
|
||||
* @param bool|null $autodetectManualMerge Enable AutodetectManualMerge (optional).
|
||||
* @param string|null $defaultBranch Sets the default branch for this repository (optional).
|
||||
* @param bool|null $defaultDeleteBranchAfterMerge Set to true to delete pr branch after merge by default (optional).
|
||||
* @param string|null $defaultMergeStyle Set to a merge style to be used by this repository (optional).
|
||||
* @param bool|null $enablePrune Enable prune - remove obsolete remote-tracking references (optional).
|
||||
* @param object|null $externalTracker External tracker settings (optional).
|
||||
* @param object|null $externalWiki External wiki settings (optional).
|
||||
* @param bool|null $hasPullRequests Set the repository to have pull requests (optional).
|
||||
* @param bool|null $ignoreWhitespaceConflicts Ignore whitespace for conflicts (optional).
|
||||
* @param object|null $internalTracker Internal tracker settings (optional).
|
||||
* @param string|null $mirrorInterval Set the mirror interval time (optional).
|
||||
* @param bool|null $template Set to true to make this repository a template (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(
|
||||
string $owner,
|
||||
string $repo,
|
||||
?string $description = null,
|
||||
?string $website = null,
|
||||
?bool $private = null,
|
||||
?bool $hasIssues = null,
|
||||
?bool $hasWiki = null,
|
||||
?bool $hasProjects = null,
|
||||
?bool $allowManualMerge = null,
|
||||
?bool $allowMergeCommits = null,
|
||||
?bool $allowRebase = null,
|
||||
?bool $allowRebaseExplicit = null,
|
||||
?bool $allowRebaseUpdate = null,
|
||||
?bool $allowSquashMerge = null,
|
||||
?bool $archived = null,
|
||||
?bool $autodetectManualMerge = null,
|
||||
?string $defaultBranch = null,
|
||||
?bool $defaultDeleteBranchAfterMerge = null,
|
||||
?string $defaultMergeStyle = null,
|
||||
?bool $enablePrune = null,
|
||||
?object $externalTracker = null,
|
||||
?object $externalWiki = null,
|
||||
?bool $hasPullRequests = null,
|
||||
?bool $ignoreWhitespaceConflicts = null,
|
||||
?object $internalTracker = null,
|
||||
?string $mirrorInterval = null,
|
||||
?bool $template = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}";
|
||||
|
||||
// Set the repository properties to update.
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($description !== null)
|
||||
{
|
||||
$data->description = $description;
|
||||
}
|
||||
|
||||
if ($website !== null)
|
||||
{
|
||||
$data->website = $website;
|
||||
}
|
||||
|
||||
if ($private !== null)
|
||||
{
|
||||
$data->private = $private;
|
||||
}
|
||||
|
||||
if ($hasIssues !== null)
|
||||
{
|
||||
$data->has_issues = $hasIssues;
|
||||
}
|
||||
|
||||
if ($hasWiki !== null)
|
||||
{
|
||||
$data->has_wiki = $hasWiki;
|
||||
}
|
||||
|
||||
if ($hasProjects !== null)
|
||||
{
|
||||
$data->has_projects = $hasProjects;
|
||||
}
|
||||
|
||||
// Add the additional properties to update.
|
||||
if ($allowManualMerge !== null)
|
||||
{
|
||||
$data->allow_manual_merge = $allowManualMerge;
|
||||
}
|
||||
|
||||
if ($allowMergeCommits !== null)
|
||||
{
|
||||
$data->allow_merge_commits = $allowMergeCommits;
|
||||
}
|
||||
|
||||
if ($allowRebase !== null)
|
||||
{
|
||||
$data->allow_rebase = $allowRebase;
|
||||
}
|
||||
|
||||
if ($allowRebaseExplicit !== null)
|
||||
{
|
||||
$data->allow_rebase_explicit = $allowRebaseExplicit;
|
||||
}
|
||||
|
||||
if ($allowRebaseUpdate !== null)
|
||||
{
|
||||
$data->allow_rebase_update = $allowRebaseUpdate;
|
||||
}
|
||||
|
||||
if ($allowSquashMerge !== null)
|
||||
{
|
||||
$data->allow_squash_merge = $allowSquashMerge;
|
||||
}
|
||||
|
||||
if ($archived !== null)
|
||||
{
|
||||
$data->archived = $archived;
|
||||
}
|
||||
|
||||
if ($autodetectManualMerge !== null)
|
||||
{
|
||||
$data->autodetect_manual_merge = $autodetectManualMerge;
|
||||
}
|
||||
|
||||
if ($defaultBranch !== null)
|
||||
{
|
||||
$data->default_branch = $defaultBranch;
|
||||
}
|
||||
|
||||
if ($defaultDeleteBranchAfterMerge !== null)
|
||||
{
|
||||
$data->default_delete_branch_after_merge = $defaultDeleteBranchAfterMerge;
|
||||
}
|
||||
|
||||
if ($defaultMergeStyle !==
|
||||
null)
|
||||
{
|
||||
$data->default_merge_style = $defaultMergeStyle;
|
||||
}
|
||||
|
||||
if ($enablePrune !== null)
|
||||
{
|
||||
$data->enable_prune = $enablePrune;
|
||||
}
|
||||
|
||||
if ($externalTracker !== null)
|
||||
{
|
||||
$data->external_tracker = $externalTracker;
|
||||
}
|
||||
|
||||
if ($externalWiki !== null)
|
||||
{
|
||||
$data->external_wiki = $externalWiki;
|
||||
}
|
||||
|
||||
if ($hasPullRequests !== null)
|
||||
{
|
||||
$data->has_pull_requests = $hasPullRequests;
|
||||
}
|
||||
|
||||
if ($ignoreWhitespaceConflicts !== null)
|
||||
{
|
||||
$data->ignore_whitespace_conflicts = $ignoreWhitespaceConflicts;
|
||||
}
|
||||
|
||||
if ($internalTracker !== null)
|
||||
{
|
||||
$data->internal_tracker = $internalTracker;
|
||||
}
|
||||
|
||||
if ($mirrorInterval !== null)
|
||||
{
|
||||
$data->mirror_interval = $mirrorInterval;
|
||||
}
|
||||
|
||||
if ($template !== null)
|
||||
{
|
||||
$data->template = $template;
|
||||
}
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a repository.
|
||||
*
|
||||
* @param string $name The name of the new repository.
|
||||
* @param string|null $description Optional. The description of the new repository.
|
||||
* @param bool|null $private Optional. Set to true if the new repository should be private.
|
||||
* @param bool|null $autoInit Optional. Set to true to initialize the repository with a README.
|
||||
* @param string|null $defaultBranch Optional. Default branch of the repository (used when initializes and in template).
|
||||
* @param string|null $gitignores Optional. The desired .gitignore templates to apply.
|
||||
* @param string|null $issueLabels Optional. Label-Set to use.
|
||||
* @param string|null $license Optional. The desired license for the repository.
|
||||
* @param string|null $readme Optional. Readme of the repository to create.
|
||||
* @param bool|null $template Optional. Set to true if 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 = null,
|
||||
?bool $autoInit = null,
|
||||
?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 repo data.
|
||||
$data = new \stdClass();
|
||||
$data->name = $name;
|
||||
|
||||
if ($description !== null)
|
||||
{
|
||||
$data->description = $description;
|
||||
}
|
||||
|
||||
if ($private !== null)
|
||||
{
|
||||
$data->private = $private;
|
||||
}
|
||||
|
||||
if ($autoInit !== null)
|
||||
{
|
||||
$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
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,58 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Archive
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Archive extends Api
|
||||
{
|
||||
/**
|
||||
* Get an archive of a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $archive The archive format, e.g., "zip" or "tar.gz".
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $archive
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/archive/{$archive}";
|
||||
|
||||
// Set the required variables to the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('owner', $owner);
|
||||
$uri->setVar('repo', $repo);
|
||||
$uri->setVar('archive', $archive);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,51 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Assignees
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Assignees extends Api
|
||||
{
|
||||
/**
|
||||
* Return all users that have write access and can be assigned to issues.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/assignees";
|
||||
|
||||
// Set the required variables to the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('owner', $owner);
|
||||
$uri->setVar('repo', $repo);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,196 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Attachments
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Attachments extends Api
|
||||
{
|
||||
/**
|
||||
* List release's attachments.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param int $releaseId The release ID.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
int $releaseId
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases/{$releaseId}/assets";
|
||||
|
||||
// Retrieve the URI object with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a release attachment.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param int $releaseId The release ID.
|
||||
* @param string $attachmentFile The attachment file content.
|
||||
* @param string $attachmentName The attachment file name.
|
||||
* @param string $contentType The attachment content type.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
int $releaseId,
|
||||
string $attachmentFile,
|
||||
string $attachmentName,
|
||||
string $contentType
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases/{$releaseId}/assets";
|
||||
|
||||
// Retrieve the URI object with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the attachment name as a query parameter.
|
||||
$uri->setVar('name', $attachmentName);
|
||||
|
||||
// Set the request headers.
|
||||
$headers = [
|
||||
"Content-Type: {$contentType}",
|
||||
"Content-Disposition: attachment; filename={$attachmentName}"
|
||||
];
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$uri, $attachmentFile, $headers
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a release attachment.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $id The release ID.
|
||||
* @param int $attachmentId The attachment ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $id,
|
||||
int $attachmentId
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/releases/{$id}/assets/{$attachmentId}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a release attachment.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $id The release ID.
|
||||
* @param int $attachmentId The attachment ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $id,
|
||||
int $attachmentId
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/releases/{$id}/assets/{$attachmentId}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a release attachment.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $id The release ID.
|
||||
* @param int $attachmentId The attachment ID.
|
||||
* @param string|null $name The new name of the attachment (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $id,
|
||||
int $attachmentId,
|
||||
?string $name = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/releases/{$id}/assets/{$attachmentId}";
|
||||
|
||||
// Set the attachment data
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($name !== null)
|
||||
{
|
||||
$data->name = $name;
|
||||
}
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
148
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Branch.php
Normal file
148
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Branch.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Branch
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Branch extends Api
|
||||
{
|
||||
/**
|
||||
* List a repository's branches.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @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 $owner,
|
||||
string $repo,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/branches";
|
||||
|
||||
// Set the required variables to the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('owner', $owner);
|
||||
$uri->setVar('repo', $repo);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a branch.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $branch_name The name of the new branch.
|
||||
* @param string $old_branch The name of the existing branch from which to create the new branch.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $branch_name,
|
||||
string $old_branch
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/branches";
|
||||
|
||||
// Set the branch data.
|
||||
$data = new \stdClass();
|
||||
$data->branch_name = $branch_name;
|
||||
$data->old_branch = $old_branch;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a specific branch from a repository, including its effective branch protection.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $branch The branch name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo, string $branch): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/branches/{$branch}";
|
||||
|
||||
// Set the required variables to the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('owner', $owner);
|
||||
$uri->setVar('repo', $repo);
|
||||
$uri->setVar('branch', $branch);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a specific branch from a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $branch The branch name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $branch
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/branches/{$branch}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,380 @@
|
||||
<?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\Repository\Branch;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Branch Protection
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Protection extends Api
|
||||
{
|
||||
/**
|
||||
* List branch protections for a repository.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repositoryName The repository name.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(string $ownerName, string $repositoryName): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repositoryName}/branch_protections";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a branch protection for a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $branchName The name of the branch to protect.
|
||||
* @param array $approvalsWhitelistUsernames An array of usernames that can approve.
|
||||
* @param array $approvalsWhitelistTeams An array of team names that can approve.
|
||||
* @param bool $blockOnOfficialReviewRequests Enable/disable blocking on official review requests (optional, default false).
|
||||
* @param bool $blockOnOutdatedBranch Enable/disable blocking on outdated branch (optional, default false).
|
||||
* @param bool $blockOnRejectedReviews Enable/disable blocking on rejected reviews (optional, default false).
|
||||
* @param bool $dismissStaleApprovals Enable/disable dismissing stale approvals (optional, default false).
|
||||
* @param bool $enableApprovalsWhitelist Enable/disable approvals whitelist (optional, default false).
|
||||
* @param bool $enableMergeWhitelist Enable/disable merge whitelist (optional, default false).
|
||||
* @param bool $enablePush Enable/disable push (optional, default true).
|
||||
* @param bool $enablePushWhitelist Enable/disable push whitelist (optional, default false).
|
||||
* @param bool $enableStatusCheck Enable/disable status check (optional, default false).
|
||||
* @param array $mergeWhitelistUsernames An array of usernames that can merge (optional).
|
||||
* @param array $mergeWhitelistTeams An array of team names that can merge (optional).
|
||||
* @param string $protectedFilePatterns Protected file patterns (optional).
|
||||
* @param bool $pushWhitelistDeployKeys Enable/disable push whitelist deploy keys (optional, default false).
|
||||
* @param array $pushWhitelistUsernames An array of usernames that can push (optional).
|
||||
* @param array $pushWhitelistTeams An array of team names that can push (optional).
|
||||
* @param bool $requireSignedCommits Enable/disable requiring signed commits (optional, default false).
|
||||
* @param int $requiredApprovals Number of required approvals (optional, default 0).
|
||||
* @param array $statusCheckContexts An array of status check contexts (optional).
|
||||
* @param string $unprotectedFilePatterns Unprotected file patterns (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $branchName,
|
||||
array $approvalsWhitelistUsernames,
|
||||
array $approvalsWhitelistTeams,
|
||||
bool $blockOnOfficialReviewRequests = false,
|
||||
bool $blockOnOutdatedBranch = false,
|
||||
bool $blockOnRejectedReviews = false,
|
||||
bool $dismissStaleApprovals = false,
|
||||
bool $enableApprovalsWhitelist = false,
|
||||
bool $enableMergeWhitelist = false,
|
||||
bool $enablePush = true,
|
||||
bool $enablePushWhitelist = false,
|
||||
bool $enableStatusCheck = false,
|
||||
array $mergeWhitelistUsernames = [],
|
||||
array $mergeWhitelistTeams = [],
|
||||
string $protectedFilePatterns = '',
|
||||
bool $pushWhitelistDeployKeys = false,
|
||||
array $pushWhitelistUsernames = [],
|
||||
array $pushWhitelistTeams = [],
|
||||
bool $requireSignedCommits = false,
|
||||
int $requiredApprovals = 0,
|
||||
array $statusCheckContexts = [],
|
||||
string $unprotectedFilePatterns = ''
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/branch_protections";
|
||||
|
||||
// Set the branch protection data.
|
||||
$data = new \stdClass();
|
||||
$data->branch_name = $branchName;
|
||||
$data->approvals_whitelist_usernames = $approvalsWhitelistUsernames;
|
||||
$data->approvals_whitelist_teams = $approvalsWhitelistTeams;
|
||||
$data->block_on_official_review_requests = $blockOnOfficialReviewRequests;
|
||||
$data->block_on_outdated_branch = $blockOnOutdatedBranch;
|
||||
$data->block_on_rejected_reviews = $blockOnRejectedReviews;
|
||||
$data->dismiss_stale_approvals = $dismissStaleApprovals;
|
||||
$data->enable_approvals_whitelist = $enableApprovalsWhitelist;
|
||||
$data->enable_merge_whitelist = $enableMergeWhitelist;
|
||||
$data->enable_push = $enablePush;
|
||||
$data->enable_push_whitelist = $enablePushWhitelist;
|
||||
$data->enable_status_check = $enableStatusCheck;
|
||||
$data->merge_whitelist_usernames = $mergeWhitelistUsernames;
|
||||
$data->merge_whitelist_teams = $mergeWhitelistTeams;
|
||||
$data->protected_file_patterns = $protectedFilePatterns;
|
||||
$data->push_whitelist_deploy_keys = $pushWhitelistDeployKeys;
|
||||
$data->push_whitelist_usernames = $pushWhitelistUsernames;
|
||||
$data->push_whitelist_teams = $pushWhitelistTeams;
|
||||
$data->require_signed_commits = $requireSignedCommits;
|
||||
$data->required_approvals = $requiredApprovals;
|
||||
$data->status_check_contexts = $statusCheckContexts;
|
||||
$data->unprotected_file_patterns = $unprotectedFilePatterns;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific branch protection for the repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $branchName The branch protection name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $branchName
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/branch_protections/{$branchName}";
|
||||
|
||||
// Get the URI object with the given path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a specific branch protection for the repository.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $branchName The branch protection name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $branchName
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/branch_protections/{$branchName}";
|
||||
|
||||
// Set the required variables in the URI.
|
||||
$this->uri->setVar('owner', $ownerName);
|
||||
$this->uri->setVar('repo', $repoName);
|
||||
$this->uri->setVar('name', $branchName);
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a branch protection for a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $name The branch protection name.
|
||||
* @param array|null $approvalsWhitelistTeams An array of team names that are allowed to approve (optional).
|
||||
* @param array|null $approvalsWhitelistUsernames An array of usernames that are allowed to approve (optional).
|
||||
* @param bool|null $blockOnOfficialReviewRequests Block when official review requests are pending (optional).
|
||||
* @param bool|null $blockOnOutdatedBranch Block when the branch is outdated (optional).
|
||||
* @param bool|null $blockOnRejectedReviews Block when reviews are rejected (optional).
|
||||
* @param bool|null $dismissStaleApprovals Dismiss stale approvals when new commits are pushed (optional).
|
||||
* @param bool|null $enableApprovalsWhitelist Enable/disable approvals whitelist (optional).
|
||||
* @param bool|null $enableMergeWhitelist Enable/disable merge whitelist (optional).
|
||||
* @param bool|null $enablePush Enable/disable push (optional).
|
||||
* @param bool|null $enablePushWhitelist Enable/disable push whitelist (optional).
|
||||
* @param bool|null $enableStatusCheck Enable/disable status check (optional).
|
||||
* @param array|null $mergeWhitelistTeams An array of team names that are allowed to merge (optional).
|
||||
* @param array|null $mergeWhitelistUsernames An array of usernames that are allowed to merge (optional).
|
||||
* @param string|null $protectedFilePatterns A string pattern for protected files (optional).
|
||||
* @param bool|null $pushWhitelistDeployKeys Enable/disable push whitelist for deploy keys (optional).
|
||||
* @param array|null $pushWhitelistTeams An array of team names that are allowed to push (optional).
|
||||
* @param array|null $pushWhitelistUsernames An array of usernames that are allowed to push (optional).
|
||||
* @param bool|null $requireSignedCommits Require signed commits (optional).
|
||||
* @param int|null $requiredApprovals Number of required approvals (optional).
|
||||
* @param array|null $statusCheckContexts An array of status check contexts (optional).
|
||||
* @param string|null $unprotectedFilePatterns A string pattern for unprotected files (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $name,
|
||||
?array $approvalsWhitelistTeams = null,
|
||||
?array $approvalsWhitelistUsernames = null,
|
||||
?bool $blockOnOfficialReviewRequests = null,
|
||||
?bool $blockOnOutdatedBranch = null,
|
||||
?bool $blockOnRejectedReviews = null,
|
||||
?bool $dismissStaleApprovals = null,
|
||||
?bool $enableApprovalsWhitelist = null,
|
||||
?bool $enableMergeWhitelist = null,
|
||||
?bool $enablePush = null,
|
||||
?bool $enablePushWhitelist = null,
|
||||
?bool $enableStatusCheck = null,
|
||||
?array $mergeWhitelistTeams = null,
|
||||
?array $mergeWhitelistUsernames = null,
|
||||
?string $protectedFilePatterns = null,
|
||||
?bool $pushWhitelistDeployKeys = null,
|
||||
?array $pushWhitelistTeams = null,
|
||||
?array $pushWhitelistUsernames = null,
|
||||
?bool $requireSignedCommits = null,
|
||||
?int $requiredApprovals = null,
|
||||
?array $statusCheckContexts = null,
|
||||
?string $unprotectedFilePatterns = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/branch_protections/{$name}";
|
||||
|
||||
// Set the branch protection data.
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($approvalsWhitelistTeams !== null)
|
||||
{
|
||||
$data->approvals_whitelist_teams = $approvalsWhitelistTeams;
|
||||
}
|
||||
|
||||
if ($approvalsWhitelistUsernames !== null)
|
||||
{
|
||||
$data->approvals_whitelist_usernames = $approvalsWhitelistUsernames;
|
||||
}
|
||||
|
||||
if ($blockOnOfficialReviewRequests !== null)
|
||||
{
|
||||
$data->block_on_official_review_requests = $blockOnOfficialReviewRequests;
|
||||
}
|
||||
|
||||
if ($blockOnOutdatedBranch !== null)
|
||||
{
|
||||
$data->block_on_outdated_branch = $blockOnOutdatedBranch;
|
||||
}
|
||||
|
||||
if ($blockOnRejectedReviews !== null)
|
||||
{
|
||||
$data->block_on_rejected_reviews = $blockOnRejectedReviews;
|
||||
}
|
||||
|
||||
if ($dismissStaleApprovals !== null)
|
||||
{
|
||||
$data->dismiss_stale_approvals = $dismissStaleApprovals;
|
||||
}
|
||||
|
||||
if ($enableApprovalsWhitelist !== null)
|
||||
{
|
||||
$data->enable_approvals_whitelist = $enableApprovalsWhitelist;
|
||||
}
|
||||
|
||||
if ($enableMergeWhitelist !== null)
|
||||
{
|
||||
$data->enable_merge_whitelist = $enableMergeWhitelist;
|
||||
}
|
||||
|
||||
if ($enablePush !== null)
|
||||
{
|
||||
$data->enable_push = $enablePush;
|
||||
}
|
||||
|
||||
if ($enablePushWhitelist !== null)
|
||||
{
|
||||
$data->enable_push_whitelist = $enablePushWhitelist;
|
||||
}
|
||||
|
||||
if ($enableStatusCheck !== null)
|
||||
{
|
||||
$data->enable_status_check = $enableStatusCheck;
|
||||
}
|
||||
|
||||
if ($mergeWhitelistTeams !== null)
|
||||
{
|
||||
$data->merge_whitelist_teams = $mergeWhitelistTeams;
|
||||
}
|
||||
|
||||
if ($mergeWhitelistUsernames !== null)
|
||||
{
|
||||
$data->merge_whitelist_usernames = $mergeWhitelistUsernames;
|
||||
}
|
||||
|
||||
if ($protectedFilePatterns !== null)
|
||||
{
|
||||
$data->protected_file_patterns = $protectedFilePatterns;
|
||||
}
|
||||
|
||||
if ($pushWhitelistDeployKeys !== null)
|
||||
{
|
||||
$data->push_whitelist_deploy_keys = $pushWhitelistDeployKeys;
|
||||
}
|
||||
|
||||
if ($pushWhitelistTeams !== null)
|
||||
{
|
||||
$data->push_whitelist_teams = $pushWhitelistTeams;
|
||||
}
|
||||
|
||||
if ($pushWhitelistUsernames !== null)
|
||||
{
|
||||
$data->push_whitelist_usernames = $pushWhitelistUsernames;
|
||||
}
|
||||
|
||||
if ($requireSignedCommits !== null)
|
||||
{
|
||||
$data->require_signed_commits = $requireSignedCommits;
|
||||
}
|
||||
|
||||
if ($requiredApprovals !== null)
|
||||
{
|
||||
$data->required_approvals = $requiredApprovals;
|
||||
}
|
||||
|
||||
if ($statusCheckContexts !== null)
|
||||
{
|
||||
$data->status_check_contexts = $statusCheckContexts;
|
||||
}
|
||||
|
||||
if ($unprotectedFilePatterns !== null)
|
||||
{
|
||||
$data->unprotected_file_patterns = $unprotectedFilePatterns;
|
||||
}
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,175 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Collaborator
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Collaborator extends Api
|
||||
{
|
||||
/**
|
||||
* List a repository's collaborators.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(string $owner, string $repo, int $page = 1, int $limit = 10): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/collaborators";
|
||||
|
||||
// Get the URI object for the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set the page and limit variables.
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a user is a collaborator of a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $collaborator The collaborator username.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function check(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $collaborator
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/collaborators/{$collaborator}";
|
||||
|
||||
// Get the URI object for the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a collaborator to a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $collaborator The collaborator username.
|
||||
* @param string $permission The permission level for the collaborator (optional).
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function add(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $collaborator,
|
||||
string $permission = null
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/collaborators/{$collaborator}";
|
||||
|
||||
// Get the URI object for the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Prepare the request body.
|
||||
$body = new stdClass();
|
||||
if ($permission !== null) {
|
||||
$body->permission = $permission;
|
||||
}
|
||||
$bodyJson = json_encode($body);
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put($uri, $bodyJson), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a collaborator from a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $collaborator The collaborator username.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $collaborator
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/collaborators/{$collaborator}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get repository permissions for a user.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $collaborator The collaborator username.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function permission(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $collaborator
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/collaborators/{$collaborator}/permission";
|
||||
|
||||
// Get the URI object for the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
225
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Commits.php
Normal file
225
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Commits.php
Normal file
@@ -0,0 +1,225 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Commit
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Commits extends Api
|
||||
{
|
||||
/**
|
||||
* Get a list of all commits from a repository.
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The name of the repo.
|
||||
* @param string|null $sha SHA or branch to start listing commits from (usually 'master').
|
||||
* @param string|null $path Filepath of a file/dir.
|
||||
* @param bool|null $stat Include diff stats for every commit (disable for speedup, default 'true').
|
||||
* @param int|null $page Page number of results to return (1-based).
|
||||
* @param int|null $limit Page size of results (ignored if used with 'path').
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getList(
|
||||
string $owner,
|
||||
string $repo,
|
||||
?string $sha = null,
|
||||
?string $path = null,
|
||||
?bool $stat = true,
|
||||
?int $page = 1,
|
||||
?int $limit = 10
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$uriPath = "/repos/{$owner}/{$repo}/commits";
|
||||
|
||||
// Set query parameters.
|
||||
$uri = $this->uri->get($uriPath);
|
||||
|
||||
if ($sha !== null)
|
||||
{
|
||||
$uri->setVar('sha', $sha);
|
||||
}
|
||||
|
||||
if ($path !== null)
|
||||
{
|
||||
$uri->setVar('path', $path);
|
||||
}
|
||||
|
||||
if ($stat !== null)
|
||||
{
|
||||
$uri->setVar('stat', $stat ? 'true' : 'false');
|
||||
}
|
||||
|
||||
if ($page !== null)
|
||||
{
|
||||
$uri->setVar('page', $page);
|
||||
}
|
||||
|
||||
if ($limit !== null)
|
||||
{
|
||||
$uri->setVar('limit', $limit);
|
||||
}
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a single commit from a repository.
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The name of the repo.
|
||||
* @param string $sha A git ref or commit sha.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getCommit(string $owner, string $repo, string $sha): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$uriPath = "/repos/{$owner}/{$repo}/git/commits/{$sha}";
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($uriPath)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a commit's combined status, by branch/tag/commit reference.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $ref The branch, tag, or commit reference.
|
||||
* @param int $page Page number of results to return (1-based).
|
||||
* @param int $limit Page size of results.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function status(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $ref,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/commits/{$ref}/status";
|
||||
|
||||
// Set up the URI with the required 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 a commit's statuses, by branch/tag/commit reference.
|
||||
*
|
||||
* @param string $owner The owner of the repository.
|
||||
* @param string $repo The name of the repository.
|
||||
* @param string $ref The branch, tag, or commit reference.
|
||||
* @param string $sort The type of sort. Available values: oldest, recentupdate, leastupdate, leastindex, highestindex.
|
||||
* @param string $state The type of state. Available values: pending, success, error, failure, warning.
|
||||
* @param int $page The page number of results to return (1-based). Default value: 1.
|
||||
* @param int $limit The page size of results. Default value: 10.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function statuses(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $ref,
|
||||
string $sort = null,
|
||||
string $state = null,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/commits/{$ref}/statuses";
|
||||
|
||||
// Add query parameters to the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
if ($sort !== null)
|
||||
{
|
||||
$uri->setVar('sort', $sort);
|
||||
}
|
||||
|
||||
if ($state !== null)
|
||||
{
|
||||
$uri->setVar('state', $state);
|
||||
}
|
||||
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the GET request.
|
||||
$response = $this->http->get($uri);
|
||||
return $this->response->get($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a commit's diff or patch.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $sha The SHA hash of the commit.
|
||||
* @param string $diffType The diff type, either 'diff' or 'patch'.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function diff(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $sha,
|
||||
string $diffType
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/git/commits/{$sha}";
|
||||
|
||||
// Set the diffType as a variable in the URI.
|
||||
$this->uri->setVar('diffType', $diffType);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,511 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Contents
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Contents extends Api
|
||||
{
|
||||
/**
|
||||
* Get a file from a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $filepath The file path.
|
||||
* @param string|null $ref Optional. The name of the commit/branch/tag.
|
||||
* Default the repository's default branch (usually master).
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo, string $filepath, ?string $ref = null)
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/raw/{$filepath}";
|
||||
|
||||
// Get the URI with the specified path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the ref parameter if provided.
|
||||
if ($ref !== null)
|
||||
{
|
||||
$uri->setVar('ref', $ref);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the metadata and contents (if a file) of an entry in a repository,
|
||||
* or a list of entries if a directory.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $filepath The file or directory path.
|
||||
* @param string|null $ref Optional. The name of the commit/branch/tag.
|
||||
* Default the repository's default branch (usually master).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function metadata(string $owner, string $repo, string $filepath, ?string $ref = null): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/contents/{$filepath}";
|
||||
|
||||
// Get the URI with the specified path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the ref parameter if provided.
|
||||
if ($ref !== null)
|
||||
{
|
||||
$uri->setVar('ref', $ref);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a file in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $filepath The file path.
|
||||
* @param string $content The file content.
|
||||
* @param string $message The commit message.
|
||||
* @param string $branch The branch name. Defaults to the repository's default branch.
|
||||
* @param string|null $authorName The author's name.
|
||||
* @param string|null $authorEmail The author's email.
|
||||
* @param string|null $committerName The committer's name.
|
||||
* @param string|null $committerEmail The committer's email.
|
||||
* @param bool|null $newBranch Whether to create a new branch. Defaults to false.
|
||||
* @param string|null $authorDate The author's date.
|
||||
* @param string|null $committerDate The committer's date.
|
||||
* @param bool|null $signoff Add a Signed-off-by trailer. Defaults to null.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $filepath,
|
||||
string $content,
|
||||
string $message,
|
||||
string $branch = 'master',
|
||||
?string $authorName = null,
|
||||
?string $authorEmail = null,
|
||||
?string $committerName = null,
|
||||
?string $committerEmail = null,
|
||||
?bool $newBranch = false,
|
||||
?string $authorDate = null,
|
||||
?string $committerDate = null,
|
||||
?bool $signoff = null
|
||||
): ?object {
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/contents/{$filepath}";
|
||||
|
||||
// Set the post data
|
||||
$data = new \stdClass();
|
||||
$data->content = base64_encode($content);
|
||||
$data->message = $message;
|
||||
$data->branch = $branch;
|
||||
|
||||
if ($authorName !== null || $authorEmail !== null)
|
||||
{
|
||||
$data->author = new \stdClass();
|
||||
if ($authorName !== null)
|
||||
{
|
||||
$data->author->name = $authorName;
|
||||
}
|
||||
if ($authorEmail !== null)
|
||||
{
|
||||
$data->author->email = $authorEmail;
|
||||
}
|
||||
}
|
||||
|
||||
if ($committerName !== null || $committerEmail !== null)
|
||||
{
|
||||
$data->committer = new \stdClass();
|
||||
if ($committerName !== null)
|
||||
{
|
||||
$data->committer->name = $committerName;
|
||||
}
|
||||
if ($committerEmail !== null)
|
||||
{
|
||||
$data->committer->email = $committerEmail;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newBranch !== null)
|
||||
{
|
||||
$data->new_branch = $newBranch;
|
||||
}
|
||||
|
||||
if ($authorDate !== null || $committerDate !== null)
|
||||
{
|
||||
$data->dates = new \stdClass();
|
||||
if ($authorDate !== null)
|
||||
{
|
||||
$data->dates->author = $authorDate;
|
||||
}
|
||||
if ($committerDate !== null)
|
||||
{
|
||||
$data->dates->committer = $committerDate;
|
||||
}
|
||||
}
|
||||
|
||||
if ($signoff !== null)
|
||||
{
|
||||
$data->signoff = $signoff;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the metadata of all the entries of the root directory.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string|null $ref The name of the commit/branch/tag. Default the repository's default branch (usually master).
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function root(string $owner, string $repo, ?string $ref = null): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/contents";
|
||||
|
||||
// Get the URI with the specified path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the 'ref' parameter if it's provided.
|
||||
if ($ref !== null)
|
||||
{
|
||||
$uri->setVar('ref', $ref);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$uri
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a file in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $filepath The file path.
|
||||
* @param string $content The file content.
|
||||
* @param string $message The commit message.
|
||||
* @param string $sha The blob SHA of the file.
|
||||
* @param string $branch The branch name. Defaults to the repository's default branch.
|
||||
* @param string|null $authorName The author name. Defaults to the authenticated user.
|
||||
* @param string|null $authorEmail The author email. Defaults to the authenticated user.
|
||||
* @param string|null $committerName The committer name. Defaults to the authenticated user.
|
||||
* @param string|null $committerEmail The committer email. Defaults to the authenticated user.
|
||||
* @param string|null $authorDate The author date.
|
||||
* @param string|null $committerDate The committer date.
|
||||
* @param string|null $fromPath The original file path to move/rename.
|
||||
* @param string|null $newBranch The new branch to create from the specified branch.
|
||||
* @param bool|null $signoff Add a Signed-off-by trailer.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function update(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $filepath,
|
||||
string $content,
|
||||
string $message,
|
||||
string $sha,
|
||||
string $branch = 'master',
|
||||
?string $authorName = null,
|
||||
?string $authorEmail = null,
|
||||
?string $committerName = null,
|
||||
?string $committerEmail = null,
|
||||
?string $authorDate = null,
|
||||
?string $committerDate = null,
|
||||
?string $fromPath = null,
|
||||
?string $newBranch = null,
|
||||
?bool $signoff = null
|
||||
): ?object {
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/contents/{$filepath}";
|
||||
|
||||
// Set the file data.
|
||||
$data = new \stdClass();
|
||||
$data->content = base64_encode($content);
|
||||
$data->message = $message;
|
||||
$data->branch = $branch;
|
||||
$data->sha = $sha;
|
||||
|
||||
if ($authorName !== null || $authorEmail !== null)
|
||||
{
|
||||
$data->author = new \stdClass();
|
||||
|
||||
if ($authorName !== null)
|
||||
{
|
||||
$data->author->name = $authorName;
|
||||
}
|
||||
|
||||
if ($authorEmail !== null)
|
||||
{
|
||||
$data->author->email = $authorEmail;
|
||||
}
|
||||
}
|
||||
|
||||
if ($committerName !== null || $committerEmail !== null)
|
||||
{
|
||||
$data->committer = new \stdClass();
|
||||
|
||||
if ($committerName !== null)
|
||||
{
|
||||
$data->committer->name = $committerName;
|
||||
}
|
||||
|
||||
if ($committerEmail !== null)
|
||||
{
|
||||
$data->committer->email = $committerEmail;
|
||||
}
|
||||
}
|
||||
|
||||
if ($authorDate !== null || $committerDate !== null)
|
||||
{
|
||||
$data->dates = new \stdClass();
|
||||
|
||||
if ($authorDate !== null)
|
||||
{
|
||||
$data->dates->author = $authorDate;
|
||||
}
|
||||
|
||||
if ($committerDate !== null)
|
||||
{
|
||||
$data->dates->committer = $committerDate;
|
||||
}
|
||||
}
|
||||
|
||||
if ($fromPath !== null)
|
||||
{
|
||||
$data->from_path = $fromPath;
|
||||
}
|
||||
|
||||
if ($newBranch !== null)
|
||||
{
|
||||
$data->new_branch = $newBranch;
|
||||
}
|
||||
|
||||
if ($signoff !== null)
|
||||
{
|
||||
$data->signoff = $signoff;
|
||||
}
|
||||
|
||||
// Send the put request.
|
||||
return $this->response->get(
|
||||
$this->http->put(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $filepath The file path.
|
||||
* @param string $message The commit message.
|
||||
* @param string $branch The branch name (optional).
|
||||
* @param string $sha The blob SHA of the file.
|
||||
* @param string $authorName The author name (optional).
|
||||
* @param string $authorEmail The author email (optional).
|
||||
* @param string $committerName The committer name (optional).
|
||||
* @param string $committerEmail The committer email (optional).
|
||||
* @param string $authorDate The author date (optional).
|
||||
* @param string $committerDate The committer date (optional).
|
||||
* @param string $newBranch The new branch name (optional).
|
||||
* @param bool $signoff Add a Signed-off-by trailer (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $filepath,
|
||||
string $message,
|
||||
string $sha,
|
||||
?string $branch = null,
|
||||
?string $authorName = null,
|
||||
?string $authorEmail = null,
|
||||
?string $committerName = null,
|
||||
?string $committerEmail = null,
|
||||
?string $authorDate = null,
|
||||
?string $committerDate = null,
|
||||
?string $newBranch = null,
|
||||
?bool $signoff = null
|
||||
): ?object {
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/contents/{$filepath}";
|
||||
|
||||
// Set the file data.
|
||||
$data = new \stdClass();
|
||||
$data->message = $message;
|
||||
$data->sha = $sha;
|
||||
|
||||
if ($branch !== null) {
|
||||
$data->branch = $branch;
|
||||
}
|
||||
|
||||
if ($authorName !== null || $authorEmail !== null)
|
||||
{
|
||||
$data->author = new \stdClass();
|
||||
|
||||
if ($authorName !== null)
|
||||
{
|
||||
$data->author->name = $authorName;
|
||||
}
|
||||
|
||||
if ($authorEmail !== null)
|
||||
{
|
||||
$data->author->email = $authorEmail;
|
||||
}
|
||||
}
|
||||
|
||||
if ($committerName !== null || $committerEmail !== null)
|
||||
{
|
||||
$data->committer = new \stdClass();
|
||||
|
||||
if ($committerName !== null)
|
||||
{
|
||||
$data->committer->name = $committerName;
|
||||
}
|
||||
|
||||
if ($committerEmail !== null)
|
||||
{
|
||||
$data->committer->email = $committerEmail;
|
||||
}
|
||||
}
|
||||
|
||||
if ($authorDate !== null || $committerDate !== null)
|
||||
{
|
||||
$data->dates = new \stdClass();
|
||||
|
||||
if ($authorDate !== null)
|
||||
{
|
||||
$data->dates->author = $authorDate;
|
||||
}
|
||||
|
||||
if ($committerDate !== null)
|
||||
{
|
||||
$data->dates->committer = $committerDate;
|
||||
}
|
||||
}
|
||||
|
||||
if ($newBranch !== null)
|
||||
{
|
||||
$data->new_branch = $newBranch;
|
||||
}
|
||||
|
||||
if ($signoff !== null)
|
||||
{
|
||||
$data->signoff = $signoff;
|
||||
}
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the EditorConfig definitions of a file in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $filepath The file path.
|
||||
* @param string $ref The name of the commit/branch/tag.
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function editor(string $owner, string $repo, string $filepath, string $ref = null): ?string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/editorconfig/{$filepath}";
|
||||
|
||||
// Set the request parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
if ($ref !== null)
|
||||
{
|
||||
$uri->setVar('ref', $ref);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the blob of a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $sha The SHA hash of the blob.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function blob(string $owner, string $repo, string $sha): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/git/blobs/{$sha}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
102
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Forks.php
Normal file
102
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Forks.php
Normal file
@@ -0,0 +1,102 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Forks
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Forks extends Api
|
||||
{
|
||||
/**
|
||||
* List a repository's forks.
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The name of the repo.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function listForks(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$uriPath = "/repos/{$owner}/{$repo}/forks";
|
||||
|
||||
// Set the query parameters.
|
||||
$uri = $this->uri->get($uriPath);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fork a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $forkName The name of the forked repository (optional).
|
||||
* @param string $organization The organization name (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function repo(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $forkName = '',
|
||||
string $organization = ''
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/forks";
|
||||
|
||||
// Set the fork data.
|
||||
$data = new \stdClass();
|
||||
|
||||
if (!empty($forkName))
|
||||
{
|
||||
$data->name = $forkName;
|
||||
}
|
||||
|
||||
if (!empty($organization))
|
||||
{
|
||||
$data->organization = $organization;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 202
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
48
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Gpg.php
Normal file
48
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Gpg.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Gpg
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Gpg extends Api
|
||||
{
|
||||
/**
|
||||
* Get signing-key.gpg for a given repository.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $ownerName, string $repoName): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/signing-key.gpg";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
214
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Hooks.php
Normal file
214
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Hooks.php
Normal file
@@ -0,0 +1,214 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Hooks
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Hooks extends Api
|
||||
{
|
||||
/**
|
||||
* List the hooks in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/hooks";
|
||||
|
||||
// Set up 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)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a hook in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $type The hook type.
|
||||
* @param array $config The hook configuration.
|
||||
* @param bool $active The hook's active status (optional, default: false).
|
||||
* @param array|null $events The events for the hook (optional).
|
||||
* @param string $branchFilter The branch filter (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $type,
|
||||
array $config,
|
||||
string $type,
|
||||
array $config,
|
||||
bool $active = false,
|
||||
?array $events = null,
|
||||
string $branchFilter = ''
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/hooks";
|
||||
|
||||
// Set the hook data.
|
||||
$data = new \stdClass();
|
||||
$data->type = $type;
|
||||
$data->config = (object) $config;
|
||||
$data->active = $active;
|
||||
|
||||
if ($events !== null)
|
||||
{
|
||||
$data->events = $events;
|
||||
}
|
||||
|
||||
if (!empty($branchFilter))
|
||||
{
|
||||
$data->branch_filter = $branchFilter;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a hook.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $hookId The hook ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $hookId
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/hooks/{$hookId}";
|
||||
|
||||
// Get the URI for the request path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a hook in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $id The hook ID.
|
||||
* @param array $config The hook configuration.
|
||||
* @param array $events The events to trigger the hook.
|
||||
* @param bool $active Whether the hook is active.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $id,
|
||||
array $config,
|
||||
array $events,
|
||||
bool $active
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/hooks/{$id}";
|
||||
|
||||
// Set the hook data.
|
||||
$data = new \stdClass();
|
||||
$data->config = $config;
|
||||
$data->events = $events;
|
||||
$data->active = $active;
|
||||
|
||||
// Send the PATCH request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a push webhook.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $hookId The hook ID.
|
||||
* @param string $ref The name of the commit/branch/tag (optional).
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function test(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $hookId,
|
||||
string $ref = ''
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/hooks/{$hookId}/tests";
|
||||
|
||||
// Get the URI for the request path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
if (!empty($ref))
|
||||
{
|
||||
$uri->setVar('ref', $ref);
|
||||
}
|
||||
|
||||
// Send the POST request.
|
||||
return $this->response->get(
|
||||
$this->http->post($uri), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,137 @@
|
||||
<?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\Repository\Hooks;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Hooks Git
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Git extends Api
|
||||
{
|
||||
/**
|
||||
* List the Git hooks in a repository.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(string $ownerName, string $repoName): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/hooks/git";
|
||||
|
||||
// Get the URI object with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Git hook.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param int $hookId The Git hook ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
int $hookId
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/hooks/git/{$hookId}";
|
||||
|
||||
// Get the URI object with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a Git hook in a repository.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repositoryName The repository name.
|
||||
* @param string $hookId The Git hook ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $ownerName,
|
||||
string $repositoryName,
|
||||
string $hookId
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repositoryName}/hooks/git/{$hookId}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a Git hook in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $hookId The Git hook ID.
|
||||
* @param array $hookOptions The hook configuration.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function edit(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $hookId,
|
||||
array $hookOptions
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/hooks/git/{$hookId}";
|
||||
|
||||
// Set the hook data.
|
||||
$data = new \stdClass();
|
||||
$data->config = (object) $hookOptions;
|
||||
|
||||
// Send the PATCH request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
159
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Keys.php
Normal file
159
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Keys.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Keys
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Keys extends Api
|
||||
{
|
||||
/**
|
||||
* List a repository's keys.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int|null $keyId The key_id to search for. (Optional)
|
||||
* @param string|null $fingerprint The fingerprint of the key. (Optional)
|
||||
* @param int $page The page number of results to return. (Default: 1)
|
||||
* @param int $limit The page size of results. (Default: 10)
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function list(string $owner, string $repo, ?int $keyId = null, ?string $fingerprint = null, int $page = 1, int $limit = 10): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/keys";
|
||||
|
||||
// Prepare the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the optional query parameters.
|
||||
if ($keyId !== null)
|
||||
{
|
||||
$uri->setVar('key_id', $keyId);
|
||||
}
|
||||
|
||||
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)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a key to a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $key The public key.
|
||||
* @param string $title The title of the key.
|
||||
* @param bool $readOnly Whether the key is read-only.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function add(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $key,
|
||||
string $title,
|
||||
bool $readOnly
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/keys";
|
||||
|
||||
// Set the key data.
|
||||
$data = new \stdClass();
|
||||
$data->key = $key;
|
||||
$data->title = $title;
|
||||
$data->read_only = $readOnly;
|
||||
|
||||
// Send the POST request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path),
|
||||
json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a repository's key by id.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $id The key ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function id(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $id
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/keys/{$id}";
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a key from a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $id The key ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $id
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/keys/{$id}";
|
||||
|
||||
// Send the DELETE request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,49 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Languages
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Languages extends Api
|
||||
{
|
||||
/**
|
||||
* Get languages and number of bytes of code written in a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function getLanguages(string $owner, string $repo): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/languages";
|
||||
|
||||
// Build the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,63 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Media
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Media extends Api
|
||||
{
|
||||
/**
|
||||
* Get a file or its LFS object from a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $filepath The file path.
|
||||
* @param string|null $ref The name of the commit/branch/tag. (Optional)
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $filepath,
|
||||
?string $ref = null
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$encodedFilepath = rawurlencode($filepath);
|
||||
$path = "/repos/{$owner}/{$repo}/media/{$encodedFilepath}";
|
||||
|
||||
// Prepare the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add the 'ref' query parameter if provided.
|
||||
if ($ref !== null)
|
||||
{
|
||||
$uri->setVar('ref', $ref);
|
||||
}
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
167
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Merge.php
Normal file
167
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Merge.php
Normal file
@@ -0,0 +1,167 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Merge
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Merge extends Api
|
||||
{
|
||||
/**
|
||||
* Check if a pull request has been merged.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function check(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/merge";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param string|null $mergeMethod Merge method to use (optional).
|
||||
* @param string|null $mergeCommitId Merge commit ID (optional).
|
||||
* @param string|null $mergeMessageField Merge message field (optional).
|
||||
* @param string|null $mergeTitleField Merge title field (optional).
|
||||
* @param bool|null $deleteBranchAfterMerge Delete branch after merge (optional).
|
||||
* @param bool|null $forceMerge Force merge (optional).
|
||||
* @param string|null $headCommitId Head commit ID (optional).
|
||||
* @param bool|null $mergeWhenChecksSucceed Merge when checks succeed (optional).
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function pull(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
?string $mergeMethod = null,
|
||||
?string $mergeCommitId = null,
|
||||
?string $mergeMessageField = null,
|
||||
?string $mergeTitleField = null,
|
||||
?bool $deleteBranchAfterMerge = null,
|
||||
?bool $forceMerge = null,
|
||||
?string $headCommitId = null,
|
||||
?bool $mergeWhenChecksSucceed = null
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/merge";
|
||||
|
||||
// Set the merge data.
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($mergeMethod !== null)
|
||||
{
|
||||
$data->do = $mergeMethod;
|
||||
}
|
||||
|
||||
if ($mergeCommitId !== null)
|
||||
{
|
||||
$data->merge_commit_id = $mergeCommitId;
|
||||
}
|
||||
|
||||
if ($mergeMessageField !== null)
|
||||
{
|
||||
$data->merge_message_field = $mergeMessageField;
|
||||
}
|
||||
|
||||
if ($mergeTitleField !== null)
|
||||
{
|
||||
$data->merge_title_field = $mergeTitleField;
|
||||
}
|
||||
|
||||
if ($deleteBranchAfterMerge !== null)
|
||||
{
|
||||
$data->delete_branch_after_merge = $deleteBranchAfterMerge;
|
||||
}
|
||||
|
||||
if ($forceMerge !== null)
|
||||
{
|
||||
$data->force_merge = $forceMerge;
|
||||
}
|
||||
|
||||
if ($headCommitId !== null)
|
||||
{
|
||||
$data->head_commit_id = $headCommitId;
|
||||
}
|
||||
|
||||
if ($mergeWhenChecksSucceed !== null)
|
||||
{
|
||||
$data->merge_when_checks_succeed = $mergeWhenChecksSucceed;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the scheduled auto merge for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function cancel(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/merge";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete($uri), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,48 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Mirror
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Mirror extends Api
|
||||
{
|
||||
/**
|
||||
* Sync a mirrored repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function sync(string $owner, string $repo): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/mirror-sync";
|
||||
|
||||
// Send the POST request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path)
|
||||
), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
190
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Mirrors.php
Normal file
190
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Mirrors.php
Normal file
@@ -0,0 +1,190 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Mirrors
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Mirrors extends Api
|
||||
{
|
||||
/**
|
||||
* Get all push mirrors of the repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/push_mirrors";
|
||||
|
||||
// Set query parameters.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a push mirror to the repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $remoteAddress The push mirror address.
|
||||
* @param string|null $remoteUsername The push mirror user. (Optional)
|
||||
* @param string|null $remotePassword The push mirror password. (Optional)
|
||||
* @param string $interval The interval for the push mirror.
|
||||
* @param bool $syncOnCommit Sync on commit option.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function add(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $remoteAddress,
|
||||
?string $remoteUsername = null,
|
||||
?string $remotePassword = null,
|
||||
string $interval,
|
||||
bool $syncOnCommit
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/push_mirrors";
|
||||
|
||||
// Set the mirror data.
|
||||
$data = new \stdClass();
|
||||
$data->remote_address = $remoteAddress;
|
||||
$data->interval = $interval;
|
||||
$data->sync_on_commit = $syncOnCommit;
|
||||
|
||||
if ($remoteUsername !== null)
|
||||
{
|
||||
$data->remote_username = $remoteUsername;
|
||||
}
|
||||
|
||||
if ($remotePassword !== null)
|
||||
{
|
||||
$data->remote_password = $remotePassword;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync all push mirrored repositories.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function sync(
|
||||
string $owner,
|
||||
string $repo
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/push_mirrors-sync";
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path)
|
||||
), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get push mirror of the repository by remoteName.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $name The remote name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function name(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $name
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/push_mirrors/{$name}";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a push mirror from a repository by remoteName.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $name The remote name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $name
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/push_mirrors/{$name}";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->delete($uri), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,53 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Notes
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Notes extends Api
|
||||
{
|
||||
/**
|
||||
* Get a note corresponding to a single commit from a repository.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $commitSha The SHA hash of the commit.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $commitSha
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/git/notes/{$commitSha}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,78 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Patch
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Patch extends Api
|
||||
{
|
||||
/**
|
||||
* Apply a diff patch to a repository.
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The name of the repo.
|
||||
* @param array $options Options for updating files.
|
||||
* $options = [
|
||||
* 'description' => 'UpdateFileOptions',
|
||||
* 'body' => [
|
||||
* 'content' => 'string', // Content must be base64 encoded.
|
||||
* 'sha' => 'string', // The SHA for the file that already exists.
|
||||
* 'branch' => 'string', // Branch (optional) to base this file from. If not given, the default branch is used.
|
||||
* 'new_branch' => 'string', // New branch (optional) will make a new branch from branch before creating the file.
|
||||
* 'from_path' => 'string', // From_path (optional) is the path of the original file which will be moved/renamed to the path in the URL.
|
||||
* 'message' => 'string', // Message (optional) for the commit of this file. If not supplied, a default message will be used.
|
||||
* 'author' => [ // Identity for a person's identity like an author or committer.
|
||||
* 'name' => 'string',
|
||||
* 'email' => 'string($email)'
|
||||
* ],
|
||||
* 'committer' => [ // Identity for a person's identity like an author or committer.
|
||||
* 'name' => 'string',
|
||||
* 'email' => 'string($email)'
|
||||
* ],
|
||||
* 'dates' => [ // Store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE.
|
||||
* 'author' => 'string($date-time)',
|
||||
* 'committer' => 'string($date-time)'
|
||||
* ],
|
||||
* 'signoff' => 'boolean' // Add a Signed-off-by trailer by the committer at the end of the commit log message.
|
||||
* ]
|
||||
* ]
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function applyDiffPatch(
|
||||
string $owner,
|
||||
string $repo,
|
||||
array $option
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$uriPath = "/repos/{$owner}/{$repo}/diffpatch";
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($uriPath),
|
||||
json_encode($options)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
547
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Pulls.php
Normal file
547
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Pulls.php
Normal file
@@ -0,0 +1,547 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Pulls
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Pulls extends Api
|
||||
{
|
||||
/**
|
||||
* List a repository's pull requests.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string|null $state State of pull request: open, closed, or all (optional).
|
||||
* @param string|null $sort Type of sort (optional).
|
||||
* @param int|null $milestone ID of the milestone (optional).
|
||||
* @param array|null $labels Label IDs (optional).
|
||||
* @param int $page Page number of results to return (1-based, default: 1).
|
||||
* @param int $limit Page size of results (default: 10).
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function list(
|
||||
string $owner,
|
||||
string $repo,
|
||||
?string $state = null,
|
||||
?string $sort = null,
|
||||
?int $milestone = null,
|
||||
?array $labels = null,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls";
|
||||
|
||||
// Set query parameters.
|
||||
$this->uri->setVar('page', $page);
|
||||
$this->uri->setVar('limit', $limit);
|
||||
|
||||
if ($state !== null)
|
||||
{
|
||||
$this->uri->setVar('state', $state);
|
||||
}
|
||||
|
||||
if ($sort !== null)
|
||||
{
|
||||
$this->uri->setVar('sort', $sort);
|
||||
}
|
||||
|
||||
if ($milestone !== null)
|
||||
{
|
||||
$this->uri->setVar('milestone', $milestone);
|
||||
}
|
||||
|
||||
if ($labels !== null)
|
||||
{
|
||||
$this->uri->setVar('labels', implode(',', $labels));
|
||||
}
|
||||
|
||||
// Send the GET request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $title The title of the pull request.
|
||||
* @param string $head The head branch.
|
||||
* @param string $base The base branch.
|
||||
* @param string|null $body The description of the pull request (optional).
|
||||
* @param string|null $assignee The assignee of the pull request (optional).
|
||||
* @param array|null $assignees Additional assignees (optional).
|
||||
* @param array|null $labels Label IDs (optional).
|
||||
* @param int|null $milestone ID of the milestone (optional).
|
||||
* @param string|null $dueDate Due date of the pull request (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $title,
|
||||
string $head,
|
||||
string $base,
|
||||
?string $body = null,
|
||||
?string $assignee = null,
|
||||
?array $assignees = null,
|
||||
?array $labels = null,
|
||||
?int $milestone = null,
|
||||
?string $dueDate = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls";
|
||||
|
||||
// Set the pull request data.
|
||||
$data = new \stdClass();
|
||||
$data->title = $title;
|
||||
$data->head = $head;
|
||||
$data->base = $base;
|
||||
|
||||
if ($body !== null)
|
||||
{
|
||||
$data->body = $body;
|
||||
}
|
||||
|
||||
if ($assignee !== null)
|
||||
{
|
||||
$data->assignee = $assignee;
|
||||
}
|
||||
|
||||
if ($assignees !== null)
|
||||
{
|
||||
$data->assignees = $assignees;
|
||||
}
|
||||
|
||||
if ($labels !== null)
|
||||
{
|
||||
$data->labels = $labels;
|
||||
}
|
||||
|
||||
if ($milestone !== null)
|
||||
{
|
||||
$data->milestone = $milestone;
|
||||
}
|
||||
|
||||
if ($dueDate !== null)
|
||||
{
|
||||
$data->due_date = $dueDate;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo, int $index): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param string|null $title The title of the pull request (optional).
|
||||
* @param string|null $body The description of the pull request (optional).
|
||||
* @param string|null $assignee The assignee of the pull request (optional).
|
||||
* @param array|null $assignees Additional assignees (optional).
|
||||
* @param string|null $base The base branch (optional).
|
||||
* @param string|null $state The state of the pull request (optional).
|
||||
* @param array|null $labels Label IDs (optional).
|
||||
* @param int|null $milestone ID of the milestone (optional).
|
||||
* @param string|null $dueDate Due date of the pull request (optional).
|
||||
* @param bool|null $unsetDueDate Whether to unset the due date (optional).
|
||||
* @param bool|null $allowMaintainerEdit Allow maintainer to edit the pull request (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function update(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
?string $title = null,
|
||||
?string $body = null,
|
||||
?string $assignee = null,
|
||||
?array $assignees = null,
|
||||
?string $base = null,
|
||||
?string $state = null,
|
||||
?array $labels = null,
|
||||
?int $milestone = null,
|
||||
?string $dueDate = null,
|
||||
?bool $unsetDueDate = null,
|
||||
?bool $allowMaintainerEdit = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}";
|
||||
|
||||
// Set the pull request data.
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($title !== null)
|
||||
{
|
||||
$data->title = $title;
|
||||
}
|
||||
|
||||
if ($body !== null)
|
||||
{
|
||||
$data->body = $body;
|
||||
}
|
||||
|
||||
if ($assignee !== null)
|
||||
{
|
||||
$data->assignee = $assignee;
|
||||
}
|
||||
|
||||
if ($assignees !== null)
|
||||
{
|
||||
$data->assignees = $assignees;
|
||||
}
|
||||
|
||||
if ($base !== null)
|
||||
{
|
||||
$data->base = $base;
|
||||
}
|
||||
|
||||
if ($state !== null)
|
||||
{
|
||||
$data->state = $state;
|
||||
}
|
||||
|
||||
if ($labels !== null)
|
||||
{
|
||||
$data->labels = $labels;
|
||||
}
|
||||
|
||||
if ($milestone !== null)
|
||||
{
|
||||
$data->milestone = $milestone;
|
||||
}
|
||||
|
||||
if ($dueDate !== null)
|
||||
{
|
||||
$data->due_date = $dueDate;
|
||||
}
|
||||
|
||||
if ($unsetDueDate !== null)
|
||||
{
|
||||
$data->unset_due_date = $unsetDueDate;
|
||||
}
|
||||
|
||||
if ($allowMaintainerEdit !== null)
|
||||
{
|
||||
$data->allow_maintainer_edit = $allowMaintainerEdit;
|
||||
}
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a pull request diff or patch.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param string $diffType The type of the requested data, either "diff" or "patch".
|
||||
* @param bool $binary Whether to include binary file changes. If true, the diff is applicable with git apply.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function diff(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
string $diffType,
|
||||
bool $binary = false
|
||||
): string
|
||||
{
|
||||
// Validate the diff type.
|
||||
if (!in_array($diffType, ['diff', 'patch']))
|
||||
{
|
||||
throw new \InvalidArgumentException('Invalid diff type. Allowed types are "diff" and "patch".');
|
||||
}
|
||||
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}.{$diffType}";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set the binary query parameter if required.
|
||||
if ($binary)
|
||||
{
|
||||
$uri->setVar('binary', 'true');
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get commits for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @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 commits(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/commits";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set the page and limit query parameters.
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get changed files for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param string $skipTo Skip to the given file.
|
||||
* @param string $whitespace Whitespace behavior.
|
||||
* @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 files(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
?string $skipTo = null,
|
||||
?string $whitespace = null,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/files";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set the skip-to, whitespace, page, and limit query parameters if needed.
|
||||
if ($skipTo !== null)
|
||||
{
|
||||
$uri->setVar('skip-to', $skipTo);
|
||||
}
|
||||
if ($whitespace !== null)
|
||||
{
|
||||
$uri->setVar('whitespace', $whitespace);
|
||||
}
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param string|null $do Merge method.
|
||||
* @param string|null $mergeCommitId Merge commit ID.
|
||||
* @param string|null $mergeMessageField Merge message field.
|
||||
* @param string|null $mergeTitleField Merge title field.
|
||||
* @param bool|null $deleteBranchAfterMerge Whether to delete the branch after merge.
|
||||
* @param bool|null $forceMerge Whether to force merge.
|
||||
* @param string|null $headCommitId Head commit ID.
|
||||
* @param bool|null $mergeWhenChecksSucceed Whether to merge when checks succeed.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function merge(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
?string $do = null,
|
||||
?string $mergeCommitId = null,
|
||||
?string $mergeMessageField = null,
|
||||
?string $mergeTitleField = null,
|
||||
?bool $deleteBranchAfterMerge = null,
|
||||
?bool $forceMerge = null,
|
||||
?string $headCommitId = null,
|
||||
?bool $mergeWhenChecksSucceed = null
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/merge";
|
||||
|
||||
// Set the merge data.
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($do !== null)
|
||||
{
|
||||
$data->do = $do;
|
||||
}
|
||||
|
||||
if ($mergeCommitId !== null)
|
||||
{
|
||||
$data->merge_commit_id = $mergeCommitId;
|
||||
}
|
||||
|
||||
if ($mergeMessageField !== null)
|
||||
{
|
||||
$data->merge_message_field = $mergeMessageField;
|
||||
}
|
||||
|
||||
if ($mergeTitleField !== null)
|
||||
{
|
||||
$data->merge_title_field = $mergeTitleField;
|
||||
}
|
||||
|
||||
if ($deleteBranchAfterMerge !== null)
|
||||
{
|
||||
$data->delete_branch_after_merge = $deleteBranchAfterMerge;
|
||||
}
|
||||
|
||||
if ($forceMerge !== null)
|
||||
{
|
||||
$data->force_merge = $forceMerge;
|
||||
}
|
||||
|
||||
if ($headCommitId !== null)
|
||||
{
|
||||
$data->head_commit_id = $headCommitId;
|
||||
}
|
||||
|
||||
if ($mergeWhenChecksSucceed !== null)
|
||||
{
|
||||
$data->merge_when_checks_succeed = $mergeWhenChecksSucceed;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge PR's baseBranch into headBranch.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param string|null $style How to update the pull request. (Optional)
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function update(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
?string $style = null
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/update";
|
||||
|
||||
// Set the merge data.
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($style !== null)
|
||||
{
|
||||
$data->style = $style;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 200, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,77 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Refs
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Refs extends Api
|
||||
{
|
||||
/**
|
||||
* Get specified ref or filtered repository's refs.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(string $owner, string $repo): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/git/refs";
|
||||
|
||||
// Build the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specified ref.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $ref The ref name.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $ref
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/git/refs/{$ref}";
|
||||
|
||||
// Build the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,309 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Releases
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Releases extends Api
|
||||
{
|
||||
/**
|
||||
* List a repo's releases.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param bool|null $draft Filter (exclude/include) drafts (optional).
|
||||
* @param bool|null $preRelease Filter (exclude/include) pre-releases (optional).
|
||||
* @param int $page Page number of results to return (1-based, optional).
|
||||
* @param int $limit Page size of results (optional).
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function list(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
?bool $draft = null,
|
||||
?bool $preRelease = null,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases";
|
||||
|
||||
// Set additional URI values.
|
||||
$this->uri->setVar('page', $page);
|
||||
$this->uri->setVar('limit', $limit);
|
||||
|
||||
if ($draft !== null)
|
||||
{
|
||||
$this->uri->setVar('draft', $draft);
|
||||
}
|
||||
|
||||
if ($preRelease !== null)
|
||||
{
|
||||
$this->uri->setVar('pre-release', $preRelease);
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a release.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $tagName The tag name.
|
||||
* @param string $targetCommitish The commitish value that determines where the Git tag is created from.
|
||||
* @param string $releaseName The name of the release.
|
||||
* @param string $releaseBody The description of the release.
|
||||
* @param bool $isDraft Whether the release is a draft.
|
||||
* @param bool $isPrerelease Whether the release is a pre-release.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $tagName,
|
||||
string $targetCommitish,
|
||||
string $releaseName,
|
||||
string $releaseBody,
|
||||
bool $isDraft = false,
|
||||
bool $isPrerelease = false
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases";
|
||||
|
||||
// Set the release data
|
||||
$data = new \stdClass();
|
||||
$data->tag_name = $tagName;
|
||||
$data->target_commitish = $targetCommitish;
|
||||
$data->name = $releaseName;
|
||||
$data->body = $releaseBody;
|
||||
$data->draft = $isDraft;
|
||||
$data->prerelease = $isPrerelease;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a release by ID.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param int $releaseId The release ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
int $releaseId
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases/{$releaseId}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a release by ID.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param int $releaseId The release ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
int $releaseId
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases/{$releaseId}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a release.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param int $releaseId The release ID.
|
||||
* @param string|null $tagName The tag name (optional).
|
||||
* @param string|null $targetCommitish The commitish value that determines where the Git tag is created from (optional).
|
||||
* @param string|null $releaseName The name of the release (optional).
|
||||
* @param string|null $description The description of the release (optional).
|
||||
* @param bool|null $isDraft Whether the release is a draft (optional).
|
||||
* @param bool|null $isPrerelease Whether the release is a pre-release (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function update(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
int $releaseId,
|
||||
?string $tagName = null,
|
||||
?string $targetCommitish = null,
|
||||
?string $releaseName = null,
|
||||
?string $description = null,
|
||||
?bool $isDraft = null,
|
||||
?bool $isPrerelease = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases/{$releaseId}";
|
||||
|
||||
// Set the release data
|
||||
$data = new \stdClass();
|
||||
|
||||
if ($tagName !== null || $targetCommitish !== null || $releaseName !== null || $description !== null || $isDraft !== null || $isPrerelease !== null)
|
||||
{
|
||||
$data->editReleaseOption = new \stdClass();
|
||||
|
||||
if ($tagName !== null)
|
||||
{
|
||||
$data->editReleaseOption->tag_name = $tagName;
|
||||
}
|
||||
|
||||
if ($targetCommitish !== null)
|
||||
{
|
||||
$data->editReleaseOption->target_commitish = $targetCommitish;
|
||||
}
|
||||
|
||||
if ($releaseName !== null)
|
||||
{
|
||||
$data->editReleaseOption->name = $releaseName;
|
||||
}
|
||||
|
||||
if ($description !== null)
|
||||
{
|
||||
$data->editReleaseOption->body = $description;
|
||||
}
|
||||
|
||||
if ($isDraft !== null)
|
||||
{
|
||||
$data->editReleaseOption->draft = $isDraft;
|
||||
}
|
||||
|
||||
if ($isPrerelease !== null)
|
||||
{
|
||||
$data->editReleaseOption->prerelease = $isPrerelease;
|
||||
}
|
||||
}
|
||||
|
||||
// Send the patch request.
|
||||
return $this->response->get(
|
||||
$this->http->patch(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a release by tag name.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $tagName The tag name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function getByTag(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $tagName
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases/tags/{$tagName}";
|
||||
|
||||
// Configure the URI with the path.
|
||||
$this->uri->setVar('owner', $ownerName);
|
||||
$this->uri->setVar('repo', $repoName);
|
||||
$this->uri->setVar('tag', $tagName);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a release by tag name.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $tagName The tag name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function deleteByTag(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $tagName
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/releases/tags/{$tagName}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Remote
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Remote extends Api
|
||||
{
|
||||
/**
|
||||
* Migrate a remote git repository.
|
||||
*
|
||||
* @param string $cloneAddr The URL to clone the repository from.
|
||||
* @param string $repoName The desired name for the new repository.
|
||||
* @param string $repoOwner The name of the user or organization who will own the repo after migration.
|
||||
* @param string $uid The ID of the user that will own the new repository (deprecated).
|
||||
* @param string $description The description for the new repository (optional).
|
||||
* @param bool $private Set the repository to private (optional, default false).
|
||||
* @param string|null $authToken Authentication token (optional).
|
||||
* @param string|null $authUsername Authentication username (optional).
|
||||
* @param string|null $authPassword Authentication password (optional).
|
||||
* @param array $options Additional migration options (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function migrate(
|
||||
string $cloneAddr,
|
||||
string $repoName,
|
||||
string $repoOwner,
|
||||
string $uid,
|
||||
string $description = '',
|
||||
bool $private = false,
|
||||
?string $authToken = null,
|
||||
?string $authUsername = null,
|
||||
?string $authPassword = null,
|
||||
array $options = []
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/migrate";
|
||||
|
||||
// Set the repository migration data.
|
||||
$data = new \stdClass();
|
||||
$data->cloneAddr = $cloneAddr;
|
||||
$data->repoName = $repoName;
|
||||
$data->repoOwner = $repoOwner;
|
||||
$data->uid = $uid;
|
||||
$data->description = $description;
|
||||
$data->private = $private;
|
||||
|
||||
if ($authToken !== null)
|
||||
{
|
||||
$data->authToken = $authToken;
|
||||
}
|
||||
|
||||
if ($authUsername !== null)
|
||||
{
|
||||
$data->authUsername = $authUsername;
|
||||
}
|
||||
|
||||
if ($authPassword !== null)
|
||||
{
|
||||
$data->authPassword = $authPassword;
|
||||
}
|
||||
|
||||
foreach ($options as $key => $val)
|
||||
{
|
||||
$data->{$key} = $val;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,126 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Reviewers
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Reviewers extends Api
|
||||
{
|
||||
/**
|
||||
* Create review requests for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param array $reviewers Array of reviewers usernames.
|
||||
* @param array|null $teamReviewers Array of team reviewers (optional).
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function request(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
array $reviewers,
|
||||
?array $teamReviewers = null
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/requested_reviewers";
|
||||
|
||||
// Set the review requests data.
|
||||
$data = new \stdClass();
|
||||
$data->reviewers = $reviewers;
|
||||
|
||||
if ($teamReviewers !== null)
|
||||
{
|
||||
$data->team_reviewers = $teamReviewers;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel review requests for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param array $reviewers Array of reviewers usernames.
|
||||
* @param array|null $teamReviewers Array of team reviewers (optional).
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function cancel(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
array $reviewers,
|
||||
?array $teamReviewers = null
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/requested_reviewers";
|
||||
|
||||
// Get the URI and set the required variables.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('reviewers', json_encode($reviewers));
|
||||
|
||||
if ($teamReviewers !== null)
|
||||
{
|
||||
$uri->setVar('teamReviewers', json_encode($teamReviewers));
|
||||
}
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete($uri), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all users that can be requested to review in this repo.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/reviewers";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
321
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Reviews.php
Normal file
321
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Reviews.php
Normal file
@@ -0,0 +1,321 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Reviews
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Reviews extends Api
|
||||
{
|
||||
/**
|
||||
* List all reviews for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews";
|
||||
|
||||
// Get the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set query parameters.
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a review for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param string $body The review body text.
|
||||
* @param string $event The review event type (APPROVE, REQUEST_CHANGES, COMMENT).
|
||||
* @param array|null $comments An array of CreatePullReviewComment objects.
|
||||
* @param string|null $commitId The commit ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
string $body,
|
||||
string $event,
|
||||
?array $comments = null,
|
||||
?string $commitId = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews";
|
||||
|
||||
// Set the review data.
|
||||
$data = new \stdClass();
|
||||
$data->body = $body;
|
||||
$data->event = $event;
|
||||
|
||||
// Add comments if available.
|
||||
if ($comments !== null)
|
||||
{
|
||||
$data->comments = $comments;
|
||||
}
|
||||
|
||||
// Add commitId if available.
|
||||
if ($commitId !== null)
|
||||
{
|
||||
$data->commit_id = $commitId;
|
||||
}
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific review for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param int $id The review ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $id
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}";
|
||||
|
||||
// Set the variables for the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('owner', $owner);
|
||||
$uri->setVar('repo', $repo);
|
||||
$uri->setVar('index', $index);
|
||||
$uri->setVar('id', $id);
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit a pending review to a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param int $id The review ID.
|
||||
* @param string $body The review body text.
|
||||
* @param string $event The review event type (APPROVE, REQUEST_CHANGES, COMMENT).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function submit(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $id,
|
||||
string $body,
|
||||
string $event
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}";
|
||||
|
||||
// Set the review data.
|
||||
$data = new \stdClass();
|
||||
$data->body = $body;
|
||||
$data->event = $event;
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a specific review from a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param int $id The review ID.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $id
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}";
|
||||
|
||||
// Set the variables for the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('owner', $owner);
|
||||
$uri->setVar('repo', $repo);
|
||||
$uri->setVar('index', $index);
|
||||
$uri->setVar('id', $id);
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete($uri), 204, 'success'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the comments of a specific review for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param int $id The review ID.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function comments(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $id
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}/comments";
|
||||
|
||||
// Set the variables for the URI.
|
||||
$uri = $this->uri->get($path);
|
||||
$uri->setVar('owner', $owner);
|
||||
$uri->setVar('repo', $repo);
|
||||
$uri->setVar('index', $index);
|
||||
$uri->setVar('id', $id);
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dismiss a review for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param int $id The review ID.
|
||||
* @param string $message The dismissal message.
|
||||
* @param bool $priors The flag to dismiss prior reviews.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function dismiss(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $id,
|
||||
string $message,
|
||||
bool $priors = false
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}/dismissals";
|
||||
|
||||
// Set the dismissal data.
|
||||
$data = new \stdClass();
|
||||
$data->message = $message;
|
||||
$data->priors = $priors;
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the dismissal of a review for a pull request.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param int $index The pull request index.
|
||||
* @param int $id The review ID.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function undismiss(
|
||||
string $owner,
|
||||
string $repo,
|
||||
int $index,
|
||||
int $id
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}/undismissals";
|
||||
|
||||
// Send the request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,59 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Stargazers
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Stargazers extends Api
|
||||
{
|
||||
/**
|
||||
* List a repo's stargazers.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/stargazers";
|
||||
|
||||
// Set the page and limit values.
|
||||
$this->uri->setVar('page', $page);
|
||||
$this->uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Statuses
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Statuses extends Api
|
||||
{
|
||||
/**
|
||||
* Get a commit's statuses.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $commitSha The commit SHA.
|
||||
* @param string $sort The type of sort.
|
||||
* @param string $state The type of state.
|
||||
* @param int $page The page number of results to return (1-based).
|
||||
* @param int $limit The page size of results.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $commitSha,
|
||||
string $sort = 'recentupdate',
|
||||
string $state = 'pending',
|
||||
int $page = 1,
|
||||
int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/statuses/{$commitSha}";
|
||||
|
||||
// Prepare the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Set the query parameters.
|
||||
$uri->setVar('sort', $sort);
|
||||
$uri->setVar('state', $state);
|
||||
$uri->setVar('page', $page);
|
||||
$uri->setVar('limit', $limit);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a commit status.
|
||||
*
|
||||
* @param string $ownerName The owner name.
|
||||
* @param string $repoName The repository name.
|
||||
* @param string $commitSha The commit SHA.
|
||||
* @param string $state The commit status state (error, failure, pending, success, or warning).
|
||||
* @param string|null $context The context of the status (optional).
|
||||
* @param string|null $statusDescription The status description (optional).
|
||||
* @param string|null $targetUrl The URL of the associated build status (optional).
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $ownerName,
|
||||
string $repoName,
|
||||
string $commitSha,
|
||||
string $state,
|
||||
?string $context = null,
|
||||
?string $statusDescription = null,
|
||||
?string $targetUrl = null
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$ownerName}/{$repoName}/statuses/{$commitSha}";
|
||||
|
||||
// Set the commit status data
|
||||
$data = new \stdClass();
|
||||
$data->state = $state;
|
||||
|
||||
if ($context !== null)
|
||||
{
|
||||
$data->context = $context;
|
||||
}
|
||||
|
||||
if ($statusDescription !== null)
|
||||
{
|
||||
$data->description = $statusDescription;
|
||||
}
|
||||
|
||||
if ($targetUrl !== null)
|
||||
{
|
||||
$data->target_url = $targetUrl;
|
||||
}
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
), 201
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
182
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Tags.php
Normal file
182
libraries/vendor_jcb/VDM.Joomla.Gitea/src/Repository/Tags.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?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\Repository;
|
||||
|
||||
|
||||
use VDM\Joomla\Gitea\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Gitea Repository Tags
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Tags extends Api
|
||||
{
|
||||
/**
|
||||
* List a repository's tags
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The name of the repo.
|
||||
* @param int|null $page The page number of results to return (1-based).
|
||||
* @param int|null $limit The page size of results, default maximum page size is 10.
|
||||
*
|
||||
* @return array|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function list(
|
||||
string $owner,
|
||||
string $repo,
|
||||
?int $page = 1,
|
||||
?int $limit = 10
|
||||
): ?array
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/tags";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Add query parameters if they are provided.
|
||||
if ($page !== null)
|
||||
{
|
||||
$uri->setVar('page', $page);
|
||||
}
|
||||
|
||||
if ($limit !== null)
|
||||
{
|
||||
$uri->setVar('limit', $limit);
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag of a repository by tag name.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $tag The tag name.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $owner, string $repo, string $tag): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/tags/{$tag}";
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag object of an annotated tag (not lightweight tags).
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The name of the repo.
|
||||
* @param string $sha The sha of the tag. The Git tags API only supports annotated tag objects, not lightweight tags.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function sha(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $sha
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/git/tags/{$sha}";
|
||||
|
||||
// Get the URI with the path.
|
||||
$uri = $this->uri->get($path);
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get($uri)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new git tag in a repository.
|
||||
*
|
||||
* @param string $owner The owner of the repo.
|
||||
* @param string $repo The name of the repo.
|
||||
* @param string $tagName The name of the tag.
|
||||
* @param string $target The SHA of the git object this is tagging.
|
||||
* @param string $message The tag message.
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function create(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $tagName,
|
||||
string $target,
|
||||
string $message
|
||||
): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/tags";
|
||||
|
||||
// Set the tag data
|
||||
$data = new \stdClass();
|
||||
$data->tag_name = $tagName;
|
||||
$data->target = $target;
|
||||
$data->message = $message;
|
||||
|
||||
// Send the post request.
|
||||
return $this->response->get(
|
||||
$this->http->post(
|
||||
$this->uri->get($path), json_encode($data)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a repository's tag by name.
|
||||
*
|
||||
* @param string $owner The owner name.
|
||||
* @param string $repo The repository name.
|
||||
* @param string $tag The tag name.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function delete(
|
||||
string $owner,
|
||||
string $repo,
|
||||
string $tag
|
||||
): string
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/repos/{$owner}/{$repo}/tags/{$tag}";
|
||||
|
||||
// Send the delete request.
|
||||
return $this->response->get(
|
||||
$this->http->delete(
|
||||
$this->uri->get($path)
|
||||
), 204, 'succes'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user