-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,225 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
from darwin.future.core.properties.create import create_property | ||
from darwin.future.core.properties.get import ( | ||
get_property_by_id, | ||
get_team_full_properties, | ||
get_team_properties, | ||
) | ||
from darwin.future.core.properties.update import update_property, update_property_value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from typing import Optional, Union | ||
|
||
from pydantic import parse_obj_as | ||
|
||
from darwin.future.core.client import ClientCore | ||
from darwin.future.core.types.common import JSONDict | ||
from darwin.future.data_objects.properties import FullProperty | ||
|
||
|
||
def create_property( | ||
client: ClientCore, | ||
params: Union[FullProperty, JSONDict], | ||
team_slug: Optional[str] = None, | ||
) -> FullProperty: | ||
""" | ||
Creates a property for the specified team slug. | ||
Parameters: | ||
client (ClientCore): The client to use for the request. | ||
team_slug (Optional[str]): The slug of the team to get. If not specified, the | ||
default team from the client's config will be used. | ||
params (Optional[JSONType]): The JSON data to use for the request. | ||
Returns: | ||
FullProperty: FullProperty object for the created property. | ||
Raises: | ||
HTTPError: If the response status code is not in the 200-299 range. | ||
""" | ||
if not team_slug: | ||
team_slug = client.config.default_team | ||
if isinstance(params, FullProperty): | ||
params = params.to_create_endpoint() | ||
response = client.post(f"/v2/teams/{team_slug}/properties", data=params) | ||
assert isinstance(response, dict) | ||
return parse_obj_as(FullProperty, response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from typing import Optional, Union | ||
|
||
from pydantic import parse_obj_as | ||
|
||
from darwin.future.core.client import ClientCore | ||
from darwin.future.core.types.common import JSONDict | ||
from darwin.future.data_objects.properties import FullProperty, PropertyValue | ||
|
||
|
||
def update_property( | ||
client: ClientCore, | ||
params: Union[FullProperty, JSONDict], | ||
team_slug: Optional[str] = None, | ||
) -> FullProperty: | ||
""" | ||
Updates a property for the specified team slug. | ||
Parameters: | ||
client (ClientCore): The client to use for the request. | ||
team_slug (Optional[str]): The slug of the team to get. If not specified, the | ||
default team from the client's config will be used. | ||
params (Optional[JSONType]): The JSON data to use for the request. | ||
Returns: | ||
FullProperty: FullProperty object for the created property. | ||
Raises: | ||
HTTPError: If the response status code is not in the 200-299 range. | ||
""" | ||
if not team_slug: | ||
team_slug = client.config.default_team | ||
if isinstance(params, FullProperty): | ||
id, params = params.to_update_endpoint() | ||
else: | ||
id = params.get("id") | ||
del params["id"] | ||
response = client.put(f"/v2/teams/{team_slug}/properties/{id}", data=params) | ||
assert isinstance(response, dict) | ||
return parse_obj_as(FullProperty, response) | ||
|
||
|
||
def update_property_value( | ||
client: ClientCore, | ||
params: Union[PropertyValue, JSONDict], | ||
item_id: str, | ||
team_slug: Optional[str] = None, | ||
) -> PropertyValue: | ||
""" | ||
Updates a property value for the specified property id. | ||
Parameters: | ||
client (ClientCore): The client to use for the request. | ||
team_slug (Optional[str]): The slug of the team to get. If not specified, the | ||
default team from the client's config will be used. | ||
params (Optional[JSONType]): The JSON data to use for the request. | ||
Returns: | ||
FullProperty: FullProperty object for the created property. | ||
Raises: | ||
HTTPError: If the response status code is not in the 200-299 range. | ||
""" | ||
if not team_slug: | ||
team_slug = client.config.default_team | ||
if isinstance(params, PropertyValue): | ||
id, params = params.to_update_endpoint() | ||
else: | ||
id = params.get("id") | ||
del params["id"] | ||
response = client.put( | ||
f"/v2/teams/{team_slug}/properties/{item_id}/property_values/{id}", data=params | ||
) | ||
assert isinstance(response, dict) | ||
return parse_obj_as(PropertyValue, response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.