Class: JIRA::Client
- Inherits:
-
Object
- Object
- JIRA::Client
- Extended by:
- Forwardable
- Defined in:
- lib/jira/client.rb
Overview
This class is the main access point for all JIRA::Resource instances.
The client must be initialized with an options hash containing configuration options. The available options are:
:site => 'http://localhost:2990',
:context_path => '/jira',
:signature_method => 'RSA-SHA1',
:request_token_path => "/plugins/servlet/oauth/request-token",
:authorize_path => "/plugins/servlet/oauth/authorize",
:access_token_path => "/plugins/servlet/oauth/access-token",
:private_key_file => "rsakey.pem",
:rest_base_path => "/rest/api/2",
:consumer_key => nil,
:consumer_secret => nil,
:ssl_verify_mode => OpenSSL::SSL::VERIFY_PEER,
:use_ssl => true,
:username => nil,
:password => nil,
:auth_type => :oauth,
:proxy_address => nil,
:proxy_port => nil,
:additional_cookies => nil
See the JIRA::Base class methods for all of the available methods on these accessor objects.
Constant Summary collapse
- DEFAULT_OPTIONS =
{ site: 'http://localhost:2990', context_path: '/jira', rest_base_path: '/rest/api/2', ssl_verify_mode: OpenSSL::SSL::VERIFY_PEER, use_ssl: true, use_client_cert: false, auth_type: :oauth, http_debug: false }.freeze
Instance Attribute Summary collapse
-
#cache ⇒ Object
The OAuth::Consumer instance returned by the OauthClient.
-
#consumer ⇒ Object
The OAuth::Consumer instance returned by the OauthClient.
-
#http_debug ⇒ Object
The OAuth::Consumer instance returned by the OauthClient.
-
#options ⇒ Object
readonly
The configuration options for this client instance.
-
#request_client ⇒ Object
The OAuth::Consumer instance returned by the OauthClient.
Instance Method Summary collapse
- #Agile ⇒ Object
- #ApplicationLink ⇒ Object
-
#Attachment ⇒ Object
:nodoc:.
- #Board ⇒ Object
-
#Comment ⇒ Object
:nodoc:.
-
#Component ⇒ Object
:nodoc:.
- #Createmeta ⇒ Object
-
#delete(path, headers = {}) ⇒ Object
HTTP methods without a body.
-
#Field ⇒ Object
:nodoc:.
-
#Filter ⇒ Object
:nodoc:.
- #get(path, headers = {}) ⇒ Object
- #head(path, headers = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#Issue ⇒ Object
:nodoc:.
- #Issuelink ⇒ Object
- #Issuelinktype ⇒ Object
-
#Issuetype ⇒ Object
:nodoc:.
-
#post(path, body = '', headers = {}) ⇒ Object
HTTP methods with a body.
-
#Priority ⇒ Object
:nodoc:.
-
#Project ⇒ Object
:nodoc:.
- #put(path, body = '', headers = {}) ⇒ Object
- #RapidView ⇒ Object
- #Remotelink ⇒ Object
-
#request(http_method, path, body = '', headers = {}) ⇒ Object
Sends the specified HTTP request to the REST API through the appropriate method (oauth, basic).
-
#Resolution ⇒ Object
:nodoc:.
- #ServerInfo ⇒ Object
- #Sprint ⇒ Object
- #SprintReport ⇒ Object
-
#Status ⇒ Object
:nodoc:.
-
#Transition ⇒ Object
:nodoc:.
-
#User ⇒ Object
:nodoc:.
-
#Version ⇒ Object
:nodoc:.
- #Watcher ⇒ Object
- #Webhook ⇒ Object
-
#Worklog ⇒ Object
:nodoc:.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/jira/client.rb', line 58 def initialize( = {}) = DEFAULT_OPTIONS.merge() @options = @options[:rest_base_path] = @options[:context_path] + @options[:rest_base_path] if [:use_client_cert] raise ArgumentError, 'Options: :cert_path must be set when :use_client_cert is true' unless @options[:cert_path] raise ArgumentError, 'Options: :key_path must be set when :use_client_cert is true' unless @options[:key_path] @options[:cert] = OpenSSL::X509::Certificate.new(File.read(@options[:cert_path])) @options[:key] = OpenSSL::PKey::RSA.new(File.read(@options[:key_path])) end case [:auth_type] when :oauth, :oauth_2legged @request_client = OauthClient.new(@options) @consumer = @request_client.consumer when :basic @request_client = HttpClient.new(@options) when :cookie raise ArgumentError, 'Options: :use_cookies must be true for :cookie authorization type' if @options.key?(:use_cookies) && !@options[:use_cookies] @options[:use_cookies] = true @request_client = HttpClient.new(@options) @request_client. @options.delete(:username) @options.delete(:password) else raise ArgumentError, 'Options: ":auth_type" must be ":oauth",":oauth_2legged", ":cookie" or ":basic"' end @http_debug = @options[:http_debug] @options.freeze @cache = OpenStruct.new end |
Instance Attribute Details
#cache ⇒ Object
The OAuth::Consumer instance returned by the OauthClient
The authenticated client instance returned by the respective client type (Oauth, Basic)
40 41 42 |
# File 'lib/jira/client.rb', line 40 def cache @cache end |
#consumer ⇒ Object
The OAuth::Consumer instance returned by the OauthClient
The authenticated client instance returned by the respective client type (Oauth, Basic)
40 41 42 |
# File 'lib/jira/client.rb', line 40 def consumer @consumer end |
#http_debug ⇒ Object
The OAuth::Consumer instance returned by the OauthClient
The authenticated client instance returned by the respective client type (Oauth, Basic)
40 41 42 |
# File 'lib/jira/client.rb', line 40 def http_debug @http_debug end |
#options ⇒ Object (readonly)
The configuration options for this client instance
43 44 45 |
# File 'lib/jira/client.rb', line 43 def @options end |
#request_client ⇒ Object
The OAuth::Consumer instance returned by the OauthClient
The authenticated client instance returned by the respective client type (Oauth, Basic)
40 41 42 |
# File 'lib/jira/client.rb', line 40 def request_client @request_client end |
Instance Method Details
#Agile ⇒ Object
206 207 208 |
# File 'lib/jira/client.rb', line 206 def Agile JIRA::Resource::AgileFactory.new(self) end |
#ApplicationLink ⇒ Object
178 179 180 |
# File 'lib/jira/client.rb', line 178 def ApplicationLink JIRA::Resource::ApplicationLinkFactory.new(self) end |
#Attachment ⇒ Object
:nodoc:
134 135 136 |
# File 'lib/jira/client.rb', line 134 def Attachment # :nodoc: JIRA::Resource::AttachmentFactory.new(self) end |
#Board ⇒ Object
154 155 156 |
# File 'lib/jira/client.rb', line 154 def Board JIRA::Resource::BoardFactory.new(self) end |
#Comment ⇒ Object
:nodoc:
130 131 132 |
# File 'lib/jira/client.rb', line 130 def Comment # :nodoc: JIRA::Resource::CommentFactory.new(self) end |
#Component ⇒ Object
:nodoc:
106 107 108 |
# File 'lib/jira/client.rb', line 106 def Component # :nodoc: JIRA::Resource::ComponentFactory.new(self) end |
#Createmeta ⇒ Object
174 175 176 |
# File 'lib/jira/client.rb', line 174 def Createmeta JIRA::Resource::CreatemetaFactory.new(self) end |
#delete(path, headers = {}) ⇒ Object
HTTP methods without a body
211 212 213 |
# File 'lib/jira/client.rb', line 211 def delete(path, headers = {}) request(:delete, path, nil, merge_default_headers(headers)) end |
#Field ⇒ Object
:nodoc:
150 151 152 |
# File 'lib/jira/client.rb', line 150 def Field # :nodoc: JIRA::Resource::FieldFactory.new(self) end |
#Filter ⇒ Object
:nodoc:
102 103 104 |
# File 'lib/jira/client.rb', line 102 def Filter # :nodoc: JIRA::Resource::FilterFactory.new(self) end |
#get(path, headers = {}) ⇒ Object
215 216 217 |
# File 'lib/jira/client.rb', line 215 def get(path, headers = {}) request(:get, path, nil, merge_default_headers(headers)) end |
#head(path, headers = {}) ⇒ Object
219 220 221 |
# File 'lib/jira/client.rb', line 219 def head(path, headers = {}) request(:head, path, nil, merge_default_headers(headers)) end |
#Issue ⇒ Object
:nodoc:
98 99 100 |
# File 'lib/jira/client.rb', line 98 def Issue # :nodoc: JIRA::Resource::IssueFactory.new(self) end |
#Issuelink ⇒ Object
190 191 192 |
# File 'lib/jira/client.rb', line 190 def Issuelink JIRA::Resource::IssuelinkFactory.new(self) end |
#Issuelinktype ⇒ Object
194 195 196 |
# File 'lib/jira/client.rb', line 194 def Issuelinktype JIRA::Resource::IssuelinktypeFactory.new(self) end |
#Issuetype ⇒ Object
:nodoc:
114 115 116 |
# File 'lib/jira/client.rb', line 114 def Issuetype # :nodoc: JIRA::Resource::IssuetypeFactory.new(self) end |
#post(path, body = '', headers = {}) ⇒ Object
HTTP methods with a body
224 225 226 227 |
# File 'lib/jira/client.rb', line 224 def post(path, body = '', headers = {}) headers = { 'Content-Type' => 'application/json' }.merge(headers) request(:post, path, body, merge_default_headers(headers)) end |
#Priority ⇒ Object
:nodoc:
118 119 120 |
# File 'lib/jira/client.rb', line 118 def Priority # :nodoc: JIRA::Resource::PriorityFactory.new(self) end |
#Project ⇒ Object
:nodoc:
94 95 96 |
# File 'lib/jira/client.rb', line 94 def Project # :nodoc: JIRA::Resource::ProjectFactory.new(self) end |
#put(path, body = '', headers = {}) ⇒ Object
229 230 231 232 |
# File 'lib/jira/client.rb', line 229 def put(path, body = '', headers = {}) headers = { 'Content-Type' => 'application/json' }.merge(headers) request(:put, path, body, merge_default_headers(headers)) end |
#RapidView ⇒ Object
158 159 160 |
# File 'lib/jira/client.rb', line 158 def RapidView JIRA::Resource::RapidViewFactory.new(self) end |
#Remotelink ⇒ Object
198 199 200 |
# File 'lib/jira/client.rb', line 198 def Remotelink JIRA::Resource::RemotelinkFactory.new(self) end |
#request(http_method, path, body = '', headers = {}) ⇒ Object
Sends the specified HTTP request to the REST API through the appropriate method (oauth, basic).
236 237 238 239 |
# File 'lib/jira/client.rb', line 236 def request(http_method, path, body = '', headers = {}) puts "#{http_method}: #{path} - [#{body}]" if @http_debug @request_client.request(http_method, path, body, headers) end |
#Resolution ⇒ Object
:nodoc:
126 127 128 |
# File 'lib/jira/client.rb', line 126 def Resolution # :nodoc: JIRA::Resource::ResolutionFactory.new(self) end |
#ServerInfo ⇒ Object
170 171 172 |
# File 'lib/jira/client.rb', line 170 def ServerInfo JIRA::Resource::ServerInfoFactory.new(self) end |
#Sprint ⇒ Object
162 163 164 |
# File 'lib/jira/client.rb', line 162 def Sprint JIRA::Resource::SprintFactory.new(self) end |
#SprintReport ⇒ Object
166 167 168 |
# File 'lib/jira/client.rb', line 166 def SprintReport JIRA::Resource::SprintReportFactory.new(self) end |
#Status ⇒ Object
:nodoc:
122 123 124 |
# File 'lib/jira/client.rb', line 122 def Status # :nodoc: JIRA::Resource::StatusFactory.new(self) end |
#Transition ⇒ Object
:nodoc:
146 147 148 |
# File 'lib/jira/client.rb', line 146 def Transition # :nodoc: JIRA::Resource::TransitionFactory.new(self) end |
#User ⇒ Object
:nodoc:
110 111 112 |
# File 'lib/jira/client.rb', line 110 def User # :nodoc: JIRA::Resource::UserFactory.new(self) end |
#Version ⇒ Object
:nodoc:
142 143 144 |
# File 'lib/jira/client.rb', line 142 def Version # :nodoc: JIRA::Resource::VersionFactory.new(self) end |
#Watcher ⇒ Object
182 183 184 |
# File 'lib/jira/client.rb', line 182 def Watcher JIRA::Resource::WatcherFactory.new(self) end |
#Webhook ⇒ Object
186 187 188 |
# File 'lib/jira/client.rb', line 186 def Webhook JIRA::Resource::WebhookFactory.new(self) end |
#Worklog ⇒ Object
:nodoc:
138 139 140 |
# File 'lib/jira/client.rb', line 138 def Worklog # :nodoc: JIRA::Resource::WorklogFactory.new(self) end |