Skip to content

Commit 1182c68

Browse files
Merge pull request #129 from cortexapps/128-integrations-github-get-personal-missing-in-10x
fix(integrations github) add get-personal sub-command
2 parents c433bb2 + e5665a2 commit 1182c68

File tree

3 files changed

+32
-36
lines changed

3 files changed

+32
-36
lines changed

.github/workflows/test-pr.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ jobs:
3434
# the publish workflow runs..
3535
- name: Install git-chglog
3636
run: |
37-
GIT_CHGLOG_VERSION="0.15.4"
38-
curl -LO https://github.com/git-chglog/git-chglog/releases/download/v${GIT_CHGLOG_VERSION}/git-chglog_linux_amd64.tar.gz
39-
tar -xzf git-chglog_linux_amd64.tar.gz
37+
curl -LO https://github.com/git-chglog/git-chglog/releases/download/v0.15.4/git-chglog_0.15.4_linux_386.tar.gz
38+
tar -xzf git-chglog_0.15.4_linux_386.tar.gz
4039
chmod +x git-chglog
4140
sudo mv git-chglog /usr/local/bin/
4241
git-chglog --version

cortexapps_cli/commands/integrations_commands/github.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,64 +35,62 @@ def add(
3535
# remove any data elements that are None - can only be is_default
3636
data = {k: v for k, v in data.items() if v is not None}
3737

38-
r = client.post("api/v1/github/configuration", data=data)
38+
r = client.post("api/v1/github/configurations/app", data=data)
3939
print_json(data=r)
4040

4141
@app.command()
42-
def add_multiple(
42+
def delete(
4343
ctx: typer.Context,
44-
file_input: Annotated[typer.FileText, typer.Option("--file", "-f", help="JSON file containing configurations; can be passed as stdin with -, example: -f-")] = None,
44+
alias: str = typer.Option(..., "--alias", "-a", help="The alias of the configuration"),
4545
):
4646
"""
47-
Add multiple configurations
47+
Delete a configuration
4848
"""
4949

5050
client = ctx.obj["client"]
5151

52-
data = json.loads("".join([line for line in file_input]))
53-
54-
r = client.put("api/v1/aws/configurations", data=data)
52+
r = client.delete("api/v1/github/configurations/app/" + alias)
5553
print_json(data=r)
5654

5755
@app.command()
58-
def delete(
56+
def delete_all(
5957
ctx: typer.Context,
60-
alias: str = typer.Option(..., "--alias", "-a", help="The alias of the configuration"),
6158
):
6259
"""
63-
Delete a configuration
60+
Delete all configurations
6461
"""
6562

6663
client = ctx.obj["client"]
6764

68-
r = client.delete("api/v1/github/configuration/" + alias)
65+
r = client.delete("api/v1/github/configurations")
6966
print_json(data=r)
7067

7168
@app.command()
72-
def delete_all(
69+
def get(
7370
ctx: typer.Context,
71+
alias: str = typer.Option(..., "--alias", "-a", help="The alias of the configuration"),
7472
):
7573
"""
76-
Delete all configurations
74+
Get a single app configuration
7775
"""
7876

7977
client = ctx.obj["client"]
8078

81-
r = client.delete("api/v1/github/configurations")
79+
r = client.get("api/v1/github/configurations/app/" + alias)
8280
print_json(data=r)
8381

8482
@app.command()
85-
def get(
83+
def get_personal(
8684
ctx: typer.Context,
8785
alias: str = typer.Option(..., "--alias", "-a", help="The alias of the configuration"),
8886
):
8987
"""
90-
Get a configuration
88+
Get a personal configuration
9189
"""
9290

9391
client = ctx.obj["client"]
9492

95-
r = client.get("api/v1/github/configuration/" + alias)
93+
r = client.get("api/v1/github/configurations/personal/" + alias)
9694
print_json(data=r)
9795

9896
@app.command()
@@ -129,7 +127,7 @@ def update(
129127
is_default: bool = typer.Option(False, "--is-default", "-i", help="If this is the default configuration"),
130128
):
131129
"""
132-
Update a configuration
130+
Update a single app configuration
133131
"""
134132

135133
client = ctx.obj["client"]
@@ -139,7 +137,7 @@ def update(
139137
"isDefault": is_default
140138
}
141139

142-
r = client.put("api/v1/github/configuration/" + alias, data=data)
140+
r = client.put("api/v1/github/configurations/app/" + alias, data=data)
143141
print_json(data=r)
144142

145143
@app.command()
@@ -153,7 +151,7 @@ def validate(
153151

154152
client = ctx.obj["client"]
155153

156-
r = client.post("api/v1/github/configurations/validate" + alias)
154+
r = client.post("api/v1/github/configurations/validate/" + alias)
157155
print_json(data=r)
158156

159157
@app.command()
@@ -166,7 +164,7 @@ def validate_all(
166164

167165
client = ctx.obj["client"]
168166

169-
r = client.post("api/v1/github/configurations")
167+
r = client.post("api/v1/github/configurations/validate")
170168
print_json(data=r)
171169

172170
@app.command()

tests/test_integrations_github.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,12 @@ def _dummy_file(tmp_path):
99

1010
@responses.activate
1111
def test_integrations_github_add():
12-
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configuration", json={}, status=200)
12+
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/app", json={}, status=200)
1313
cli(["integrations", "github", "add", "-a", "myAlias", "-h", "my.host.com", "--api-key", "123456", "-i"])
1414

15-
@responses.activate
16-
def test_integrations_github_add_multiple(tmp_path):
17-
f = _dummy_file(tmp_path)
18-
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations", json={}, status=200)
19-
cli(["integrations", "github", "add-multiple", "-f", str(f)])
20-
2115
@responses.activate
2216
def test_integrations_github_delete():
23-
responses.add(responses.DELETE, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configuration/test", status=200)
17+
responses.add(responses.DELETE, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/app/test", status=200)
2418
cli(["integrations", "github", "delete", "-a", "test"])
2519

2620
@responses.activate
@@ -30,7 +24,7 @@ def test_integrations_github_delete_all():
3024

3125
@responses.activate
3226
def test_integrations_github_get():
33-
responses.add(responses.GET, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configuration/test", json={}, status=200)
27+
responses.add(responses.GET, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configuration/app/test", json={}, status=200)
3428
cli(["integrations", "github", "get", "-a", "test"])
3529

3630
@responses.activate
@@ -45,17 +39,17 @@ def test_integrations_github_get_default():
4539

4640
@responses.activate
4741
def test_integrations_github_update():
48-
responses.add(responses.PUT, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configuration/test", json={}, status=200)
42+
responses.add(responses.PUT, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/app/test", json={}, status=200)
4943
cli(["integrations", "github", "update", "-a", "test", "-i"])
5044

5145
@responses.activate
5246
def test_integrations_github_validate():
53-
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configuration/validate/test", json={}, status=200)
47+
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/validate/test", json={}, status=200)
5448
cli(["integrations", "github", "validate", "-a", "test"])
5549

5650
@responses.activate
5751
def test_integrations_github_validate_all():
58-
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configuration/validate", json={}, status=200)
52+
responses.add(responses.POST, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/validate", json={}, status=200)
5953
cli(["integrations", "github", "validate-all"])
6054

6155
@responses.activate
@@ -68,6 +62,11 @@ def test_integrations_github_update_personal():
6862
responses.add(responses.PUT, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/personal/test", json={}, status=200)
6963
cli(["integrations", "github", "update-personal", "-a", "test", "-i"])
7064

65+
@responses.activate
66+
def test_integrations_github_get_personal():
67+
responses.add(responses.GET, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/personal/test", json={}, status=200)
68+
cli(["integrations", "github", "get", "-a", "test"])
69+
7170
@responses.activate
7271
def test_integrations_github_delete_personal():
7372
responses.add(responses.DELETE, os.getenv("CORTEX_BASE_URL") + "/api/v1/github/configurations/personal/test", status=200)

0 commit comments

Comments
 (0)