Skip to content

Commit 4c44c6b

Browse files
authored
Feature/teams (#1)
* feat(src/codesphere/team): adding team resources from public api BREAKING CHANGE: * bump: version 0.0.4 → 0.1.0 * fix(.github/ci.yml): fix trigger condition * bump: version 0.1.0 → 0.1.1
1 parent 41433a7 commit 4c44c6b

File tree

22 files changed

+610
-3998
lines changed

22 files changed

+610
-3998
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: Python backend server tests
1+
name: Python tests
22

33
on:
44
pull_request:
55
types: [opened, synchronize, reopened, ready_for_review, draft]
66
paths:
7-
- 'src/codesphere_sdk/**'
8-
- '.github/workflows/backend-app.yml'
7+
- 'src/codesphere/**'
8+
- '.github/workflows/ci.yml'
99

1010
permissions:
1111
contents: write

.github/workflows/publish.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# .github/workflows/release.yml
2-
31
name: Create Release and Publish to PyPI
42

53
on:

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## v0.1.1 (2025-07-16)
2+
3+
### Fix
4+
5+
- **.github/ci.yml**: fix trigger condition
6+
7+
## v0.1.0 (2025-07-16)
8+
9+
### Feat
10+
11+
- **src/codesphere/team**: adding team resources from public api
12+
113
## v0.0.4 (2025-07-16)
214

315
## v0.0.3 (2025-07-16)

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
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.
6+
7+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8+
9+
## Our Standards
10+
11+
Examples of behavior that contributes to a positive environment for our community include:
12+
13+
* Demonstrating empathy and kindness toward other people
14+
* Being respectful of differing opinions, viewpoints, and experiences
15+
* Giving and gracefully accepting constructive feedback
16+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17+
* Focusing on what is best not just for us as individuals, but for the overall community
18+
19+
Examples of unacceptable behavior include:
20+
21+
* The use of sexualized language or imagery, and sexual attention or advances of any kind
22+
* Trolling, insulting or derogatory comments, and personal or political attacks
23+
* Public or private harassment
24+
* Publishing others' private information, such as a physical or email address, without their explicit permission
25+
* Other conduct which could reasonably be considered inappropriate in a professional setting
26+
27+
## Enforcement Responsibilities
28+
29+
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.
30+
31+
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.
32+
33+
## Scope
34+
35+
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.
36+
37+
## Enforcement
38+
39+
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.
40+
41+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
42+
43+
## Enforcement Guidelines
44+
45+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
46+
47+
### 1. Correction
48+
49+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
50+
51+
**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.
52+
53+
### 2. Warning
54+
55+
**Community Impact**: A violation through a single incident or series of actions.
56+
57+
**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.
58+
59+
### 3. Temporary Ban
60+
61+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
62+
63+
**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.
64+
65+
### 4. Permanent Ban
66+
67+
**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.
68+
69+
**Consequence**: A permanent ban from any sort of public interaction within the community.
70+
71+
## Attribution
72+
73+
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].
74+
75+
[homepage]: https://www.contributor-covenant.org
76+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html

CONTRIBUTING

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Contributing to codesphere-python
2+
3+
First off, thank you for considering contributing to our project! We welcome any contributions, from fixing bugs and improving documentation to submitting new features.
4+
5+
---
6+
7+
## How Can I Contribute?
8+
9+
* **Reporting Bugs**: If you find a bug, please open a **GitHub Issue** and provide as much detail as possible, including steps to reproduce it.
10+
* **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.
11+
* **Pull Requests**: If you're ready to contribute code, documentation, or tests, you can open a Pull Request.
12+
13+
---
14+
15+
## Development Setup
16+
17+
To get your local development environment set up, please follow these steps:
18+
19+
1. **Fork the repository** on GitHub.
20+
2. **Clone your forked repository** to your local machine:
21+
```bash
22+
git clone [https://github.com/YOUR_USERNAME/codesphere-python.git](https://github.com/YOUR_USERNAME/codesphere-python.git)
23+
cd codesphere-python
24+
```
25+
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:
26+
```bash
27+
make install
28+
```
29+
4. **Activate the virtual environment**:
30+
```bash
31+
source .venv/bin/activate
32+
```
33+
34+
You are now ready to start developing!
35+
36+
---
37+
38+
## Contribution Workflow
39+
40+
1. **Create a new branch** for your changes. Please use a descriptive branch name.
41+
```bash
42+
# Example for a new feature:
43+
git checkout -b feature/my-new-feature
44+
45+
# Example for a bug fix:
46+
git checkout -b fix/bug-description
47+
```
48+
2. **Make your code changes.** Write clean, readable code and add comments where necessary.
49+
3. **Format and lint your code** before committing to ensure it meets our style guidelines.
50+
```bash
51+
make format
52+
make lint
53+
```
54+
4. **Run the tests** to ensure that your changes don't break existing functionality.
55+
```bash
56+
make test
57+
```
58+
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:
59+
```bash
60+
make commit
61+
```
62+
6. **Push your changes** to your forked repository.
63+
```bash
64+
git push origin feature/my-new-feature
65+
```
66+
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.
67+
68+
---
69+
70+
## Pull Request Guidelines
71+
72+
* Ensure all tests and CI checks are passing.
73+
* If you've added new functionality, please add corresponding tests.
74+
* Keep your PR focused on a single issue or feature.
75+
* A maintainer will review your PR and provide feedback.
76+
77+
---
78+
79+
## Code of Conduct
80+
81+
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.

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ commit: ## Starts Commitizen for a guided commit message
2727

2828
lint: ## Checks code quality with ruff
2929
@echo ">>> Checking code quality with ruff..."
30-
uv run ruff check src tests
30+
uv run ruff check src
3131

3232
format: ## Formats code with ruff
3333
@echo ">>> Formatting code with ruff..."
34-
uv run ruff format src tests
34+
uv run ruff format src
3535

3636
test: ## Runs tests with pytest
3737
@echo ">>> Running tests with pytest..."

examples/teams/create_team.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
import asyncio
2-
import os
32
import pprint
4-
from codesphere import CodesphereClient, Team
5-
from codesphere.models import TeamsCreateTeamRequest
63

4+
from codesphere import CodesphereSDK
75

8-
async def main(api_token: str = ""):
9-
api_token = api_token or os.getenv("CS_TOKEN")
106

11-
request_args = TeamsCreateTeamRequest(
12-
name="Test Team",
13-
dc=2, # data center 2 => FRA
14-
)
7+
async def main():
8+
try:
9+
async with CodesphereSDK() as sdk:
10+
created_team = await sdk.teams.create(name="hello", dc=2)
11+
print("\n--- Details for the created team ---")
12+
pprint.pprint(created_team.model_dump())
1513

16-
async with CodesphereClient(api_token) as client:
17-
team: Team = await client.teams.teams_create_team(request_args)
14+
print(f"Team ID: {created_team.id}, Name: {created_team.name}")
1815

19-
pprint.pprint(team.model_dump())
16+
except Exception as e:
17+
print(f"An error occurred: {e}")
2018

2119

2220
if __name__ == "__main__":

examples/teams/delete_team.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import asyncio
2-
import os
32
import pprint
4-
from codesphere import CodesphereClient
53

4+
from codesphere import CodesphereSDK
65

7-
async def main(team_id: int, api_token: str = ""):
8-
api_token = api_token or os.getenv("CS_TOKEN")
96

10-
async with CodesphereClient(api_token) as client:
11-
status = await client.teams.teams_delete_team(team_id=team_id)
7+
async def main():
8+
try:
9+
async with CodesphereSDK() as sdk:
10+
team_to_delete = await sdk.teams.get(team_id="<id>")
11+
print("\n--- Details of the team to be deleted ---")
12+
pprint.pprint(team_to_delete.model_dump())
13+
await team_to_delete.delete()
14+
print(f"Team with ID {team_to_delete.id} was successfully deleted.")
1215

13-
pprint.pprint(status)
16+
except Exception as e:
17+
print(f"An error occurred: {e}")
1418

1519

1620
if __name__ == "__main__":
17-
asyncio.run(main("insert here teamid ro delete"))
21+
asyncio.run(main())

examples/teams/get_team.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import asyncio
2-
import os
32
import pprint
4-
from codesphere import CodesphereClient, Team
53

4+
from codesphere import CodesphereSDK
65

7-
async def main(team_id: int, api_token: str = ""):
8-
api_token = api_token or os.getenv("CS_TOKEN")
96

10-
async with CodesphereClient(api_token) as client:
11-
team: Team = await client.teams.teams_get_team(team_id=team_id)
7+
async def main():
8+
try:
9+
async with CodesphereSDK() as sdk:
10+
teams = await sdk.teams.list()
11+
first_team = await sdk.teams.get(team_id=teams[0].id)
12+
print("\n--- Details for the first team ---")
13+
pprint.pprint(first_team.model_dump())
1214

13-
pprint.pprint(team.model_dump())
15+
except Exception as e:
16+
print(f"An error occurred: {e}")
1417

1518

1619
if __name__ == "__main__":
17-
asyncio.run(main(team_id="insert team id here"))
20+
asyncio.run(main())

examples/teams/list_teams.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import asyncio
2-
import os
3-
import pprint
4-
from codesphere import CodesphereClient, Team
52

3+
from codesphere import CodesphereSDK
64

7-
async def main(api_token: str = ""):
8-
api_token = api_token or os.getenv("CS_TOKEN")
95

10-
async with CodesphereClient(api_token) as client:
11-
teams: list[Team] = await client.teams.teams_list_teams()
12-
for team in teams:
13-
pprint.pprint(team.model_dump())
6+
async def main():
7+
try:
8+
async with CodesphereSDK() as sdk:
9+
teams = await sdk.teams.list()
10+
print(f"Found {len(teams)} teams:")
11+
for team in teams:
12+
print(f"Team ID: {team.id}, Name: {team.name}")
13+
14+
except Exception as e:
15+
print(f"An error occurred: {e}")
1416

1517

1618
if __name__ == "__main__":

0 commit comments

Comments
 (0)