-- |
-- The actions API as documented at
-- <https://docs.github.com/en/rest/reference/actions>.

module GitHub.Endpoints.Actions.Secrets (
    organizationSecretsR,
    organizationPublicKeyR,
    organizationSecretR,
    setOrganizationSecretR,
    deleteOrganizationSecretR,
    organizationSelectedRepositoriesForSecretR,
    setOrganizationSelectedRepositoriesForSecretR,
    addOrganizationSelectedRepositoriesForSecretR,
    removeOrganizationSelectedRepositoriesForSecretR,
    repoSecretsR,
    repoPublicKeyR,
    repoSecretR,
    setRepoSecretR,
    deleteRepoSecretR,
    environmentSecretsR,
    environmentPublicKeyR,
    environmentSecretR,
    setEnvironmentSecretR,
    deleteEnvironmentSecretR,
    module GitHub.Data
    ) where

import GitHub.Data
import GitHub.Internal.Prelude
import Prelude ()

-- | List organization secrets.
-- See <https://docs.github.com/en/rest/actions/secrets#list-organization-secrets>
organizationSecretsR
    :: Name Organization
    -> FetchCount
    -> GenRequest 'MtJSON 'RA (WithTotalCount OrganizationSecret)
organizationSecretsR :: Name Organization
-> FetchCount
-> GenRequest 'MtJSON 'RA (WithTotalCount OrganizationSecret)
organizationSecretsR Name Organization
org =
    forall a (t :: * -> *) b (mt :: MediaType (*)) (rw :: RW).
(a ~ t b, Foldable t, Semigroup a) =>
Paths -> QueryString -> FetchCount -> GenRequest mt rw a
PagedQuery [Text
"orgs", forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets"] []

-- | List organization secrets.
-- See <https://docs.github.com/en/rest/actions/secrets#get-an-organization-public-key>
organizationPublicKeyR
    :: Name Organization
    -> GenRequest 'MtJSON 'RA PublicKey
organizationPublicKeyR :: Name Organization -> GenRequest 'MtJSON 'RA PublicKey
organizationPublicKeyR Name Organization
org =
    forall (mt :: MediaType (*)) (rw :: RW) a.
Paths -> QueryString -> GenRequest mt rw a
Query [Text
"orgs", forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", Text
"public-key"] []

-- | Get an organization secret.
-- See <https://docs.github.com/en/rest/actions/secrets#get-an-organization-secret>
organizationSecretR
    :: Name Organization
    -> Name OrganizationSecret
    -> GenRequest 'MtJSON 'RA OrganizationSecret
organizationSecretR :: Name Organization
-> Name OrganizationSecret
-> GenRequest 'MtJSON 'RA OrganizationSecret
organizationSecretR Name Organization
org Name OrganizationSecret
name =
    forall (mt :: MediaType (*)) (rw :: RW) a.
Paths -> QueryString -> GenRequest mt rw a
Query [Text
"orgs", forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", forall a. IsPathPart a => a -> Text
toPathPart Name OrganizationSecret
name] []

-- | Create or update an organization secret.
-- See <https://docs.github.com/en/rest/actions/secrets#create-or-update-an-organization-secret>
setOrganizationSecretR
    :: Name Organization
    -> Name OrganizationSecret
    -> SetSecret
    -> GenRequest 'MtUnit 'RW ()
setOrganizationSecretR :: Name Organization
-> Name OrganizationSecret
-> SetSecret
-> GenRequest 'MtUnit 'RW ()
setOrganizationSecretR Name Organization
org Name OrganizationSecret
name =
    forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Put [Text
"orgs", forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", forall a. IsPathPart a => a -> Text
toPathPart Name OrganizationSecret
name] forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. ToJSON a => a -> ByteString
encode

-- | Delete an organization secret.
-- See <https://docs.github.com/en/rest/actions/secrets#delete-an-organization-secret>
deleteOrganizationSecretR
    :: Name Organization
    -> Name OrganizationSecret
    -> GenRequest 'MtUnit 'RW ()
deleteOrganizationSecretR :: Name Organization
-> Name OrganizationSecret -> GenRequest 'MtUnit 'RW ()
deleteOrganizationSecretR Name Organization
org Name OrganizationSecret
name =
    forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Delete Paths
parts forall a. Monoid a => a
mempty
    where
        parts :: Paths
parts = [Text
"orgs", forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", forall a. IsPathPart a => a -> Text
toPathPart Name OrganizationSecret
name]

-- | Get selected repositories for an organization secret.
-- See <https://docs.github.com/en/rest/actions/secrets#list-selected-repositories-for-an-organization-secret>
organizationSelectedRepositoriesForSecretR
    :: Name Organization
    -> Name OrganizationSecret
    -> FetchCount
    -> GenRequest 'MtJSON 'RA (WithTotalCount SelectedRepo)
organizationSelectedRepositoriesForSecretR :: Name Organization
-> Name OrganizationSecret
-> FetchCount
-> GenRequest 'MtJSON 'RA (WithTotalCount SelectedRepo)
organizationSelectedRepositoriesForSecretR Name Organization
org Name OrganizationSecret
name =
    forall a (t :: * -> *) b (mt :: MediaType (*)) (rw :: RW).
(a ~ t b, Foldable t, Semigroup a) =>
Paths -> QueryString -> FetchCount -> GenRequest mt rw a
PagedQuery [Text
"orgs", forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", forall a. IsPathPart a => a -> Text
toPathPart Name OrganizationSecret
name, Text
"repositories"] []

-- | Set selected repositories for an organization secret.
-- See <https://docs.github.com/en/rest/actions/secrets#set-selected-repositories-for-an-organization-secret>
setOrganizationSelectedRepositoriesForSecretR
    :: Name Organization
    -> Name OrganizationSecret
    -> SetSelectedRepositories
    -> GenRequest 'MtUnit 'RW ()
setOrganizationSelectedRepositoriesForSecretR :: Name Organization
-> Name OrganizationSecret
-> SetSelectedRepositories
-> GenRequest 'MtUnit 'RW ()
setOrganizationSelectedRepositoriesForSecretR Name Organization
org Name OrganizationSecret
name =
    forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Put [Text
"orgs", forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", forall a. IsPathPart a => a -> Text
toPathPart Name OrganizationSecret
name, Text
"repositories"]  forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. ToJSON a => a -> ByteString
encode

-- | Add selected repository to an organization secret.
-- See <https://docs.github.com/en/rest/actions/secrets#add-selected-repository-to-an-organization-secret>
addOrganizationSelectedRepositoriesForSecretR
    :: Name Organization
    -> Name OrganizationSecret
    -> Id Repo
    -> GenRequest 'MtUnit 'RW ()
addOrganizationSelectedRepositoriesForSecretR :: Name Organization
-> Name OrganizationSecret -> Id Repo -> GenRequest 'MtUnit 'RW ()
addOrganizationSelectedRepositoriesForSecretR Name Organization
org Name OrganizationSecret
name Id Repo
repo =
    forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Put [Text
"orgs", forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", forall a. IsPathPart a => a -> Text
toPathPart Name OrganizationSecret
name, Text
"repositories", forall a. IsPathPart a => a -> Text
toPathPart Id Repo
repo] forall a. Monoid a => a
mempty

-- | Remove selected repository from an organization secret.
-- See <https://docs.github.com/en/rest/actions/secrets#remove-selected-repository-from-an-organization-secret>
removeOrganizationSelectedRepositoriesForSecretR
    :: Name Organization
    -> Name OrganizationSecret
    -> Id Repo
    -> GenRequest 'MtUnit 'RW ()
removeOrganizationSelectedRepositoriesForSecretR :: Name Organization
-> Name OrganizationSecret -> Id Repo -> GenRequest 'MtUnit 'RW ()
removeOrganizationSelectedRepositoriesForSecretR Name Organization
org Name OrganizationSecret
name Id Repo
repo =
    forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Delete [Text
"orgs", forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", forall a. IsPathPart a => a -> Text
toPathPart Name OrganizationSecret
name, Text
"repositories", forall a. IsPathPart a => a -> Text
toPathPart Id Repo
repo] forall a. Monoid a => a
mempty

-- | List repository secrets.
-- See <https://docs.github.com/en/rest/actions/secrets#list-repository-secrets>
repoSecretsR
    :: Name Owner
    -> Name Repo
    -> FetchCount
    -> GenRequest 'MtJSON 'RA (WithTotalCount RepoSecret)
repoSecretsR :: Name Owner
-> Name Repo
-> FetchCount
-> GenRequest 'MtJSON 'RA (WithTotalCount RepoSecret)
repoSecretsR Name Owner
user Name Repo
repo =
    forall a (t :: * -> *) b (mt :: MediaType (*)) (rw :: RW).
(a ~ t b, Foldable t, Semigroup a) =>
Paths -> QueryString -> FetchCount -> GenRequest mt rw a
PagedQuery [Text
"repos", forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user,  forall a. IsPathPart a => a -> Text
toPathPart Name Repo
repo, Text
"actions", Text
"secrets"] []

-- | Get a repository public key.
-- See <https://docs.github.com/en/rest/actions/secrets#get-a-repository-public-key>
repoPublicKeyR
    :: Name Owner
    -> Name Organization
    -> GenRequest 'MtJSON 'RA PublicKey
repoPublicKeyR :: Name Owner -> Name Organization -> GenRequest 'MtJSON 'RA PublicKey
repoPublicKeyR Name Owner
user Name Organization
org =
    forall (mt :: MediaType (*)) (rw :: RW) a.
Paths -> QueryString -> GenRequest mt rw a
Query [Text
"repos", forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", Text
"public-key"] []

-- | Get a repository secret.
-- See <https://docs.github.com/en/rest/actions/secrets#get-a-repository-secret>
repoSecretR
    :: Name Owner
    -> Name Organization
    -> Name RepoSecret
    -> GenRequest 'MtJSON 'RA RepoSecret
repoSecretR :: Name Owner
-> Name Organization
-> Name RepoSecret
-> GenRequest 'MtJSON 'RA RepoSecret
repoSecretR Name Owner
user Name Organization
org Name RepoSecret
name =
    forall (mt :: MediaType (*)) (rw :: RW) a.
Paths -> QueryString -> GenRequest mt rw a
Query [Text
"repos", forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", forall a. IsPathPart a => a -> Text
toPathPart Name RepoSecret
name] []

-- | Create or update a repository secret.
-- See <https://docs.github.com/en/rest/actions/secrets#create-or-update-a-repository-secret>
setRepoSecretR
    :: Name Owner
    -> Name Organization
    -> Name RepoSecret
    -> SetRepoSecret
    -> GenRequest 'MtUnit 'RW ()
setRepoSecretR :: Name Owner
-> Name Organization
-> Name RepoSecret
-> SetRepoSecret
-> GenRequest 'MtUnit 'RW ()
setRepoSecretR Name Owner
user Name Organization
org Name RepoSecret
name =
    forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Put [Text
"repos", forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", forall a. IsPathPart a => a -> Text
toPathPart Name RepoSecret
name] forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. ToJSON a => a -> ByteString
encode

-- | Delete a repository secret.
-- See <https://docs.github.com/en/rest/actions/secrets#delete-a-repository-secret>
deleteRepoSecretR
    :: Name Owner
    -> Name Organization
    -> Name RepoSecret
    -> GenRequest 'MtUnit 'RW ()
deleteRepoSecretR :: Name Owner
-> Name Organization
-> Name RepoSecret
-> GenRequest 'MtUnit 'RW ()
deleteRepoSecretR Name Owner
user Name Organization
org Name RepoSecret
name =
    forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Delete Paths
parts forall a. Monoid a => a
mempty
    where
        parts :: Paths
parts = [Text
"repos", forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", forall a. IsPathPart a => a -> Text
toPathPart Name RepoSecret
name]

-- | List environment secrets.
-- See <https://docs.github.com/en/rest/actions/secrets#list-environment-secrets>
environmentSecretsR
    :: Id Repo
    -> Name Environment
    -> FetchCount
    -> GenRequest 'MtJSON 'RA (WithTotalCount RepoSecret)
environmentSecretsR :: Id Repo
-> Name Environment
-> FetchCount
-> GenRequest 'MtJSON 'RA (WithTotalCount RepoSecret)
environmentSecretsR Id Repo
repo Name Environment
env =
    forall a (t :: * -> *) b (mt :: MediaType (*)) (rw :: RW).
(a ~ t b, Foldable t, Semigroup a) =>
Paths -> QueryString -> FetchCount -> GenRequest mt rw a
PagedQuery [Text
"repositories", forall a. IsPathPart a => a -> Text
toPathPart Id Repo
repo, Text
"environments", forall a. IsPathPart a => a -> Text
toPathPart Name Environment
env, Text
"secrets"] []

-- | Get an environment public key.
-- See <https://docs.github.com/en/rest/actions/secrets#get-an-environment-public-key>
environmentPublicKeyR
    :: Id Repo
    -> Name Environment
    -> GenRequest 'MtJSON 'RA PublicKey
environmentPublicKeyR :: Id Repo -> Name Environment -> GenRequest 'MtJSON 'RA PublicKey
environmentPublicKeyR Id Repo
repo Name Environment
env =
    forall (mt :: MediaType (*)) (rw :: RW) a.
Paths -> QueryString -> GenRequest mt rw a
Query [Text
"repositories", forall a. IsPathPart a => a -> Text
toPathPart Id Repo
repo, Text
"environments", forall a. IsPathPart a => a -> Text
toPathPart Name Environment
env, Text
"secrets", Text
"public-key"] []

-- | Get an environment secret
-- See <https://docs.github.com/en/rest/actions/secrets#get-an-environment-secret>
environmentSecretR
    :: Id Repo
    -> Name Environment
    -> Name RepoSecret
    -> GenRequest 'MtJSON 'RA RepoSecret
environmentSecretR :: Id Repo
-> Name Environment
-> Name RepoSecret
-> GenRequest 'MtJSON 'RA RepoSecret
environmentSecretR Id Repo
repo Name Environment
env Name RepoSecret
name =
    forall (mt :: MediaType (*)) (rw :: RW) a.
Paths -> QueryString -> GenRequest mt rw a
Query [Text
"repositories", forall a. IsPathPart a => a -> Text
toPathPart Id Repo
repo, Text
"environments", forall a. IsPathPart a => a -> Text
toPathPart Name Environment
env, Text
"secrets", forall a. IsPathPart a => a -> Text
toPathPart Name RepoSecret
name] []

-- | Create or update an environment secret.
-- See <https://docs.github.com/en/rest/actions/secrets#create-or-update-an-environment-secret>
setEnvironmentSecretR
    :: Id Repo
    -> Name Environment
    -> Name RepoSecret
    -> SetRepoSecret
    -> GenRequest 'MtUnit 'RW ()
setEnvironmentSecretR :: Id Repo
-> Name Environment
-> Name RepoSecret
-> SetRepoSecret
-> GenRequest 'MtUnit 'RW ()
setEnvironmentSecretR Id Repo
repo Name Environment
env Name RepoSecret
name =
    forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Put [Text
"repositories", forall a. IsPathPart a => a -> Text
toPathPart Id Repo
repo, Text
"environments", forall a. IsPathPart a => a -> Text
toPathPart Name Environment
env, Text
"secrets", forall a. IsPathPart a => a -> Text
toPathPart Name RepoSecret
name] forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. ToJSON a => a -> ByteString
encode

-- | Delete an environment secret.
-- See <https://docs.github.com/en/rest/actions/secrets#delete-an-environment-secret>
deleteEnvironmentSecretR
    :: Id Repo
    -> Name Environment
    -> Name RepoSecret
    -> GenRequest 'MtUnit 'RW ()
deleteEnvironmentSecretR :: Id Repo
-> Name Environment -> Name RepoSecret -> GenRequest 'MtUnit 'RW ()
deleteEnvironmentSecretR Id Repo
repo Name Environment
env Name RepoSecret
name =
    forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Delete Paths
parts forall a. Monoid a => a
mempty
    where
        parts :: Paths
parts = [Text
"repositories", forall a. IsPathPart a => a -> Text
toPathPart Id Repo
repo, Text
"environments", forall a. IsPathPart a => a -> Text
toPathPart Name Environment
env, Text
"secrets", forall a. IsPathPart a => a -> Text
toPathPart Name RepoSecret
name]