|
| 1 | +----------------------------------------------------------------------------- |
| 2 | +-- | |
| 3 | +-- License : BSD-3-Clause |
| 4 | +-- Maintainer : Todd Mohney <toddmohney@gmail.com> |
| 5 | +-- |
| 6 | +-- The public keys API, as described at |
| 7 | +-- <https://developer.github.com/v3/users/keys/> |
| 8 | +module GitHub.Endpoints.Users.PublicSSHKeys ( |
| 9 | + -- * Querying public SSH keys |
| 10 | + publicSSHKeys', |
| 11 | + publicSSHKeysR, |
| 12 | + publicSSHKeysFor', |
| 13 | + publicSSHKeysForR, |
| 14 | + publicSSHKey', |
| 15 | + publicSSHKeyR, |
| 16 | + |
| 17 | + -- ** Create |
| 18 | + createUserPublicSSHKey', |
| 19 | + createUserPublicSSHKeyR, |
| 20 | + |
| 21 | + -- ** Delete |
| 22 | + deleteUserPublicSSHKey', |
| 23 | + deleteUserPublicSSHKeyR, |
| 24 | +) where |
| 25 | + |
| 26 | +import GitHub.Data |
| 27 | +import GitHub.Internal.Prelude |
| 28 | +import GitHub.Request |
| 29 | +import Prelude () |
| 30 | + |
| 31 | +-- | Querying public SSH keys. |
| 32 | +publicSSHKeysFor' :: Name Owner -> IO (Either Error (Vector PublicSSHKeyBasic)) |
| 33 | +publicSSHKeysFor' user = |
| 34 | + executeRequest' $ publicSSHKeysForR user FetchAll |
| 35 | + |
| 36 | +-- | Querying public SSH keys. |
| 37 | +-- See <https://developer.github.com/v3/users/keys/#list-public-keys-for-a-user> |
| 38 | +publicSSHKeysForR :: Name Owner -> FetchCount -> Request 'RO (Vector PublicSSHKeyBasic) |
| 39 | +publicSSHKeysForR user = |
| 40 | + pagedQuery ["users", toPathPart user, "keys"] [] |
| 41 | + |
| 42 | +-- | Querying the authenticated users' public SSH keys |
| 43 | +publicSSHKeys' :: Auth -> IO (Either Error (Vector PublicSSHKey)) |
| 44 | +publicSSHKeys' auth = |
| 45 | + executeRequest auth publicSSHKeysR |
| 46 | + |
| 47 | +-- | Querying the authenticated users' public SSH keys |
| 48 | +-- See <https://developer.github.com/v3/users/keys/#list-your-public-keys> |
| 49 | +publicSSHKeysR :: Request 'RA (Vector PublicSSHKey) |
| 50 | +publicSSHKeysR = |
| 51 | + query ["user", "keys"] [] |
| 52 | + |
| 53 | +-- | Querying a public SSH key |
| 54 | +publicSSHKey' :: Auth -> Id PublicSSHKey -> IO (Either Error PublicSSHKey) |
| 55 | +publicSSHKey' auth keyId = |
| 56 | + executeRequest auth $ publicSSHKeyR keyId |
| 57 | + |
| 58 | +-- | Querying a public SSH key. |
| 59 | +-- See <https://developer.github.com/v3/users/keys/#get-a-single-public-key> |
| 60 | +publicSSHKeyR :: Id PublicSSHKey -> Request 'RA PublicSSHKey |
| 61 | +publicSSHKeyR keyId = |
| 62 | + query ["user", "keys", toPathPart keyId] [] |
| 63 | + |
| 64 | +-- | Create a public SSH key |
| 65 | +createUserPublicSSHKey' :: Auth -> NewPublicSSHKey -> IO (Either Error PublicSSHKey) |
| 66 | +createUserPublicSSHKey' auth key = |
| 67 | + executeRequest auth $ createUserPublicSSHKeyR key |
| 68 | + |
| 69 | +-- | Create a public SSH key. |
| 70 | +-- See <https://developer.github.com/v3/users/keys/#create-a-public-key>. |
| 71 | +createUserPublicSSHKeyR :: NewPublicSSHKey -> Request 'RW PublicSSHKey |
| 72 | +createUserPublicSSHKeyR key = |
| 73 | + command Post ["user", "keys"] (encode key) |
| 74 | + |
| 75 | +deleteUserPublicSSHKey' :: Auth -> Id PublicSSHKey -> IO (Either Error ()) |
| 76 | +deleteUserPublicSSHKey' auth keyId = |
| 77 | + executeRequest auth $ deleteUserPublicSSHKeyR keyId |
| 78 | + |
| 79 | +-- | Delete a public SSH key. |
| 80 | +-- See <https://developer.github.com/v3/users/keys/#delete-a-public-key> |
| 81 | +deleteUserPublicSSHKeyR :: Id PublicSSHKey -> Request 'RW () |
| 82 | +deleteUserPublicSSHKeyR keyId = |
| 83 | + command Delete ["user", "keys", toPathPart keyId] mempty |
0 commit comments