ghub 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/LICENSE.adoc +134 -0
- data/README.adoc +198 -0
- data/ghub.gemspec +37 -0
- data/lib/ghub/api/client.rb +49 -0
- data/lib/ghub/api/page.rb +59 -0
- data/lib/ghub/client.rb +34 -0
- data/lib/ghub/configuration/content.rb +8 -0
- data/lib/ghub/configuration/loader.rb +30 -0
- data/lib/ghub/container.rb +15 -0
- data/lib/ghub/endpoints/branches/protection/actions/show.rb +31 -0
- data/lib/ghub/endpoints/branches/protection/actions/update.rb +38 -0
- data/lib/ghub/endpoints/branches/protection/container.rb +35 -0
- data/lib/ghub/endpoints/branches/protection/import.rb +13 -0
- data/lib/ghub/endpoints/branches/protection/models/show.rb +48 -0
- data/lib/ghub/endpoints/branches/protection/requests/update.rb +52 -0
- data/lib/ghub/endpoints/branches/protection/responses/show.rb +27 -0
- data/lib/ghub/endpoints/branches/protection/root.rb +26 -0
- data/lib/ghub/endpoints/branches/signature/container.rb +26 -0
- data/lib/ghub/endpoints/branches/signature/import.rb +13 -0
- data/lib/ghub/endpoints/branches/signature/root.rb +48 -0
- data/lib/ghub/endpoints/container.rb +19 -0
- data/lib/ghub/endpoints/import.rb +9 -0
- data/lib/ghub/endpoints/organizations/members/actions/index.rb +32 -0
- data/lib/ghub/endpoints/organizations/members/container.rb +30 -0
- data/lib/ghub/endpoints/organizations/members/import.rb +13 -0
- data/lib/ghub/endpoints/organizations/members/responses/index.rb +14 -0
- data/lib/ghub/endpoints/organizations/members/root.rb +16 -0
- data/lib/ghub/endpoints/pulls/actions/index.rb +28 -0
- data/lib/ghub/endpoints/pulls/actions/show.rb +26 -0
- data/lib/ghub/endpoints/pulls/container.rb +30 -0
- data/lib/ghub/endpoints/pulls/import.rb +11 -0
- data/lib/ghub/endpoints/pulls/models/show.rb +81 -0
- data/lib/ghub/endpoints/pulls/responses/index.rb +12 -0
- data/lib/ghub/endpoints/pulls/responses/show.rb +62 -0
- data/lib/ghub/endpoints/pulls/root.rb +16 -0
- data/lib/ghub/endpoints/repositories/actions/create.rb +37 -0
- data/lib/ghub/endpoints/repositories/actions/index.rb +36 -0
- data/lib/ghub/endpoints/repositories/actions/patch.rb +37 -0
- data/lib/ghub/endpoints/repositories/actions/show.rb +32 -0
- data/lib/ghub/endpoints/repositories/container.rb +39 -0
- data/lib/ghub/endpoints/repositories/import.rb +11 -0
- data/lib/ghub/endpoints/repositories/path.rb +54 -0
- data/lib/ghub/endpoints/repositories/requests/create.rb +32 -0
- data/lib/ghub/endpoints/repositories/requests/patch.rb +38 -0
- data/lib/ghub/endpoints/repositories/responses/index.rb +12 -0
- data/lib/ghub/endpoints/repositories/responses/show.rb +97 -0
- data/lib/ghub/endpoints/repositories/root.rb +28 -0
- data/lib/ghub/endpoints/users/actions/index.rb +28 -0
- data/lib/ghub/endpoints/users/actions/show.rb +24 -0
- data/lib/ghub/endpoints/users/container.rb +31 -0
- data/lib/ghub/endpoints/users/import.rb +11 -0
- data/lib/ghub/endpoints/users/models/index.rb +39 -0
- data/lib/ghub/endpoints/users/models/show.rb +53 -0
- data/lib/ghub/endpoints/users/responses/index.rb +33 -0
- data/lib/ghub/endpoints/users/responses/show.rb +45 -0
- data/lib/ghub/endpoints/users/root.rb +16 -0
- data/lib/ghub/import.rb +7 -0
- data/lib/ghub/models/application.rb +34 -0
- data/lib/ghub/models/boolean_link.rb +13 -0
- data/lib/ghub/models/branch.rb +20 -0
- data/lib/ghub/models/check.rb +17 -0
- data/lib/ghub/models/dismissal_restriction.rb +31 -0
- data/lib/ghub/models/label.rb +22 -0
- data/lib/ghub/models/license.rb +20 -0
- data/lib/ghub/models/link.rb +13 -0
- data/lib/ghub/models/links.rb +28 -0
- data/lib/ghub/models/owner.rb +27 -0
- data/lib/ghub/models/permissions/branch.rb +21 -0
- data/lib/ghub/models/permissions/repository.rb +22 -0
- data/lib/ghub/models/repository.rb +111 -0
- data/lib/ghub/models/restriction.rb +32 -0
- data/lib/ghub/models/review.rb +28 -0
- data/lib/ghub/models/status_check.rb +25 -0
- data/lib/ghub/models/team.rb +27 -0
- data/lib/ghub/models/user.rb +33 -0
- data/lib/ghub/responses/application.rb +42 -0
- data/lib/ghub/responses/boolean_link.rb +11 -0
- data/lib/ghub/responses/branch.rb +14 -0
- data/lib/ghub/responses/dismissal_restriction.rb +15 -0
- data/lib/ghub/responses/label.rb +16 -0
- data/lib/ghub/responses/license.rb +14 -0
- data/lib/ghub/responses/link.rb +8 -0
- data/lib/ghub/responses/links.rb +17 -0
- data/lib/ghub/responses/permission.rb +14 -0
- data/lib/ghub/responses/repository.rb +90 -0
- data/lib/ghub/responses/restriction.rb +16 -0
- data/lib/ghub/responses/review.rb +15 -0
- data/lib/ghub/responses/status_check.rb +20 -0
- data/lib/ghub/responses/team.rb +20 -0
- data/lib/ghub/responses/user.rb +27 -0
- data/lib/ghub/resultable.rb +20 -0
- data/lib/ghub.rb +16 -0
- data.tar.gz.sig +0 -0
- metadata +276 -0
- metadata.gz.sig +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ghub
|
|
4
|
+
module Endpoints
|
|
5
|
+
module Pulls
|
|
6
|
+
module Responses
|
|
7
|
+
# Defines a single pull request.
|
|
8
|
+
Show = Dry::Schema.Params do
|
|
9
|
+
required(:_links).hash(Ghub::Responses::Links)
|
|
10
|
+
required(:active_lock_reason).maybe :string
|
|
11
|
+
required(:assignee).hash(Ghub::Responses::User)
|
|
12
|
+
required(:assignees).array(Ghub::Responses::User)
|
|
13
|
+
required(:author_association).filled :string
|
|
14
|
+
required(:auto_merge).maybe :bool
|
|
15
|
+
required(:base).hash(Ghub::Responses::Branch)
|
|
16
|
+
required(:body).filled :string
|
|
17
|
+
required(:closed_at).filled :string
|
|
18
|
+
required(:comments_url).filled :string
|
|
19
|
+
required(:commits_url).filled :string
|
|
20
|
+
required(:created_at).filled :string
|
|
21
|
+
required(:diff_url).filled :string
|
|
22
|
+
required(:draft).filled :bool
|
|
23
|
+
required(:head).hash(Ghub::Responses::Branch)
|
|
24
|
+
required(:html_url).filled :string
|
|
25
|
+
required(:id).filled :integer
|
|
26
|
+
required(:issue_url).filled :string
|
|
27
|
+
required(:labels).array(Ghub::Responses::Label)
|
|
28
|
+
required(:locked).filled :bool
|
|
29
|
+
required(:merge_commit_sha).filled :string
|
|
30
|
+
required(:merged_at).maybe :date_time
|
|
31
|
+
required(:milestone).maybe :hash
|
|
32
|
+
required(:node_id).filled :string
|
|
33
|
+
required(:number).filled :integer
|
|
34
|
+
required(:patch_url).filled :string
|
|
35
|
+
required(:requested_reviewers).maybe :array
|
|
36
|
+
required(:requested_teams).maybe :array
|
|
37
|
+
required(:review_comment_url).filled :string
|
|
38
|
+
required(:review_comments_url).filled :string
|
|
39
|
+
required(:state).filled :string
|
|
40
|
+
required(:statuses_url).filled :string
|
|
41
|
+
required(:title).filled :string
|
|
42
|
+
required(:updated_at).filled :string
|
|
43
|
+
required(:url).filled :string
|
|
44
|
+
required(:user).hash(Ghub::Responses::User)
|
|
45
|
+
|
|
46
|
+
optional(:additions).filled :integer
|
|
47
|
+
optional(:changed_files).filled :integer
|
|
48
|
+
optional(:comments).filled :integer
|
|
49
|
+
optional(:commits).filled :integer
|
|
50
|
+
optional(:deletions).filled :integer
|
|
51
|
+
optional(:maintainer_can_modify).filled :bool
|
|
52
|
+
optional(:mergable).filled :bool
|
|
53
|
+
optional(:mergeable_state).filled :string
|
|
54
|
+
optional(:merged).filled :bool
|
|
55
|
+
optional(:merged_by).maybe :string
|
|
56
|
+
optional(:rebaseable).filled :bool
|
|
57
|
+
optional(:review_comments).filled :integer
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ghub
|
|
4
|
+
module Endpoints
|
|
5
|
+
module Pulls
|
|
6
|
+
# Provides access to the pulls API endpoint.
|
|
7
|
+
class Root
|
|
8
|
+
include Pulls::Import[index_action: "actions.index", show_action: "actions.show"]
|
|
9
|
+
|
|
10
|
+
def index(...) = index_action.call(...)
|
|
11
|
+
|
|
12
|
+
def show(...) = show_action.call(...)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "transactable"
|
|
4
|
+
|
|
5
|
+
module Ghub
|
|
6
|
+
module Endpoints
|
|
7
|
+
module Repositories
|
|
8
|
+
module Actions
|
|
9
|
+
# Handles a repository create action.
|
|
10
|
+
class Create
|
|
11
|
+
include Import[
|
|
12
|
+
:client,
|
|
13
|
+
:path,
|
|
14
|
+
request: "requests.create",
|
|
15
|
+
response: "responses.show",
|
|
16
|
+
model: "models.show"
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
include Transactable
|
|
20
|
+
|
|
21
|
+
def call kind, body, owner: nil, **parameters
|
|
22
|
+
path.create(kind, owner:)
|
|
23
|
+
.bind do |url_path|
|
|
24
|
+
pipe body,
|
|
25
|
+
validate(request),
|
|
26
|
+
insert(url_path, parameters, at: 0),
|
|
27
|
+
to(client, :post),
|
|
28
|
+
try(:parse, catch: JSON::ParserError),
|
|
29
|
+
validate(response),
|
|
30
|
+
to(model, :for)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "transactable"
|
|
4
|
+
|
|
5
|
+
module Ghub
|
|
6
|
+
module Endpoints
|
|
7
|
+
module Repositories
|
|
8
|
+
module Actions
|
|
9
|
+
# Handles a repository index action.
|
|
10
|
+
class Index
|
|
11
|
+
include Repositories::Import[
|
|
12
|
+
:client,
|
|
13
|
+
:path,
|
|
14
|
+
response: "responses.index",
|
|
15
|
+
model: "models.show"
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
include Transactable
|
|
19
|
+
|
|
20
|
+
def call kind, owner, **parameters
|
|
21
|
+
pipe(
|
|
22
|
+
path.index(kind, owner),
|
|
23
|
+
insert(parameters),
|
|
24
|
+
to(client, :get),
|
|
25
|
+
try(:parse, catch: JSON::ParserError),
|
|
26
|
+
fmap { |body| {body:} },
|
|
27
|
+
validate(response),
|
|
28
|
+
as(:fetch, :body),
|
|
29
|
+
map { |item| model.for item }
|
|
30
|
+
)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "transactable"
|
|
4
|
+
|
|
5
|
+
module Ghub
|
|
6
|
+
module Endpoints
|
|
7
|
+
module Repositories
|
|
8
|
+
module Actions
|
|
9
|
+
# Handles a repository patch action.
|
|
10
|
+
class Patch
|
|
11
|
+
include Import[
|
|
12
|
+
:client,
|
|
13
|
+
:path,
|
|
14
|
+
request: "requests.patch",
|
|
15
|
+
response: "responses.show",
|
|
16
|
+
model: "models.show"
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
include Transactable
|
|
20
|
+
|
|
21
|
+
def call owner, id, body, **parameters
|
|
22
|
+
path.patch(owner, id)
|
|
23
|
+
.bind do |url_path|
|
|
24
|
+
pipe body,
|
|
25
|
+
validate(request),
|
|
26
|
+
insert(url_path, parameters, at: 0),
|
|
27
|
+
to(client, :patch),
|
|
28
|
+
try(:parse, catch: JSON::ParserError),
|
|
29
|
+
validate(response),
|
|
30
|
+
to(model, :for)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "transactable"
|
|
4
|
+
|
|
5
|
+
module Ghub
|
|
6
|
+
module Endpoints
|
|
7
|
+
module Repositories
|
|
8
|
+
module Actions
|
|
9
|
+
# Handles a repository show action.
|
|
10
|
+
class Show
|
|
11
|
+
include Repositories::Import[
|
|
12
|
+
:client,
|
|
13
|
+
:path,
|
|
14
|
+
response: "responses.show",
|
|
15
|
+
model: "models.show"
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
include Transactable
|
|
19
|
+
|
|
20
|
+
def call owner, id, **parameters
|
|
21
|
+
pipe path.show(owner, id),
|
|
22
|
+
insert(parameters),
|
|
23
|
+
to(client, :get),
|
|
24
|
+
try(:parse, catch: JSON::ParserError),
|
|
25
|
+
validate(response),
|
|
26
|
+
to(model, :for)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "dry/container"
|
|
4
|
+
|
|
5
|
+
module Ghub
|
|
6
|
+
module Endpoints
|
|
7
|
+
module Repositories
|
|
8
|
+
# Defines repository dependencies.
|
|
9
|
+
module Container
|
|
10
|
+
extend Dry::Container::Mixin
|
|
11
|
+
|
|
12
|
+
merge Ghub::Container
|
|
13
|
+
|
|
14
|
+
namespace :requests do
|
|
15
|
+
register(:create) { Requests::Create }
|
|
16
|
+
register(:patch) { Requests::Patch }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
namespace :responses do
|
|
20
|
+
register(:index) { Responses::Index }
|
|
21
|
+
register(:show) { Ghub::Responses::Repository }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
namespace :models do
|
|
25
|
+
register(:show) { Ghub::Models::Repository }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
register(:path) { Path.new }
|
|
29
|
+
|
|
30
|
+
namespace :actions do
|
|
31
|
+
register(:create) { Actions::Create.new }
|
|
32
|
+
register(:index) { Actions::Index.new }
|
|
33
|
+
register(:patch) { Actions::Patch.new }
|
|
34
|
+
register(:show) { Actions::Show.new }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "dry/monads"
|
|
4
|
+
require "refinements/arrays"
|
|
5
|
+
|
|
6
|
+
module Ghub
|
|
7
|
+
module Endpoints
|
|
8
|
+
module Repositories
|
|
9
|
+
# Dynamically builds API repository path sfor users or organizations.
|
|
10
|
+
class Path
|
|
11
|
+
include Dry::Monads[:result]
|
|
12
|
+
|
|
13
|
+
using Refinements::Arrays
|
|
14
|
+
|
|
15
|
+
KINDS = %w[users orgs].freeze
|
|
16
|
+
|
|
17
|
+
def initialize kinds: KINDS
|
|
18
|
+
@kinds = kinds
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def index kind, owner
|
|
22
|
+
kinds.include?(kind.to_s) ? Success("#{kind}/#{owner}/repos") : error(kind)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def show(...) = resource(...)
|
|
26
|
+
|
|
27
|
+
def create kind, owner: nil
|
|
28
|
+
case kind.to_s
|
|
29
|
+
when "users" then Success "user/repos"
|
|
30
|
+
when "orgs"
|
|
31
|
+
owner ? Success("orgs/#{owner}/repos") : Failure("Organization name is missing.")
|
|
32
|
+
else error kind
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def patch(...) = resource(...)
|
|
37
|
+
|
|
38
|
+
def destroy(...) = resource(...)
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
attr_reader :kinds
|
|
43
|
+
|
|
44
|
+
def resource(owner, id) = Success "repos/#{owner}/#{id}"
|
|
45
|
+
|
|
46
|
+
def error kind
|
|
47
|
+
kinds.map(&:inspect)
|
|
48
|
+
.to_sentence(conjunction: "or")
|
|
49
|
+
.then { |choices| Failure "Invalid kind: #{kind.inspect}. Use: #{choices}." }
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ghub
|
|
4
|
+
module Endpoints
|
|
5
|
+
module Repositories
|
|
6
|
+
module Requests
|
|
7
|
+
# Defines the data structure for creating a repository.
|
|
8
|
+
Create = Dry::Schema.JSON do
|
|
9
|
+
required(:name).filled :string
|
|
10
|
+
|
|
11
|
+
optional(:allow_auto_merge).filled :bool
|
|
12
|
+
optional(:allow_merge_commit).filled :bool
|
|
13
|
+
optional(:allow_rebase_merge).filled :bool
|
|
14
|
+
optional(:allow_squash_merge).filled :bool
|
|
15
|
+
optional(:auto_init).filled :bool
|
|
16
|
+
optional(:delete_branch_on_merge).filled :bool
|
|
17
|
+
optional(:description).filled :string
|
|
18
|
+
optional(:gitignore_template).filled :string
|
|
19
|
+
optional(:has_downloads).filled :bool
|
|
20
|
+
optional(:has_issues).filled :bool
|
|
21
|
+
optional(:has_projects).filled :bool
|
|
22
|
+
optional(:has_wiki).filled :bool
|
|
23
|
+
optional(:homepage).filled :string
|
|
24
|
+
optional(:is_template).filled :bool
|
|
25
|
+
optional(:license_template).filled :string
|
|
26
|
+
optional(:private).filled :bool
|
|
27
|
+
optional(:team_id).filled :integer
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ghub
|
|
4
|
+
module Endpoints
|
|
5
|
+
module Repositories
|
|
6
|
+
module Requests
|
|
7
|
+
# Defines the data structure for patching a repository.
|
|
8
|
+
Patch = Dry::Schema.JSON do
|
|
9
|
+
optional(:allow_auto_merge).filled :bool
|
|
10
|
+
optional(:allow_forking).filled :bool
|
|
11
|
+
optional(:allow_merge_commit).filled :bool
|
|
12
|
+
optional(:allow_rebase_merge).filled :bool
|
|
13
|
+
optional(:allow_squash_merge).filled :bool
|
|
14
|
+
optional(:archived).filled :bool
|
|
15
|
+
optional(:default_branch).filled :string
|
|
16
|
+
optional(:delete_branch_on_merge).filled :bool
|
|
17
|
+
optional(:description).filled :string
|
|
18
|
+
optional(:has_issues).filled :bool
|
|
19
|
+
optional(:has_projects).filled :bool
|
|
20
|
+
optional(:has_wiki).filled :bool
|
|
21
|
+
optional(:homepage).filled :string
|
|
22
|
+
optional(:is_template).filled :bool
|
|
23
|
+
optional(:name).filled :string
|
|
24
|
+
optional(:private).filled :bool
|
|
25
|
+
|
|
26
|
+
optional(:security_and_analysis).hash do
|
|
27
|
+
optional(:advanced_security).hash { required(:status).filled :string }
|
|
28
|
+
optional(:secret_scanning).hash { required(:status).filled :string }
|
|
29
|
+
optional(:secret_scanning_push_protection).hash { required(:status).filled :string }
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
optional(:use_squash_pr_title_as_default).filled :bool
|
|
33
|
+
optional(:visibility).filled :bool
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ghub
|
|
4
|
+
module Endpoints
|
|
5
|
+
module Repositories
|
|
6
|
+
module Responses
|
|
7
|
+
# Defines a repository.
|
|
8
|
+
Show = Dry::Schema.Params do
|
|
9
|
+
required(:allow_forking).filled :bool
|
|
10
|
+
required(:archive_url).filled :string
|
|
11
|
+
required(:archived).filled :bool
|
|
12
|
+
required(:assignees_url).filled :string
|
|
13
|
+
required(:blobs_url).filled :string
|
|
14
|
+
required(:branches_url).filled :string
|
|
15
|
+
required(:clone_url).filled :string
|
|
16
|
+
required(:collaborators_url).filled :string
|
|
17
|
+
required(:comments_url).filled :string
|
|
18
|
+
required(:commits_url).filled :string
|
|
19
|
+
required(:compare_url).filled :string
|
|
20
|
+
required(:contents_url).filled :string
|
|
21
|
+
required(:contributors_url).filled :string
|
|
22
|
+
required(:created_at).filled :date_time
|
|
23
|
+
required(:default_branch).filled :string
|
|
24
|
+
required(:deployments_url).filled :string
|
|
25
|
+
required(:description).maybe :string
|
|
26
|
+
required(:disabled).filled :bool
|
|
27
|
+
required(:downloads_url).filled :string
|
|
28
|
+
required(:events_url).filled :string
|
|
29
|
+
required(:fork).filled :bool
|
|
30
|
+
required(:forks).filled :integer
|
|
31
|
+
required(:forks_count).filled :integer
|
|
32
|
+
required(:forks_url).filled :string
|
|
33
|
+
required(:full_name).filled :string
|
|
34
|
+
required(:git_commits_url).filled :string
|
|
35
|
+
required(:git_refs_url).filled :string
|
|
36
|
+
required(:git_tags_url).filled :string
|
|
37
|
+
required(:git_url).filled :string
|
|
38
|
+
required(:has_downloads).filled :bool
|
|
39
|
+
required(:has_issues).filled :bool
|
|
40
|
+
required(:has_pages).filled :bool
|
|
41
|
+
required(:has_projects).filled :bool
|
|
42
|
+
required(:has_wiki).filled :bool
|
|
43
|
+
required(:homepage).maybe :string
|
|
44
|
+
required(:hooks_url).filled :string
|
|
45
|
+
required(:html_url).filled :string
|
|
46
|
+
required(:id).filled :integer
|
|
47
|
+
required(:is_template).filled :bool
|
|
48
|
+
required(:issue_comment_url).filled :string
|
|
49
|
+
required(:issue_events_url).filled :string
|
|
50
|
+
required(:issues_url).filled :string
|
|
51
|
+
required(:keys_url).filled :string
|
|
52
|
+
required(:labels_url).filled :string
|
|
53
|
+
required(:language).maybe :string
|
|
54
|
+
required(:languages_url).filled :string
|
|
55
|
+
required(:license).maybe :hash, Ghub::Responses::License
|
|
56
|
+
required(:merges_url).filled :string
|
|
57
|
+
required(:milestones_url).filled :string
|
|
58
|
+
required(:mirror_url).maybe :string
|
|
59
|
+
required(:name).filled :string
|
|
60
|
+
required(:node_id).filled :string
|
|
61
|
+
required(:notifications_url).filled :string
|
|
62
|
+
required(:open_issues).filled :integer
|
|
63
|
+
required(:open_issues_count).filled :integer
|
|
64
|
+
required(:owner).hash Ghub::Responses::User
|
|
65
|
+
required(:private).filled :bool
|
|
66
|
+
required(:pulls_url).filled :string
|
|
67
|
+
required(:pushed_at).filled :date_time
|
|
68
|
+
required(:releases_url).filled :string
|
|
69
|
+
required(:size).filled :integer
|
|
70
|
+
required(:ssh_url).filled :string
|
|
71
|
+
required(:stargazers_count).filled :integer
|
|
72
|
+
required(:stargazers_url).filled :string
|
|
73
|
+
required(:statuses_url).filled :string
|
|
74
|
+
required(:subscribers_url).filled :string
|
|
75
|
+
required(:subscription_url).filled :string
|
|
76
|
+
required(:svn_url).filled :string
|
|
77
|
+
required(:tags_url).filled :string
|
|
78
|
+
required(:teams_url).filled :string
|
|
79
|
+
required(:topics).array(:str?)
|
|
80
|
+
required(:trees_url).filled :string
|
|
81
|
+
required(:updated_at).filled :date_time
|
|
82
|
+
required(:url).filled :string
|
|
83
|
+
required(:visibility).filled :string
|
|
84
|
+
required(:watchers).filled :integer
|
|
85
|
+
required(:watchers_count).filled :integer
|
|
86
|
+
required(:web_commit_signoff_required).filled :bool
|
|
87
|
+
|
|
88
|
+
optional(:network_count).filled :integer
|
|
89
|
+
optional(:organization).hash Ghub::Responses::User
|
|
90
|
+
optional(:permissions).hash Ghub::Responses::Permission
|
|
91
|
+
optional(:subscribers_count).filled :integer
|
|
92
|
+
optional(:temp_clone_token).maybe :string
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ghub
|
|
4
|
+
module Endpoints
|
|
5
|
+
module Repositories
|
|
6
|
+
# Provides access to the users API endpoint.
|
|
7
|
+
class Root
|
|
8
|
+
include Repositories::Import[
|
|
9
|
+
:client,
|
|
10
|
+
create_action: "actions.create",
|
|
11
|
+
index_action: "actions.index",
|
|
12
|
+
patch_action: "actions.patch",
|
|
13
|
+
show_action: "actions.show"
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
def index(...) = index_action.call(...)
|
|
17
|
+
|
|
18
|
+
def show(...) = show_action.call(...)
|
|
19
|
+
|
|
20
|
+
def create(...) = create_action.call(...)
|
|
21
|
+
|
|
22
|
+
def patch(...) = patch_action.call(...)
|
|
23
|
+
|
|
24
|
+
def destroy(owner, id) = client.delete "repos/#{owner}/#{id}"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "transactable"
|
|
4
|
+
|
|
5
|
+
module Ghub
|
|
6
|
+
module Endpoints
|
|
7
|
+
module Users
|
|
8
|
+
module Actions
|
|
9
|
+
# Handles a user index action.
|
|
10
|
+
class Index
|
|
11
|
+
include Users::Import[:client, response: "responses.index", model: "models.index"]
|
|
12
|
+
include Transactable
|
|
13
|
+
|
|
14
|
+
def call **parameters
|
|
15
|
+
pipe(
|
|
16
|
+
client.get("users", **parameters),
|
|
17
|
+
try(:parse, catch: JSON::ParserError),
|
|
18
|
+
fmap { |body| {body:} },
|
|
19
|
+
validate(response),
|
|
20
|
+
as(:fetch, :body),
|
|
21
|
+
map { |item| model.new item.to_h }
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "transactable"
|
|
4
|
+
|
|
5
|
+
module Ghub
|
|
6
|
+
module Endpoints
|
|
7
|
+
module Users
|
|
8
|
+
module Actions
|
|
9
|
+
# Handles a user show action.
|
|
10
|
+
class Show
|
|
11
|
+
include Users::Import[:client, response: "responses.show", model: "models.show"]
|
|
12
|
+
include Transactable
|
|
13
|
+
|
|
14
|
+
def call id, **parameters
|
|
15
|
+
pipe client.get("users/#{id}", **parameters),
|
|
16
|
+
try(:parse, catch: JSON::ParserError),
|
|
17
|
+
validate(response),
|
|
18
|
+
to(model, :new)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "dry/container"
|
|
4
|
+
|
|
5
|
+
module Ghub
|
|
6
|
+
module Endpoints
|
|
7
|
+
module Users
|
|
8
|
+
# Defines user dependencies.
|
|
9
|
+
module Container
|
|
10
|
+
extend Dry::Container::Mixin
|
|
11
|
+
|
|
12
|
+
merge Ghub::Container
|
|
13
|
+
|
|
14
|
+
namespace :responses do
|
|
15
|
+
register(:index) { Responses::Index }
|
|
16
|
+
register(:show) { Responses::Show }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
namespace :models do
|
|
20
|
+
register(:index) { Models::Index }
|
|
21
|
+
register(:show) { Models::Show }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
namespace :actions do
|
|
25
|
+
register(:index) { Actions::Index.new }
|
|
26
|
+
register(:show) { Actions::Show.new }
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Ghub
|
|
4
|
+
module Endpoints
|
|
5
|
+
module Users
|
|
6
|
+
module Models
|
|
7
|
+
# Defines a user within a collection.
|
|
8
|
+
Index = Struct.new(
|
|
9
|
+
:avatar_url,
|
|
10
|
+
:events_url,
|
|
11
|
+
:followers_url,
|
|
12
|
+
:following_url,
|
|
13
|
+
:gists_url,
|
|
14
|
+
:gravatar_id,
|
|
15
|
+
:html_url,
|
|
16
|
+
:id,
|
|
17
|
+
:login,
|
|
18
|
+
:node_id,
|
|
19
|
+
:organizations_url,
|
|
20
|
+
:received_events_url,
|
|
21
|
+
:repos_url,
|
|
22
|
+
:site_admin,
|
|
23
|
+
:starred_url,
|
|
24
|
+
:subscriptions_url,
|
|
25
|
+
:type,
|
|
26
|
+
:url,
|
|
27
|
+
keyword_init: true
|
|
28
|
+
) do
|
|
29
|
+
include Resultable
|
|
30
|
+
|
|
31
|
+
def initialize *arguments
|
|
32
|
+
super
|
|
33
|
+
freeze
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|