Skip to content

Commit

Permalink
feat: OPTIC-1360: [BE] create Account settings endpoints that handle …
Browse files Browse the repository at this point in the history
…existing functionality in the django template (#364)

Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
Co-authored-by: Marcel Canu <[email protected]>
  • Loading branch information
3 people authored Dec 4, 2024
1 parent 114c2b3 commit 83ec0f8
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .mock/definition/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ types:
allow_newsletters:
type: optional<boolean>
docs: Allow sending newsletters to user
date_joined: optional<datetime>
source:
openapi: openapi/openapi.yaml
Filter:
Expand Down Expand Up @@ -373,6 +374,7 @@ types:
validation:
format: email
maxLength: 254
created_at: optional<datetime>
source:
openapi: openapi/openapi.yaml
Organization:
Expand Down Expand Up @@ -430,6 +432,7 @@ types:
allow_newsletters:
type: optional<boolean>
docs: Allow sending newsletters to user
date_joined: optional<datetime>
created_projects: optional<string>
contributed_to_projects: optional<string>
source:
Expand Down Expand Up @@ -2265,6 +2268,19 @@ types:
docs: A unique integer value identifying this project.
source:
openapi: openapi/openapi.yaml
OrganizationMember:
properties:
user:
type: integer
docs: User ID
organization:
type: integer
docs: Organization ID
contributed_projects_count: optional<string>
annotations_count: optional<string>
created_at: optional<datetime>
source:
openapi: openapi/openapi.yaml
PromptCreatedBy:
discriminated: false
docs: User ID of the creator of the prompt
Expand Down
1 change: 1 addition & 0 deletions .mock/definition/organizations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ service:
- id: 1
title: title
contact_info: contact_info
created_at: '2024-01-15T09:30:00Z'
get:
path: /api/organizations/{id}
method: GET
Expand Down
27 changes: 27 additions & 0 deletions .mock/definition/organizations/members.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,33 @@ service:
organization: 1
user:
username: username
get:
path: /api/organizations/{id}/memberships/{user_pk}/
method: GET
auth: true
docs: Get organization member details by user ID.
path-parameters:
id: string
user_pk:
type: integer
docs: >-
A unique integer value identifying the user to get organization
details for.
display-name: Get organization member details
response:
docs: ''
type: root.OrganizationMember
examples:
- path-parameters:
id: id
user_pk: 1
response:
body:
user: 1
organization: 1
contributed_projects_count: contributed_projects_count
annotations_count: annotations_count
created_at: '2024-01-15T09:30:00Z'
delete:
path: /api/organizations/{id}/memberships/{user_pk}/
method: DELETE
Expand Down
5 changes: 5 additions & 0 deletions .mock/definition/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ service:
phone: phone
active_organization: 1
allow_newsletters: true
date_joined: '2024-01-15T09:30:00Z'
audiences:
- public
list:
Expand Down Expand Up @@ -107,6 +108,7 @@ service:
phone: phone
active_organization: 1
allow_newsletters: true
date_joined: '2024-01-15T09:30:00Z'
audiences:
- public
create:
Expand Down Expand Up @@ -166,6 +168,7 @@ service:
phone: phone
active_organization: 1
allow_newsletters: true
date_joined: '2024-01-15T09:30:00Z'
audiences:
- public
get:
Expand Down Expand Up @@ -202,6 +205,7 @@ service:
phone: phone
active_organization: 1
allow_newsletters: true
date_joined: '2024-01-15T09:30:00Z'
audiences:
- public
delete:
Expand Down Expand Up @@ -299,6 +303,7 @@ service:
phone: phone
active_organization: 1
allow_newsletters: true
date_joined: '2024-01-15T09:30:00Z'
audiences:
- public
source:
Expand Down
13 changes: 13 additions & 0 deletions .mock/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8279,6 +8279,10 @@ components:
description: Allow sending newsletters to user
type: boolean
nullable: true
date_joined:
title: Date joined
type: string
format: date-time
Filter:
required:
- column
Expand Down Expand Up @@ -8696,6 +8700,11 @@ components:
format: email
maxLength: 254
nullable: true
created_at:
title: Created at
type: string
format: date-time
readOnly: true
Organization:
required:
- title
Expand Down Expand Up @@ -8794,6 +8803,10 @@ components:
description: Allow sending newsletters to user
type: boolean
nullable: true
date_joined:
title: Date joined
type: string
format: date-time
created_projects:
title: Created projects
type: string
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "label-studio-sdk"
version = "1.0.9.dev"
version = "1.0.9"
description = ""
readme = "README.md"
authors = []
Expand Down
2 changes: 1 addition & 1 deletion src/label_studio_sdk/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_headers(self) -> typing.Dict[str, str]:
headers: typing.Dict[str, str] = {
"X-Fern-Language": "Python",
"X-Fern-SDK-Name": "label-studio-sdk",
"X-Fern-SDK-Version": "1.0.8",
"X-Fern-SDK-Version": "1.0.9",
}
headers["Authorization"] = f"Token {self.api_key}"
return headers
Expand Down
2 changes: 2 additions & 0 deletions src/label_studio_sdk/types/base_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class BaseUser(pydantic_v1.BaseModel):
Allow sending newsletters to user
"""

date_joined: typing.Optional[dt.datetime] = None

def json(self, **kwargs: typing.Any) -> str:
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
return super().json(**kwargs_with_defaults)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ async def test_whoami(client: LabelStudio, async_client: AsyncLabelStudio) -> No
"phone": "phone",
"active_organization": 1,
"allow_newsletters": True,
"date_joined": "2024-01-15T09:30:00Z",
}
expected_types: typing.Any = {
"id": "integer",
Expand All @@ -53,6 +54,7 @@ async def test_whoami(client: LabelStudio, async_client: AsyncLabelStudio) -> No
"phone": None,
"active_organization": "integer",
"allow_newsletters": None,
"date_joined": "datetime",
}
response = client.users.whoami()
validate_response(response, expected_response, expected_types)
Expand All @@ -75,6 +77,7 @@ async def test_list_(client: LabelStudio, async_client: AsyncLabelStudio) -> Non
"phone": "phone",
"active_organization": 1,
"allow_newsletters": True,
"date_joined": "2024-01-15T09:30:00Z",
}
]
expected_types: typing.Any = (
Expand All @@ -92,6 +95,7 @@ async def test_list_(client: LabelStudio, async_client: AsyncLabelStudio) -> Non
"phone": None,
"active_organization": "integer",
"allow_newsletters": None,
"date_joined": "datetime",
}
},
)
Expand All @@ -115,6 +119,7 @@ async def test_create(client: LabelStudio, async_client: AsyncLabelStudio) -> No
"phone": "phone",
"active_organization": 1,
"allow_newsletters": True,
"date_joined": "2024-01-15T09:30:00Z",
}
expected_types: typing.Any = {
"id": "integer",
Expand All @@ -128,6 +133,7 @@ async def test_create(client: LabelStudio, async_client: AsyncLabelStudio) -> No
"phone": None,
"active_organization": "integer",
"allow_newsletters": None,
"date_joined": "datetime",
}
response = client.users.create()
validate_response(response, expected_response, expected_types)
Expand All @@ -149,6 +155,7 @@ async def test_get(client: LabelStudio, async_client: AsyncLabelStudio) -> None:
"phone": "phone",
"active_organization": 1,
"allow_newsletters": True,
"date_joined": "2024-01-15T09:30:00Z",
}
expected_types: typing.Any = {
"id": "integer",
Expand All @@ -162,6 +169,7 @@ async def test_get(client: LabelStudio, async_client: AsyncLabelStudio) -> None:
"phone": None,
"active_organization": "integer",
"allow_newsletters": None,
"date_joined": "datetime",
}
response = client.users.get(id=1)
validate_response(response, expected_response, expected_types)
Expand Down Expand Up @@ -190,6 +198,7 @@ async def test_update(client: LabelStudio, async_client: AsyncLabelStudio) -> No
"phone": "phone",
"active_organization": 1,
"allow_newsletters": True,
"date_joined": "2024-01-15T09:30:00Z",
}
expected_types: typing.Any = {
"id": "integer",
Expand All @@ -203,6 +212,7 @@ async def test_update(client: LabelStudio, async_client: AsyncLabelStudio) -> No
"phone": None,
"active_organization": "integer",
"allow_newsletters": None,
"date_joined": "datetime",
}
response = client.users.update(id=1)
validate_response(response, expected_response, expected_types)
Expand Down

0 comments on commit 83ec0f8

Please sign in to comment.