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
15 changes: 15 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Release History
===============

1.0.2 (2025-06-16)
------------------

**Improvements**
- Add sub-commands for integrations github (these were missed with the upgrade to 1.0.0):
- add-personal
- delete-personal
- update-personal

1.0.1 (2025-06-16)
------------------

**Bugfixes**
- Homebrew fix for ZIP does not support timestamps before 1980

1.0.0 (2025-06-13)
------------------

Expand Down
69 changes: 68 additions & 1 deletion cortexapps_cli/commands/integrations_commands/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def add(

if file_input:
if alias or api_key or is_default or host:
raise typer.BadParameter("When providing a custom event definition file, do not specify any other custom event attributes")
raise typer.BadParameter("When providing a configuration file, do not specify any other attributes")
data = json.loads("".join([line for line in file_input]))
else:
data = {
Expand Down Expand Up @@ -168,3 +168,70 @@ def validate_all(

r = client.post("api/v1/github/configurations")
print_json(data=r)

@app.command()
def add_personal(
ctx: typer.Context,
alias: str = typer.Option(..., "--alias", "-a", help="Alias for this configuration"),
access_token: str = typer.Option(..., "--access-token", "-at", help="Access Token"),
host: str = typer.Option(None, "--host", "-h", help="Optional host name"),
is_default: bool = typer.Option(False, "--is-default", "-i", help="If this is the default configuration"),
file_input: Annotated[typer.FileText, typer.Option("--file", "-f", help="JSON file containing configurations, if command line options not used; can be passed as stdin with -, example: -f-")] = None,
):
"""
Add a single personal configuration
"""

client = ctx.obj["client"]

if file_input:
if alias or access_token or is_default or host:
raise typer.BadParameter("When providing a configuration file, do not specify any other attributes")
data = json.loads("".join([line for line in file_input]))
else:
data = {
"alias": alias,
"accessToken": access_token,
"apiHost": host,
"isDefault": is_default,
}

# remove any data elements that are None - can only be is_default
data = {k: v for k, v in data.items() if v is not None}

r = client.post("api/v1/github/configurations/personal", data=data)
print_json(data=r)

@app.command()
def delete_personal(
ctx: typer.Context,
alias: str = typer.Option(..., "--alias", "-a", help="The alias of the configuration"),
):
"""
Delete a personal configuration
"""

client = ctx.obj["client"]

r = client.delete("api/v1/github/configurations/personal/" + alias)
print_json(data=r)

@app.command()
def update_personal(
ctx: typer.Context,
alias: str = typer.Option(..., "--alias", "-a", help="The alias of the configuration"),
is_default: bool = typer.Option(False, "--is-default", "-i", help="If this is the default configuration"),
):
"""
Update a personal configuration
"""

client = ctx.obj["client"]

data = {
"alias": alias,
"isDefault": is_default
}

r = client.put("api/v1/github/configurations/personal/" + alias, data=data)
print_json(data=r)
Loading