-- |
-- 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 =
    Paths
-> QueryString
-> FetchCount
-> GenRequest 'MtJSON 'RA (WithTotalCount OrganizationSecret)
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", Name Organization -> Text
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 =
    Paths -> QueryString -> GenRequest 'MtJSON 'RA PublicKey
forall (mt :: MediaType (*)) (rw :: RW) a.
Paths -> QueryString -> GenRequest mt rw a
Query [Text
"orgs", Name Organization -> Text
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 =
    Paths -> QueryString -> GenRequest 'MtJSON 'RA OrganizationSecret
forall (mt :: MediaType (*)) (rw :: RW) a.
Paths -> QueryString -> GenRequest mt rw a
Query [Text
"orgs", Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", Name OrganizationSecret -> Text
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 =
    CommandMethod -> Paths -> ByteString -> GenRequest 'MtUnit 'RW ()
forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Put [Text
"orgs", Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", Name OrganizationSecret -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name OrganizationSecret
name] (ByteString -> GenRequest 'MtUnit 'RW ())
-> (SetSecret -> ByteString)
-> SetSecret
-> GenRequest 'MtUnit 'RW ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SetSecret -> ByteString
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 =
    CommandMethod -> Paths -> ByteString -> GenRequest 'MtUnit 'RW ()
forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Delete Paths
parts ByteString
forall a. Monoid a => a
mempty
    where
        parts :: Paths
parts = [Text
"orgs", Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", Name OrganizationSecret -> Text
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 =
    Paths
-> QueryString
-> FetchCount
-> GenRequest 'MtJSON 'RA (WithTotalCount SelectedRepo)
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", Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", Name OrganizationSecret -> Text
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 =
    CommandMethod -> Paths -> ByteString -> GenRequest 'MtUnit 'RW ()
forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Put [Text
"orgs", Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", Name OrganizationSecret -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name OrganizationSecret
name, Text
"repositories"]  (ByteString -> GenRequest 'MtUnit 'RW ())
-> (SetSelectedRepositories -> ByteString)
-> SetSelectedRepositories
-> GenRequest 'MtUnit 'RW ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SetSelectedRepositories -> ByteString
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 =
    CommandMethod -> Paths -> ByteString -> GenRequest 'MtUnit 'RW ()
forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Put [Text
"orgs", Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", Name OrganizationSecret -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name OrganizationSecret
name, Text
"repositories", Id Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Repo
repo] ByteString
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 =
    CommandMethod -> Paths -> ByteString -> GenRequest 'MtUnit 'RW ()
forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Delete [Text
"orgs", Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", Name OrganizationSecret -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name OrganizationSecret
name, Text
"repositories", Id Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Repo
repo] ByteString
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 =
    Paths
-> QueryString
-> FetchCount
-> GenRequest 'MtJSON 'RA (WithTotalCount RepoSecret)
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", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user,  Name Repo -> Text
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 =
    Paths -> QueryString -> GenRequest 'MtJSON 'RA PublicKey
forall (mt :: MediaType (*)) (rw :: RW) a.
Paths -> QueryString -> GenRequest mt rw a
Query [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Organization -> Text
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 =
    Paths -> QueryString -> GenRequest 'MtJSON 'RA RepoSecret
forall (mt :: MediaType (*)) (rw :: RW) a.
Paths -> QueryString -> GenRequest mt rw a
Query [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", Name RepoSecret -> Text
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 =
    CommandMethod -> Paths -> ByteString -> GenRequest 'MtUnit 'RW ()
forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Put [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", Name RepoSecret -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name RepoSecret
name] (ByteString -> GenRequest 'MtUnit 'RW ())
-> (SetRepoSecret -> ByteString)
-> SetRepoSecret
-> GenRequest 'MtUnit 'RW ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SetRepoSecret -> ByteString
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 =
    CommandMethod -> Paths -> ByteString -> GenRequest 'MtUnit 'RW ()
forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Delete Paths
parts ByteString
forall a. Monoid a => a
mempty
    where
        parts :: Paths
parts = [Text
"repos", Name Owner -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Owner
user, Name Organization -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Organization
org, Text
"actions", Text
"secrets", Name RepoSecret -> Text
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 =
    Paths
-> QueryString
-> FetchCount
-> GenRequest 'MtJSON 'RA (WithTotalCount RepoSecret)
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", Id Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Repo
repo, Text
"environments", Name Environment -> Text
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 =
    Paths -> QueryString -> GenRequest 'MtJSON 'RA PublicKey
forall (mt :: MediaType (*)) (rw :: RW) a.
Paths -> QueryString -> GenRequest mt rw a
Query [Text
"repositories", Id Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Repo
repo, Text
"environments", Name Environment -> Text
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 =
    Paths -> QueryString -> GenRequest 'MtJSON 'RA RepoSecret
forall (mt :: MediaType (*)) (rw :: RW) a.
Paths -> QueryString -> GenRequest mt rw a
Query [Text
"repositories", Id Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Repo
repo, Text
"environments", Name Environment -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Environment
env, Text
"secrets", Name RepoSecret -> Text
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 =
    CommandMethod -> Paths -> ByteString -> GenRequest 'MtUnit 'RW ()
forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Put [Text
"repositories", Id Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Repo
repo, Text
"environments", Name Environment -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Environment
env, Text
"secrets", Name RepoSecret -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name RepoSecret
name] (ByteString -> GenRequest 'MtUnit 'RW ())
-> (SetRepoSecret -> ByteString)
-> SetRepoSecret
-> GenRequest 'MtUnit 'RW ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SetRepoSecret -> ByteString
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 =
    CommandMethod -> Paths -> ByteString -> GenRequest 'MtUnit 'RW ()
forall (mt :: MediaType (*)) a.
CommandMethod -> Paths -> ByteString -> GenRequest mt 'RW a
Command CommandMethod
Delete Paths
parts ByteString
forall a. Monoid a => a
mempty
    where
        parts :: Paths
parts = [Text
"repositories", Id Repo -> Text
forall a. IsPathPart a => a -> Text
toPathPart Id Repo
repo, Text
"environments", Name Environment -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name Environment
env, Text
"secrets", Name RepoSecret -> Text
forall a. IsPathPart a => a -> Text
toPathPart Name RepoSecret
name]