packages feed

github 0.14.0 → 0.14.1

raw patch · 10 files changed

+146/−18 lines, 10 filesdep ~aeson

Dependency ranges changed: aeson

Files

+ CHANGELOG.md view
@@ -0,0 +1,62 @@+Changes for 0.14.1++- Add `membersOfWithR`, `listTeamMembersR`+- Add related enums: `OrgMemberFilter`, `OrgMemberRole`, `TeamMemberRole`+- Add `Enum` and `Bounded` instances to `Privacy`, `Permission`,+  `RepoPublicity`+- Don't require network access for search tests++Changes for 0.14.0++Large API changes:++- Use `Text` and `Vector` in place of `String` and `[]`.+- Use `Name` and `Id` tagged types for names and identifiers.+- Make detailed structures un-prefixed, simple ones prefixed with `Simple`. Example: `Team` and `SimpleTeam`.+- Decouple request creation from execution (`*R` and `executeRequest*` functions).+- Add `Binary` instances for all data+- `GithubOwner` is a `newtype` of `Either User Organization`. There's still `SimpleOwner`.++Changes for 0.5.0:++* OAuth.+* New function: `Github.Repos.organizationRepo`, to get the repo for a specific organization.+* Introduce a new `newRepoAutoInit` flag to `NewRepo`, for whether to initialize a repo while creating it.+* Relax the attoparsec version requirements.+* The above by [John Wiegley](https://github.com/jwiegley).++Changes for 0.4.1:++* Stop using the uri package.+* Use aeson version 0.6.1.0.+* Use attoparsec version 0.10.3.0.+* Use http-conduit over 1.8.+* Use unordered-containers between 0.2 and 0.3.++Changes for 0.4.0:++* Use http-conduit version 1.4.1.10.++Changes for 0.3.0:++* Re-instantiate the Blobs API.+* `repoDescription1` and `repoPushedAt` are a `Maybe GithubDate`.+* Add `deleteRepo`, `editRepo`, and `createRepo`.+* Private gists, issues, organizations, pull requests, and users.+* Lock down `tls` and `tls-extra` instead of keeping up with the+  ever-changing `http-conduit` package.+* Features by [Pavel Ryzhov](https://github.com/paulrzcz) and [Simon Hengel](https://github.com/sol).++Changes for 0.2.1:++* Expand the unordered-containers dependency to anything in 0.1.x .++Changes for 0.2.0:++* `milestoneDueOn` and `repoLanguage` are now `Maybe` types.+* Introduce `GithubOwner` as the sum type for a `GithubUser` or `GithubOrganization`. Everything that once produced a `GithubUser` now produces a `GithubOwner`. All record accessors have changed their names+* Similar to `GithubOwner`, introduce `DetailedOwner`, which can be a `DetailedUser` or a `DetailedOrganization`. All record accessors have changed their names+* An `HTTPConnectionError` now composes `SomeException` instead of `IOException`. All exceptions raised by the underlying http-conduit library are encapulated there.+* The `githubIssueClosedBy` function now produces a `Maybe GithubOwner`.+* Remove the Blobs API, as it is broken upstream.+* Bugs found and squashed thanks to [Joey Hess](https://github.com/joeyh) and [Simon Hengel](https://github.com/sol).
README.md view
@@ -1,6 +1,11 @@ Github ------ +[![Build Status](https://travis-ci.org/phadej/github.svg?branch=master)](https://travis-ci.org/phadej/github)+[![Hackage](https://img.shields.io/hackage/v/github.svg)](http://hackage.haskell.org/package/github)+[![Stackage LTS 5](http://stackage.org/package/github/badge/lts-5)](http://stackage.org/lts-5/package/github)+[![Stackage Nightly](http://stackage.org/package/github/badge/nightly)](http://stackage.org/nightly/package/github)+ The Github API v3 for Haskell.  Some functions are missing; these are functions where the Github API did
github.cabal view
@@ -1,5 +1,5 @@ name:                github-version:             0.14.0+version:             0.14.1 synopsis:            Access to the GitHub API, v3. description:   The GitHub API provides programmatic access to the full@@ -29,6 +29,7 @@ cabal-version:       >=1.10 extra-source-files:   README.md,+  CHANGELOG.md,   fixtures/issue-search.json,   fixtures/list-teams.json,   fixtures/members-list.json,
spec/GitHub/SearchSpec.hs view
@@ -5,20 +5,29 @@ import Prelude        () import Prelude.Compat -import Data.Aeson.Compat (eitherDecodeStrict)-import Data.FileEmbed    (embedFile)-import Test.Hspec        (Spec, describe, it, shouldBe)+import Data.Aeson.Compat  (eitherDecodeStrict)+import Data.FileEmbed     (embedFile)+import Data.Proxy         (Proxy (..))+import Data.String        (fromString)+import System.Environment (lookupEnv)+import Test.Hspec         (Spec, describe, it, pendingWith, shouldBe)  import qualified Data.Vector as V -import GitHub.Data.Id     (Id (..))-import GitHub.Data.Issues (Issue (..))-import GitHub.Endpoints.Search      (SearchResult (..), searchIssues)+import GitHub.Data             (Auth (..), Issue (..), mkId)+import GitHub.Endpoints.Search (SearchResult (..), searchIssues')  fromRightS :: Show a => Either a b -> b fromRightS (Right b) = b fromRightS (Left a) = error $ "Expected a Right and got a Left" ++ show a +withAuth :: (Auth -> IO ()) -> IO ()+withAuth action = do+  mtoken <- lookupEnv "GITHUB_TOKEN"+  case mtoken of+    Nothing    -> pendingWith "no GITHUB_TOKEN"+    Just token -> action (OAuth $ fromString token)+ spec :: Spec spec = do   describe "searchIssues" $ do@@ -30,19 +39,19 @@       V.length issues `shouldBe` 2        let issue1 = issues V.! 0-      issueId issue1 `shouldBe` Id 123898390+      issueId issue1 `shouldBe` mkId (Proxy :: Proxy Issue) 123898390       issueNumber issue1 `shouldBe` 130       issueTitle issue1 `shouldBe` "Make test runner more robust"       issueState issue1 `shouldBe` "closed"        let issue2 = issues V.! 1-      issueId issue2 `shouldBe` Id 119694665+      issueId issue2 `shouldBe` mkId (Proxy :: Proxy Issue) 119694665       issueNumber issue2 `shouldBe` 127       issueTitle issue2 `shouldBe` "Decouple request creation from execution"       issueState issue2 `shouldBe` "open" -    it "performs an issue search via the API" $ do+    it "performs an issue search via the API" $ withAuth $ \auth -> do       let query = "Decouple in:title repo:phadej/github created:<=2015-12-01"-      issues <- searchResultResults . fromRightS <$> searchIssues query+      issues <- searchResultResults . fromRightS <$> searchIssues' (Just auth) query       length issues `shouldBe` 1-      issueId (V.head issues) `shouldBe` Id 119694665+      issueId (V.head issues) `shouldBe` mkId (Proxy :: Proxy Issue) 119694665
src/GitHub.hs view
@@ -158,13 +158,13 @@     --     -- Missing endpoints: All except /Members List/     membersOfR,+    membersOfWithR,      -- ** Teams     -- | See <https://developer.github.com/v3/orgs/teams/>     --     -- Missing endpoints:     ---    -- * List team members     -- * Query team member (deprecated)     -- * Add team member (deprecated)     -- * Remove team member (deprecated)@@ -177,6 +177,7 @@     createTeamForR,     editTeamR,     deleteTeamR,+    listTeamMembersR,     teamMembershipInfoForR,     addTeamMembershipForR,     deleteTeamMembershipForR,
src/GitHub/Data/Definitions.hs view
@@ -229,3 +229,16 @@         case t of             OwnerUser         -> Owner . Left <$> parseUser obj             OwnerOrganization -> Owner . Right <$> parseOrganization obj++-- | Filter members returned in the list.+data OrgMemberFilter+    = OrgMemberFilter2faDisabled  -- ^ Members without two-factor authentication enabled. Available for organization owners.+    | OrgMemberFilterAll          -- ^ All members the authenticated user can see.+    deriving (Show, Eq, Ord, Enum, Bounded, Typeable, Data, Generic)++-- | Filter members returned by their role.+data OrgMemberRole+    = OrgMemberRoleAll     -- ^ All members of the organization, regardless of role.+    | OrgMemberRoleAdmin   -- ^ Organization owners.+    | OrgMemberRoleMember  -- ^ Non-owner organization members.+    deriving (Show, Eq, Ord, Enum, Bounded, Typeable, Data, Generic)
src/GitHub/Data/Repos.hs view
@@ -120,7 +120,7 @@     | RepoPublicityPublic  -- ^ Only public repos.     | RepoPublicityPrivate -- ^ Only private repos.     | RepoPublicityMember  -- ^ Only repos to which the user is a member but not an owner.-    deriving (Show, Eq, Ord, Typeable, Data, Generic)+    deriving (Show, Eq, Ord, Enum, Bounded, Typeable, Data, Generic)  -- | The value is the number of bytes of code written in that language. type Languages = HM.HashMap Language Int
src/GitHub/Data/Teams.hs view
@@ -30,7 +30,7 @@ data Privacy =     PrivacyClosed   | PrivacySecret-  deriving (Show, Data, Typeable, Eq, Ord, Generic)+  deriving (Show, Data, Enum, Bounded, Typeable, Eq, Ord, Generic)  instance NFData Privacy where rnf = genericRnf instance Binary Privacy@@ -39,7 +39,7 @@     PermissionPull   | PermissionPush   | PermissionAdmin-  deriving (Show, Data, Typeable, Eq, Ord, Generic)+  deriving (Show, Data, Enum, Bounded, Typeable, Eq, Ord, Generic)  instance NFData Permission where rnf = genericRnf instance Binary Permission@@ -47,7 +47,7 @@ data SimpleTeam = SimpleTeam {    simpleTeamId              :: !(Id Team)   ,simpleTeamUrl             :: !Text-  ,simpleTeamName            :: !Text+  ,simpleTeamName            :: !Text  -- TODO (0.15.0): unify this and 'simpleTeamSlug' as in 'Team'.   ,simpleTeamSlug            :: !(Name Team)   ,simpleTeamDescription     :: !(Maybe Text)   ,simpleTeamPrivacy         :: !(Maybe Privacy)@@ -243,3 +243,10 @@ instance ToJSON ReqState where   toJSON StateActive  = String "active"   toJSON StatePending = String "pending"++-- | Filters members returned by their role in the team.+data TeamMemberRole+    = TeamMemberRoleAll         -- ^ all members of the team.+    | TeamMemberRoleMaintainer  -- ^ team maintainers+    | TeamMemberRoleMember      -- ^ normal members of the team.+    deriving (Show, Eq, Ord, Enum, Bounded, Typeable, Data, Generic)
src/GitHub/Endpoints/Organizations/Members.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE OverloadedStrings #-} ----------------------------------------------------------------------------- -- | -- License     :  BSD-3-Clause@@ -9,6 +10,7 @@     membersOf,     membersOf',     membersOfR,+    membersOfWithR,     module GitHub.Data,     ) where @@ -37,3 +39,17 @@ -- See <https://developer.github.com/v3/orgs/members/#members-list> membersOfR :: Name Organization -> Maybe Count -> Request k (Vector SimpleUser) membersOfR organization = PagedQuery ["orgs", toPathPart organization, "members"] []++-- | 'membersOfR' with filters.+--+-- See <https://developer.github.com/v3/orgs/members/#members-list>+membersOfWithR :: Name Organization -> OrgMemberFilter -> OrgMemberRole -> Maybe Count -> Request k (Vector SimpleUser)+membersOfWithR org f r = PagedQuery ["orgs", toPathPart org, "members"] [("filter", Just f'), ("role", Just r')]+  where+    f' = case f of+        OrgMemberFilter2faDisabled -> "2fa_disabled"+        OrgMemberFilterAll         -> "all"+    r' = case r of+        OrgMemberRoleAll    -> "all"+        OrgMemberRoleAdmin  -> "admin"+        OrgMemberRoleMember -> "member"
src/GitHub/Endpoints/Organizations/Teams.hs view
@@ -1,4 +1,5 @@-{-# LANGUAGE DataKinds #-}+{-# LANGUAGE DataKinds         #-}+{-# LANGUAGE OverloadedStrings #-} ----------------------------------------------------------------------------- -- | -- License     :  BSD-3-Clause@@ -19,6 +20,7 @@     editTeamR,     deleteTeam',     deleteTeamR,+    listTeamMembersR,     teamMembershipInfoFor,     teamMembershipInfoFor',     teamMembershipInfoForR,@@ -120,10 +122,22 @@     executeRequest auth $ deleteTeamR tid  -- | Delete team.+-- -- See <https://developer.github.com/v3/orgs/teams/#delete-team> deleteTeamR :: Id Team -> Request 'True () deleteTeamR tid =     Command Delete ["teams", toPathPart tid] mempty++-- List team members.+--+-- See <https://developer.github.com/v3/orgs/teams/#list-team-members>+listTeamMembersR :: Id Team -> TeamMemberRole -> Maybe Count -> Request 'True (Vector SimpleUser)+listTeamMembersR tid r = PagedQuery ["teams", toPathPart tid, "members"] [("role", Just r')]+  where+    r' = case r of+        TeamMemberRoleAll         -> "all"+        TeamMemberRoleMaintainer  -> "maintainer"+        TeamMemberRoleMember      -> "member"  -- | Retrieve team mebership information for a user. -- | With authentication