Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Add workspaces.create method
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-balitskyi committed Nov 28, 2023
1 parent 71db16e commit 99e4071
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
3 changes: 3 additions & 0 deletions seamapi/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ class Workspace:
workspace_id: str
name: str
is_sandbox: bool
connect_partner_name: str = None
webview_primary_button_color: str = None
webview_logo_shape: str = None


@dataclass_json
Expand Down
58 changes: 58 additions & 0 deletions seamapi/workspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,61 @@ def reset_sandbox(self) -> None:
message="Successfully reset workspace sandbox",
ok=True,
)

@report_error
def create(
self,
name: str,
connect_partner_name: str,
is_sandbox: Optional[bool],
webview_primary_button_color: Optional[str],
webview_logo_shape: Optional[str],
) -> Workspace:
"""Creates a workspace.
Parameters
----------
name : string
Workspace name
connect_partner_name : string
Name shown on the connect webview
is_sandbox : string, optional
If true, creates a sandbox workspace; if false, creates a production workspace. Defaults to false.
webview_primary_button_color : string, optional
The color of the primary button in the webview, represented in hex format (e.g., "#RRGGBB").
webview_logo_shape : string, optional
The shape of the logo in the webview: "circle" or "square".
Raises
------
Exception
If the API request wasn't successful.
Returns
------
Workspace
"""

create_payload = {"name": name, "connect_partner_name": connect_partner_name}

if is_sandbox is not None:
create_payload["is_sandbox"] = is_sandbox
if webview_primary_button_color is not None:
create_payload["webview_primary_button_color"] = webview_primary_button_color
if webview_logo_shape is not None:
create_payload["webview_logo_shape"] = webview_logo_shape

res = self.seam.make_request(
"POST",
"/workspaces/create",
json=create_payload,
)
return Workspace(
workspace_id=res["workspace"]["workspace_id"],
name=res["workspace"]["name"],
is_sandbox=res["workspace"]["is_sandbox"],
connect_partner_name=res["workspace"]["connect_partner_name"],
webview_primary_button_color=res["workspace"]["webview_primary_button_color"],
webview_logo_shape=res["workspace"]["webview_logo_shape"],
)

0 comments on commit 99e4071

Please sign in to comment.