Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use send() to execute requests instead of fetchHttpStatusCode() #1455

Merged
merged 1 commit into from May 15, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GHArtifact.java
Expand Up @@ -99,7 +99,7 @@ public URL getHtmlUrl() throws IOException {
* the io exception
*/
public void delete() throws IOException {
root().createRequest().method("DELETE").withUrlPath(getApiRoute()).fetchHttpStatusCode();
root().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/kohsuke/github/GHWorkflow.java
Expand Up @@ -87,7 +87,7 @@ public URL getBadgeUrl() {
* the io exception
*/
public void disable() throws IOException {
root().createRequest().method("PUT").withUrlPath(getApiRoute(), "disable").fetchHttpStatusCode();
root().createRequest().method("PUT").withUrlPath(getApiRoute(), "disable").send();
}

/**
Expand All @@ -97,7 +97,7 @@ public void disable() throws IOException {
* the io exception
*/
public void enable() throws IOException {
root().createRequest().method("PUT").withUrlPath(getApiRoute(), "enable").fetchHttpStatusCode();
root().createRequest().method("PUT").withUrlPath(getApiRoute(), "enable").send();
}

/**
Expand Down Expand Up @@ -133,7 +133,7 @@ public void dispatch(String ref, Map<String, Object> inputs) throws IOException
requester.with("inputs", inputs);
}

requester.fetchHttpStatusCode();
requester.send();
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/kohsuke/github/GHWorkflowRun.java
Expand Up @@ -276,7 +276,7 @@ public List<GHPullRequest> getPullRequests() throws IOException {
* the io exception
*/
public void cancel() throws IOException {
root().createRequest().method("POST").withUrlPath(getApiRoute(), "cancel").fetchHttpStatusCode();
root().createRequest().method("POST").withUrlPath(getApiRoute(), "cancel").send();
}

/**
Expand All @@ -286,7 +286,7 @@ public void cancel() throws IOException {
* the io exception
*/
public void delete() throws IOException {
root().createRequest().method("DELETE").withUrlPath(getApiRoute()).fetchHttpStatusCode();
root().createRequest().method("DELETE").withUrlPath(getApiRoute()).send();
}

/**
Expand All @@ -296,7 +296,7 @@ public void delete() throws IOException {
* the io exception
*/
public void rerun() throws IOException {
root().createRequest().method("POST").withUrlPath(getApiRoute(), "rerun").fetchHttpStatusCode();
root().createRequest().method("POST").withUrlPath(getApiRoute(), "rerun").send();
}

/**
Expand Down Expand Up @@ -336,7 +336,7 @@ public <T> T downloadLogs(InputStreamFunction<T> streamFunction) throws IOExcept
* the io exception
*/
public void deleteLogs() throws IOException {
root().createRequest().method("DELETE").withUrlPath(getApiRoute(), "logs").fetchHttpStatusCode();
root().createRequest().method("DELETE").withUrlPath(getApiRoute(), "logs").send();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/Requester.java
Expand Up @@ -50,7 +50,7 @@ class Requester extends GitHubRequest.Builder<Requester> {
}

/**
* Sends a request to the specified URL and checks that it is sucessful.
* Sends a request to the specified URL and checks that it is successful.
*
* @throws IOException
* the io exception
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/kohsuke/github/GHWorkflowTest.java
Expand Up @@ -115,7 +115,7 @@ public void testListWorkflowRuns() throws IOException {
GHWorkflow workflow = repo.getWorkflow("test-workflow.yml");

List<GHWorkflowRun> workflowRuns = workflow.listRuns().toList();
assertThat(workflowRuns.size(), is(2));
assertThat(workflowRuns.size(), greaterThan(2));

checkWorkflowRunProperties(workflowRuns.get(0), workflow.getId());
checkWorkflowRunProperties(workflowRuns.get(1), workflow.getId());
Expand Down
Expand Up @@ -65,8 +65,8 @@
"releases_url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowTest/releases{/id}",
"deployments_url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowTest/deployments",
"created_at": "2021-03-17T09:32:03Z",
"updated_at": "2021-03-17T09:33:34Z",
"pushed_at": "2021-03-17T09:33:32Z",
"updated_at": "2022-05-12T12:41:19Z",
"pushed_at": "2022-05-12T12:41:16Z",
"git_url": "git://github.com/hub4j-test-org/GHWorkflowTest.git",
"ssh_url": "git@github.com:hub4j-test-org/GHWorkflowTest.git",
"clone_url": "https://github.com/hub4j-test-org/GHWorkflowTest.git",
Expand All @@ -87,20 +87,28 @@
"disabled": false,
"open_issues_count": 0,
"license": null,
"allow_forking": true,
"is_template": false,
"topics": [],
"visibility": "public",
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "main",
"permissions": {
"admin": true,
"maintain": true,
"push": true,
"triage": true,
"pull": true
},
"temp_clone_token": "",
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"allow_auto_merge": false,
"delete_branch_on_merge": false,
"allow_update_branch": false,
"organization": {
"login": "hub4j-test-org",
"id": 7544739,
Expand All @@ -122,5 +130,5 @@
"site_admin": false
},
"network_count": 0,
"subscribers_count": 10
"subscribers_count": 11
}
Expand Up @@ -5,7 +5,7 @@
"path": ".github/workflows/test-workflow.yml",
"state": "active",
"created_at": "2021-03-17T10:33:32.000+01:00",
"updated_at": "2021-03-22T14:55:53.000+01:00",
"updated_at": "2022-05-12T14:43:11.000+02:00",
"url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/6817859",
"html_url": "https://github.com/hub4j-test-org/GHWorkflowTest/blob/main/.github/workflows/test-workflow.yml",
"badge_url": "https://github.com/hub4j-test-org/GHWorkflowTest/workflows/test-workflow/badge.svg"
Expand Down
Expand Up @@ -5,7 +5,7 @@
"path": ".github/workflows/test-workflow.yml",
"state": "active",
"created_at": "2021-03-17T10:33:32.000+01:00",
"updated_at": "2021-03-25T11:36:24.000+01:00",
"updated_at": "2022-05-12T14:43:11.000+02:00",
"url": "https://api.github.com/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/6817859",
"html_url": "https://github.com/hub4j-test-org/GHWorkflowTest/blob/main/.github/workflows/test-workflow.yml",
"badge_url": "https://github.com/hub4j-test-org/GHWorkflowTest/workflows/test-workflow/badge.svg"
Expand Down

This file was deleted.

@@ -1,5 +1,5 @@
{
"id": "1fbf864b-587b-4d30-8a65-43dfecc97028",
"id": "220d20d4-be30-4b64-931a-832cea0fea16",
"name": "repos_hub4j-test-org_ghworkflowtest",
"request": {
"url": "/repos/hub4j-test-org/GHWorkflowTest",
Expand All @@ -12,35 +12,36 @@
},
"response": {
"status": 200,
"bodyFileName": "repos_hub4j-test-org_ghworkflowtest-2.json",
"bodyFileName": "repos_hub4j-test-org_ghworkflowtest-1.json",
"headers": {
"Server": "GitHub.com",
"Date": "Thu, 25 Mar 2021 10:36:28 GMT",
"Date": "Thu, 12 May 2022 12:43:14 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With"
],
"ETag": "W/\"082e0c2ae9f1d8387e22ebe7279d627738b78d114a3badc2d9e60dfb0b2a6abf\"",
"Last-Modified": "Wed, 17 Mar 2021 09:33:34 GMT",
"X-OAuth-Scopes": "repo, user, workflow",
"ETag": "W/\"b29404b8f46b810b45089727292ea01bec52720af73a92806b6826296fd3785b\"",
"Last-Modified": "Thu, 12 May 2022 12:41:19 GMT",
"X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, gist, notifications, repo, user, workflow, write:discussion",
"X-Accepted-OAuth-Scopes": "repo",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-GitHub-Media-Type": "github.v3; format=json",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4973",
"X-RateLimit-Reset": "1616672182",
"X-RateLimit-Used": "27",
"X-RateLimit-Remaining": "4928",
"X-RateLimit-Reset": "1652362924",
"X-RateLimit-Used": "72",
"X-RateLimit-Resource": "core",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "0",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"X-GitHub-Request-Id": "D5A4:4AE4:1010430:10B0B4D:605C67AC"
"X-GitHub-Request-Id": "C910:5519:542B692:555E102:627D00E2"
}
},
"uuid": "1fbf864b-587b-4d30-8a65-43dfecc97028",
"uuid": "220d20d4-be30-4b64-931a-832cea0fea16",
"persistent": true,
"insertionIndex": 2
"insertionIndex": 1
}
@@ -1,5 +1,5 @@
{
"id": "a37a5c44-61eb-4460-87e8-3207a15c7d2c",
"id": "16128b7f-ff64-4091-85ab-5f0f6fd70dfb",
"name": "repos_hub4j-test-org_ghworkflowtest_actions_workflows_6817859",
"request": {
"url": "/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/6817859",
Expand All @@ -12,34 +12,35 @@
},
"response": {
"status": 200,
"bodyFileName": "repos_hub4j-test-org_ghworkflowtest_actions_workflows_6817859-4.json",
"bodyFileName": "repos_hub4j-test-org_ghworkflowtest_actions_workflows_6817859-3.json",
"headers": {
"Server": "GitHub.com",
"Date": "Thu, 25 Mar 2021 10:36:29 GMT",
"Date": "Thu, 12 May 2022 12:43:15 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With"
],
"ETag": "W/\"72a49555d2625ba9f490d619d324726f5192dc2a030dc22033b9cadf7a2ba076\"",
"X-OAuth-Scopes": "repo, user, workflow",
"ETag": "W/\"37311efa336094063a53d1313b6f73af8a2d5f81a7f10c95f7173189235ace0a\"",
"X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, gist, notifications, repo, user, workflow, write:discussion",
"X-Accepted-OAuth-Scopes": "",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-GitHub-Media-Type": "github.v3; format=json",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4971",
"X-RateLimit-Reset": "1616672182",
"X-RateLimit-Used": "29",
"X-RateLimit-Remaining": "4926",
"X-RateLimit-Reset": "1652362924",
"X-RateLimit-Used": "74",
"X-RateLimit-Resource": "core",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "0",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"X-GitHub-Request-Id": "D5A4:4AE4:1010476:10B0B89:605C67AC"
"X-GitHub-Request-Id": "C914:90C1:253005B:25D30D4:627D00E3"
}
},
"uuid": "a37a5c44-61eb-4460-87e8-3207a15c7d2c",
"uuid": "16128b7f-ff64-4091-85ab-5f0f6fd70dfb",
"persistent": true,
"insertionIndex": 4
"insertionIndex": 3
}
@@ -1,5 +1,5 @@
{
"id": "1ca8cc16-7af0-40c3-832f-197e68817ac1",
"id": "7618fd94-ee84-4b67-a401-45e1edfc38df",
"name": "repos_hub4j-test-org_ghworkflowtest_actions_workflows_test-workflowyml",
"request": {
"url": "/repos/hub4j-test-org/GHWorkflowTest/actions/workflows/test-workflow.yml",
Expand All @@ -12,34 +12,35 @@
},
"response": {
"status": 200,
"bodyFileName": "repos_hub4j-test-org_ghworkflowtest_actions_workflows_test-workflowyml-3.json",
"bodyFileName": "repos_hub4j-test-org_ghworkflowtest_actions_workflows_test-workflowyml-2.json",
"headers": {
"Server": "GitHub.com",
"Date": "Thu, 25 Mar 2021 10:36:28 GMT",
"Date": "Thu, 12 May 2022 12:43:14 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": [
"Accept, Authorization, Cookie, X-GitHub-OTP",
"Accept-Encoding, Accept, X-Requested-With"
],
"ETag": "W/\"72a49555d2625ba9f490d619d324726f5192dc2a030dc22033b9cadf7a2ba076\"",
"X-OAuth-Scopes": "repo, user, workflow",
"ETag": "W/\"37311efa336094063a53d1313b6f73af8a2d5f81a7f10c95f7173189235ace0a\"",
"X-OAuth-Scopes": "admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, gist, notifications, repo, user, workflow, write:discussion",
"X-Accepted-OAuth-Scopes": "",
"X-GitHub-Media-Type": "unknown, github.v3",
"X-GitHub-Media-Type": "github.v3; format=json",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4972",
"X-RateLimit-Reset": "1616672182",
"X-RateLimit-Used": "28",
"X-RateLimit-Remaining": "4927",
"X-RateLimit-Reset": "1652362924",
"X-RateLimit-Used": "73",
"X-RateLimit-Resource": "core",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "0",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"X-GitHub-Request-Id": "D5A4:4AE4:101045A:10B0B77:605C67AC"
"X-GitHub-Request-Id": "C912:90C0:19079B9:19965E8:627D00E2"
}
},
"uuid": "1ca8cc16-7af0-40c3-832f-197e68817ac1",
"uuid": "7618fd94-ee84-4b67-a401-45e1edfc38df",
"persistent": true,
"insertionIndex": 3
"insertionIndex": 2
}