-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #249 from emilymye/monitoring
Migrate monitoring code to V3 API
- Loading branch information
Showing
26 changed files
with
431 additions
and
462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# All examples presume that you have a ~/.fog credentials file set up. | ||
# # More info on it can be found here: http://fog.io/about/getting_started.html | ||
# | ||
require "bundler" | ||
Bundler.require(:default, :development) | ||
# Uncomment this if you want to make real requests to GCE (you _will_ be billed!) | ||
# WebMock.disable! | ||
# | ||
|
||
def test | ||
connection = Fog::Google::Monitoring.new | ||
|
||
puts "Listing all MonitoredResourceDescriptors..." | ||
puts "--------------------------------" | ||
md = connection.monitored_resource_descriptors | ||
puts "Number of all monitored resource descriptors: #{md.length}" | ||
|
||
puts "\nListing MonitoredResourceDescriptors related to Google Compute Engine..." | ||
puts "-----------------------------------------------------------------" | ||
md = connection.monitored_resource_descriptors.all(:filter => 'resource.type = starts_with("gce_")') | ||
puts "Number of compute monitored resource : #{md.length}" | ||
end | ||
|
||
test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
lib/fog/google/models/monitoring/monitored_resource_descriptor.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require "fog/core/model" | ||
|
||
module Fog | ||
module Google | ||
class Monitoring | ||
## | ||
# A monitoredResourceDescriptor defines a metric type and its schema. | ||
# | ||
# @see https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.monitoredResourceDescriptors#MonitoredResourceDescriptor | ||
class MonitoredResourceDescriptor < Fog::Model | ||
identity :name | ||
|
||
attribute :description | ||
attribute :display_name, :aliases => "displayName" | ||
attribute :type | ||
attribute :labels | ||
end | ||
end | ||
end | ||
end |
26 changes: 26 additions & 0 deletions
26
lib/fog/google/models/monitoring/monitored_resource_descriptors.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require "fog/core/collection" | ||
require "fog/google/models/monitoring/monitored_resource_descriptor" | ||
|
||
module Fog | ||
module Google | ||
class Monitoring | ||
class MonitoredResourceDescriptors < Fog::Collection | ||
model Fog::Google::Monitoring::MonitoredResourceDescriptor | ||
|
||
## | ||
# Lists all Monitored Resource Descriptors. | ||
# | ||
# @param [Hash] options Optional query parameters. | ||
# @option options [String] page_size Maximum number of metric descriptors per page. Used for pagination. | ||
# @option options [String] page_token The pagination token, which is used to page through large result sets. | ||
# @option options [String] filter The monitoring filter used to search against existing descriptors. | ||
# See | ||
# @return [Array<Fog::Google::Monitoring::MetricDescriptor>] List of Monitored Resource Descriptors. | ||
def all(options = {}) | ||
data = service.list_monitored_resource_descriptors(options).body["resourceDescriptors"] || [] | ||
load(data) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
lib/fog/google/models/monitoring/timeseries_descriptors.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.