Release of v4.0.0-alpha8
Add power path override option on component level. Fix the sql build feature. #1032.
This commit is contained in:
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>
|
Reference in New Issue
Block a user