Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,48 @@ cycleops --api-key=<cycleops_api_key> services update <service_id> --variable <k
cycleops units list
```

### Environments

#### List your environments

```
cycleops environments list
```


### Hosts

#### List your hosts

```
cycleops hosts list
```

#### Retrieve a host

```
cycleops hosts retrieve <host_name>|<host_id>
```

#### Create a host

```
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>
```

#### Update a host

```
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>
```

#### Delete a host

```
cycleops hosts delete <host_name>|<host_id>
```


### Services

#### List your services
Expand Down Expand Up @@ -168,9 +210,11 @@ cycleops setups delete <setup_name>|<setup_id>
#### Deploy a setup

```
cycleops setups deploy <setup_name>|<setup_id>
cycleops setups deploy <setup_name>|<setup_id> --wait
```

Using `--wait` you can wait for the deployment job to complete.

### GitHub Actions

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:
Expand Down
2 changes: 2 additions & 0 deletions cycleops/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ def _request(
params: Optional[Dict[str, Any]] = None,
) -> Optional[Dict[str, Any]]:
url: str = f"{self.base_url}/{endpoint}"
headers: Dict[str] = {"Accept": "application/json; version=v2"}
response: Response = requests.request(
method,
url,
json=payload,
auth=CycleopsAuthentication(self.api_key),
params=params,
headers=headers,
)
return self._handle_response(response)

Expand Down
20 changes: 13 additions & 7 deletions cycleops/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ def list() -> None:
if not environments:
raise NotFound("No environments available")

table = Table(show_header=True, leading=True)
table.add_column("ID", width=5)
table.add_column("Name", width=30)

environments_result = []
for environment in environments:
table.add_row(str(environment["id"]), environment["name"])

print(table)
environment_result = {
"id": environment["id"],
"hosts": environment["hosts"],
"hostgroups": environment["hostgroups"],
"account": environment["account"],
"name": environment["name"],
"description": environment["description"],
}

environments_result.append(environment_result)

print(environments_result)
except Exception as error:
display_error_message(error)
raise typer.Exit(code=1)
11 changes: 11 additions & 0 deletions cycleops/hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@

host_client: HostClient = HostClient(cycleops_client)

REGISTRATION_STATUS_CHOICES = {
11: "Registering",
6: "Registered",
5: "Unregistered",
}


@app.command()
def list() -> None:
Expand All @@ -24,6 +30,11 @@ def list() -> None:
if not hosts:
raise NotFound("No hosts available")

for host in hosts:
host["register_status"] = REGISTRATION_STATUS_CHOICES.get(
host["register_status"]
)

print(hosts)
except Exception as error:
display_error_message(error)
Expand Down