avh4 / elm-github-v3 / Github

Authorization


type OAuthToken

An OAuth token used to authenticate various Github API requests. Not to be confused with OAuthCode which is used in order to generate an OAuthToken.

oauthToken : String -> OAuthToken

oauthTokenToString : OAuthToken -> String


type alias AccessTokenResponse =
{ accessToken : OAuthToken
, scope : String
, tokenType : String 
}

oauthLink : { clientId : ClientId, redirectUri : Maybe String, scopes : List Scope, state : Maybe String } -> String

The link a user clicks on to be prompted about authorizing a github app. See https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps#1-request-a-users-github-identity


type OAuthCode

Not to be confused with OAuthToken! This is an intermediate value you get while generating an OAuthToken.

oauthCode : String -> OAuthCode

oauthCodeToString : OAuthCode -> String


type ClientId

Github application client id

clientId : String -> ClientId

clientIdToString : ClientId -> String


type ClientSecret

Github application client secret (do not include this on your frontend!)

clientSecret : String -> ClientSecret

clientSecretToString : ClientSecret -> String

getAccessToken : { clientId : ClientId, clientSecret : ClientSecret, oauthCode : OAuthCode, state : Maybe String } -> Task Http.Error AccessTokenResponse

See https://docs.github.com/en/developers/apps/building-github-apps/identifying-and-authorizing-users-for-github-apps#2-users-are-redirected-back-to-your-site-by-github


type Scope
    = RepoScope
    | RepoStatusScope
    | RepoDeploymentScope
    | PublicRepoScope
    | RepoInviteScope

See https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps

scopeFromString : String -> Maybe Scope

scopeToString : Scope -> String

Get repository

getRepository : { authToken : OAuthToken, owner : Owner, repo : String } -> Task Http.Error { defaultBranch : Branch }

See https://docs.github.com/en/rest/reference/repos#get-a-repository

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

getContents : { authToken : OAuthToken, owner : Owner, repo : String, ref : Maybe String, path : String } -> Task Http.Error Content

See https://docs.github.com/en/rest/reference/repos#contents

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.


type Owner

The the name of owner of a repo, ("avh4" for example)

owner : String -> Owner

ownerToString : Owner -> String

updateFileContents : { authToken : OAuthToken, repo : String, branch : Branch, path : String, sha : ShaHash a, message : String, content : String } -> Task Http.Error { content : { sha : ShaHash a } }

See https://developer.github.com/v3/repos/contents/#update-a-file

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

Work with git


type Branch

The name of a git branch, i.e. "master", "main", "feature-branch"

branch : String -> Branch

branchToString : Branch -> String

getBranches : { authToken : OAuthToken, owner : Owner, repo : String } -> Task Http.Error (List { name : String, sha : ShaHash CommitSha })

Get all branches for a git repo.

getBranch : { authToken : OAuthToken, owner : Owner, repo : String, branchName : Branch } -> Task Http.Error (ShaHash CommitSha)

See https://docs.github.com/en/rest/reference/git#get-a-reference

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

updateBranch : { authToken : OAuthToken, owner : Owner, repo : String, branchName : Branch, sha : ShaHash CommitSha, force : Basics.Bool } -> Task Http.Error (ShaHash CommitSha)

See https://docs.github.com/en/rest/reference/git#update-a-reference

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

listTags : { authToken : OAuthToken, owner : Owner, repo : String } -> Task Http.Error (List Tag)

See https://docs.github.com/en/rest/reference/repos#list-repository-tags

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

createBranch : { authToken : OAuthToken, owner : Owner, repo : String, branchName : Branch, sha : ShaHash CommitSha } -> Task Http.Error ()

See https://developer.github.com/v3/git/refs/#create-a-reference

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

getBranchZip : { authToken : Maybe OAuthToken, owner : Owner, repo : String, branchName : Maybe Branch } -> Task Http.Error Bytes

authToken is Maybe here because it seems like there can be problems request a zip from a public repo if you provide authentication.

getTag : { authToken : OAuthToken, owner : Owner, repo : String, tagName : String } -> Task Http.Error (ShaHash CommitSha)

See https://docs.github.com/en/rest/reference/git#get-a-reference

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

getCommit : { authToken : OAuthToken, owner : Owner, repo : String, sha : ShaHash CommitSha } -> Task Http.Error (ShaHash TreeSha)

See https://docs.github.com/en/rest/reference/git#get-a-commit

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

createCommit : { authToken : OAuthToken, owner : Owner, repo : String, message : String, tree : ShaHash TreeSha, parents : List (ShaHash CommitSha) } -> Task Http.Error (ShaHash CommitSha)

See https://docs.github.com/en/rest/reference/git#create-a-commit

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

getCommitZip : { authToken : OAuthToken, owner : Owner, repo : String, sha : ShaHash CommitSha } -> Task Http.Error Bytes

sha : String -> ShaHash a

shaToString : ShaHash a -> String

Get the raw sha string.


type ShaHash a

A SHA identifier


type CommitSha

A SHA that's used as a pointer for a commit


type TreeSha

A SHA that's used as a pointer for a tree


type Content
    = FileContent ({ encoding : String, content : String, sha : ShaHash CommitSha, downloadUrl : Url, url : Url })
    | DirectoryContent (List DirectoryEntry)
    | Symlink
    | Submodule


type ContentType
    = FileContentType
    | DirectoryContentType
    | SymLinkType
    | SubmoduleType


type alias DirectoryEntry =
{ contentType : ContentType
, name : String
, path : String
, sha : ShaHash CommitSha
, downloadUrl : Maybe Url
, url : Maybe Url 
}

A file directory in a git repo.

createTree : { authToken : OAuthToken, owner : Owner, repo : String, treeNodes : List.Nonempty.Nonempty { path : String, content : String }, baseTree : Maybe (ShaHash TreeSha) } -> Task Http.Error { treeSha : ShaHash TreeSha }

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

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

Pull request


type alias PullRequest =
{ number : Basics.Int
, title : String 
}

The data returned by getPullRequests.

getPullRequests : { authToken : OAuthToken, repo : String } -> Task Http.Error (List PullRequest)

See https://developer.github.com/v3/pulls/#list-pull-requests

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

getPullRequest : { authToken : OAuthToken, repo : String, number : Basics.Int } -> Task Http.Error { head : { ref : String, sha : ShaHash CommitSha } }

See https://developer.github.com/v3/pulls/#get-a-single-pull-request

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

createPullRequest : { authToken : OAuthToken, destinationOwner : Owner, destinationRepo : String, destinationBranch : Branch, sourceBranchOwner : Owner, sourceBranch : Branch, title : String, description : String } -> Task Http.Error { apiUrl : String, htmlUrl : String }

See https://developer.github.com/v3/pulls/#create-a-pull-request

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

createFork : { authToken : OAuthToken, owner : Owner, repo : String } -> Task Http.Error { owner : Owner, repo : String }

See https://docs.github.com/en/rest/reference/repos#create-a-fork

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

Issues

getComments : { authToken : OAuthToken, repo : String, issueNumber : Basics.Int } -> Task Http.Error (List { body : String, user : { login : String, avatarUrl : String }, createdAt : Time.Posix, updatedAt : Time.Posix })

See https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

createComment : { authToken : OAuthToken, repo : String, issueNumber : Basics.Int, body : String } -> Task Http.Error { body : String, user : { login : String, avatarUrl : String }, createdAt : Time.Posix, updatedAt : Time.Posix }

See https://developer.github.com/v3/issues/comments/#create-a-comment

NOTE: Not all input options and output fields are supported yet. Pull requests adding more complete support are welcome.

createIssue : { authToken : OAuthToken, owner : Owner, repo : String, title : String.Nonempty.NonemptyString, body : String } -> Task Http.Error ()

See https://docs.github.com/en/rest/reference/issues#create-an-issue