Class: PlatformSdk::Jira::ServiceManagementClient
- Inherits:
-
Object
- Object
- PlatformSdk::Jira::ServiceManagementClient
- Defined in:
- lib/platform_sdk/jira/service_management_client.rb
Instance Attribute Summary collapse
-
#cloud_id ⇒ Object
Returns the value of attribute cloud_id.
-
#conn ⇒ Object
Returns the value of attribute conn.
-
#team_id ⇒ Object
Returns the value of attribute team_id.
Instance Method Summary collapse
- #build_connection(auth_email, auth_api_token) ⇒ Object
- #headers ⇒ Object
-
#initialize(auth_email, auth_api_token, cloud_id, team_id, conn = nil) ⇒ ServiceManagementClient
constructor
A new instance of ServiceManagementClient.
- #send_heartbeat(heartbeat_name) ⇒ Object
Constructor Details
#initialize(auth_email, auth_api_token, cloud_id, team_id, conn = nil) ⇒ ServiceManagementClient
Returns a new instance of ServiceManagementClient.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/platform_sdk/jira/service_management_client.rb', line 8 def initialize(auth_email, auth_api_token, cloud_id, team_id, conn = nil) raise ArgumentError, 'auth_email cannot be nil' unless auth_email raise ArgumentError, 'auth_api_token cannot be nil' unless auth_api_token raise ArgumentError, 'cloud_id cannot be nil' unless cloud_id raise ArgumentError, 'team_id cannot be nil' unless team_id @conn = conn || build_connection(auth_email, auth_api_token) @cloud_id = cloud_id @team_id = team_id end |
Instance Attribute Details
#cloud_id ⇒ Object
Returns the value of attribute cloud_id.
6 7 8 |
# File 'lib/platform_sdk/jira/service_management_client.rb', line 6 def cloud_id @cloud_id end |
#conn ⇒ Object
Returns the value of attribute conn.
6 7 8 |
# File 'lib/platform_sdk/jira/service_management_client.rb', line 6 def conn @conn end |
#team_id ⇒ Object
Returns the value of attribute team_id.
6 7 8 |
# File 'lib/platform_sdk/jira/service_management_client.rb', line 6 def team_id @team_id end |
Instance Method Details
#build_connection(auth_email, auth_api_token) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/platform_sdk/jira/service_management_client.rb', line 19 def build_connection(auth_email, auth_api_token) Faraday.new(url: 'https://api.atlassian.com/jsm/ops/api') do |conn| conn.request(:authorization, :basic, auth_email, auth_api_token) conn.request :url_encoded conn.request :retry conn.response :raise_error conn.adapter :net_http conn.headers = headers end end |
#headers ⇒ Object
30 31 32 |
# File 'lib/platform_sdk/jira/service_management_client.rb', line 30 def headers { 'Content-Type': 'application/json' } end |
#send_heartbeat(heartbeat_name) ⇒ Object
34 35 36 |
# File 'lib/platform_sdk/jira/service_management_client.rb', line 34 def send_heartbeat(heartbeat_name) @conn.get("#{cloud_id}/v1/teams/#{team_id}/heartbeats/ping?name=#{heartbeat_name}") end |