Skip to content

Commit 3980627

Browse files
authored
Merge pull request #27 from Stackmasters/api-v2
Use api version v2
2 parents befba06 + 5f3b323 commit 3980627

4 files changed

Lines changed: 71 additions & 8 deletions

File tree

README.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,48 @@ cycleops --api-key=<cycleops_api_key> services update <service_id> --variable <k
5757
cycleops units list
5858
```
5959

60+
### Environments
61+
62+
#### List your environments
63+
64+
```
65+
cycleops environments list
66+
```
67+
68+
69+
### Hosts
70+
71+
#### List your hosts
72+
73+
```
74+
cycleops hosts list
75+
```
76+
77+
#### Retrieve a host
78+
79+
```
80+
cycleops hosts retrieve <host_name>|<host_id>
81+
```
82+
83+
#### Create a host
84+
85+
```
86+
cycleops hosts create --name <host_name> --ip <host_ip> --environment-id <environment_id> --jump-host true|false --hostgroup-id <hostgroup_id> ... --hostgroup-id <hostgroup_id>
87+
```
88+
89+
#### Update a host
90+
91+
```
92+
cycleops hosts update <host_name>|<host_id> --name <host_name> --ip <host_ip> --environment-id <environment_id> --jump-host true|false --hostgroup-id <hostgroup_id> ... --hostgroup-id <hostgroup_id>
93+
```
94+
95+
#### Delete a host
96+
97+
```
98+
cycleops hosts delete <host_name>|<host_id>
99+
```
100+
101+
60102
### Services
61103

62104
#### List your services
@@ -168,9 +210,11 @@ cycleops setups delete <setup_name>|<setup_id>
168210
#### Deploy a setup
169211

170212
```
171-
cycleops setups deploy <setup_name>|<setup_id>
213+
cycleops setups deploy <setup_name>|<setup_id> --wait
172214
```
173215

216+
Using `--wait` you can wait for the deployment job to complete.
217+
174218
### GitHub Actions
175219

176220
You can use Cycleops with your GitHub Actions to deploy a setup right from GitHub. For example this is how you could update the Docker image of a service and deploy a setup:

cycleops/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ def _request(
3131
params: Optional[Dict[str, Any]] = None,
3232
) -> Optional[Dict[str, Any]]:
3333
url: str = f"{self.base_url}/{endpoint}"
34+
headers: Dict[str] = {"Accept": "application/json; version=v2"}
3435
response: Response = requests.request(
3536
method,
3637
url,
3738
json=payload,
3839
auth=CycleopsAuthentication(self.api_key),
3940
params=params,
41+
headers=headers,
4042
)
4143
return self._handle_response(response)
4244

cycleops/environments.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,20 @@ def list() -> None:
2323
if not environments:
2424
raise NotFound("No environments available")
2525

26-
table = Table(show_header=True, leading=True)
27-
table.add_column("ID", width=5)
28-
table.add_column("Name", width=30)
29-
26+
environments_result = []
3027
for environment in environments:
31-
table.add_row(str(environment["id"]), environment["name"])
32-
33-
print(table)
28+
environment_result = {
29+
"id": environment["id"],
30+
"hosts": environment["hosts"],
31+
"hostgroups": environment["hostgroups"],
32+
"account": environment["account"],
33+
"name": environment["name"],
34+
"description": environment["description"],
35+
}
36+
37+
environments_result.append(environment_result)
38+
39+
print(environments_result)
3440
except Exception as error:
3541
display_error_message(error)
3642
raise typer.Exit(code=1)

cycleops/hosts.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111

1212
host_client: HostClient = HostClient(cycleops_client)
1313

14+
REGISTRATION_STATUS_CHOICES = {
15+
11: "Registering",
16+
6: "Registered",
17+
5: "Unregistered",
18+
}
19+
1420

1521
@app.command()
1622
def list() -> None:
@@ -24,6 +30,11 @@ def list() -> None:
2430
if not hosts:
2531
raise NotFound("No hosts available")
2632

33+
for host in hosts:
34+
host["register_status"] = REGISTRATION_STATUS_CHOICES.get(
35+
host["register_status"]
36+
)
37+
2738
print(hosts)
2839
except Exception as error:
2940
display_error_message(error)

0 commit comments

Comments
 (0)