rollthecloudinc / hedge

Award winning climate aware database trimming cloud carbon and costs.
22 stars 2 forks source link

Create shapeshifter end-points #39

Open ng-druid opened 2 years ago

ng-druid commented 2 years ago

The shapshifter end-points are used to write freeform JSON and media files to repositories outside of rollthecloudinc. These APIs can be used once the app is installed on an account or organization. This is secondary step to making vertigo available for everyone to use. One problem that we have run into is that the graph api isn't accessible by user access tokens generated via github app. However, the REST APIs are available. Therefore, the graph API implementation of writing JSON and Media files will need to be accompanied by a rest api equivalent. We have confirmed that the end-point to fetch the most recent commit for repository outside rollthecloud works once the app is installed. Expectation is that other end-points necessary to facilitate reading and writing commits can also be used once the app is installed.

This also needs to be recognized going forward when users of druid require making changes to their resources like creating repos, branches, etc. This will all come into play as dc is built out. I guess its good to know this now although we did implement the graph api for writing json and media files but now we know.

List of end-points available: https://docs.github.com/en/rest/overview/endpoints-available-for-github-apps

Second post down provides a template for doing this, just need to figure out the exact details and apply to v3 go api. https://stackoverflow.com/questions/11801983/how-to-create-a-commit-and-push-into-repo-with-github-api-v3

v3 Flow

Latest Commit SHA

Fetch latest commit on target branch.

https://docs.github.com/en/rest/branches/branches#get-a-branch

GET https://api.github.com/repos/ng-druid/sample-extension/branches/dev

Create Blob

Create blob with files content.

https://docs.github.com/en/rest/git/blobs#create-a-blob

Create Tree

Create a tree.

https://docs.github.com/en/rest/git/trees#create-a-tree

ng-druid commented 2 years ago

https://hackernoon.com/how-to-fetch-large-data-files-through-github-api