primitive 0.2.21__py3-none-any.whl → 0.2.25__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- primitive/__about__.py +1 -1
- primitive/auth/actions.py +0 -2
- primitive/auth/commands.py +13 -13
- primitive/hardware/commands.py +20 -4
- primitive/organizations/actions.py +28 -0
- {primitive-0.2.21.dist-info → primitive-0.2.25.dist-info}/METADATA +2 -4
- {primitive-0.2.21.dist-info → primitive-0.2.25.dist-info}/RECORD +10 -10
- {primitive-0.2.21.dist-info → primitive-0.2.25.dist-info}/WHEEL +0 -0
- {primitive-0.2.21.dist-info → primitive-0.2.25.dist-info}/entry_points.txt +0 -0
- {primitive-0.2.21.dist-info → primitive-0.2.25.dist-info}/licenses/LICENSE.txt +0 -0
primitive/__about__.py
CHANGED
primitive/auth/actions.py
CHANGED
@@ -18,14 +18,12 @@ class Auth(BaseAction):
|
|
18
18
|
|
19
19
|
def setup_config(
|
20
20
|
self,
|
21
|
-
username: str,
|
22
21
|
token: str,
|
23
22
|
host: str = "api.primitive.tech",
|
24
23
|
transport: str = "https",
|
25
24
|
):
|
26
25
|
full_config = read_config_file()
|
27
26
|
new_host_config = {
|
28
|
-
"username": username,
|
29
27
|
"token": token,
|
30
28
|
"transport": transport,
|
31
29
|
}
|
primitive/auth/commands.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import os
|
2
|
-
import typing
|
3
2
|
import webbrowser
|
3
|
+
from typing import TYPE_CHECKING, Optional
|
4
4
|
|
5
5
|
import click
|
6
6
|
|
@@ -8,7 +8,7 @@ from ..utils.config import PRIMITIVE_CREDENTIALS_FILEPATH
|
|
8
8
|
from ..utils.printer import print_result
|
9
9
|
from .actions import Auth
|
10
10
|
|
11
|
-
if
|
11
|
+
if TYPE_CHECKING:
|
12
12
|
from ..client import Primitive
|
13
13
|
|
14
14
|
|
@@ -34,13 +34,6 @@ def whoami_command(context):
|
|
34
34
|
|
35
35
|
@cli.command("config")
|
36
36
|
@click.pass_context
|
37
|
-
@click.option(
|
38
|
-
"--username",
|
39
|
-
prompt=True,
|
40
|
-
default=lambda: os.environ.get("PRIMITIVE_USER", ""),
|
41
|
-
show_default="current user",
|
42
|
-
help="Username for Primitive API",
|
43
|
-
)
|
44
37
|
@click.option(
|
45
38
|
"--transport",
|
46
39
|
required=False,
|
@@ -48,9 +41,16 @@ def whoami_command(context):
|
|
48
41
|
show_default="https",
|
49
42
|
help="Transport protocol for Primitive API",
|
50
43
|
)
|
51
|
-
|
44
|
+
@click.option(
|
45
|
+
"--auth-token",
|
46
|
+
prompt=True,
|
47
|
+
default=lambda: os.environ.get("PRIMITIVE_TOKEN", ""),
|
48
|
+
hide_input=True,
|
49
|
+
help="Authentication token for Primitive API",
|
50
|
+
)
|
51
|
+
def config_command(context, transport: str, auth_token: Optional[str] = None):
|
52
52
|
"""Configure the CLI"""
|
53
|
-
token = os.environ.get("PRIMITIVE_TOKEN",
|
53
|
+
token = os.environ.get("PRIMITIVE_TOKEN", auth_token)
|
54
54
|
if not token and context.obj.get("YES"):
|
55
55
|
raise click.ClickException(
|
56
56
|
"PRIMITIVE_TOKEN environment variable is required for non-interactive mode"
|
@@ -73,6 +73,6 @@ def config_command(context, username: str, transport: str):
|
|
73
73
|
)
|
74
74
|
|
75
75
|
auth = Auth(primitive=None)
|
76
|
-
auth.setup_config(
|
77
|
-
message = f"Config created at '{PRIMITIVE_CREDENTIALS_FILEPATH}'
|
76
|
+
auth.setup_config(token=token, host=host, transport=transport)
|
77
|
+
message = f"Config created at '{PRIMITIVE_CREDENTIALS_FILEPATH}' on host '{host}'" # noqa
|
78
78
|
print_result(message=message, context=context, fg="green")
|
primitive/hardware/commands.py
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
-
import
|
1
|
+
from typing import TYPE_CHECKING, Optional
|
2
2
|
|
3
3
|
import click
|
4
4
|
|
5
5
|
from ..utils.printer import print_result
|
6
6
|
from .ui import render_hardware_table
|
7
7
|
|
8
|
-
if
|
8
|
+
if TYPE_CHECKING:
|
9
9
|
from ..client import Primitive
|
10
10
|
|
11
|
+
from loguru import logger
|
12
|
+
|
11
13
|
|
12
14
|
@click.group()
|
13
15
|
@click.pass_context
|
@@ -26,11 +28,25 @@ def systeminfo_command(context):
|
|
26
28
|
|
27
29
|
|
28
30
|
@cli.command("register")
|
31
|
+
@click.option(
|
32
|
+
"--organization",
|
33
|
+
type=str,
|
34
|
+
help="Organization [slug] to register hardware with",
|
35
|
+
)
|
29
36
|
@click.pass_context
|
30
|
-
def register_command(context):
|
37
|
+
def register_command(context, organization: Optional[str] = None):
|
31
38
|
"""Register Hardware with Primitive"""
|
32
39
|
primitive: Primitive = context.obj.get("PRIMITIVE")
|
33
|
-
|
40
|
+
|
41
|
+
organization_id = None
|
42
|
+
if organization:
|
43
|
+
organization_data = primitive.organizations.get_organization(slug=organization)
|
44
|
+
organization_id = organization_data.get("id")
|
45
|
+
|
46
|
+
if not organization_id:
|
47
|
+
logger.info("Registering hardware with the default organization.")
|
48
|
+
|
49
|
+
result = primitive.hardware.register(organization_id=organization_id)
|
34
50
|
color = "green" if result else "red"
|
35
51
|
if result.data.get("registerHardware"):
|
36
52
|
message = "Hardware registered successfully"
|
@@ -39,3 +39,31 @@ class Organizations(BaseAction):
|
|
39
39
|
)
|
40
40
|
organizations = [edge["node"] for edge in result.data["organizations"]["edges"]]
|
41
41
|
return organizations
|
42
|
+
|
43
|
+
@guard
|
44
|
+
def get_organization(
|
45
|
+
self,
|
46
|
+
organization_id: Optional[str] = None,
|
47
|
+
slug: Optional[str] = None,
|
48
|
+
):
|
49
|
+
query = gql(organizations_query)
|
50
|
+
|
51
|
+
filters = {}
|
52
|
+
if organization_id:
|
53
|
+
filters["organization"] = {"id": organization_id}
|
54
|
+
if slug:
|
55
|
+
filters["slug"] = {"exact": slug}
|
56
|
+
|
57
|
+
variables = {
|
58
|
+
"first": 1,
|
59
|
+
"filters": filters,
|
60
|
+
"order": {
|
61
|
+
"createdAt": "DESC",
|
62
|
+
},
|
63
|
+
}
|
64
|
+
|
65
|
+
result = self.primitive.session.execute(
|
66
|
+
query, variable_values=variables, get_execution_result=True
|
67
|
+
)
|
68
|
+
organizations = [edge["node"] for edge in result.data["organizations"]["edges"]]
|
69
|
+
return organizations[0]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: primitive
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.25
|
4
4
|
Project-URL: Documentation, https://github.com//primitivecorp/primitive-cli#readme
|
5
5
|
Project-URL: Issues, https://github.com//primitivecorp/primitive-cli/issues
|
6
6
|
Project-URL: Source, https://github.com//primitivecorp/primitive-cli
|
@@ -22,7 +22,6 @@ Requires-Dist: click
|
|
22
22
|
Requires-Dist: gql[all]
|
23
23
|
Requires-Dist: loguru
|
24
24
|
Requires-Dist: paramiko[invoke]
|
25
|
-
Requires-Dist: primitive-pal==0.1.4
|
26
25
|
Requires-Dist: psutil>=7.0.0
|
27
26
|
Requires-Dist: pyyaml
|
28
27
|
Requires-Dist: rich>=13.9.4
|
@@ -127,10 +126,9 @@ source .venv/bin/activate
|
|
127
126
|
source .venv/bin/activate.fish
|
128
127
|
|
129
128
|
primitive --host localhost:8000 config --transport http
|
130
|
-
Username []: <username> # find this on the frontend app at [http://localhost:3000](http://localhost:3000)
|
131
129
|
You can find or create a Primitive API token at http://localhost:3000/account/tokens
|
132
130
|
Please enter your Primitive API token: # create a token and copy the value here
|
133
|
-
Config created at '/Users/<user>/.config/primitive/credentials.json'
|
131
|
+
Config created at '/Users/<user>/.config/primitive/credentials.json' on host 'localhost:8000'
|
134
132
|
|
135
133
|
# verify the configuration worked via
|
136
134
|
primitive --host localhost:8000 whoami
|
@@ -1,4 +1,4 @@
|
|
1
|
-
primitive/__about__.py,sha256=
|
1
|
+
primitive/__about__.py,sha256=emMCm4cHzvmdYDOL83iUzQz3eDl0L-1JkrP95MpoyT8,130
|
2
2
|
primitive/__init__.py,sha256=bwKdgggKNVssJFVPfKSxqFMz4IxSr54WWbmiZqTMPNI,106
|
3
3
|
primitive/cli.py,sha256=g7EtHI9MATAB0qQu5w-WzbXtxz_8zu8z5E7sETmMkKU,2509
|
4
4
|
primitive/client.py,sha256=h8WZVnQylVe0vbpuyC8YZHl2JyITSPC-1HbUcmrE5pc,3623
|
@@ -8,8 +8,8 @@ primitive/agent/commands.py,sha256=cK7d3OcN5Z65gQWVZFQ-Y9ddw9Pes4f9OVBpeMsj5sE,2
|
|
8
8
|
primitive/agent/runner.py,sha256=CoRyReO3jPV8B7vILVWdszFD4GVop7HsVEUo1hoRXjo,14556
|
9
9
|
primitive/agent/uploader.py,sha256=ZzrzsajNBogwEC7mT6Ejy0h2Jd9axMYGzt9pbCvVMlk,3171
|
10
10
|
primitive/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
|
-
primitive/auth/actions.py,sha256=
|
12
|
-
primitive/auth/commands.py,sha256=
|
11
|
+
primitive/auth/actions.py,sha256=9NIEXJ1BNJutJs6AMMSjMN_ziONUAUhY_xHwojYJCLA,942
|
12
|
+
primitive/auth/commands.py,sha256=Krm38ioduDJZw0OIrIcb6eR2X6iECiWX0JPAI-2HNxY,2352
|
13
13
|
primitive/auth/graphql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
14
|
primitive/auth/graphql/queries.py,sha256=jhrr_VFzHIn8vcVprMIzUx7V4kkWYdR6CKMKPoVFv60,180
|
15
15
|
primitive/daemons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -44,7 +44,7 @@ primitive/graphql/utility_fragments.py,sha256=uIjwILC4QtWNyO5vu77VjQf_p0jvP3A9q_
|
|
44
44
|
primitive/hardware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
45
45
|
primitive/hardware/actions.py,sha256=d5KwuSsceOhDH9rgOL7YTCpQPhqT2inRTiZnROtiDic,26076
|
46
46
|
primitive/hardware/android.py,sha256=tu7pBPxWFrIwb_mm5CEdFFf1_veNDOKjOCQg13i_Lh4,2758
|
47
|
-
primitive/hardware/commands.py,sha256=
|
47
|
+
primitive/hardware/commands.py,sha256=NMliVHBZDl4UAvhmNEjrvN9KWPuqn87-d7eVb0ZqEYA,3752
|
48
48
|
primitive/hardware/ui.py,sha256=12rucuZ2s-w5R4bKyxON5dEbrdDnVf5sbj3K_nbdo44,2473
|
49
49
|
primitive/hardware/graphql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
50
50
|
primitive/hardware/graphql/fragments.py,sha256=kI6qnTNjaEaUr-C6eD55COphtueVYbYOWZwN5EW_3qw,350
|
@@ -60,7 +60,7 @@ primitive/jobs/graphql/queries.py,sha256=BrU_GnLjK0bTAmWsLSmGEUea7EM8MqTKxN1Qp6s
|
|
60
60
|
primitive/monitor/actions.py,sha256=GUQrwuan82pOJ5gI2FvQYzgDoP4fs28PdcI_fg_aXRs,8692
|
61
61
|
primitive/monitor/commands.py,sha256=dZsD8WKGU4OYO_AlKawfeRNVTMN0xJ-DFRkmKTS464s,258
|
62
62
|
primitive/organizations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
63
|
-
primitive/organizations/actions.py,sha256=
|
63
|
+
primitive/organizations/actions.py,sha256=kVHOhG1oS2sI5p8uldSo5L-RUZsnG36eaulVuKLyZ-M,1863
|
64
64
|
primitive/organizations/commands.py,sha256=_dwgVEJCqMa5VgB_7P1wLPFc0AuT1p9dtyR9JRr4kpw,487
|
65
65
|
primitive/organizations/graphql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
66
66
|
primitive/organizations/graphql/fragments.py,sha256=a1qKq4FZB5qze0XTo1fOUeGAscIasjn_Ig4gA2_vStY,142
|
@@ -96,8 +96,8 @@ primitive/utils/memory_size.py,sha256=4xfha21kW82nFvOTtDFx9Jk2ZQoEhkfXii-PGNTpIU
|
|
96
96
|
primitive/utils/printer.py,sha256=f1XUpqi5dkTL3GWvYRUGlSwtj2IxU1q745T4Fxo7Tn4,370
|
97
97
|
primitive/utils/shell.py,sha256=jWzb7ky7p987dJas6ZvarK3IJNZ5cwBXcryRWb9Uh6U,2072
|
98
98
|
primitive/utils/text.py,sha256=XiESMnlhjQ534xE2hMNf08WehE1SKaYFRNih0MmnK0k,829
|
99
|
-
primitive-0.2.
|
100
|
-
primitive-0.2.
|
101
|
-
primitive-0.2.
|
102
|
-
primitive-0.2.
|
103
|
-
primitive-0.2.
|
99
|
+
primitive-0.2.25.dist-info/METADATA,sha256=KzAEz2pPIFN5lBO7_7jERQ7oIL1trv05Jjqdp8icC9w,3569
|
100
|
+
primitive-0.2.25.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
101
|
+
primitive-0.2.25.dist-info/entry_points.txt,sha256=p1K8DMCWka5FqLlqP1sPek5Uovy9jq8u51gUsP-z334,48
|
102
|
+
primitive-0.2.25.dist-info/licenses/LICENSE.txt,sha256=B8kmQMJ2sxYygjCLBk770uacaMci4mPSoJJ8WoDBY_c,1098
|
103
|
+
primitive-0.2.25.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|