gitlabarty 0.1.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
- data/.gitignore +8 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +84 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/gitlabarty.gemspec +39 -0
- data/lib/gitlabarty.rb +26 -0
- data/lib/gitlabarty/configuration.rb +13 -0
- data/lib/gitlabarty/issuerequest.rb +74 -0
- data/lib/gitlabarty/version.rb +3 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a492b391c034353cd6601d54fb4bb496623d74a9c1083725ade9c0522d4dc95f
|
4
|
+
data.tar.gz: e2efdb101a554170382f19fbb6b9a929b847db526a751f68407329f34faf1e94
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f85721d56f4cd637eaf520e3547a3503086c79f43aaac11616faa5224fea67d288e5fc0f68cff3320e2fc5c3efb45430662448f90fa3903791a9a1464fec610f
|
7
|
+
data.tar.gz: 6bb2c28b3d21baae7047eb2077da4e15154f2c9df20ca63051a871831aa73d81bb173143f7837c17c24ddaf0f8aac213aee80e04bf480a16b4887f5a7bd6cbbc
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 Ongewitter
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 CedricDeMits
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Gitlabarty
|
2
|
+
A bare-bones gem for making Gitlab API requests
|
3
|
+
|
4
|
+
1. Can only do issue CRUD actions
|
5
|
+
1. Needs your personal-access-token which you should have stored when activating 2FA: [Gitlab API](https://docs.gitlab.com/ee/api/#personal-access-tokens)
|
6
|
+
1. I might work on this more, I might not
|
7
|
+
1. No tests as of yet, living' dat yolo life
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'gitlabarty'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install gitlabarty
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Set config:
|
28
|
+
```rb
|
29
|
+
Gitlabarty.configuration do |config|
|
30
|
+
config.url = "https://your.project.com/api/v4/projects/" # url to your project
|
31
|
+
config.id = 1 # id of the project you want to create issues in
|
32
|
+
config.private_token = "your-personal-access-token" # your personal access token for the gitlab project
|
33
|
+
end
|
34
|
+
```
|
35
|
+
|
36
|
+
Create an issue: [gitlab API](https://docs.gitlab.com/ee/api/issues.html#new-issue)
|
37
|
+
```rb
|
38
|
+
Gitlabarty.create_issue(:options)
|
39
|
+
```
|
40
|
+
|
41
|
+
Update/Edit an issue: [gitlab API](https://docs.gitlab.com/ee/api/issues.html#edit-issue)
|
42
|
+
```rb
|
43
|
+
Gitlabarty.update_issue(:issue_id, :options)
|
44
|
+
```
|
45
|
+
|
46
|
+
Read/Get an issue: [gitlab API](https://docs.gitlab.com/ee/api/issues.html#single-issue)
|
47
|
+
```rb
|
48
|
+
Gitlabarty.read_issue(:issue_id)
|
49
|
+
```
|
50
|
+
|
51
|
+
Delete/Destroy an issue: [gitlab API](https://docs.gitlab.com/ee/api/issues.html#delete-an-issue)
|
52
|
+
```rb
|
53
|
+
Gitlabarty.delete_issue(:issue_id)
|
54
|
+
```
|
55
|
+
|
56
|
+
Responses are all JSON objects, as per the gitlab API docs.
|
57
|
+
|
58
|
+
### Table of available options: (No validation yet)
|
59
|
+
|
60
|
+
Option | Type | Required |Description
|
61
|
+
---|---|---|---
|
62
|
+
title | String | yes | The title of an issue
|
63
|
+
description | String | no | The description of an issue. Limited to 1,048,576 characters.
|
64
|
+
confidential | Boolean | no | Set an issue to be confidential. Default is false.
|
65
|
+
assignee_ids | Integer | array | no The ID of a user to assign issue
|
66
|
+
milestone_id | Integer | no | The global ID of a milestone to assign issue
|
67
|
+
labels | String | no | Comma-separated label names for an issue
|
68
|
+
created_at | String | no | Date time string, ISO 8601 formatted, e.g. 2016-03-11T03:45:40Z (requires admin or project/group owner rights)
|
69
|
+
due_date | String | no | Date time string in the format YEAR-MONTH-DAY, e.g. 2016-03-11
|
70
|
+
merge_request_to_resolve_discussions_of | Integer | no | The IID of a merge request in which to resolve all issues. This will fill the issue with a default description and mark all discussions as resolved. When passing a description or title, these values will take precedence over the default values.
|
71
|
+
discussion_to_resolve | String | no | The ID of a discussion to resolve. This will fill in the issue with a default description and mark the discussion as resolved. Use in combination with merge_request_to_resolve_discussions_of.
|
72
|
+
weight | Integer | no | The weight of the issue. Valid values are greater than or equal to 0.
|
73
|
+
epic_id | Integer | no | ID of the epic to add the issue to. Valid values are greater than or equal to 0.
|
74
|
+
epic_iid | Integer | no | IID of the epic to add the issue to. Valid values are greater than or equal to 0. (deprecated, will be removed in 13.0)
|
75
|
+
|
76
|
+
## Development
|
77
|
+
|
78
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
79
|
+
|
80
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
81
|
+
|
82
|
+
## License
|
83
|
+
|
84
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "gitlabarty"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/gitlabarty.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gitlabarty/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'gitlabarty'
|
8
|
+
spec.version = Gitlabarty::VERSION
|
9
|
+
spec.authors = ['Cedric DeMits']
|
10
|
+
spec.email = ['cedricdemits@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'A pure ruby gem for making gitlab api requests.'
|
13
|
+
spec.description = "Can only do issue's CRUD actions. I might work on this more, I might not."
|
14
|
+
spec.homepage = 'https://github.com/Ongewitter/gitlabarty.git'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = 'https://rubygems.org'
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
|
32
|
+
spec.bindir = 'exe'
|
33
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ['lib']
|
35
|
+
|
36
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
37
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
38
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
39
|
+
end
|
data/lib/gitlabarty.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'gitlabarty/version'
|
2
|
+
require 'gitlabarty/issuerequest'
|
3
|
+
require 'gitlabarty/configuration'
|
4
|
+
|
5
|
+
module Gitlabarty
|
6
|
+
def self.read_issue(id)
|
7
|
+
Gitlabarty::IssueRequest.read(id)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.create_issue(options = {})
|
11
|
+
Gitlabarty::IssueRequest.create(options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.update_issue(id, options = {})
|
15
|
+
Gitlabarty::IssueRequest.update(id, options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.delete_issue(id)
|
19
|
+
Gitlabarty::IssueRequest.delete(id)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.configuration
|
23
|
+
@configuration ||= Configuration.new
|
24
|
+
block_given? ? yield(@configuration) : @configuration
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Gitlabarty
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :url,
|
4
|
+
:id,
|
5
|
+
:private_token
|
6
|
+
|
7
|
+
def initialize(options = {url: 'https://gitlab.example.com/api/v4/projects/', id: 1, private_token: 'something'})
|
8
|
+
self.url = options[:url]
|
9
|
+
self.id = options[:id]
|
10
|
+
self.private_token = options[:private_token]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Gitlabarty
|
5
|
+
module IssueRequest
|
6
|
+
def self.issue_url
|
7
|
+
"#{Gitlabarty.configuration.url}/#{Gitlabarty.configuration.id}/issues"
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.create(params)
|
11
|
+
default_params = { title: 'New Issue' }
|
12
|
+
params = default_params.merge(post_params(params))
|
13
|
+
|
14
|
+
post = Net::HTTP::Post.new("#{issue_url}?#{URI.encode_www_form(params)}")
|
15
|
+
post['PRIVATE-TOKEN'] = Gitlabarty.configuration.private_token
|
16
|
+
|
17
|
+
response = send_request(post)
|
18
|
+
JSON.parse(response.body).to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.read(id)
|
22
|
+
return unless id
|
23
|
+
|
24
|
+
get = Net::HTTP::Get.new("#{issue_url}/#{id}")
|
25
|
+
get['PRIVATE-TOKEN'] = Gitlabarty.configuration.private_token
|
26
|
+
|
27
|
+
response = send_request(get)
|
28
|
+
JSON.parse(response.body).to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.update(id, params)
|
32
|
+
return unless id
|
33
|
+
|
34
|
+
params = put_params(params)
|
35
|
+
|
36
|
+
put = Net::HTTP::Put.new("#{issue_url}/#{id}?#{URI.encode_www_form(params)}")
|
37
|
+
put['PRIVATE-TOKEN'] = Gitlabarty.configuration.private_token
|
38
|
+
|
39
|
+
response = send_request(put)
|
40
|
+
JSON.parse(response.body).to_s
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.delete(id)
|
44
|
+
return unless id
|
45
|
+
|
46
|
+
del = Net::HTTP::Delete.new("#{issue_url}/#{id}")
|
47
|
+
del['PRIVATE-TOKEN'] = Gitlabarty.configuration.private_token
|
48
|
+
|
49
|
+
response = send_request(del)
|
50
|
+
JSON.parse(response.body).to_s
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.post_params(params)
|
54
|
+
params.slice(:title, :description, :confidential, :assignee_ids,
|
55
|
+
:milestone_id, :labels, :created_at, :due_date, :merge_request_to_resolve_discussions_of,
|
56
|
+
:discussion_to_resolve, :weight, :epic_id, :epic_iid)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.put_params(params)
|
60
|
+
params.slice(:title, :description, :confidential, :assignee_ids,
|
61
|
+
:milestone_id, :labels, :state_event, :updated_at, :due_date, :weight,
|
62
|
+
:discussion_locked, :epic_id, :epic_iid)
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.send_request(request)
|
66
|
+
response = nil
|
67
|
+
uri = URI(Gitlabarty.configuration.url)
|
68
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
69
|
+
response = http.request request
|
70
|
+
end
|
71
|
+
response
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitlabarty
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cedric DeMits
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Can only do issue's CRUD actions. I might work on this more, I might
|
56
|
+
not.
|
57
|
+
email:
|
58
|
+
- cedricdemits@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- gitlabarty.gemspec
|
73
|
+
- lib/gitlabarty.rb
|
74
|
+
- lib/gitlabarty/configuration.rb
|
75
|
+
- lib/gitlabarty/issuerequest.rb
|
76
|
+
- lib/gitlabarty/version.rb
|
77
|
+
homepage: https://github.com/Ongewitter/gitlabarty.git
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata:
|
81
|
+
allowed_push_host: https://rubygems.org
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubygems_version: 3.0.3
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: A pure ruby gem for making gitlab api requests.
|
101
|
+
test_files: []
|