datakit-github

Abstraction of the GitHub API, suitable for DataKit clients
Library datakit-github
type t

The type for API capabilities.

val pp : t Fmt.t

pp is the pretty-printer for capabilities.

val equal : t -> t -> bool

equal equalizes capabilities.

val parse : string -> [ `Error of string | `Ok of t ]

parse is the parses capabilites, such that parse (Fmt.to_to_string pp x) = `Ok x.

type op = [
| `Read
| `Write
| `Excl
]

The type for API operations.

  • `Read allows the bridge to read the corresponding kind of GitHub resources
  • `Write allows the bridge to update the corresponding kind of resource.
  • `Excl means that the bridge has exclusive write access to the corresponding GitHub resource. In particular, this means that when the bridge is disconnect/reconnect it will always try to update GitHub to match with the current state of its local resources and it will revert any changes made by other GitHub users on this kind of resources.
val pp_op : op Fmt.t

pp_op is the pretty-printer for resource operations.

type resource = [
| `Repo of string list
| `PR
| `Commit
| `Status of string list
| `Ref
| `Webhook
]

The type for API resources.

val pp_resource : resource Fmt.t

pp_resource is the pretty-printer for resources.

val none : t

none is the capability to do nothing.

val all : t

all is the capability to do everything.

val allow : t -> op -> [ `Default | resource ] -> t

allow t o r is t with the capability to do API calls of type o to the kind of resource r.

val disallow : t -> op -> [ `Default | resource ] -> t

disallow t o r is t without the capability to do API calls of type o to the kind of resource r.

val check : t -> op -> resource -> bool

check t o r is true if t is allowed to to o on the kind of resource r.

val filter_diff : t -> op -> Snapshot.diff -> Snapshot.diff

filter_diff t op d filters the diff d to only apply the subset of operations op over the capabilities defined by t.

val filter_elt : t -> op -> Elt.t -> bool