diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0e97df..db59ab0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,11 @@ -name: Python backend server tests +name: Python tests on: pull_request: types: [opened, synchronize, reopened, ready_for_review, draft] paths: - - 'src/codesphere_sdk/**' - - '.github/workflows/backend-app.yml' + - 'src/codesphere/**' + - '.github/workflows/ci.yml' permissions: contents: write diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index bc624d5..b4d5a4f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,5 +1,3 @@ -# .github/workflows/release.yml - name: Create Release and Publish to PyPI on: diff --git a/CHANGELOG.md b/CHANGELOG.md index f0819ef..5691d47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,15 @@ +## v0.1.1 (2025-07-16) + +### Fix + +- **.github/ci.yml**: fix trigger condition + +## v0.1.0 (2025-07-16) + +### Feat + +- **src/codesphere/team**: adding team resources from public api + ## v0.0.4 (2025-07-16) ## v0.0.3 (2025-07-16) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..5ad5c39 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at **[INSERT EMAIL ADDRESS]**. All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of actions. + +**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interaction in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html \ No newline at end of file diff --git a/CONTRIBUTING b/CONTRIBUTING index e69de29..709fc92 100644 --- a/CONTRIBUTING +++ b/CONTRIBUTING @@ -0,0 +1,81 @@ +# Contributing to codesphere-python + +First off, thank you for considering contributing to our project! We welcome any contributions, from fixing bugs and improving documentation to submitting new features. + +--- + +## How Can I Contribute? + +* **Reporting Bugs**: If you find a bug, please open a **GitHub Issue** and provide as much detail as possible, including steps to reproduce it. +* **Suggesting Enhancements**: If you have an idea for a new feature or an improvement, open a **GitHub Issue** to discuss it. This lets us coordinate our efforts and prevent duplicated work. +* **Pull Requests**: If you're ready to contribute code, documentation, or tests, you can open a Pull Request. + +--- + +## Development Setup + +To get your local development environment set up, please follow these steps: + +1. **Fork the repository** on GitHub. +2. **Clone your forked repository** to your local machine: + ```bash + git clone [https://github.com/YOUR_USERNAME/codesphere-python.git](https://github.com/YOUR_USERNAME/codesphere-python.git) + cd codesphere-python + ``` +3. **Set up the project and install dependencies.** We use `uv` for package management. The following command will create a virtual environment and install all necessary dependencies for development: + ```bash + make install + ``` +4. **Activate the virtual environment**: + ```bash + source .venv/bin/activate + ``` + +You are now ready to start developing! + +--- + +## Contribution Workflow + +1. **Create a new branch** for your changes. Please use a descriptive branch name. + ```bash + # Example for a new feature: + git checkout -b feature/my-new-feature + + # Example for a bug fix: + git checkout -b fix/bug-description + ``` +2. **Make your code changes.** Write clean, readable code and add comments where necessary. +3. **Format and lint your code** before committing to ensure it meets our style guidelines. + ```bash + make format + make lint + ``` +4. **Run the tests** to ensure that your changes don't break existing functionality. + ```bash + make test + ``` +5. **Commit your changes.** We follow the **[Conventional Commits](https://www.conventionalcommits.org/)** specification. You can use our commit command, which will guide you through the process: + ```bash + make commit + ``` +6. **Push your changes** to your forked repository. + ```bash + git push origin feature/my-new-feature + ``` +7. **Open a Pull Request** from your fork to our `main` branch. Please provide a clear title and description for your changes, linking to any relevant issues. + +--- + +## Pull Request Guidelines + +* Ensure all tests and CI checks are passing. +* If you've added new functionality, please add corresponding tests. +* Keep your PR focused on a single issue or feature. +* A maintainer will review your PR and provide feedback. + +--- + +## Code of Conduct + +By participating in this project, you agree to abide by our [Code of Conduct](CODE_OF_CONDUCT.md). Please be respectful and considerate in all your interactions. \ No newline at end of file diff --git a/Makefile b/Makefile index acc78e7..0f20c73 100644 --- a/Makefile +++ b/Makefile @@ -27,11 +27,11 @@ commit: ## Starts Commitizen for a guided commit message lint: ## Checks code quality with ruff @echo ">>> Checking code quality with ruff..." - uv run ruff check src tests + uv run ruff check src format: ## Formats code with ruff @echo ">>> Formatting code with ruff..." - uv run ruff format src tests + uv run ruff format src test: ## Runs tests with pytest @echo ">>> Running tests with pytest..." diff --git a/examples/teams/create_team.py b/examples/teams/create_team.py index 9c7a9c9..c08fff5 100644 --- a/examples/teams/create_team.py +++ b/examples/teams/create_team.py @@ -1,22 +1,20 @@ import asyncio -import os import pprint -from codesphere import CodesphereClient, Team -from codesphere.models import TeamsCreateTeamRequest +from codesphere import CodesphereSDK -async def main(api_token: str = ""): - api_token = api_token or os.getenv("CS_TOKEN") - request_args = TeamsCreateTeamRequest( - name="Test Team", - dc=2, # data center 2 => FRA - ) +async def main(): + try: + async with CodesphereSDK() as sdk: + created_team = await sdk.teams.create(name="hello", dc=2) + print("\n--- Details for the created team ---") + pprint.pprint(created_team.model_dump()) - async with CodesphereClient(api_token) as client: - team: Team = await client.teams.teams_create_team(request_args) + print(f"Team ID: {created_team.id}, Name: {created_team.name}") - pprint.pprint(team.model_dump()) + except Exception as e: + print(f"An error occurred: {e}") if __name__ == "__main__": diff --git a/examples/teams/delete_team.py b/examples/teams/delete_team.py index 8641cda..bc332da 100644 --- a/examples/teams/delete_team.py +++ b/examples/teams/delete_team.py @@ -1,17 +1,21 @@ import asyncio -import os import pprint -from codesphere import CodesphereClient +from codesphere import CodesphereSDK -async def main(team_id: int, api_token: str = ""): - api_token = api_token or os.getenv("CS_TOKEN") - async with CodesphereClient(api_token) as client: - status = await client.teams.teams_delete_team(team_id=team_id) +async def main(): + try: + async with CodesphereSDK() as sdk: + team_to_delete = await sdk.teams.get(team_id="") + print("\n--- Details of the team to be deleted ---") + pprint.pprint(team_to_delete.model_dump()) + await team_to_delete.delete() + print(f"Team with ID {team_to_delete.id} was successfully deleted.") - pprint.pprint(status) + except Exception as e: + print(f"An error occurred: {e}") if __name__ == "__main__": - asyncio.run(main("insert here teamid ro delete")) + asyncio.run(main()) diff --git a/examples/teams/get_team.py b/examples/teams/get_team.py index 5a67490..b98bf29 100644 --- a/examples/teams/get_team.py +++ b/examples/teams/get_team.py @@ -1,17 +1,20 @@ import asyncio -import os import pprint -from codesphere import CodesphereClient, Team +from codesphere import CodesphereSDK -async def main(team_id: int, api_token: str = ""): - api_token = api_token or os.getenv("CS_TOKEN") - async with CodesphereClient(api_token) as client: - team: Team = await client.teams.teams_get_team(team_id=team_id) +async def main(): + try: + async with CodesphereSDK() as sdk: + teams = await sdk.teams.list() + first_team = await sdk.teams.get(team_id=teams[0].id) + print("\n--- Details for the first team ---") + pprint.pprint(first_team.model_dump()) - pprint.pprint(team.model_dump()) + except Exception as e: + print(f"An error occurred: {e}") if __name__ == "__main__": - asyncio.run(main(team_id="insert team id here")) + asyncio.run(main()) diff --git a/examples/teams/list_teams.py b/examples/teams/list_teams.py index a31c9ae..e28291c 100644 --- a/examples/teams/list_teams.py +++ b/examples/teams/list_teams.py @@ -1,16 +1,18 @@ import asyncio -import os -import pprint -from codesphere import CodesphereClient, Team +from codesphere import CodesphereSDK -async def main(api_token: str = ""): - api_token = api_token or os.getenv("CS_TOKEN") - async with CodesphereClient(api_token) as client: - teams: list[Team] = await client.teams.teams_list_teams() - for team in teams: - pprint.pprint(team.model_dump()) +async def main(): + try: + async with CodesphereSDK() as sdk: + teams = await sdk.teams.list() + print(f"Found {len(teams)} teams:") + for team in teams: + print(f"Team ID: {team.id}, Name: {team.name}") + + except Exception as e: + print(f"An error occurred: {e}") if __name__ == "__main__": diff --git a/openapi.json b/openapi.json deleted file mode 100644 index 240e3a4..0000000 --- a/openapi.json +++ /dev/null @@ -1,3951 +0,0 @@ -{ - "openapi": "3.0.0", - "info": { - "title": "Codesphere Public API", - "version": "0.1.0" - }, - "paths": { - "/domains/team/{teamId}/domain/{domainName}": { - "get": { - "summary": "getDomain", - "tags": [ - "domains" - ], - "parameters": [ - { - "name": "teamId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "domainName", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "A valid FQDN.", - "example": "foo.example.com" - } - } - ], - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "teamId": { - "type": "integer", - "minimum": 0 - }, - "dataCenterId": { - "type": "integer", - "minimum": 0 - }, - "workspaces": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "integer", - "minimum": 0 - } - } - }, - "name": { - "type": "string" - }, - "certificateRequestStatus": { - "type": "object", - "properties": { - "issued": { - "type": "boolean" - }, - "reason": { - "type": "string", - "nullable": true - } - }, - "required": [ - "issued", - "reason" - ] - }, - "dnsEntries": { - "type": "object", - "properties": { - "a": { - "type": "string" - }, - "cname": { - "type": "string" - }, - "txt": { - "type": "string" - } - }, - "required": [ - "a", - "cname", - "txt" - ] - }, - "domainVerificationStatus": { - "type": "object", - "properties": { - "verified": { - "type": "boolean" - }, - "reason": { - "type": "string", - "nullable": true - } - }, - "required": [ - "verified", - "reason" - ] - }, - "customConfigRevision": { - "type": "integer", - "minimum": 0 - }, - "customConfig": { - "type": "object", - "properties": { - "maxBodySizeMb": { - "type": "number" - }, - "maxConnectionTimeoutS": { - "type": "number" - }, - "useRegex": { - "type": "boolean" - }, - "restricted": { - "type": "boolean" - } - } - } - }, - "required": [ - "teamId", - "dataCenterId", - "workspaces", - "name", - "certificateRequestStatus", - "dnsEntries", - "domainVerificationStatus" - ] - } - } - } - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Domain not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "domains-getDomain" - }, - "post": { - "summary": "createDomain", - "tags": [ - "domains" - ], - "parameters": [ - { - "name": "teamId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "domainName", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "A valid FQDN.", - "example": "foo.example.com" - } - } - ], - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "teamId": { - "type": "integer", - "minimum": 0 - }, - "dataCenterId": { - "type": "integer", - "minimum": 0 - }, - "workspaces": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "integer", - "minimum": 0 - } - } - }, - "name": { - "type": "string" - }, - "certificateRequestStatus": { - "type": "object", - "properties": { - "issued": { - "type": "boolean" - }, - "reason": { - "type": "string", - "nullable": true - } - }, - "required": [ - "issued", - "reason" - ] - }, - "dnsEntries": { - "type": "object", - "properties": { - "a": { - "type": "string" - }, - "cname": { - "type": "string" - }, - "txt": { - "type": "string" - } - }, - "required": [ - "a", - "cname", - "txt" - ] - }, - "domainVerificationStatus": { - "type": "object", - "properties": { - "verified": { - "type": "boolean" - }, - "reason": { - "type": "string", - "nullable": true - } - }, - "required": [ - "verified", - "reason" - ] - }, - "customConfigRevision": { - "type": "integer", - "minimum": 0 - }, - "customConfig": { - "type": "object", - "properties": { - "maxBodySizeMb": { - "type": "number" - }, - "maxConnectionTimeoutS": { - "type": "number" - }, - "useRegex": { - "type": "boolean" - }, - "restricted": { - "type": "boolean" - } - } - } - }, - "required": [ - "teamId", - "dataCenterId", - "workspaces", - "name", - "certificateRequestStatus", - "dnsEntries", - "domainVerificationStatus" - ] - } - } - } - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "domains-createDomain" - }, - "patch": { - "summary": "updateDomain", - "tags": [ - "domains" - ], - "parameters": [ - { - "name": "teamId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "domainName", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "A valid FQDN.", - "example": "foo.example.com" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "maxBodySizeMb": { - "type": "number" - }, - "maxConnectionTimeoutS": { - "type": "number" - }, - "useRegex": { - "type": "boolean" - }, - "restricted": { - "type": "boolean" - } - } - } - } - } - }, - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "teamId": { - "type": "integer", - "minimum": 0 - }, - "dataCenterId": { - "type": "integer", - "minimum": 0 - }, - "workspaces": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "integer", - "minimum": 0 - } - } - }, - "name": { - "type": "string" - }, - "certificateRequestStatus": { - "type": "object", - "properties": { - "issued": { - "type": "boolean" - }, - "reason": { - "type": "string", - "nullable": true - } - }, - "required": [ - "issued", - "reason" - ] - }, - "dnsEntries": { - "type": "object", - "properties": { - "a": { - "type": "string" - }, - "cname": { - "type": "string" - }, - "txt": { - "type": "string" - } - }, - "required": [ - "a", - "cname", - "txt" - ] - }, - "domainVerificationStatus": { - "type": "object", - "properties": { - "verified": { - "type": "boolean" - }, - "reason": { - "type": "string", - "nullable": true - } - }, - "required": [ - "verified", - "reason" - ] - }, - "customConfigRevision": { - "type": "integer", - "minimum": 0 - }, - "customConfig": { - "type": "object", - "properties": { - "maxBodySizeMb": { - "type": "number" - }, - "maxConnectionTimeoutS": { - "type": "number" - }, - "useRegex": { - "type": "boolean" - }, - "restricted": { - "type": "boolean" - } - } - } - }, - "required": [ - "teamId", - "dataCenterId", - "workspaces", - "name", - "certificateRequestStatus", - "dnsEntries", - "domainVerificationStatus" - ] - } - } - } - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Domain not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "409": { - "description": "Another request is in progress.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "domains-updateDomain" - }, - "delete": { - "summary": "deleteDomain", - "tags": [ - "domains" - ], - "parameters": [ - { - "name": "teamId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "domainName", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "A valid FQDN.", - "example": "foo.example.com" - } - } - ], - "responses": { - "200": { - "description": "Success." - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Domain not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "domains-deleteDomain" - } - }, - "/domains/team/{teamId}": { - "get": { - "summary": "listDomains", - "tags": [ - "domains" - ], - "parameters": [ - { - "name": "teamId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "object", - "properties": { - "teamId": { - "type": "integer", - "minimum": 0 - }, - "dataCenterId": { - "type": "integer", - "minimum": 0 - }, - "workspaces": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "integer", - "minimum": 0 - } - } - }, - "name": { - "type": "string" - }, - "certificateRequestStatus": { - "type": "object", - "properties": { - "issued": { - "type": "boolean" - }, - "reason": { - "type": "string", - "nullable": true - } - }, - "required": [ - "issued", - "reason" - ] - }, - "dnsEntries": { - "type": "object", - "properties": { - "a": { - "type": "string" - }, - "cname": { - "type": "string" - }, - "txt": { - "type": "string" - } - }, - "required": [ - "a", - "cname", - "txt" - ] - }, - "domainVerificationStatus": { - "type": "object", - "properties": { - "verified": { - "type": "boolean" - }, - "reason": { - "type": "string", - "nullable": true - } - }, - "required": [ - "verified", - "reason" - ] - }, - "customConfigRevision": { - "type": "integer", - "minimum": 0 - }, - "customConfig": { - "type": "object", - "properties": { - "maxBodySizeMb": { - "type": "number" - }, - "maxConnectionTimeoutS": { - "type": "number" - }, - "useRegex": { - "type": "boolean" - }, - "restricted": { - "type": "boolean" - } - } - } - }, - "required": [ - "teamId", - "dataCenterId", - "workspaces", - "name", - "certificateRequestStatus", - "dnsEntries", - "domainVerificationStatus" - ] - } - } - } - } - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "domains-listDomains" - } - }, - "/domains/team/{teamId}/domain/{domainName}/verify": { - "post": { - "summary": "verifyDomain", - "tags": [ - "domains" - ], - "parameters": [ - { - "name": "teamId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "domainName", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "A valid FQDN.", - "example": "foo.example.com" - } - } - ], - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "verified": { - "type": "boolean" - }, - "reason": { - "type": "string", - "nullable": true - } - }, - "required": [ - "verified", - "reason" - ] - } - } - } - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Domain not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "domains-verifyDomain" - } - }, - "/domains/team/{teamId}/domain/{domainName}/workspace-connections": { - "put": { - "summary": "updateWorkspaceConnections", - "tags": [ - "domains" - ], - "parameters": [ - { - "name": "teamId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "domainName", - "in": "path", - "required": true, - "schema": { - "type": "string", - "description": "A valid FQDN.", - "example": "foo.example.com" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "integer", - "minimum": 0 - } - } - } - } - } - }, - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "teamId": { - "type": "integer", - "minimum": 0 - }, - "dataCenterId": { - "type": "integer", - "minimum": 0 - }, - "workspaces": { - "type": "object", - "additionalProperties": { - "type": "array", - "items": { - "type": "integer", - "minimum": 0 - } - } - }, - "name": { - "type": "string" - }, - "certificateRequestStatus": { - "type": "object", - "properties": { - "issued": { - "type": "boolean" - }, - "reason": { - "type": "string", - "nullable": true - } - }, - "required": [ - "issued", - "reason" - ] - }, - "dnsEntries": { - "type": "object", - "properties": { - "a": { - "type": "string" - }, - "cname": { - "type": "string" - }, - "txt": { - "type": "string" - } - }, - "required": [ - "a", - "cname", - "txt" - ] - }, - "domainVerificationStatus": { - "type": "object", - "properties": { - "verified": { - "type": "boolean" - }, - "reason": { - "type": "string", - "nullable": true - } - }, - "required": [ - "verified", - "reason" - ] - }, - "customConfigRevision": { - "type": "integer", - "minimum": 0 - }, - "customConfig": { - "type": "object", - "properties": { - "maxBodySizeMb": { - "type": "number" - }, - "maxConnectionTimeoutS": { - "type": "number" - }, - "useRegex": { - "type": "boolean" - }, - "restricted": { - "type": "boolean" - } - } - } - }, - "required": [ - "teamId", - "dataCenterId", - "workspaces", - "name", - "certificateRequestStatus", - "dnsEntries", - "domainVerificationStatus" - ] - } - } - } - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Domain not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "domains-updateWorkspaceConnections" - } - }, - "/metadata/datacenters": { - "get": { - "summary": "getDatacenters", - "tags": [ - "metadata" - ], - "parameters": [], - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "minimum": 0 - }, - "name": { - "type": "string" - }, - "city": { - "type": "string" - }, - "countryCode": { - "type": "string" - } - }, - "required": [ - "id", - "name", - "city", - "countryCode" - ] - } - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "metadata-getDatacenters" - } - }, - "/metadata/workspace-plans": { - "get": { - "summary": "getWorkspacePlans", - "tags": [ - "metadata" - ], - "parameters": [], - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "minimum": 0 - }, - "priceUsd": { - "type": "number" - }, - "title": { - "type": "string" - }, - "deprecated": { - "type": "boolean" - }, - "characteristics": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "minimum": 0 - }, - "CPU": { - "type": "number" - }, - "GPU": { - "type": "number" - }, - "RAM": { - "type": "integer", - "minimum": 0 - }, - "SSD": { - "type": "integer", - "minimum": 0 - }, - "TempStorage": { - "type": "integer", - "minimum": 0 - }, - "onDemand": { - "type": "boolean" - } - }, - "required": [ - "id", - "CPU", - "GPU", - "RAM", - "SSD", - "TempStorage", - "onDemand" - ] - }, - "maxReplicas": { - "type": "integer", - "minimum": 1 - } - }, - "required": [ - "id", - "priceUsd", - "title", - "deprecated", - "characteristics", - "maxReplicas" - ] - } - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "metadata-getWorkspacePlans" - } - }, - "/metadata/workspace-base-images": { - "get": { - "summary": "getWorkspaceBaseImages", - "tags": [ - "metadata" - ], - "parameters": [], - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "name": { - "type": "string" - }, - "supportedUntil": { - "type": "string", - "format": "date-time" - } - }, - "required": [ - "id", - "name", - "supportedUntil" - ] - } - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "metadata-getWorkspaceBaseImages" - } - }, - "/teams/{teamId}": { - "get": { - "summary": "getTeam", - "tags": [ - "teams" - ], - "parameters": [ - { - "name": "teamId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "minimum": 0 - }, - "defaultDataCenterId": { - "type": "integer", - "minimum": 0 - }, - "name": { - "type": "string" - }, - "description": { - "type": "string", - "nullable": true - }, - "avatarId": { - "type": "string", - "nullable": true - }, - "avatarUrl": { - "type": "string", - "nullable": true - }, - "isFirst": { - "type": "boolean" - } - }, - "required": [ - "id", - "defaultDataCenterId", - "name" - ] - } - } - } - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Team not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "teams-getTeam" - }, - "delete": { - "summary": "deleteTeam", - "tags": [ - "teams" - ], - "parameters": [ - { - "name": "teamId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "Success." - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Team not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "teams-deleteTeam" - } - }, - "/teams": { - "get": { - "summary": "listTeams", - "tags": [ - "teams" - ], - "parameters": [], - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "minimum": 0 - }, - "defaultDataCenterId": { - "type": "integer", - "minimum": 0 - }, - "name": { - "type": "string" - }, - "description": { - "type": "string", - "nullable": true - }, - "avatarId": { - "type": "string", - "nullable": true - }, - "avatarUrl": { - "type": "string", - "nullable": true - }, - "isFirst": { - "type": "boolean" - }, - "role": { - "type": "integer", - "enum": [ - 0, - 1 - ], - "description": "Role{0:'Admin',1:'Member'}" - } - }, - "required": [ - "id", - "defaultDataCenterId", - "name", - "role" - ] - } - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "teams-listTeams" - }, - "post": { - "summary": "createTeam", - "tags": [ - "teams" - ], - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "dc": { - "type": "integer", - "minimum": 0 - } - }, - "required": [ - "name", - "dc" - ] - } - } - } - }, - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "minimum": 0 - }, - "defaultDataCenterId": { - "type": "integer", - "minimum": 0 - }, - "name": { - "type": "string" - }, - "description": { - "type": "string", - "nullable": true - }, - "avatarId": { - "type": "string", - "nullable": true - }, - "avatarUrl": { - "type": "string", - "nullable": true - }, - "isFirst": { - "type": "boolean" - } - }, - "required": [ - "id", - "defaultDataCenterId", - "name" - ] - } - } - } - }, - "400": { - "description": "Invalid datacenter, path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "teams-createTeam" - } - }, - "/workspaces/{workspaceId}": { - "get": { - "summary": "getWorkspace", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "teamId": { - "type": "integer", - "minimum": 0 - }, - "name": { - "type": "string" - }, - "planId": { - "type": "integer", - "minimum": 0 - }, - "isPrivateRepo": { - "type": "boolean" - }, - "replicas": { - "type": "integer", - "minimum": 1 - }, - "id": { - "type": "integer", - "minimum": 0 - }, - "baseImage": { - "type": "string" - }, - "dataCenterId": { - "type": "integer", - "minimum": 0 - }, - "userId": { - "type": "integer", - "minimum": 0 - }, - "gitUrl": { - "type": "string", - "nullable": true - }, - "initialBranch": { - "type": "string", - "nullable": true - }, - "sourceWorkspaceId": { - "type": "integer", - "minimum": 0, - "nullable": true - }, - "welcomeMessage": { - "type": "string", - "nullable": true - }, - "vpnConfig": { - "type": "string", - "nullable": true - } - }, - "required": [ - "teamId", - "name", - "planId", - "isPrivateRepo", - "replicas", - "id", - "dataCenterId", - "userId", - "gitUrl", - "initialBranch", - "sourceWorkspaceId", - "welcomeMessage", - "vpnConfig" - ] - } - } - } - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-getWorkspace" - }, - "patch": { - "summary": "updateWorkspace", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "planId": { - "type": "integer", - "minimum": 0 - }, - "baseImage": { - "type": "string" - }, - "name": { - "type": "string" - }, - "replicas": { - "type": "integer", - "minimum": 1 - }, - "vpnConfig": { - "type": "string", - "nullable": true - } - } - } - } - } - }, - "responses": { - "200": { - "description": "Success." - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-updateWorkspace" - }, - "delete": { - "summary": "deleteWorkspace", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "Success." - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-deleteWorkspace" - } - }, - "/workspaces/{workspaceId}/status": { - "get": { - "summary": "getWorkspaceStatus", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "isRunning": { - "type": "boolean" - } - }, - "required": [ - "isRunning" - ] - } - } - } - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-getWorkspaceStatus" - } - }, - "/workspaces": { - "post": { - "summary": "createWorkspace", - "tags": [ - "workspaces" - ], - "parameters": [], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "teamId": { - "type": "integer", - "minimum": 0 - }, - "name": { - "type": "string" - }, - "planId": { - "type": "integer", - "minimum": 0 - }, - "isPrivateRepo": { - "type": "boolean" - }, - "replicas": { - "type": "integer", - "minimum": 1 - }, - "baseImage": { - "type": "string" - }, - "gitUrl": { - "type": "string" - }, - "initialBranch": { - "type": "string" - }, - "cloneDepth": { - "type": "integer", - "minimum": 1 - }, - "sourceWorkspaceId": { - "type": "integer", - "minimum": 0 - }, - "welcomeMessage": { - "type": "string" - }, - "vpnConfig": { - "type": "string" - } - }, - "required": [ - "teamId", - "name", - "planId", - "isPrivateRepo", - "replicas" - ] - } - } - } - }, - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "teamId": { - "type": "integer", - "minimum": 0 - }, - "name": { - "type": "string" - }, - "planId": { - "type": "integer", - "minimum": 0 - }, - "isPrivateRepo": { - "type": "boolean" - }, - "replicas": { - "type": "integer", - "minimum": 1 - }, - "id": { - "type": "integer", - "minimum": 0 - }, - "baseImage": { - "type": "string" - }, - "dataCenterId": { - "type": "integer", - "minimum": 0 - }, - "userId": { - "type": "integer", - "minimum": 0 - }, - "gitUrl": { - "type": "string", - "nullable": true - }, - "initialBranch": { - "type": "string", - "nullable": true - }, - "sourceWorkspaceId": { - "type": "integer", - "minimum": 0, - "nullable": true - }, - "welcomeMessage": { - "type": "string", - "nullable": true - }, - "vpnConfig": { - "type": "string", - "nullable": true - } - }, - "required": [ - "teamId", - "name", - "planId", - "isPrivateRepo", - "replicas", - "id", - "dataCenterId", - "userId", - "gitUrl", - "initialBranch", - "sourceWorkspaceId", - "welcomeMessage", - "vpnConfig" - ] - } - } - } - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-createWorkspace" - } - }, - "/workspaces/team/{teamId}": { - "get": { - "summary": "listWorkspaces", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "teamId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "object", - "properties": { - "teamId": { - "type": "integer", - "minimum": 0 - }, - "name": { - "type": "string" - }, - "planId": { - "type": "integer", - "minimum": 0 - }, - "isPrivateRepo": { - "type": "boolean" - }, - "replicas": { - "type": "integer", - "minimum": 1 - }, - "id": { - "type": "integer", - "minimum": 0 - }, - "baseImage": { - "type": "string" - }, - "dataCenterId": { - "type": "integer", - "minimum": 0 - }, - "userId": { - "type": "integer", - "minimum": 0 - }, - "gitUrl": { - "type": "string", - "nullable": true - }, - "initialBranch": { - "type": "string", - "nullable": true - }, - "sourceWorkspaceId": { - "type": "integer", - "minimum": 0, - "nullable": true - }, - "welcomeMessage": { - "type": "string", - "nullable": true - }, - "vpnConfig": { - "type": "string", - "nullable": true - } - }, - "required": [ - "teamId", - "name", - "planId", - "isPrivateRepo", - "replicas", - "id", - "dataCenterId", - "userId", - "gitUrl", - "initialBranch", - "sourceWorkspaceId", - "welcomeMessage", - "vpnConfig" - ] - } - } - } - } - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-listWorkspaces" - } - }, - "/workspaces/{workspaceId}/landscape/deploy/{profile}": { - "post": { - "summary": "deployLandscape", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "profile", - "in": "path", - "required": true, - "schema": { - "type": "string", - "pattern": "^[A-Za-z0-9-_]+$", - "example": "my-profile" - } - } - ], - "responses": { - "200": { - "description": "Success." - }, - "400": { - "description": "Workspace does not supportMulti Server Deployments, path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-deployLandscape-1" - } - }, - "/workspaces/{workspaceId}/landscape/deploy": { - "post": { - "summary": "deployLandscape", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "Success." - }, - "400": { - "description": "Workspace does not supportMulti Server Deployments, path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-deployLandscape" - } - }, - "/workspaces/{workspaceId}/landscape/teardown": { - "delete": { - "summary": "teardownLandscape", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "Success." - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-teardownLandscape" - } - }, - "/workspaces/{workspaceId}/pipeline/{stage}/start/{profile}": { - "post": { - "summary": "startPipelineStage", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "stage", - "in": "path", - "required": true, - "schema": { - "type": "string", - "enum": [ - "prepare", - "test", - "run" - ] - } - }, - { - "name": "profile", - "in": "path", - "required": true, - "schema": { - "type": "string", - "pattern": "^[A-Za-z0-9-_]+$", - "example": "my-profile" - } - } - ], - "responses": { - "200": { - "description": "Success." - }, - "400": { - "description": "Workspace is not running, path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-startPipelineStage-1" - } - }, - "/workspaces/{workspaceId}/pipeline/{stage}/start": { - "post": { - "summary": "startPipelineStage", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "stage", - "in": "path", - "required": true, - "schema": { - "type": "string", - "enum": [ - "prepare", - "test", - "run" - ] - } - } - ], - "responses": { - "200": { - "description": "Success." - }, - "400": { - "description": "Workspace is not running, path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-startPipelineStage" - } - }, - "/workspaces/{workspaceId}/pipeline/{stage}/stop": { - "post": { - "summary": "stopPipelineStage", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "stage", - "in": "path", - "required": true, - "schema": { - "type": "string", - "enum": [ - "prepare", - "test", - "run" - ] - } - } - ], - "responses": { - "200": { - "description": "Success." - }, - "400": { - "description": "Workspace is not running, path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-stopPipelineStage" - } - }, - "/workspaces/{workspaceId}/pipeline/{stage}": { - "get": { - "summary": "pipelineStatus", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "stage", - "in": "path", - "required": true, - "schema": { - "type": "string", - "enum": [ - "prepare", - "test", - "run" - ] - } - } - ], - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "object", - "properties": { - "state": { - "type": "string", - "enum": [ - "waiting", - "running", - "success", - "failure", - "aborted" - ] - }, - "startedAt": { - "type": "string", - "format": "date-time" - }, - "finishedAt": { - "type": "string", - "format": "date-time" - }, - "steps": { - "type": "array", - "items": { - "type": "object", - "properties": { - "state": { - "type": "string", - "enum": [ - "waiting", - "running", - "success", - "failure", - "aborted" - ] - }, - "startedAt": { - "type": "string", - "format": "date-time" - }, - "finishedAt": { - "type": "string", - "format": "date-time" - } - }, - "required": [ - "state" - ] - } - }, - "replica": { - "type": "string" - }, - "server": { - "type": "string", - "pattern": "^(?:[a-z]|[a-z][-a-z0-9]{0,30}[a-z0-9])$", - "example": "myServer" - } - }, - "required": [ - "state", - "steps", - "replica", - "server" - ] - } - } - } - } - }, - "400": { - "description": "Workspace is not running, path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-pipelineStatus" - } - }, - "/workspaces/{workspaceId}/env-vars": { - "get": { - "summary": "listEnvVars", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "object", - "properties": { - "name": { - "type": "string", - "pattern": "^[A-Za-z_][A-Za-z0-9_.-]*$", - "example": "MY_VAR" - }, - "value": { - "type": "string" - } - }, - "required": [ - "name", - "value" - ] - } - } - } - } - }, - "400": { - "description": "Path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-listEnvVars" - }, - "put": { - "summary": "setEnvVar", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "object", - "properties": { - "name": { - "type": "string", - "pattern": "^[A-Za-z_][A-Za-z0-9_.-]*$", - "example": "MY_VAR" - }, - "value": { - "type": "string" - } - }, - "required": [ - "name", - "value" - ] - } - } - } - } - }, - "responses": { - "200": { - "description": "Success." - }, - "400": { - "description": "Workspace is not running, path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-setEnvVar" - }, - "delete": { - "summary": "deleteEnvVar", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "string", - "pattern": "^[A-Za-z_][A-Za-z0-9_.-]*$", - "example": "MY_VAR" - } - } - } - } - }, - "responses": { - "200": { - "description": "Success." - }, - "400": { - "description": "Workspace is not running, path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-deleteEnvVar" - } - }, - "/workspaces/{workspaceId}/execute": { - "post": { - "summary": "executeCommand", - "description": "Executes the command with \"bash -c command\". Timeouts after 5000ms.", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "command": { - "type": "string" - }, - "workingDir": { - "type": "string" - }, - "env": { - "type": "object", - "additionalProperties": { - "type": "string" - } - } - }, - "required": [ - "command" - ] - } - } - } - }, - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "command": { - "type": "string" - }, - "workingDir": { - "type": "string" - }, - "output": { - "type": "string" - }, - "error": { - "type": "string" - } - }, - "required": [ - "command", - "workingDir", - "output", - "error" - ] - } - } - } - }, - "400": { - "description": "Workspace is not running, path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-executeCommand" - } - }, - "/workspaces/{workspaceId}/git/head": { - "get": { - "summary": "gitHead", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "Success.", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "head": { - "type": "string" - } - }, - "required": [ - "head" - ] - } - } - } - }, - "400": { - "description": "Workspace is not running, git error, path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-gitHead" - } - }, - "/workspaces/{workspaceId}/git/pull/{remote}/{branch}": { - "post": { - "summary": "gitPull", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "remote", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "branch", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "Success." - }, - "400": { - "description": "Workspace is not running, git error, path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-gitPull-2" - } - }, - "/workspaces/{workspaceId}/git/pull/{remote}": { - "post": { - "summary": "gitPull", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "remote", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "Success." - }, - "400": { - "description": "Workspace is not running, git error, path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-gitPull-1" - } - }, - "/workspaces/{workspaceId}/git/pull": { - "post": { - "summary": "gitPull", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "Success." - }, - "400": { - "description": "Workspace is not running, git error, path or request body variable does not match schema.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "401": { - "description": "Authorization information is missing or invalid.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - }, - "404": { - "description": "Workspace is not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/_problem" - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-gitPull" - } - }, - "/workspaces/{workspaceId}/logs/{stage}/{step}": { - "get": { - "summary": "logs", - "description": "Returns a stream of logs for a given \"stage\" and \"step\". For \"run\" stage logs of Multi Server Deployments use [serverLogs](#/workspaces/workspaces-serverLogs) or [replicaLogs](#/workspaces/workspaces-replicaLogs).", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "stage", - "in": "path", - "required": true, - "schema": { - "type": "string", - "enum": [ - "prepare", - "test", - "run" - ] - } - }, - { - "name": "step", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - } - ], - "responses": { - "200": { - "description": "Success: Opens a Server Side Event(SSE) stream.", - "content": { - "text/event-stream": { - "schema": { - "description": "SSE stream with two event types: \"data\" and \"problem\". Both event data contain JSON objects in the form described by their schemas. Possible problem statuses and reasons:400: Workspace is not running, run stage logs requested for Multi Server Deployment, path or request body variable does not match schema. 401: Authorization information is missing or invalid. 404: Workspace is not found.", - "oneOf": [ - { - "$ref": "#/components/schemas/workspaces.logs.get.response" - }, - { - "$ref": "#/components/schemas/_problem" - } - ], - "discriminator": { - "propertyName": "event", - "mapping": { - "data": "#/components/schemas/workspaces.logs.get.response", - "problem": "#/components/schemas/_problem" - } - } - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-logs" - } - }, - "/workspaces/{workspaceId}/logs/run/{step}/server/{server}": { - "get": { - "summary": "serverLogs", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "step", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "server", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "Success: Opens a Server Side Event(SSE) stream.", - "content": { - "text/event-stream": { - "schema": { - "description": "SSE stream with two event types: \"data\" and \"problem\". Both event data contain JSON objects in the form described by their schemas. Possible problem statuses and reasons:400: Workspace is not running, path or request body variable does not match schema. 401: Authorization information is missing or invalid. 404: Workspace is not found.", - "oneOf": [ - { - "$ref": "#/components/schemas/workspaces.serverLogs.get.response" - }, - { - "$ref": "#/components/schemas/_problem" - } - ], - "discriminator": { - "propertyName": "event", - "mapping": { - "data": "#/components/schemas/workspaces.serverLogs.get.response", - "problem": "#/components/schemas/_problem" - } - } - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-serverLogs" - } - }, - "/workspaces/{workspaceId}/logs/run/{step}/replica/{replica}": { - "get": { - "summary": "replicaLogs", - "tags": [ - "workspaces" - ], - "parameters": [ - { - "name": "workspaceId", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "step", - "in": "path", - "required": true, - "schema": { - "type": "number" - } - }, - { - "name": "replica", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "Success: Opens a Server Side Event(SSE) stream.", - "content": { - "text/event-stream": { - "schema": { - "description": "SSE stream with two event types: \"data\" and \"problem\". Both event data contain JSON objects in the form described by their schemas. Possible problem statuses and reasons:400: Workspace is not running, path or request body variable does not match schema. 401: Authorization information is missing or invalid. 404: Workspace is not found.", - "oneOf": [ - { - "$ref": "#/components/schemas/workspaces.replicaLogs.get.response" - }, - { - "$ref": "#/components/schemas/_problem" - } - ], - "discriminator": { - "propertyName": "event", - "mapping": { - "data": "#/components/schemas/workspaces.replicaLogs.get.response", - "problem": "#/components/schemas/_problem" - } - } - } - } - } - } - }, - "security": [ - { - "bearerAuth": [] - } - ], - "operationId": "workspaces-replicaLogs" - } - } - }, - "components": { - "securitySchemes": { - "bearerAuth": { - "type": "http", - "scheme": "bearer" - } - }, - "schemas": { - "_problem": { - "description": "An SSE event of type problem. Data contains a JSON object with given properties.", - "properties": { - "data": { - "type": "object", - "properties": { - "status": { - "type": "integer", - "enum": [ - 100, - 101, - 102, - 200, - 201, - 202, - 203, - 204, - 205, - 206, - 207, - 208, - 226, - 300, - 301, - 302, - 303, - 304, - 305, - 306, - 307, - 308, - 400, - 401, - 402, - 403, - 404, - 405, - 406, - 407, - 408, - 409, - 410, - 411, - 412, - 413, - 414, - 415, - 416, - 417, - 418, - 421, - 422, - 423, - 424, - 426, - 428, - 429, - 431, - 451, - 500, - 501, - 502, - 503, - 504, - 505, - 506, - 507, - 508, - 510, - 511 - ] - }, - "title": { - "type": "string" - }, - "detail": { - "type": "string" - }, - "traceId": { - "type": "string" - } - }, - "required": [ - "status", - "title", - "traceId" - ] - }, - "event": { - "type": "string", - "enum": [ - "problem" - ] - } - }, - "required": [ - "data", - "event" - ] - }, - "workspaces.logs.get.response": { - "description": "An SSE event of type data. Data contains a JSON object with given properties.", - "properties": { - "data": { - "type": "array", - "items": { - "type": "object", - "properties": { - "timestamp": { - "type": "string", - "format": "date-time" - }, - "kind": { - "type": "string", - "enum": [ - "E", - "I" - ] - }, - "data": { - "type": "string" - } - }, - "required": [ - "timestamp", - "kind", - "data" - ] - } - }, - "event": { - "type": "string", - "enum": [ - "data" - ] - } - }, - "required": [ - "data", - "event" - ] - }, - "workspaces.serverLogs.get.response": { - "description": "An SSE event of type data. Data contains a JSON object with given properties.", - "properties": { - "data": { - "type": "array", - "items": { - "type": "object", - "properties": { - "timestamp": { - "type": "string", - "format": "date-time" - }, - "kind": { - "type": "string", - "enum": [ - "E", - "I" - ] - }, - "data": { - "type": "string" - } - }, - "required": [ - "timestamp", - "kind", - "data" - ] - } - }, - "event": { - "type": "string", - "enum": [ - "data" - ] - } - }, - "required": [ - "data", - "event" - ] - }, - "workspaces.replicaLogs.get.response": { - "description": "An SSE event of type data. Data contains a JSON object with given properties.", - "properties": { - "data": { - "type": "array", - "items": { - "type": "object", - "properties": { - "timestamp": { - "type": "string", - "format": "date-time" - }, - "kind": { - "type": "string", - "enum": [ - "E", - "I" - ] - }, - "data": { - "type": "string" - } - }, - "required": [ - "timestamp", - "kind", - "data" - ] - } - }, - "event": { - "type": "string", - "enum": [ - "data" - ] - } - }, - "required": [ - "data", - "event" - ] - } - } - }, - "tags": [ - { - "name": "domains" - }, - { - "name": "metadata" - }, - { - "name": "teams" - }, - { - "name": "workspaces" - } - ], - "servers": [ - { - "url": "https://codesphere.com/api" - } - ] - } diff --git a/pyproject.toml b/pyproject.toml index b343b16..7af67a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "codesphere" -version = "0.0.4" +version = "0.1.1" description = "Use Codesphere within python scripts." readme = "README.md" license = { file="LICENSE" } @@ -12,6 +12,7 @@ requires-python = ">=3.12.9" dependencies = [ "aiohttp>=3.12.13", "aiohttp-retry>=2.9.1", + "httpx>=0.28.1", "pydantic>=2.11.7", "python-dateutil>=2.9.0.post0", "typing-extensions>=4.14.0", @@ -109,4 +110,4 @@ skips = ["B101"] [project.urls] Homepage = "https://codesphere.com/" Repository = "https://github.com/Datata1/codesphere-python" -"Bug Tracker" = "https://github.com/Datata1/codesphere-python/issues" \ No newline at end of file +"Bug Tracker" = "https://github.com/Datata1/codesphere-python/issues" diff --git a/src/codesphere/__init__.py b/src/codesphere/__init__.py new file mode 100644 index 0000000..c3ef8b6 --- /dev/null +++ b/src/codesphere/__init__.py @@ -0,0 +1,24 @@ +# z.B. in src/codesphere/__init__.py oder einer eigenen client.py +from .client import APIHttpClient +from .resources.team.resource import TeamsResource + + +class CodesphereSDK: + def __init__(self, token: str = None): + self._http_client = APIHttpClient() + # Die Ressourcen werden erst im __aenter__ initialisiert + self.teams: TeamsResource | None = None + + async def __aenter__(self): + """Wird beim Eintritt in den 'async with'-Block aufgerufen.""" + # Startet den internen HTTP-Client + await self._http_client.__aenter__() + + # Initialisiert die Ressourcen-Handler mit dem aktiven Client + self.teams = TeamsResource(self._http_client) + return self + + async def __aexit__(self, exc_type, exc_val, exc_tb): + """Wird beim Verlassen des 'async with'-Blocks aufgerufen.""" + # Schließt den internen HTTP-Client sicher + await self._http_client.__aexit__(exc_type, exc_val, exc_tb) diff --git a/src/codesphere/client.py b/src/codesphere/client.py new file mode 100644 index 0000000..3b0aa34 --- /dev/null +++ b/src/codesphere/client.py @@ -0,0 +1,58 @@ +import os +import httpx +from pydantic import BaseModel +from typing import Optional, Any + +from .resources.exceptions.exceptions import AuthenticationError + + +class APIHttpClient: + def __init__(self, base_url: str = "https://codesphere.com/api"): + auth_token = os.environ.get("CS_TOKEN") + + if not auth_token: + raise AuthenticationError() + + self._token = auth_token + self._base_url = base_url + self.client: Optional[httpx.Client] = None + + async def __aenter__(self): + self.client = httpx.AsyncClient( + base_url=self._base_url, headers={"Authorization": f"Bearer {self._token}"} + ) + return self + + async def __aexit__(self, exc_type: Any, exc_val: Any, exc_tb: Any): + if self.client: + await self.client.aclose() + + async def request( + self, method: str, endpoint: str, **kwargs: Any + ) -> httpx.Response: + if not self.client: + raise RuntimeError("APIHttpClient must be used within a 'with' statement.") + print(f"{method} {endpoint} {kwargs}") + + response = await self.client.request(method, endpoint, **kwargs) + response.raise_for_status() + return response + + async def get(self, endpoint: str, json: Optional[dict] = None) -> httpx.Response: + json_data = json.model_dump() if json else None + return await self.request("GET", endpoint, json=json_data) + + async def post( + self, endpoint: str, json: Optional[BaseModel] = None + ) -> httpx.Response: + json_data = json.model_dump() if json else None + return await self.request("POST", endpoint, json=json_data) + + async def put( + self, endpoint: str, json: Optional[BaseModel] = None + ) -> httpx.Response: + json_data = json.model_dump() if json else None + return await self.request("PUT", endpoint, json=json_data) + + async def delete(self, endpoint: str) -> httpx.Response: + return await self.request("DELETE", endpoint) diff --git a/src/codesphere/resources/__init__.py b/src/codesphere/resources/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/codesphere/resources/base.py b/src/codesphere/resources/base.py new file mode 100644 index 0000000..ccd6ea6 --- /dev/null +++ b/src/codesphere/resources/base.py @@ -0,0 +1,67 @@ +from functools import partial +from typing import Any, Type, List, get_origin, get_args, Optional +from pydantic import BaseModel +from ..client import APIHttpClient + + +class APIOperation: + """Describes a single, reusable API operation.""" + + def __init__( + self, + method: str, + endpoint_template: str, + response_model: Type[BaseModel] | Type[List[BaseModel]], + input_model: Optional[Type[BaseModel]] = None, + ): + self.method = method + self.endpoint_template = endpoint_template + self.response_model = response_model + self.input_model = input_model + + +class ResourceBase: + """The base class for all resources, containing the logic to execute APIOperations.""" + + def __init__(self, http_client: APIHttpClient): + self._http_client = http_client + + def __getattribute__(self, name: str) -> Any: + """Intercepts attribute access to execute APIOperations dynamically.""" + attr = super().__getattribute__(name) + if isinstance(attr, APIOperation): + return partial(self._execute_operation, operation=attr) + return attr + + async def _execute_operation(self, operation: APIOperation, **kwargs: Any) -> Any: + """Executes an APIOperation, fills placeholders, and parses the response.""" + format_args = {**self.__dict__, **kwargs} + endpoint = operation.endpoint_template.format(**format_args) + + params = kwargs.get("params") + payload = None + + if operation.input_model: + input_data = operation.input_model(**kwargs) + payload = input_data.model_dump() + + response = await self._http_client.request( + method=operation.method, endpoint=endpoint, json=payload, params=params + ) + + if operation.response_model is None: + return None + + json_response = response.json() + + origin = get_origin(operation.response_model) + if origin is list or origin is List: + item_model = get_args(operation.response_model)[0] + instances = [item_model.model_validate(item) for item in json_response] + for instance in instances: + instance._http_client = self._http_client + return instances + else: + instance = operation.response_model.model_validate(json_response) + instance._http_client = self._http_client + return instance diff --git a/src/codesphere/resources/domain/models.py b/src/codesphere/resources/domain/models.py new file mode 100644 index 0000000..4f4ed6f --- /dev/null +++ b/src/codesphere/resources/domain/models.py @@ -0,0 +1,37 @@ +from __future__ import annotations +from pydantic import BaseModel, PrivateAttr +from typing import Optional, TYPE_CHECKING +from datetime import datetime + +if TYPE_CHECKING: + from ...client import APIHttpClient + + +class Domain(BaseModel): + _http_client: Optional[APIHttpClient] = PrivateAttr(default=None) + + id: str + name: str + verified_at: Optional[datetime] = None + + async def delete(self) -> None: + """Deletes this specific domain instance via the API.""" + if not self._http_client: + raise RuntimeError("Cannot make API calls on a detached model.") + if not self.id: + raise ValueError("Cannot delete a domain without an ID.") + + await self._http_client.delete(f"/domains/{self.id}") + print(f"Domain '{self.name}' has been deleted.") + + async def save(self) -> None: + """Updates this domain with its current data.""" + if not self._http_client: + raise RuntimeError("Cannot make API calls on a detached model.") + if not self.id: + raise ValueError("Cannot update a domain without an ID.") + + update_data = self.model_dump(exclude={"id"}) + + await self._http_client.put(f"/domains/{self.id}", json=update_data) + print(f"Domain '{self.name}' has been updated.") diff --git a/src/codesphere/resources/domain/resource.py b/src/codesphere/resources/domain/resource.py new file mode 100644 index 0000000..9f841e1 --- /dev/null +++ b/src/codesphere/resources/domain/resource.py @@ -0,0 +1,21 @@ +from typing import List +from ..base import ResourceBase, APIOperation +from .models import Domain + + +class DomainsResource(ResourceBase): + def __init__(self, http_client, team_id: str): + super().__init__(http_client) + self.team_id = team_id + + list = APIOperation( + method="GET", + endpoint_template="/domains/team/{team_id}", + response_model=List[Domain], + ) + + get = APIOperation( + method="GET", + endpoint_template="/domains/team/{team_id}/{domain_name}", + response_model=Domain, + ) diff --git a/src/codesphere/resources/exceptions/exceptions.py b/src/codesphere/resources/exceptions/exceptions.py new file mode 100644 index 0000000..19bb0d9 --- /dev/null +++ b/src/codesphere/resources/exceptions/exceptions.py @@ -0,0 +1,16 @@ +class CodesphereError(Exception): + """Base exception class for all errors in the Codesphere SDK.""" + + pass + + +class AuthenticationError(CodesphereError): + """Raised for authentication-related errors, like a missing API token.""" + + def __init__(self, message: str = None): + if message is None: + message = ( + "Authentication token not provided. Please pass it as an argument " + "or set the 'CS_TOKEN' environment variable." + ) + super().__init__(message) diff --git a/src/codesphere/resources/team/models.py b/src/codesphere/resources/team/models.py new file mode 100644 index 0000000..f21afa1 --- /dev/null +++ b/src/codesphere/resources/team/models.py @@ -0,0 +1,59 @@ +from __future__ import annotations +from pydantic import BaseModel, PrivateAttr, model_validator +from typing import Optional, TYPE_CHECKING + +from ..domain.resource import DomainsResource + +if TYPE_CHECKING: + from ...client import APIHttpClient + + +class TeamCreate(BaseModel): + """Defines the request body for creating a team.""" + + name: str + dc: int + + +class TeamBase(BaseModel): + """Contains all fields that appear in almost every team response.""" + + id: int + name: str + description: Optional[str] = None + avatarId: Optional[str] = None + avatarUrl: Optional[str] = None + isFirst: bool + defaultDataCenterId: int + role: Optional[int] = None + + +class TeamInList(TeamBase): + """Represents a team as it appears in the list response.""" + + role: int + + +class Team(TeamBase): + """ + Represents a complete, single team object (detail view). + This is the "active" model with methods. + """ + + _http_client: Optional[APIHttpClient] = PrivateAttr(default=None) + _domains: Optional[DomainsResource] = PrivateAttr(default=None) + + @model_validator(mode="after") + def setup_sub_resources(self) -> "Team": + """Creates the sub-resources after initialization.""" + if self._http_client: + self._domains = DomainsResource( + http_client=self._http_client, team_id=str(self.id) + ) + return self + + async def delete(self) -> None: + """Deletes this team via the API.""" + if not self._http_client: + raise RuntimeError("Cannot make API calls on a detached model.") + await self._http_client.delete(f"/teams/{self.id}") diff --git a/src/codesphere/resources/team/resource.py b/src/codesphere/resources/team/resource.py new file mode 100644 index 0000000..0ab738d --- /dev/null +++ b/src/codesphere/resources/team/resource.py @@ -0,0 +1,35 @@ +from typing import List +from ..base import ResourceBase, APIOperation +from .models import Team, TeamCreate + + +class TeamsResource(ResourceBase): + """Contains all API operations for team ressources.""" + + list = APIOperation( + method="GET", + endpoint_template="/teams", + input_model=None, + response_model=List[Team], + ) + + get = APIOperation( + method="GET", + endpoint_template="/teams/{team_id}", + input_model=None, + response_model=Team, + ) + + create = APIOperation( + method="POST", + endpoint_template="/teams", + input_model=TeamCreate, + response_model=Team, + ) + + delete = APIOperation( + method="DELETE", + endpoint_template="/teams/{team_id}", + input_model=None, + response_model=None, + ) diff --git a/uv.lock b/uv.lock index d35cca4..5aa1dfd 100644 --- a/uv.lock +++ b/uv.lock @@ -95,6 +95,20 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53", size = 13643, upload-time = "2024-05-20T21:33:24.1Z" }, ] +[[package]] +name = "anyio" +version = "4.9.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "idna" }, + { name = "sniffio" }, + { name = "typing-extensions", marker = "python_full_version < '3.13'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/95/7d/4c1bd541d4dffa1b52bd83fb8527089e097a106fc90b467a7313b105f840/anyio-4.9.0.tar.gz", hash = "sha256:673c0c244e15788651a4ff38710fea9675823028a6f08a5eda409e0c9840a028", size = 190949, upload-time = "2025-03-17T00:02:54.77Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a1/ee/48ca1a7c89ffec8b6a0c5d02b89c305671d5ffd8d3c94acf8b8c408575bb/anyio-4.9.0-py3-none-any.whl", hash = "sha256:9f76d541cad6e36af7beb62e978876f3b41e3e04f2c1fbf0884604c0a9c4d93c", size = 100916, upload-time = "2025-03-17T00:02:52.713Z" }, +] + [[package]] name = "argcomplete" version = "3.6.2" @@ -113,6 +127,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/77/06/bb80f5f86020c4551da315d78b3ab75e8228f89f0162f2c3a819e407941a/attrs-25.3.0-py3-none-any.whl", hash = "sha256:427318ce031701fea540783410126f03899a97ffc6f61596ad581ac2e40e3bc3", size = 63815, upload-time = "2025-03-13T11:10:21.14Z" }, ] +[[package]] +name = "certifi" +version = "2025.7.14" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/b3/76/52c535bcebe74590f296d6c77c86dabf761c41980e1347a2422e4aa2ae41/certifi-2025.7.14.tar.gz", hash = "sha256:8ea99dbdfaaf2ba2f9bac77b9249ef62ec5218e7c2b2e903378ed5fccf765995", size = 163981, upload-time = "2025-07-14T03:29:28.449Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/4f/52/34c6cf5bb9285074dc3531c437b3919e825d976fde097a7a73f79e726d03/certifi-2025.7.14-py3-none-any.whl", hash = "sha256:6b31f564a415d79ee77df69d757bb49a5bb53bd9f756cbbe24394ffd6fc1f4b2", size = 162722, upload-time = "2025-07-14T03:29:26.863Z" }, +] + [[package]] name = "cfgv" version = "3.4.0" @@ -159,11 +182,12 @@ wheels = [ [[package]] name = "codesphere" -version = "0.0.4" +version = "0.1.1" source = { editable = "." } dependencies = [ { name = "aiohttp" }, { name = "aiohttp-retry" }, + { name = "httpx" }, { name = "pydantic" }, { name = "python-dateutil" }, { name = "typing-extensions" }, @@ -184,6 +208,7 @@ requires-dist = [ { name = "aiohttp", specifier = ">=3.12.13" }, { name = "aiohttp-retry", specifier = ">=2.9.1" }, { name = "commitizen", marker = "extra == 'dev'", specifier = ">=4.8.3" }, + { name = "httpx", specifier = ">=0.28.1" }, { name = "pre-commit", marker = "extra == 'dev'", specifier = ">=4.2.0" }, { name = "pydantic", specifier = ">=2.11.7" }, { name = "pytest", marker = "extra == 'dev'", specifier = ">=8.4.0" }, @@ -355,6 +380,43 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/ee/45/b82e3c16be2182bff01179db177fe144d58b5dc787a7d4492c6ed8b9317f/frozenlist-1.7.0-py3-none-any.whl", hash = "sha256:9a5af342e34f7e97caf8c995864c7a396418ae2859cc6fdf1b1073020d516a7e", size = 13106, upload-time = "2025-06-09T23:02:34.204Z" }, ] +[[package]] +name = "h11" +version = "0.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/01/ee/02a2c011bdab74c6fb3c75474d40b3052059d95df7e73351460c8588d963/h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1", size = 101250, upload-time = "2025-04-24T03:35:25.427Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/4b/29cac41a4d98d144bf5f6d33995617b185d14b22401f75ca86f384e87ff1/h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86", size = 37515, upload-time = "2025-04-24T03:35:24.344Z" }, +] + +[[package]] +name = "httpcore" +version = "1.0.9" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "certifi" }, + { name = "h11" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/06/94/82699a10bca87a5556c9c59b5963f2d039dbd239f25bc2a63907a05a14cb/httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8", size = 85484, upload-time = "2025-04-24T22:06:22.219Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7e/f5/f66802a942d491edb555dd61e3a9961140fd64c90bce1eafd741609d334d/httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55", size = 78784, upload-time = "2025-04-24T22:06:20.566Z" }, +] + +[[package]] +name = "httpx" +version = "0.28.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "certifi" }, + { name = "httpcore" }, + { name = "idna" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/b1/df/48c586a5fe32a0f01324ee087459e112ebb7224f646c0b5023f5e79e9956/httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc", size = 141406, upload-time = "2024-12-06T15:37:23.222Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad", size = 73517, upload-time = "2024-12-06T15:37:21.509Z" }, +] + [[package]] name = "identify" version = "2.6.12" @@ -805,6 +867,15 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050, upload-time = "2024-12-04T17:35:26.475Z" }, ] +[[package]] +name = "sniffio" +version = "1.3.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a2/87/a6771e1546d97e7e041b6ae58d80074f81b7d5121207425c964ddf5cfdbd/sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc", size = 20372, upload-time = "2024-02-25T23:20:04.057Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2", size = 10235, upload-time = "2024-02-25T23:20:01.196Z" }, +] + [[package]] name = "termcolor" version = "3.1.0"