gitea.actions.async_variable
async_variable
The Actions variables of a repository, an organization or the authenticated account.
A variable is the readable counterpart of a secret: the same three scopes, the
same paths with variables in place of secrets, and a value that comes back -
under data - when it is read.
Where a secret has one endpoint that both creates and replaces, a variable has
two, and they behave differently: create_variable answers 409 on a name that
already exists, while update_variable replaces the value of one that does. So
creating is safe to retry against a name believed to be free, and replacing is
asked for rather than arrived at.
The listing here is the other bare-array listing of the Actions API: a list, not
an object with total_count.
The asynchronous mirror of gitea.actions.variable. The endpoints, the
arguments and the answers are that module's, and it is the one to read for what
each method does and why. The difference here is aiohttp in place of
requests, and the awaits that come with it.
Classes
gitea.actions.async_variable.AsyncVariables
Bases: BaseActions, AsyncResource
The Actions endpoints over the variables of a scope.
Source code in src/gitea/resource/async_resource.py
Methods:
gitea.actions.async_variable.AsyncVariables.list_variables
async
list_variables(
owner: str | None = None,
repository: str | None = None,
page: int | None = None,
limit: int | None = None,
**kwargs: Any,
) -> tuple[list[dict[str, Any]], dict[str, Any]]
List the variables of a scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
owner
|
str | None
|
The owner of the repository, or the organization whose
variables are listed. Omitting both this and |
None
|
repository
|
str | None
|
The name of the repository, to list its variables alone. |
None
|
page
|
int | None
|
The page number for pagination. |
None
|
limit
|
int | None
|
The number of variables per page. |
None
|
**kwargs
|
Any
|
Additional arguments for the request. |
{}
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
A tuple containing the variables as a list and a dictionary with |
dict[str, Any]
|
metadata. Each entry carries the value under |
tuple[list[dict[str, Any]], dict[str, Any]]
|
makes a variable a variable rather than a secret. |
Source code in src/gitea/actions/async_variable.py
gitea.actions.async_variable.AsyncVariables.get_variable
async
get_variable(
variable_name: str,
owner: str | None = None,
repository: str | None = None,
**kwargs: Any,
) -> tuple[dict[str, Any], dict[str, Any]]
Get one variable of a scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str
|
The name of the variable. |
required |
owner
|
str | None
|
The owner of the repository, or the organization the variable
belongs to. Omitting both this and |
None
|
repository
|
str | None
|
The name of the repository the variable belongs to. |
None
|
**kwargs
|
Any
|
Additional arguments for the request. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A tuple containing the variable as a dictionary, its value under |
dict[str, Any]
|
|
Source code in src/gitea/actions/async_variable.py
gitea.actions.async_variable.AsyncVariables.create_variable
async
create_variable(
variable_name: str,
value: str,
owner: str | None = None,
repository: str | None = None,
description: str | None = None,
**kwargs: Any,
) -> tuple[dict[str, Any], dict[str, Any]]
Create a variable of a scope.
A name that already exists answers 409 rather than being replaced, so
this never overwrites a value by accident; update_variable is how one is
replaced on purpose.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str
|
The name of the variable to create. |
required |
value
|
str
|
The value to store. |
required |
owner
|
str | None
|
The owner of the repository, or the organization the variable
belongs to. Omitting both this and |
None
|
repository
|
str | None
|
The name of the repository the variable belongs to. |
None
|
description
|
str | None
|
What the variable is for, shown alongside it in the web UI. |
None
|
**kwargs
|
Any
|
Additional arguments for the request. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A tuple containing an empty dictionary - the endpoint answers |
dict[str, Any]
|
with no body - and a dictionary with metadata. |
Source code in src/gitea/actions/async_variable.py
gitea.actions.async_variable.AsyncVariables.update_variable
async
update_variable(
variable_name: str,
value: str,
owner: str | None = None,
repository: str | None = None,
new_name: str | None = None,
description: str | None = None,
**kwargs: Any,
) -> tuple[dict[str, Any], dict[str, Any]]
Update a variable of a scope, replacing its value and optionally its name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str
|
The name of the variable to update, which is how the endpoint is addressed. |
required |
value
|
str
|
The value to store. Gitea requires it, so an update meaning
only to rename a variable still sends the value it is to keep -
read it with |
required |
owner
|
str | None
|
The owner of the repository, or the organization the variable
belongs to. Omitting both this and |
None
|
repository
|
str | None
|
The name of the repository the variable belongs to. |
None
|
new_name
|
str | None
|
A name to rename the variable to, sent as the API's |
None
|
description
|
str | None
|
What the variable is for. |
None
|
**kwargs
|
Any
|
Additional arguments for the request. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A tuple containing an empty dictionary - the endpoint answers without |
dict[str, Any]
|
a body - and a dictionary with metadata. |
Source code in src/gitea/actions/async_variable.py
gitea.actions.async_variable.AsyncVariables.delete_variable
async
delete_variable(
variable_name: str,
owner: str | None = None,
repository: str | None = None,
**kwargs: Any,
) -> tuple[dict[str, Any], dict[str, Any]]
Delete a variable of a scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str
|
The name of the variable. |
required |
owner
|
str | None
|
The owner of the repository, or the organization the variable
belongs to. Omitting both this and |
None
|
repository
|
str | None
|
The name of the repository the variable belongs to. |
None
|
**kwargs
|
Any
|
Additional arguments for the request. |
{}
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A tuple containing an empty dictionary - the endpoint answers without |
dict[str, Any]
|
a body - and a dictionary with metadata. |