JinkoOrgClient
JinkoOrgClient {#}
JinkoOrgClient(
*,
api_key: str | None = None,
base_url: str | None = None,
app_url: str | None = None,
timeout: float = 30.0,
validate_config: bool = True,
transport: JinkoTransport | None = None
)
Client for the organization routes, with any API key of an organization.
The client lists and creates projects, lists, creates, and renames groups,
and opens a regular JinkoClient for a project. It sends no project
header. Use auth_check() to validate credentials and read key metadata.
Use JinkoClient directly for work inside one project.
A project key also works here: it lists the projects of its owner, but it
reaches only its own project. Project resource requests enforce key scope.
A project client's auth_check() checks its key's declared scope too.
from jinko import JinkoOrgClient
org = JinkoOrgClient() # reads JINKO_API_KEY and JINKO_BASE_URL
for project in org.list_projects():
print(project.id, project.name)
client = org.project(project.id)
client.search(limit=5)
| Member | Kind | Description |
|---|---|---|
auth_check | method | Validate credentials and return authentication status and key metadata. |
list_projects | method | List the organization projects visible to the API key. |
create_project | method | Create a project in a group and return its identifier. |
project | method | Open a project client reusing this key, base URL, app URL, and timeout. |
list_groups | method | List the groups in the organization. |
get_group | method | Return one group. |
create_group | method | Create a group and return its identifier. |
update_group | method | Rename a group and return its identifier. |
raw_request | method | Send a raw request to the Jinko API with only the bearer token added. |
set_timeout | method | Set the timeout used for each request sent by this client. |
auth_check
auth_check() -> AuthCheckResult
Validate credentials and return authentication status and key metadata.
This check needs no project ID and works with project and organization
keys. It does not check access to any project. Use a project client's
auth_check() to check its key's declared scope, then request a
project resource to verify access.
Raises:
AuthenticationError: Credentials are invalid.
list_projects
list_projects(
*, name: str | None = None, group_id: str | None = None
) -> list[Project]
List the organization projects visible to the API key.
A key tied to a list of projects sees only those projects. Any other key sees the organization projects of its owner, including projects outside the key scope: a project key reaches only one of them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | None | When set, keep projects whose name contains this text. | None |
group_id | str | None | When set, keep projects that belong to this group. | None |
Returns:
list[Project]: The visible projects, in the key's order for a key tied to a listlist[Project]: of projects.
create_project
create_project(
name: str, group_id: str, *, description: str | None = None
) -> ProjectRef
Create a project in a group and return its identifier.
The key owner creates the project. A key limited to a fixed list of projects cannot create one, because the new project would fall outside that list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | Name of the project. | |
group_id | str | Group the project is created in. | |
description | str | None | Optional description of the project. | None |
Returns:
ProjectRef: The identifier of the created project.
Raises:
AuthorizationError: The key cannot create a project.
project
project(project: str | Project) -> JinkoClient
Open a project client reusing this key, base URL, app URL, and timeout.
This sends no request. Call auth_check() on the returned client to
validate credentials and check the key's declared scope. It raises
AuthenticationError for an out-of-scope project. Request a project
resource to verify that the project exists and is accessible.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project | str | Project | A project returned by list_projects(), or a project id. |
Returns:
JinkoClient: AJinkoClientbound to that project.
list_groups
list_groups(*, name: str | None = None) -> list[Group]
List the groups in the organization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | None | When set, keep groups whose name contains this text. | None |
Returns:
list[Group]: The matching groups.
get_group
get_group(group_id: str) -> Group
Return one group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_id | str | Identifier of the group. |
Returns:
Group: The group.
create_group
create_group(name: str, *, parent_id: str | None = None) -> GroupRef
Create a group and return its identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name | str | Name of the group. | |
parent_id | str | None | When set, the new group is created under this group. | None |
Returns:
GroupRef: The identifier of the created group.
update_group
update_group(group_id: str, name: str) -> GroupRef
Rename a group and return its identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group_id | str | Identifier of the group. | |
name | str | New name of the group. |
Returns:
GroupRef: The identifier of the renamed group.
raw_request
raw_request(
method: str,
path: str,
*,
params: dict[str, Any] | None = None,
json_body: Any | None = None,
data: bytes | None = None,
headers: dict[str, str] | None = None,
accept: str | None = None,
content_type: str | None = None
) -> Any
Send a raw request to the Jinko API with only the bearer token added.
set_timeout
set_timeout(value: float | int | None)
Set the timeout used for each request sent by this client.