-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for creating and updating file contents (#148)
- Loading branch information
1 parent
012a8c3
commit 832fe33
Showing
9 changed files
with
344 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/com/spotify/github/v3/repos/CommitWithFolderContent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*- | ||
* -\-\- | ||
* github-api | ||
* -- | ||
* Copyright (C) 2016 - 2023 Spotify AB | ||
* -- | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* -/-/- | ||
*/ | ||
|
||
package com.spotify.github.v3.repos; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import com.spotify.github.GithubStyle; | ||
import com.spotify.github.v3.git.Commit; | ||
import org.immutables.value.Value; | ||
|
||
@Value.Immutable | ||
@GithubStyle | ||
@JsonSerialize(as = ImmutableCommitWithFolderContent.class) | ||
@JsonDeserialize(as = ImmutableCommitWithFolderContent.class) | ||
public interface CommitWithFolderContent { | ||
|
||
/** Repository content resource */ | ||
FolderContent content(); | ||
|
||
/** Commit resource */ | ||
Commit commit(); | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/com/spotify/github/v3/repos/requests/FileCreate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/*- | ||
* -\-\- | ||
* github-api | ||
* -- | ||
* Copyright (C) 2016 - 2023 Spotify AB | ||
* -- | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* -/-/- | ||
*/ | ||
|
||
package com.spotify.github.v3.repos.requests; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import com.spotify.github.GithubStyle; | ||
import org.immutables.value.Value; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* Request to create a file. | ||
*/ | ||
@Value.Immutable | ||
@GithubStyle | ||
@JsonSerialize(as = ImmutableFileCreate.class) | ||
@JsonDeserialize(as = ImmutableFileCreate.class) | ||
public interface FileCreate { | ||
|
||
/** The commit message */ | ||
String message(); | ||
|
||
/** The new file content, using Base64 encoding */ | ||
String content(); | ||
|
||
/** The branch name. Default: the repository’s default branch */ | ||
@Nullable | ||
String branch(); | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/com/spotify/github/v3/repos/requests/FileUpdate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/*- | ||
* -\-\- | ||
* github-api | ||
* -- | ||
* Copyright (C) 2016 - 2023 Spotify AB | ||
* -- | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* -/-/- | ||
*/ | ||
|
||
package com.spotify.github.v3.repos.requests; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import com.spotify.github.GithubStyle; | ||
import org.immutables.value.Value; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* Request to update file content. | ||
*/ | ||
@Value.Immutable | ||
@GithubStyle | ||
@JsonSerialize(as = ImmutableFileUpdate.class) | ||
@JsonDeserialize(as = ImmutableFileUpdate.class) | ||
public interface FileUpdate { | ||
|
||
/** The commit message */ | ||
String message(); | ||
|
||
/** The new file content, using Base64 encoding */ | ||
String content(); | ||
|
||
/** The SHA of the file being replaced. */ | ||
String sha(); | ||
|
||
/** The branch name. Default: the repository’s default branch */ | ||
@Nullable | ||
String branch(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/test/resources/com/spotify/github/v3/repos/create-content-repsonse.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"content": { | ||
"name": "README.md", | ||
"path": "test/README.md", | ||
"sha": "95b966ae1c166bd92f8ae7d1c313e738c731dfc3", | ||
"size": 9, | ||
"url": "https://api.github.com/repos/someowner/somerepo/contents/test/README.md", | ||
"html_url": "https://github.com/someowner/somerepo/blob/master/test/README.md", | ||
"git_url": "https://api.github.com/repos/someowner/somerepo/git/blobs/95b966ae1c166bd92f8ae7d1c313e738c731dfc3", | ||
"download_url": "https://raw.githubusercontent.com/someowner/HelloWorld/master/test/README.md", | ||
"type": "file", | ||
"_links": { | ||
"self": "https://api.github.com/repos/someowner/somerepo/contents/test/README.md", | ||
"git": "https://api.github.com/repos/someowner/somerepo/git/blobs/95b966ae1c166bd92f8ae7d1c313e738c731dfc3", | ||
"html": "https://github.com/someowner/somerepo/blob/master/test/README.md" | ||
} | ||
}, | ||
"commit": { | ||
"sha": "7638417db6d59f3c431d3e1f261cc637155684cd", | ||
"node_id": "MDY6Q29tbWl0NzYzODQxN2RiNmQ1OWYzYzQzMWQzZTFmMjYxY2M2MzcxNTU2ODRjZA==", | ||
"url": "https://api.github.com/repos/someowner/somerepo/git/commits/7638417db6d59f3c431d3e1f261cc637155684cd", | ||
"html_url": "https://github.com/someowner/somerepo/git/commit/7638417db6d59f3c431d3e1f261cc637155684cd", | ||
"author": { | ||
"date": "2014-11-07T22:01:45Z", | ||
"name": "Monalisa Octocat", | ||
"email": "octocat@github.com" | ||
}, | ||
"committer": { | ||
"date": "2014-11-07T22:01:45Z", | ||
"name": "Monalisa Octocat", | ||
"email": "octocat@github.com" | ||
}, | ||
"message": "my commit message", | ||
"tree": { | ||
"url": "https://api.github.com/repos/someowner/somerepo/git/trees/691272480426f78a0138979dd3ce63b77f706feb", | ||
"sha": "691272480426f78a0138979dd3ce63b77f706feb" | ||
}, | ||
"parents": [ | ||
{ | ||
"url": "https://api.github.com/repos/someowner/somerepo/git/commits/1acc419d4d6a9ce985db7be48c6349a0475975b5", | ||
"html_url": "https://github.com/someowner/somerepo/git/commit/1acc419d4d6a9ce985db7be48c6349a0475975b5", | ||
"sha": "1acc419d4d6a9ce985db7be48c6349a0475975b5" | ||
} | ||
], | ||
"verification": { | ||
"verified": false, | ||
"reason": "unsigned", | ||
"signature": null, | ||
"payload": null | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/test/resources/com/spotify/github/v3/repos/create-content-request.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"message": "my commit message", | ||
"content": "encoded content ..." | ||
} |
52 changes: 52 additions & 0 deletions
52
src/test/resources/com/spotify/github/v3/repos/update-content-repsonse.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"content": { | ||
"name": "README.md", | ||
"path": "test/README.md", | ||
"sha": "95b966ae1c166bd92f8ae7d1c313e738c731dfc3", | ||
"size": 9, | ||
"url": "https://api.github.com/repos/someowner/somerepo/contents/test/README.md", | ||
"html_url": "https://github.com/someowner/somerepo/blob/master/test/README.md", | ||
"git_url": "https://api.github.com/repos/someowner/somerepo/git/blobs/95b966ae1c166bd92f8ae7d1c313e738c731dfc3", | ||
"download_url": "https://raw.githubusercontent.com/someowner/HelloWorld/master/test/README.md", | ||
"type": "file", | ||
"_links": { | ||
"self": "https://api.github.com/repos/someowner/somerepo/contents/test/README.md", | ||
"git": "https://api.github.com/repos/someowner/somerepo/git/blobs/95b966ae1c166bd92f8ae7d1c313e738c731dfc3", | ||
"html": "https://github.com/someowner/somerepo/blob/master/test/README.md" | ||
} | ||
}, | ||
"commit": { | ||
"sha": "7638417db6d59f3c431d3e1f261cc637155684cd", | ||
"node_id": "MDY6Q29tbWl0NzYzODQxN2RiNmQ1OWYzYzQzMWQzZTFmMjYxY2M2MzcxNTU2ODRjZA==", | ||
"url": "https://api.github.com/repos/someowner/somerepo/git/commits/7638417db6d59f3c431d3e1f261cc637155684cd", | ||
"html_url": "https://github.com/someowner/somerepo/git/commit/7638417db6d59f3c431d3e1f261cc637155684cd", | ||
"author": { | ||
"date": "2014-11-07T22:01:45Z", | ||
"name": "Monalisa Octocat", | ||
"email": "octocat@github.com" | ||
}, | ||
"committer": { | ||
"date": "2014-11-07T22:01:45Z", | ||
"name": "Monalisa Octocat", | ||
"email": "octocat@github.com" | ||
}, | ||
"message": "my commit message", | ||
"tree": { | ||
"url": "https://api.github.com/repos/someowner/somerepo/git/trees/691272480426f78a0138979dd3ce63b77f706feb", | ||
"sha": "691272480426f78a0138979dd3ce63b77f706feb" | ||
}, | ||
"parents": [ | ||
{ | ||
"url": "https://api.github.com/repos/someowner/somerepo/git/commits/1acc419d4d6a9ce985db7be48c6349a0475975b5", | ||
"html_url": "https://github.com/someowner/somerepo/git/commit/1acc419d4d6a9ce985db7be48c6349a0475975b5", | ||
"sha": "1acc419d4d6a9ce985db7be48c6349a0475975b5" | ||
} | ||
], | ||
"verification": { | ||
"verified": false, | ||
"reason": "unsigned", | ||
"signature": null, | ||
"payload": null | ||
} | ||
} | ||
} |
Oops, something went wrong.