This repository has been archived by the owner on Jun 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
14950d3
commit 4a0cb44
Showing
9 changed files
with
87 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
from .packages import * | ||
from .public import * | ||
from .dashes import * | ||
from .subdomains import * |
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,4 @@ | ||
import abstra_cli.apis.main as api_main | ||
import abstra_cli.utils as utils | ||
|
||
|
||
def list_workspace_packages(): | ||
|
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 @@ | ||
import abstra_cli.apis.main as api_main | ||
|
||
|
||
def get_subdomain(): | ||
query = """ | ||
query Subdomains { | ||
subdomains { | ||
name | ||
} | ||
} | ||
""" | ||
|
||
subdomains = api_main.hf_hasura_runner(query, {}).get("subdomains", []) | ||
if not len(subdomains): | ||
print("Could not find subdomain.") | ||
exit() | ||
|
||
return subdomains[0]["name"] | ||
|
||
def update_subdomain(old_name, new_name): | ||
query = """ | ||
mutation UpdateSubdomain($old_name: String!, $new_name: String!) { | ||
update_subdomains(where: {name: {_eq: $old_name}}, _set: {name: $new_name}) { | ||
returning { | ||
name | ||
} | ||
} | ||
} | ||
""" | ||
return ( | ||
api_main.hf_hasura_runner(query, {"old_name": old_name, "new_name": new_name}) | ||
.get("update_subdomains", {}) | ||
.get("returning", []) | ||
) | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from abstra_cli.resources.resources import Resource | ||
from abstra_cli.apis import get_subdomain, update_subdomain | ||
import abstra_cli.messages as messages | ||
|
||
class Subdomains(Resource): | ||
@staticmethod | ||
def list(): | ||
subdomain = get_subdomain() | ||
messages.print_subdomains(subdomain) | ||
|
||
@staticmethod | ||
def update(*args, **kwargs): | ||
if not len(args): | ||
messages.missing_parameters_to_update("name", "subdomain") | ||
exit() | ||
|
||
new_subdomain = args[0] | ||
old_subdomain = get_subdomain() | ||
try: | ||
updated_subdomain = update_subdomain(old_subdomain, new_subdomain) | ||
messages.print_subdomains(updated_subdomain[0]['name']) | ||
except Exception as error: | ||
if len(error.args) > 0 and len(error.args[0]) > 0 and error.args[0][0]['extensions']['code'] == 'constraint-violation': | ||
messages.conflict_name('name', 'subdomain') | ||
else: | ||
messages.update_failed('subdomain') |