go_api_client 0.5.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.travis.yml +26 -0
- data/README.md +86 -0
- data/go_api_client.gemspec +11 -11
- data/lib/go_api_client/api/abstract_api.rb +12 -0
- data/lib/go_api_client/api/cctray.rb +53 -0
- data/lib/go_api_client/api/config.rb +60 -0
- data/lib/go_api_client/api/feed.rb +39 -0
- data/lib/go_api_client/api/job.rb +34 -0
- data/lib/go_api_client/api/pipeline.rb +87 -0
- data/lib/go_api_client/api/properties.rb +43 -0
- data/lib/go_api_client/api/stage.rb +45 -0
- data/lib/go_api_client/attribute_helper.rb +9 -0
- data/lib/go_api_client/client.rb +20 -0
- data/lib/go_api_client/domain/artifact.rb +16 -0
- data/lib/go_api_client/domain/author.rb +22 -0
- data/lib/go_api_client/domain/changeset.rb +13 -0
- data/lib/go_api_client/domain/config/job.rb +15 -0
- data/lib/go_api_client/domain/config/pipeline.rb +15 -0
- data/lib/go_api_client/domain/config/stage.rb +15 -0
- data/lib/go_api_client/domain/entry.rb +13 -0
- data/lib/go_api_client/domain/feed.rb +13 -0
- data/lib/go_api_client/domain/internal_cache.rb +28 -0
- data/lib/go_api_client/domain/job.rb +17 -0
- data/lib/go_api_client/domain/material.rb +14 -0
- data/lib/go_api_client/domain/pipeline.rb +27 -0
- data/lib/go_api_client/domain/project.rb +14 -0
- data/lib/go_api_client/domain/scheduled_job.rb +12 -0
- data/lib/go_api_client/domain/stage.rb +28 -0
- data/lib/go_api_client/domain/user.rb +30 -0
- data/lib/go_api_client/http_fetcher.rb +73 -48
- data/lib/go_api_client/parsers/artifact_parser.rb +17 -0
- data/lib/go_api_client/parsers/author_parser.rb +24 -0
- data/lib/go_api_client/parsers/changeset.rb +26 -0
- data/lib/go_api_client/parsers/config/job_parser.rb +48 -0
- data/lib/go_api_client/parsers/config/pipeline_parser.rb +42 -0
- data/lib/go_api_client/parsers/config/stage_parser.rb +33 -0
- data/lib/go_api_client/parsers/entry_parser.rb +27 -0
- data/lib/go_api_client/parsers/feed_parser.rb +27 -0
- data/lib/go_api_client/parsers/job_parser.rb +47 -0
- data/lib/go_api_client/parsers/material_parser.rb +29 -0
- data/lib/go_api_client/parsers/parser_helper.rb +11 -0
- data/lib/go_api_client/parsers/pipeline_parser.rb +30 -0
- data/lib/go_api_client/parsers/project_parser.rb +26 -0
- data/lib/go_api_client/parsers/scheduled_job_parser.rb +28 -0
- data/lib/go_api_client/parsers/stage_parser.rb +31 -0
- data/lib/go_api_client/parsers/user_parser.rb +12 -0
- data/lib/go_api_client/version.rb +4 -4
- data/lib/go_api_client.rb +56 -110
- data/test/go_api_client/artifact_test.rb +8 -8
- data/test/go_api_client/author_test.rb +27 -0
- data/test/go_api_client/building_test.rb +21 -19
- data/test/go_api_client/{atom/entry_test.rb → entry_test.rb} +8 -8
- data/test/go_api_client/job_test.rb +15 -14
- data/test/go_api_client/pipeline_test.rb +24 -27
- data/test/go_api_client/stage_test.rb +21 -74
- data/test/go_api_client/user_test.rb +15 -20
- metadata +108 -78
- data/.init.sh +0 -8
- data/.rbenv-gemsets +0 -1
- data/.ruby-version +0 -1
- data/.rvmrc +0 -1
- data/.yardopts +0 -6
- data/Gemfile.lock +0 -32
- data/README.textile +0 -64
- data/lib/go_api_client/artifact.rb +0 -27
- data/lib/go_api_client/atom/author.rb +0 -42
- data/lib/go_api_client/atom/entry.rb +0 -34
- data/lib/go_api_client/atom/feed.rb +0 -40
- data/lib/go_api_client/atom/feed_page.rb +0 -49
- data/lib/go_api_client/atom.rb +0 -4
- data/lib/go_api_client/commit.rb +0 -30
- data/lib/go_api_client/helpers/simple_attribute_support.rb +0 -11
- data/lib/go_api_client/helpers.rb +0 -1
- data/lib/go_api_client/job.rb +0 -68
- data/lib/go_api_client/pipeline.rb +0 -48
- data/lib/go_api_client/stage.rb +0 -57
- data/lib/go_api_client/user.rb +0 -36
- data/test/go_api_client/atom/author_test.rb +0 -27
- data/test/go_api_client/atom/feed_page_test.rb +0 -41
- data/test/go_api_client/atom/feed_test.rb +0 -39
- data/test/go_api_client/commit_test.rb +0 -38
- data/test/schedule_test.rb +0 -12
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7aa9c91f14314043611166b22565c1c95587702d
|
4
|
+
data.tar.gz: 1a2fde5f96169a0e4ac65f85d994ee46c4a2eba2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f0951a88f086294399c4d1829d0f83d7bf01f04122715ff110ef8241f798922bbfc8ecf5d895d0e5f2e3c27901da2cda0eed85b0ac14f0a5448ede972028a3e1
|
7
|
+
data.tar.gz: ff239e75702a3bd2f2539dc4d75faa0952af375e06068f10a12e19682efe95075ea38cfa6b35ad561e2b212d61b564c92dd4bc2f6e3af569300f860d99a541a2
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 North Development AB
|
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.
|
22
|
+
|
23
|
+
language: ruby
|
24
|
+
rvm:
|
25
|
+
- 1.9.3
|
26
|
+
- 2.0.0
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Go API Client Gem
|
2
|
+
|
3
|
+
This gem provides access to the [ThoughtWorks Studios Go](http://www.thoughtworks-studios.com/go-continuous-delivery) API, it is capable of parsing out the atom feed and generate an object graph with all the pipelines/stages/jobs and committer information.
|
4
|
+
|
5
|
+
[![Build Status](https://api.travis-ci.org/unibet/go-api-client.svg)](https://travis-ci.org/unibet/go-api-client)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/go_api_client.svg)](http://badge.fury.io/rb/go_api_client)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
```
|
11
|
+
sudo gem install go_api_client
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
```
|
17
|
+
require 'go_api_client'
|
18
|
+
|
19
|
+
client = GoApiClient::Client.new({:host => 'go.example.com'})
|
20
|
+
# check if the server is building 'MyProject' pipeline
|
21
|
+
! client.api(:cctray).projects({:pipeline_name => 'MyProject', :activity => 'Building'}).empty?
|
22
|
+
|
23
|
+
# check if the build has finished
|
24
|
+
client.api(:cctray).projects({:pipeline_name => 'MyProject', :activity => 'Building'}).empty?
|
25
|
+
|
26
|
+
# schedule a pipeline
|
27
|
+
client.api(:pipeline).schedule({:pipeline_name => 'MyProject'})
|
28
|
+
|
29
|
+
# Eager fetch pipeline information with parsed stages and jobs
|
30
|
+
client.api(:pipeline).pipeline({:pipeline_name => 'MyProject', :pipeline_id => 1, :eager_parser => [:stage, :job]})
|
31
|
+
|
32
|
+
# Lazy fetch pipeline and its first stage
|
33
|
+
pipeline = client.api(:pipeline).pipeline({:pipeline_name => 'MyProject', :pipeline_id => 1})
|
34
|
+
client.api(:stage).stage({:stage_uri => pipeline.stages.first})
|
35
|
+
|
36
|
+
# Eager get feed for a pipeline tougher with related stages and jobs
|
37
|
+
client.api(:feed).feed({:pipeline_name => 'MyProject', :eager_parser => [:pipeline, :stage, :job]})
|
38
|
+
|
39
|
+
# Get all properties for a given job
|
40
|
+
client.api(:properties).properties({:pipeline_name => 'MyProject', :pipeline_counter => 1, :stage_name => 'defaultStage', :stage_counter => 1, :job_name => 'defaultJob'})
|
41
|
+
|
42
|
+
# Get value of a specific property for a given job
|
43
|
+
client.api(:properties).properties({:pipeline_name => 'MyProject', :pipeline_counter => 1, :stage_name => 'defaultStage', :stage_counter => 1, :job_name => 'defaultJob', :property_name => 'cruise_agent'})
|
44
|
+
|
45
|
+
# Create a property for a given job
|
46
|
+
client.api(:properties).create_property({:pipeline_name => 'MyProject', :pipeline_counter => 1, :stage_name => 'defaultStage', :stage_counter => 1, :job_name => 'defaultJob', :property_name => 'myproperty', :property_value => 'Showcase_for_I29'})
|
47
|
+
|
48
|
+
# Get configuration of 'MyProject' pipeline
|
49
|
+
client.api(:config).pipelines({:pipeline_name => 'MyProject'})
|
50
|
+
|
51
|
+
# Get configuration of 'MyProject' pipeline eagerly parsing the template
|
52
|
+
client.api(:config).pipelines({:pipeline_name => 'MyProject', :eager_parser => [:template]})
|
53
|
+
|
54
|
+
# Get configuration for all pipelines
|
55
|
+
client.api(:config).pipelines
|
56
|
+
|
57
|
+
# Get configuration of a template
|
58
|
+
client.api(:config).templates({:template_name => 'MyTemplate'})
|
59
|
+
```
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
Go API Client Gem is MIT Licensed
|
64
|
+
|
65
|
+
The MIT License
|
66
|
+
|
67
|
+
Copyright (c) 2014 North Development AB (http://www.unibet.com)
|
68
|
+
Copyright (c) 2012 ThoughtWorks, Inc. (http://thoughtworks.com)
|
69
|
+
|
70
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
71
|
+
of this software and associated documentation files (the "Software"), to deal
|
72
|
+
in the Software without restriction, including without limitation the rights
|
73
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
74
|
+
copies of the Software, and to permit persons to whom the Software is
|
75
|
+
furnished to do so, subject to the following conditions:
|
76
|
+
|
77
|
+
The above copyright notice and this permission notice shall be included in
|
78
|
+
all copies or substantial portions of the Software.
|
79
|
+
|
80
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
81
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
82
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
83
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
84
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
85
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
86
|
+
THE SOFTWARE.
|
data/go_api_client.gemspec
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require
|
3
|
+
require 'go_api_client/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = 'go_api_client'
|
7
7
|
s.version = GoApiClient::Version::VERSION
|
8
|
-
s.authors = [
|
9
|
-
s.email =
|
10
|
-
s.homepage =
|
8
|
+
s.authors = ['Nikhil Mungel', 'Ketan Padegaonkar', 'Shishir Das', 'Ilja Bobkevic']
|
9
|
+
s.email = %w(hyfather@gmail.com KetanPadegaonkar@gmail.com shishir.das@gmail.com iljb.bobkevic@unibet.com)
|
10
|
+
s.homepage = 'https://github.com/ThoughtWorksInc/go-api-client'
|
11
11
|
s.summary = %q{Client to parse Go CI atom feed}
|
12
12
|
s.description = %q{This gem parses atom feed generated by the Go Continuous Integration server and provides an OO representation of the pipelines and stages.}
|
13
13
|
s.license = 'MIT'
|
14
14
|
|
15
|
-
s.rubyforge_project =
|
15
|
+
s.rubyforge_project = 'go_api_client'
|
16
16
|
|
17
17
|
s.files = `git ls-files`.split("\n") - `git ls-files -- vendor/cache`.split("\n")
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -20,10 +20,10 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
22
|
# specify any dependencies here; for example:
|
23
|
-
s.add_development_dependency
|
24
|
-
s.add_development_dependency
|
25
|
-
s.add_development_dependency 'rake'
|
26
|
-
s.add_development_dependency 'test-unit'
|
23
|
+
s.add_development_dependency 'webmock', '~> 1', '>= 1.8'
|
24
|
+
s.add_development_dependency 'simplecov', '~> 0.6', '>= 0.6.1'
|
25
|
+
s.add_development_dependency 'rake', '~> 0.9', '>= 0.9.2.2'
|
26
|
+
s.add_development_dependency 'test-unit', '~> 2', '>= 2.0'
|
27
27
|
|
28
|
-
s.add_runtime_dependency
|
28
|
+
s.add_runtime_dependency 'nokogiri', '~> 1.5', '>= 1.5.2'
|
29
29
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
module Api
|
5
|
+
class Cctray < GoApiClient::Api::AbstractApi
|
6
|
+
|
7
|
+
def initialize(attributes = {})
|
8
|
+
super(attributes)
|
9
|
+
@cctray_uri = "#{@base_uri}/cctray.xml"
|
10
|
+
end
|
11
|
+
|
12
|
+
def projects(options={})
|
13
|
+
options = ({:pipeline_name => nil, :stage_name => nil, :job_name => nil, :activity => nil, :web_uri => nil, :eager_parser => []}).merge(options)
|
14
|
+
|
15
|
+
name_args = []
|
16
|
+
name_args << "starts-with(@name, '#{options[:pipeline_name]}')" if options[:pipeline_name]
|
17
|
+
name_args << "starts-with(substring-after(@name, ' :: '), '#{options[:stage_name]}')" if options[:stage_name]
|
18
|
+
name_args << "starts-with(substring-after(substring-after(@name, ' :: '), ' :: '), '#{options[:job_name]}')" if options[:job_name]
|
19
|
+
|
20
|
+
xpath_args = []
|
21
|
+
xpath_args << name_args.join(' and ') unless name_args.empty?
|
22
|
+
xpath_args << "@activity='#{options[:activity]}'" if options[:activity]
|
23
|
+
xpath_args << "@webUrl='#{options[:web_uri]}'" if options[:web_uri]
|
24
|
+
|
25
|
+
xpath_str = './Project'
|
26
|
+
unless xpath_args.empty?
|
27
|
+
xpath_str = "#{xpath_str}[#{xpath_args.join(' and ')}]"
|
28
|
+
end
|
29
|
+
|
30
|
+
doc = Nokogiri::XML(@http_fetcher.get!(@cctray_uri))
|
31
|
+
if doc.root
|
32
|
+
if options[:eager_parser] && options[:eager_parser].include?(:stage)
|
33
|
+
stage_api = GoApiClient::Api::Stage.new({:base_uri => @base_uri, :http_fetcher => @http_fetcher})
|
34
|
+
end
|
35
|
+
|
36
|
+
doc.root.xpath(xpath_str).collect do |element|
|
37
|
+
project = GoApiClient::Parsers::Project.parse(element)
|
38
|
+
project.parsed_pipeline_name, project.parsed_stage_name, project.parsed_job_name = project.name.split('::').map(&:strip)
|
39
|
+
if options[:eager_parser] && options[:eager_parser].include?(:stage) && ! project.parsed_job_name
|
40
|
+
project.parsed_stage = stage_api.stage(options.merge({:stage_uri => "#{project.web_uri}.xml"}))
|
41
|
+
end
|
42
|
+
project
|
43
|
+
end
|
44
|
+
else
|
45
|
+
[]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
attr_reader :cctray_uri
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
module Api
|
5
|
+
class Config < GoApiClient::Api::AbstractApi
|
6
|
+
|
7
|
+
def initialize(attributes = {})
|
8
|
+
super(attributes)
|
9
|
+
end
|
10
|
+
|
11
|
+
def templates(options={})
|
12
|
+
options = ({:template_name => nil, :config_uri => nil}).merge(options)
|
13
|
+
uri = options[:config_uri] ? options[:config_uri] : "#{@base_uri}/api/admin/config.xml"
|
14
|
+
|
15
|
+
xpath_str = './templates/pipeline' + (options[:template_name] ? "[@name='#{options[:template_name]}']" : '')
|
16
|
+
doc = Nokogiri::XML(@http_fetcher.get!(uri)).remove_namespaces!
|
17
|
+
if doc.root
|
18
|
+
doc.root.xpath(xpath_str).collect do |element|
|
19
|
+
GoApiClient::Parsers::Config::Pipeline.parse(element)
|
20
|
+
end
|
21
|
+
else
|
22
|
+
[]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def pipelines(options={})
|
27
|
+
options = ({:group_name => nil, :pipeline_name => nil, :config_uri => nil, :eager_parser => []}).merge(options)
|
28
|
+
uri = options[:config_uri] ? options[:config_uri] : "#{@base_uri}/api/admin/config.xml"
|
29
|
+
|
30
|
+
group_args = []
|
31
|
+
group_args << "@group='#{options[:group_name]}'" if options[:group_name]
|
32
|
+
|
33
|
+
pipeline_args= []
|
34
|
+
pipeline_args << "@name='#{options[:pipeline_name]}'" if options[:pipeline_name]
|
35
|
+
|
36
|
+
xpath_args = []
|
37
|
+
xpath_args << (group_args.empty? ? 'pipelines' : "pipelines[#{group_args.join(' and ')}]")
|
38
|
+
xpath_args << (pipeline_args.empty? ? 'pipeline' : "pipeline[#{pipeline_args.join(' and ')}]")
|
39
|
+
|
40
|
+
xpath_str = './'
|
41
|
+
unless xpath_args.empty?
|
42
|
+
xpath_str = "#{xpath_str}#{xpath_args.join('/')}"
|
43
|
+
end
|
44
|
+
|
45
|
+
doc = Nokogiri::XML(@http_fetcher.get!(uri)).remove_namespaces!
|
46
|
+
if doc.root
|
47
|
+
doc.root.xpath(xpath_str).collect do |element|
|
48
|
+
pipeline = GoApiClient::Parsers::Config::Pipeline.parse(element)
|
49
|
+
if options[:eager_parser] && options[:eager_parser].include?(:template) && pipeline.template
|
50
|
+
pipeline.parsed_template = templates(options.merge({:template_name => pipeline.template}))
|
51
|
+
end
|
52
|
+
pipeline
|
53
|
+
end
|
54
|
+
else
|
55
|
+
[]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
module Api
|
5
|
+
class Feed < GoApiClient::Api::AbstractApi
|
6
|
+
|
7
|
+
def initialize(attributes = {})
|
8
|
+
super(attributes)
|
9
|
+
end
|
10
|
+
|
11
|
+
def feed(options={})
|
12
|
+
options = ({:pipeline_name => nil, :feed_uri => nil, :eager_parser => []}).merge(options)
|
13
|
+
if options[:feed_uri]
|
14
|
+
uri = options[:feed_uri]
|
15
|
+
else
|
16
|
+
raise 'Insufficient arguments' unless options[:pipeline_name]
|
17
|
+
uri = "#{@base_uri}/api/pipelines/#{options[:pipeline_name]}/stages.xml"
|
18
|
+
end
|
19
|
+
feed = GoApiClient::Parsers::Feed.parse(Nokogiri::XML(@http_fetcher.get!(uri)).root)
|
20
|
+
|
21
|
+
if options[:eager_parser]
|
22
|
+
if options[:eager_parser].include?(:stage)
|
23
|
+
stage_api = GoApiClient::Api::Stage.new({:base_uri => @base_uri, :http_fetcher => @http_fetcher})
|
24
|
+
feed.parsed_entries.each do |entry|
|
25
|
+
entry.parsed_stage = stage_api.stage(options.merge({:stage_uri => entry.stage_uri}))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
if options[:eager_parser].include?(:pipeline)
|
29
|
+
pipeline_api = GoApiClient::Api::Pipeline.new({:base_uri => @base_uri, :http_fetcher => @http_fetcher})
|
30
|
+
feed.parsed_entries.each do |entry|
|
31
|
+
entry.parsed_pipeline = pipeline_api.pipeline(options.merge({:pipeline_uri => entry.pipeline_uri}))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
feed
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
module Api
|
5
|
+
class Job < GoApiClient::Api::AbstractApi
|
6
|
+
|
7
|
+
def initialize(attributes = {})
|
8
|
+
super(attributes)
|
9
|
+
end
|
10
|
+
|
11
|
+
def job(options = {})
|
12
|
+
if options[:job_uri]
|
13
|
+
uri = options[:job_uri]
|
14
|
+
else
|
15
|
+
raise 'Insufficient arguments' unless options[:job_id]
|
16
|
+
uri = "#{@base_uri}/api/jobs/#{options[:job_id]}.xml"
|
17
|
+
end
|
18
|
+
GoApiClient::Parsers::Job.parse(Nokogiri::XML(@http_fetcher.get!(uri)).root)
|
19
|
+
end
|
20
|
+
|
21
|
+
def scheduled_jobs
|
22
|
+
uri = "#{@base_uri}/api/jobs/scheduled.xml"
|
23
|
+
doc = Nokogiri::XML(@http_fetcher.post!(uri))
|
24
|
+
if doc.root
|
25
|
+
doc.root.xpath('./job').collect do |element|
|
26
|
+
GoApiClient::Parsers::ScheduledJob.parse(element)
|
27
|
+
end
|
28
|
+
else
|
29
|
+
[]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module GoApiClient
|
4
|
+
module Api
|
5
|
+
class Pipeline < GoApiClient::Api::AbstractApi
|
6
|
+
|
7
|
+
def initialize(attributes = {})
|
8
|
+
attributes = ({:pipeline_cache => {}, :stage_cache => {}}).merge(attributes)
|
9
|
+
super(attributes)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Schedule a particular pipeline with the latest available materials.
|
13
|
+
def schedule(options = {})
|
14
|
+
# options {:materials => nil, :variables => nil, :secure_variables => nil}
|
15
|
+
options = ({:schedule_uri => nil, :pipeline_name => nil}).merge(options)
|
16
|
+
if options[:schedule_uri]
|
17
|
+
uri = options[:schedule_uri]
|
18
|
+
else
|
19
|
+
raise 'Insufficient arguments' unless options[:pipeline_name]
|
20
|
+
uri = "#{@base_uri}/api/pipelines/#{options[:pipeline_name]}/schedule"
|
21
|
+
end
|
22
|
+
@http_fetcher.post!(uri)
|
23
|
+
end
|
24
|
+
|
25
|
+
# This API allows you to release a lock on a pipeline so that you can start up a new instance without
|
26
|
+
# having to wait for the earlier instance to finish.
|
27
|
+
def release_lock(options = {})
|
28
|
+
options = ({:release_lock_uri => nil, :pipeline_name => nil}).merge(options)
|
29
|
+
if options[:release_lock_uri]
|
30
|
+
uri = options[:release_lock_uri]
|
31
|
+
else
|
32
|
+
raise 'Insufficient arguments' unless options[:pipeline_name]
|
33
|
+
uri = "#{@base_uri}/api/pipelines/#{options[:pipeline_name]}/releaseLock"
|
34
|
+
end
|
35
|
+
@http_fetcher.post!(uri)
|
36
|
+
end
|
37
|
+
|
38
|
+
# This API provides the ability to pause a pipeline.
|
39
|
+
def pause(options = {})
|
40
|
+
options = ({:pause_uri => nil, :pipeline_name => nil}).merge(options)
|
41
|
+
if options[:pause_uri]
|
42
|
+
uri = options[:pause_uri]
|
43
|
+
else
|
44
|
+
raise 'Insufficient arguments' unless options[:pipeline_name]
|
45
|
+
uri = "#{@base_uri}/api/pipelines/#{options[:pipeline_name]}/pause"
|
46
|
+
end
|
47
|
+
@http_fetcher.post!(uri)
|
48
|
+
end
|
49
|
+
|
50
|
+
# This API provides the ability to unpause a pipeline.
|
51
|
+
def unpause(options={})
|
52
|
+
options = ({:unpause_uri => nil, :pipeline_name => nil}).merge(options)
|
53
|
+
if options[:unpause_uri]
|
54
|
+
uri = options[:unpause_uri]
|
55
|
+
else
|
56
|
+
raise 'Insufficient arguments' unless options[:pipeline_name]
|
57
|
+
uri = "#{@base_uri}/api/pipelines/#{options[:pipeline_name]}/unpause"
|
58
|
+
end
|
59
|
+
@http_fetcher.post!(uri)
|
60
|
+
end
|
61
|
+
|
62
|
+
def pipeline(options = {})
|
63
|
+
options = ({:pipeline_uri => nil, :pipeline_name => nil, :pipeline_id => nil, :eager_parser => []}).merge(options)
|
64
|
+
if options[:pipeline_uri]
|
65
|
+
uri = options[:pipeline_uri]
|
66
|
+
else
|
67
|
+
raise 'Insufficient arguments' unless options[:pipeline_name] && options[:pipeline_id]
|
68
|
+
uri = "#{@base_uri}/api/pipelines/#{options[:pipeline_name]}/#{options[:pipeline_id]}.xml"
|
69
|
+
end
|
70
|
+
pipeline = GoApiClient::Parsers::Pipeline.parse(Nokogiri::XML(@http_fetcher.get!(uri)).root)
|
71
|
+
@pipeline_cache[GoApiClient::Domain::InternalCache.new(pipeline.self_uri, options)] ||= pipeline
|
72
|
+
if options[:eager_parser] && options[:eager_parser].include?(:stage)
|
73
|
+
stage_api = GoApiClient::Api::Stage.new({:base_uri => @base_uri, :http_fetcher => @http_fetcher, :pipeline_cache => @pipeline_cache, :stage_cache => @stage_cache})
|
74
|
+
pipeline.parsed_stages = pipeline.stages.collect do |stage_uri|
|
75
|
+
stage = @stage_cache[GoApiClient::Domain::InternalCache.new(stage_uri, options)] || stage_api.stage(options.merge({:stage_uri => stage_uri}))
|
76
|
+
@stage_cache[GoApiClient::Domain::InternalCache.new(stage_uri, options)] ||= stage
|
77
|
+
stage
|
78
|
+
end
|
79
|
+
end
|
80
|
+
pipeline
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
attr_accessor :pipeline_cache, :stage_cache
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|