avh4/elm-github-v3/2.0.0

Github

Authorization

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.

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

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

oauthCode : String -> OAuthCode

Github application client id

clientId : String -> ClientId

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

type Scope
= RepoScope
| RepoStatusScope
| RepoDeploymentScope
| PublicRepoScope
| RepoInviteScope
scopeFromString : String -> Maybe Scope
scopeToString : Scope -> String

Get repository

{ authToken : OAuthToken
, owner : Owner
, repo : String
}
-> Task 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.

{ authToken : OAuthToken
, owner : Owner
, repo : String
, ref : Maybe String
, path : String
}
-> Task 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
{ authToken : OAuthToken
, repo : String
, branch : Branch
, path : String
, sha : ShaHash a
, message : String
, content : String
}
-> Task 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
{ authToken : OAuthToken
, owner : Owner
, repo : String
}
-> Task
Error
(List
{ name : String
}
)

Get all branches for a git repo.

{ authToken : OAuthToken
, owner : Owner
, repo : String
, branchName : Branch
}
-> Task 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.

{ authToken : OAuthToken
, owner : Owner
, repo : String
, branchName : Branch
, force : Bool
}
-> Task 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.

{ authToken : OAuthToken
, owner : Owner
, repo : String
}
-> Task 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.

{ authToken : OAuthToken
, owner : Owner
, repo : String
, branchName : Branch
}
-> Task 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.

{ authToken : Maybe OAuthToken
, owner : Owner
, repo : String
, branchName : Maybe Branch
}
-> Task 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.

{ authToken : OAuthToken
, owner : Owner
, repo : String
, tagName : String
}
-> Task 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.

{ authToken : OAuthToken
, owner : Owner
, repo : String
}
-> Task 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.

{ authToken : OAuthToken
, owner : Owner
, repo : String
, message : String
, tree : ShaHash TreeSha
, parents : List (ShaHash CommitSha)
}
-> Task 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.

{ authToken : OAuthToken
, owner : Owner
, repo : String
}
-> Task Error Bytes
sha : String -> ShaHash a
shaToString : ShaHash a -> String

Get the raw sha string.

type ShaHash a

A SHA identifier

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
, downloadUrl : Url
, url : Url
}
| DirectoryContent (List DirectoryEntry)
| Symlink
| Submodule
= FileContentType
| DirectoryContentType
| SymLinkType
| SubmoduleType
type alias DirectoryEntry =
{ contentType : ContentType
, name : String
, path : String
, downloadUrl : Maybe Url
, url : Maybe Url
}

A file directory in a git repo.

{ authToken : OAuthToken
, owner : Owner
, repo : String
, treeNodes :
Nonempty
{ path : String
, content : String
}
, baseTree : Maybe (ShaHash TreeSha)
}
-> Task 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 : Int
, title : String
}

The data returned by getPullRequests.

{ authToken : OAuthToken
, repo : String
}
-> Task 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.

{ authToken : OAuthToken
, repo : String
, number : Int
}
-> Task
Error
{ head :
{ ref : String
}
}

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.

{ authToken : OAuthToken
, destinationOwner : Owner
, destinationRepo : String
, destinationBranch : Branch
, sourceBranchOwner : Owner
, sourceBranch : Branch
, title : String
, description : String
}
-> Task
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.

{ authToken : OAuthToken
, owner : Owner
, repo : String
}
-> Task
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

{ authToken : OAuthToken
, repo : String
, issueNumber : Int
}
-> Task
Error
(List
{ body : String
, user :
{ login : String
, avatarUrl : String
}
, createdAt : Posix
, updatedAt : 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.

{ authToken : OAuthToken
, repo : String
, issueNumber : Int
, body : String
}
-> Task
Error
{ body : String
, user :
{ login : String
, avatarUrl : String
}
, createdAt : Posix
, updatedAt : 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.

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