Skip to content

Commit

Permalink
add activity_stream resource
Browse files Browse the repository at this point in the history
  • Loading branch information
durandom committed Jan 11, 2017
1 parent c0a9bad commit b8b04e0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/ansible_tower_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
require "ansible_tower_client/base_model"
require "ansible_tower_client/collection"

require "ansible_tower_client/base_models/activity_stream"
require "ansible_tower_client/base_models/ad_hoc_command"
require "ansible_tower_client/base_models/group"
require "ansible_tower_client/base_models/host"
Expand Down
8 changes: 8 additions & 0 deletions lib/ansible_tower_client/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def verify_credentials
JSON.parse(get("me").body).fetch_path("results", 0, "username")
end

def activity_stream
Collection.new(self, activity_stream_class)
end

def ad_hoc_commands
Collection.new(self, ad_hoc_command_class)
end
Expand Down Expand Up @@ -82,6 +86,10 @@ def respond_to_missing?(method, _include_private = false)

# Object class accessors patched for the appropriate version of the API

def activity_stream_class
@activity_stream_class ||= AnsibleTowerClient::ActivityStream
end

def ad_hoc_command_class
@ad_hoc_command_class ||= AnsibleTowerClient::AdHocCommand
end
Expand Down
7 changes: 7 additions & 0 deletions lib/ansible_tower_client/base_models/activity_stream.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module AnsibleTowerClient
class ActivityStream < BaseModel
def self.endpoint
"activity_stream".freeze
end
end
end
9 changes: 9 additions & 0 deletions spec/activity_stream_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe AnsibleTowerClient::ActivityStream do
let(:url) { "example.com/api/v1/activity_stream" }
let(:api) { AnsibleTowerClient::Api.new(instance_double("Faraday::Connection")) }
let(:collection) { api.activity_stream }
let(:raw_url_collection) { build(:response_url_collection, :klass => described_class, :url => url) }
let(:raw_instance) { build(:response_instance, :group, :klass => described_class) }

include_examples "Collection Methods"
end

0 comments on commit b8b04e0

Please sign in to comment.