Class: McAuditEntry
Overview
Instance Attribute Summary
#params
Class Method Summary
collapse
Instance Method Summary
collapse
create, filters, find, find_all, find_by, find_with_filter, load, load_all, parse_args, resource_post_name
#connection
#[], #create, #deny_methods, #filters, #find, #find_all, #find_by, #find_by_cloud_id, #find_by_id, #find_by_nickname, #find_by_nickname_speed, #find_with_filter
#connection
#[], #[]=, #actions, #hash_of_links, #href, #initialize, #load, #method_missing, #nickname, #parse_params, #rediscover, #save
#[], #[]=, #destroy, #initialize, #method_missing, #reload, #rs_id, #save
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class RightScale::Api::Gateway
Class Method Details
.filters ⇒ Object
49
50
51
|
# File 'lib/rest_connection/rightscale/mc_audit_entry.rb', line 49
def self.filters
[:auditee_href, :user_email]
end
|
.find_all(start_date = nil, end_date = nil, limit = 1000) ⇒ Object
53
54
55
56
57
|
# File 'lib/rest_connection/rightscale/mc_audit_entry.rb', line 53
def self.find_all(start_date=nil, end_date=nil, limit=1000)
start_date ||= (Time.now.utc - (60*60*24*31)).strftime(RightScale::Api::DATETIME_FMT)
end_date ||= Time.now.utc.strftime(RightScale::Api::DATETIME_FMT)
index(start_date, end_date, limit)
end
|
.find_with_filter(start_date, end_date, limit, filter) ⇒ Object
59
60
61
|
# File 'lib/rest_connection/rightscale/mc_audit_entry.rb', line 59
def self.find_with_filter(start_date, end_date, limit, filter)
index(start_date, end_date, limit, filter)
end
|
.index(start_date, end_date, limit = 1000, filter = {}) ⇒ Object
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
93
94
95
96
97
|
# File 'lib/rest_connection/rightscale/mc_audit_entry.rb', line 63
def self.index(start_date, end_date, limit=1000, filter={})
ex_fmt = "2011/06/25 00:00:00 +0000"
regex = /^(\d{4})\/(\d{2})\/(\d{2}) (\d{2}):(\d{2}):(\d{2}) ([+-]\d{4})$/
unless start_date =~ regex
raise ArgumentError.new("start_date doesn't match format. e.g., #{ex_fmt}")
end
unless end_date =~ regex
raise ArgumentError.new("end_date doesn't match format. e.g., #{ex_fmt}")
end
unless (1..1000) === limit.to_i
raise ArgumentError.new("limit is not within the range of 1..1000")
end
filter_params = []
filter.each { |key,val|
unless self.filters.include?(key.to_sym)
raise ArgumentError.new("#{key} is not a valid filter for resource #{self.resource_singular_name}")
end
filter_params << "#{key}==#{val}"
}
a = Array.new
url = self.resource_plural_name
if filter_params.empty?
connection.get(url).each do |object|
a << self.new(object)
end
else
connection.get(url, :filter => filter_params).each do |object|
a << self.new(object)
end
end
return a
end
|
.resource_plural_name ⇒ Object
41
42
43
|
# File 'lib/rest_connection/rightscale/mc_audit_entry.rb', line 41
def self.resource_plural_name
"audit_entries"
end
|
.resource_singular_name ⇒ Object
45
46
47
|
# File 'lib/rest_connection/rightscale/mc_audit_entry.rb', line 45
def self.resource_singular_name
"audit_entry"
end
|
Instance Method Details
#append(detail, offset) ⇒ Object
99
100
101
102
|
# File 'lib/rest_connection/rightscale/mc_audit_entry.rb', line 99
def append(detail, offset)
uri = URI.parse(self.href)
connection.post(uri.path + "/append", 'detail' => detail, 'offset' => offset)
end
|
#detail ⇒ Object
104
105
106
107
108
|
# File 'lib/rest_connection/rightscale/mc_audit_entry.rb', line 104
def detail
uri = URI.parse(self.href)
res = connection.post(uri.path + "/detail")
return res.body
end
|
#resource_plural_name ⇒ Object
33
34
35
|
# File 'lib/rest_connection/rightscale/mc_audit_entry.rb', line 33
def resource_plural_name
"audit_entries"
end
|
#resource_singular_name ⇒ Object
37
38
39
|
# File 'lib/rest_connection/rightscale/mc_audit_entry.rb', line 37
def resource_singular_name
"audit_entry"
end
|