Skip to content

Commit 5ed78f9

Browse files
Merge pull request #124 from cortexapps/123-github-add-personal-missing-in-version-10x
Add github personal sub-commands #patch
2 parents 7e1cf12 + 09fb345 commit 5ed78f9

File tree

4 files changed

+98
-4072
lines changed

4 files changed

+98
-4072
lines changed

HISTORY.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
Release History
22
===============
33

4+
1.0.2 (2025-06-16)
5+
------------------
6+
7+
**Improvements**
8+
- Add sub-commands for integrations github (these were missed with the upgrade to 1.0.0):
9+
- add-personal
10+
- delete-personal
11+
- update-personal
12+
13+
1.0.1 (2025-06-16)
14+
------------------
15+
16+
**Bugfixes**
17+
- Homebrew fix for ZIP does not support timestamps before 1980
18+
419
1.0.0 (2025-06-13)
520
------------------
621

cortexapps_cli/commands/integrations_commands/github.py

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def add(
2222

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

169169
r = client.post("api/v1/github/configurations")
170170
print_json(data=r)
171+
172+
@app.command()
173+
def add_personal(
174+
ctx: typer.Context,
175+
alias: str = typer.Option(..., "--alias", "-a", help="Alias for this configuration"),
176+
access_token: str = typer.Option(..., "--access-token", "-at", help="Access Token"),
177+
host: str = typer.Option(None, "--host", "-h", help="Optional host name"),
178+
is_default: bool = typer.Option(False, "--is-default", "-i", help="If this is the default configuration"),
179+
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,
180+
):
181+
"""
182+
Add a single personal configuration
183+
"""
184+
185+
client = ctx.obj["client"]
186+
187+
if file_input:
188+
if alias or access_token or is_default or host:
189+
raise typer.BadParameter("When providing a configuration file, do not specify any other attributes")
190+
data = json.loads("".join([line for line in file_input]))
191+
else:
192+
data = {
193+
"alias": alias,
194+
"accessToken": access_token,
195+
"apiHost": host,
196+
"isDefault": is_default,
197+
}
198+
199+
# remove any data elements that are None - can only be is_default
200+
data = {k: v for k, v in data.items() if v is not None}
201+
202+
r = client.post("api/v1/github/configurations/personal", data=data)
203+
print_json(data=r)
204+
205+
@app.command()
206+
def delete_personal(
207+
ctx: typer.Context,
208+
alias: str = typer.Option(..., "--alias", "-a", help="The alias of the configuration"),
209+
):
210+
"""
211+
Delete a personal configuration
212+
"""
213+
214+
client = ctx.obj["client"]
215+
216+
r = client.delete("api/v1/github/configurations/personal/" + alias)
217+
print_json(data=r)
218+
219+
@app.command()
220+
def update_personal(
221+
ctx: typer.Context,
222+
alias: str = typer.Option(..., "--alias", "-a", help="The alias of the configuration"),
223+
is_default: bool = typer.Option(False, "--is-default", "-i", help="If this is the default configuration"),
224+
):
225+
"""
226+
Update a personal configuration
227+
"""
228+
229+
client = ctx.obj["client"]
230+
231+
data = {
232+
"alias": alias,
233+
"isDefault": is_default
234+
}
235+
236+
r = client.put("api/v1/github/configurations/personal/" + alias, data=data)
237+
print_json(data=r)

0 commit comments

Comments
 (0)