dogapi 1.37.1 → 1.42.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.azure-pipelines/all.yml +16 -7
- data/.github/CODEOWNERS +10 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +36 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +77 -0
- data/.github/labeler.yml +5 -0
- data/.github/workflows/labeler.yml +11 -0
- data/.github/workflows/stale.yml +39 -0
- data/.rubocop_todo.yml +51 -71
- data/CHANGELOG.md +37 -0
- data/CONTRIBUTING.md +111 -0
- data/DEVELOPMENT.md +11 -0
- data/Gemfile +2 -0
- data/Gemfile_1.9 +13 -0
- data/LICENSE +21 -20
- data/LICENSE-3rdparty.csv +6 -0
- data/README.rdoc +14 -0
- data/RELEASING.md +46 -0
- data/SUPPORT.md +9 -0
- data/dogapi.gemspec +2 -0
- data/examples/custom_metric.rb +1 -1
- data/lib/capistrano/README.md +4 -1
- data/lib/capistrano/datadog.rb +8 -4
- data/lib/capistrano/datadog/v2.rb +9 -1
- data/lib/capistrano/datadog/v3.rb +10 -1
- data/lib/dogapi.rb +4 -0
- data/lib/dogapi/common.rb +90 -35
- data/lib/dogapi/event.rb +4 -0
- data/lib/dogapi/facade.rb +212 -10
- data/lib/dogapi/metric.rb +4 -0
- data/lib/dogapi/v1.rb +10 -0
- data/lib/dogapi/v1/alert.rb +4 -0
- data/lib/dogapi/v1/aws_integration.rb +117 -0
- data/lib/dogapi/v1/aws_logs.rb +107 -0
- data/lib/dogapi/v1/azure_integration.rb +85 -0
- data/lib/dogapi/v1/comment.rb +4 -0
- data/lib/dogapi/v1/dash.rb +10 -4
- data/lib/dogapi/v1/dashboard.rb +16 -0
- data/lib/dogapi/v1/dashboard_list.rb +4 -0
- data/lib/dogapi/v1/embed.rb +4 -0
- data/lib/dogapi/v1/event.rb +4 -0
- data/lib/dogapi/v1/gcp_integration.rb +76 -0
- data/lib/dogapi/v1/hosts.rb +4 -0
- data/lib/dogapi/v1/integration.rb +4 -0
- data/lib/dogapi/v1/metadata.rb +4 -0
- data/lib/dogapi/v1/metric.rb +4 -0
- data/lib/dogapi/v1/monitor.rb +20 -7
- data/lib/dogapi/v1/screenboard.rb +4 -0
- data/lib/dogapi/v1/search.rb +4 -0
- data/lib/dogapi/v1/service_check.rb +4 -0
- data/lib/dogapi/v1/service_level_objective.rb +113 -0
- data/lib/dogapi/v1/snapshot.rb +4 -0
- data/lib/dogapi/v1/synthetics.rb +80 -0
- data/lib/dogapi/v1/tag.rb +4 -0
- data/lib/dogapi/v1/usage.rb +4 -0
- data/lib/dogapi/v1/user.rb +4 -0
- data/lib/dogapi/v2.rb +4 -0
- data/lib/dogapi/v2/dashboard_list.rb +4 -0
- data/lib/dogapi/version.rb +5 -1
- data/spec/integration/alert_spec.rb +4 -0
- data/spec/integration/aws_integration_spec.rb +55 -0
- data/spec/integration/aws_logs_spec.rb +59 -0
- data/spec/integration/azure_integration_spec.rb +63 -0
- data/spec/integration/comment_spec.rb +5 -0
- data/spec/integration/common_spec.rb +4 -0
- data/spec/integration/dash_spec.rb +7 -1
- data/spec/integration/dashboard_list_spec.rb +4 -0
- data/spec/integration/dashboard_spec.rb +15 -1
- data/spec/integration/embed_spec.rb +4 -0
- data/spec/integration/event_spec.rb +5 -0
- data/spec/integration/gcp_integration_spec.rb +57 -0
- data/spec/integration/integration_spec.rb +4 -0
- data/spec/integration/metadata_spec.rb +4 -0
- data/spec/integration/metric_spec.rb +4 -0
- data/spec/integration/monitor_spec.rb +30 -1
- data/spec/integration/screenboard_spec.rb +4 -0
- data/spec/integration/search_spec.rb +4 -0
- data/spec/integration/service_check_spec.rb +4 -0
- data/spec/integration/service_level_objective_spec.rb +73 -0
- data/spec/integration/snapshot_spec.rb +4 -0
- data/spec/integration/synthetics_spec.rb +131 -0
- data/spec/integration/tag_spec.rb +4 -0
- data/spec/integration/usage_spec.rb +4 -0
- data/spec/integration/user_spec.rb +4 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/unit/capistrano_spec.rb +4 -0
- data/spec/unit/common_spec.rb +64 -7
- data/spec/unit/facade_spec.rb +4 -0
- metadata +37 -7
data/lib/dogapi/metric.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
|
2
|
+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
|
3
|
+
# Copyright 2011-Present Datadog, Inc.
|
4
|
+
|
1
5
|
require 'net/http'
|
2
6
|
|
3
7
|
require 'rubygems'
|
data/lib/dogapi/v1.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
|
2
|
+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
|
3
|
+
# Copyright 2011-Present Datadog, Inc.
|
4
|
+
|
1
5
|
require 'dogapi/v1/alert'
|
2
6
|
require 'dogapi/v1/comment'
|
3
7
|
require 'dogapi/v1/dash'
|
@@ -11,9 +15,15 @@ require 'dogapi/v1/monitor'
|
|
11
15
|
require 'dogapi/v1/screenboard'
|
12
16
|
require 'dogapi/v1/search'
|
13
17
|
require 'dogapi/v1/service_check'
|
18
|
+
require 'dogapi/v1/service_level_objective'
|
14
19
|
require 'dogapi/v1/snapshot'
|
20
|
+
require 'dogapi/v1/synthetics'
|
15
21
|
require 'dogapi/v1/tag'
|
16
22
|
require 'dogapi/v1/user'
|
17
23
|
require 'dogapi/v1/hosts'
|
18
24
|
require 'dogapi/v1/integration'
|
19
25
|
require 'dogapi/v1/usage'
|
26
|
+
require 'dogapi/v1/aws_integration'
|
27
|
+
require 'dogapi/v1/aws_logs'
|
28
|
+
require 'dogapi/v1/azure_integration'
|
29
|
+
require 'dogapi/v1/gcp_integration'
|
data/lib/dogapi/v1/alert.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
|
2
|
+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
|
3
|
+
# Copyright 2011-Present Datadog, Inc.
|
4
|
+
|
1
5
|
require 'dogapi'
|
2
6
|
|
3
7
|
module Dogapi
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
|
2
|
+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
|
3
|
+
# Copyright 2011-Present Datadog, Inc.
|
4
|
+
|
5
|
+
require 'dogapi'
|
6
|
+
|
7
|
+
module Dogapi
|
8
|
+
class V1 # for namespacing
|
9
|
+
|
10
|
+
# AwsIntegrationService for user interaction with AWS configs.
|
11
|
+
class AwsIntegrationService < Dogapi::APIService
|
12
|
+
|
13
|
+
API_VERSION = 'v1'
|
14
|
+
|
15
|
+
# Retrieve AWS integration information
|
16
|
+
def aws_integration_list
|
17
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/integration/aws", nil, nil, false)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Create an AWS integration
|
21
|
+
# :config => Hash: integration config.
|
22
|
+
# config = {
|
23
|
+
# :account_id => '<AWS_ACCOUNT>',
|
24
|
+
# :host_tags => ['api:example'],
|
25
|
+
# :role_name => '<AWS_ROLE_NAME>'
|
26
|
+
# }
|
27
|
+
#
|
28
|
+
# Access Key/Secret Access Key based accounts (GovCloud and China only)
|
29
|
+
#
|
30
|
+
# config = {
|
31
|
+
# :access_key_id => '<AWS_ACCESS_KEY_ID>',
|
32
|
+
# :host_tags => ['api:example'],
|
33
|
+
# :secret_access_key => '<AWS_SECRET_ACCESS_KEY>'
|
34
|
+
# }
|
35
|
+
#
|
36
|
+
# dog = Dogapi::Client.new(api_key, app_key)
|
37
|
+
#
|
38
|
+
# puts dog.aws_integration_create(config)
|
39
|
+
def aws_integration_create(config)
|
40
|
+
request(Net::HTTP::Post, "/api/#{API_VERSION}/integration/aws", nil, config, true)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Delete an integration
|
44
|
+
# :config => Hash: integration config.
|
45
|
+
# config = {
|
46
|
+
# :account_id => '<AWS_ACCOUNT>',
|
47
|
+
# :role_name => '<AWS_ROLE_NAME>'
|
48
|
+
# }
|
49
|
+
# Access Key/Secret Access Key based accounts (GovCloud and China only)
|
50
|
+
#
|
51
|
+
# config = {
|
52
|
+
# :access_key_id => '<AWS_ACCESS_KEY_ID>',
|
53
|
+
# }
|
54
|
+
#
|
55
|
+
# dog = Dogapi::Client.new(api_key, app_key)
|
56
|
+
#
|
57
|
+
# puts dog.aws_integration_delete(config)
|
58
|
+
def aws_integration_delete(config)
|
59
|
+
request(Net::HTTP::Delete, "/api/#{API_VERSION}/integration/aws", nil, config, true)
|
60
|
+
end
|
61
|
+
|
62
|
+
# List available AWS namespaces
|
63
|
+
def aws_integration_list_namespaces
|
64
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/integration/aws/available_namespace_rules", nil, nil, false)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Generate new AWS external ID for a specific integrated account
|
68
|
+
# :config => Hash: integration config.
|
69
|
+
# config = {
|
70
|
+
# :account_id => '<AWS_ACCOUNT>',
|
71
|
+
# :role_name => '<AWS_ROLE_NAME>'
|
72
|
+
# }
|
73
|
+
#
|
74
|
+
# dog = Dogapi::Client.new(api_key, app_key)
|
75
|
+
#
|
76
|
+
# puts dog.aws_integration_generate_external_id(config)
|
77
|
+
def aws_integration_generate_external_id(config)
|
78
|
+
request(Net::HTTP::Put, "/api/#{API_VERSION}/integration/aws/generate_new_external_id", nil, config, true)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Update integrated AWS account.
|
82
|
+
# :config => Hash: integration config.
|
83
|
+
# config = {
|
84
|
+
# "account_id": '<EXISTING_AWS_ACCOUNT>',
|
85
|
+
# "role_name": '<EXISTING_AWS_ROLE_NAME>'
|
86
|
+
# }
|
87
|
+
#
|
88
|
+
# new_config = {
|
89
|
+
# "account_id": '<NEW_AWS_ACCOUNT>',
|
90
|
+
# "host_tags": ['tag:example1,tag:example2'],
|
91
|
+
# "filter_tags": ['datadog:true']
|
92
|
+
# }
|
93
|
+
#
|
94
|
+
# Access Key/Secret Access Key based accounts (GovCloud and China only)
|
95
|
+
#
|
96
|
+
# config = {
|
97
|
+
# "access_key_id": '<EXISTING_ACCESS_KEY_ID>',
|
98
|
+
# "secret_access_key": '<EXISTING_SECRET_ACCESS_KEY>'
|
99
|
+
# }
|
100
|
+
#
|
101
|
+
# new_config = {
|
102
|
+
# "access_key_id": '<NEW_ACCESS_KEY_ID>',
|
103
|
+
# "host_tags": ['new:tags'],
|
104
|
+
# "filter_tags": ['datadog:true']
|
105
|
+
# }
|
106
|
+
#
|
107
|
+
# dog = Dogapi::Client.new(api_key, app_key)
|
108
|
+
|
109
|
+
# puts dog.aws_integration_update(config, new_config)
|
110
|
+
def aws_integration_update(config, new_config)
|
111
|
+
request(Net::HTTP::Put, "/api/#{API_VERSION}/integration/aws", config, new_config, true)
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
|
2
|
+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
|
3
|
+
# Copyright 2011-Present Datadog, Inc.
|
4
|
+
|
5
|
+
require 'dogapi'
|
6
|
+
|
7
|
+
module Dogapi
|
8
|
+
class V1 # for namespacing
|
9
|
+
|
10
|
+
# AwsLogsService for user interaction with AWS configs.
|
11
|
+
class AwsLogsService < Dogapi::APIService
|
12
|
+
|
13
|
+
API_VERSION = 'v1'
|
14
|
+
|
15
|
+
# Get the list of current AWS services for which Datadog offers automatic log collection.
|
16
|
+
# Use returned service IDs with the services parameter for the Enable
|
17
|
+
# an AWS service log collection API endpoint.
|
18
|
+
def aws_logs_list_services
|
19
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/integration/aws/logs/services", nil, nil, false)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Create an AWS integration
|
23
|
+
# :config => Hash: integration config.
|
24
|
+
# config = {
|
25
|
+
# :account_id => '<AWS_ACCOUNT>',
|
26
|
+
# :lambda_arn => '<LAMBDA_ARN>'
|
27
|
+
# }
|
28
|
+
#
|
29
|
+
# dog = Dogapi::Client.new(api_key, app_key)
|
30
|
+
#
|
31
|
+
# puts dog.aws_logs_add_lambda(config)
|
32
|
+
def aws_logs_add_lambda(config)
|
33
|
+
request(Net::HTTP::Post, "/api/#{API_VERSION}/integration/aws/logs", nil, config, true)
|
34
|
+
end
|
35
|
+
|
36
|
+
# List all Datadog-AWS Logs integrations configured in your Datadog account.
|
37
|
+
def aws_logs_integrations_list
|
38
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/integration/aws/logs", nil, nil, false)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Enable automatic log collection for a list of services.
|
42
|
+
# This should be run after running 'aws_logs_add_lambda' to save the config.
|
43
|
+
# config = {
|
44
|
+
# :account_id => '<AWS_ACCOUNT>',
|
45
|
+
# :services => ['s3', 'elb', 'elbv2', 'cloudfront', 'redshift', 'lambda']
|
46
|
+
# }
|
47
|
+
#
|
48
|
+
# dog = Dogapi::Client.new(api_key, app_key)
|
49
|
+
#
|
50
|
+
# puts dog.aws_logs_save_services(config)
|
51
|
+
def aws_logs_save_services(config)
|
52
|
+
request(Net::HTTP::Post, "/api/#{API_VERSION}/integration/aws/logs/services", nil, config, true)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Delete an AWS Logs integration
|
56
|
+
# :config => Hash: integration config.
|
57
|
+
# config = {
|
58
|
+
# :account_id => '<AWS_ACCOUNT>',
|
59
|
+
# :lambda_arn => '<LAMBDA_ARN>'
|
60
|
+
# }
|
61
|
+
#
|
62
|
+
# dog = Dogapi::Client.new(api_key, app_key)
|
63
|
+
#
|
64
|
+
# puts dog.aws_logs_integration_delete(config)
|
65
|
+
def aws_logs_integration_delete(config)
|
66
|
+
request(Net::HTTP::Delete, "/api/#{API_VERSION}/integration/aws/logs", nil, config, true)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Check function to see if a lambda_arn exists within an account.
|
70
|
+
# This sends a job on our side if it does not exist, then immediately returns
|
71
|
+
# the status of that job. Subsequent requests will always repeat the above, so this endpoint
|
72
|
+
# can be polled intermittently instead of blocking.
|
73
|
+
|
74
|
+
# Returns a status of 'created' when it's checking if the Lambda exists in the account.
|
75
|
+
# Returns a status of 'waiting' while checking.
|
76
|
+
# Returns a status of 'checked and ok' if the Lambda exists.
|
77
|
+
# Returns a status of 'error' if the Lambda does not exist.
|
78
|
+
|
79
|
+
# contents of config should be
|
80
|
+
# >>> :account_id => '<AWS_ACCOUNT_ID>'
|
81
|
+
# >>> :lambda_arn => '<AWS_LAMBDA_ARN>'
|
82
|
+
|
83
|
+
def aws_logs_check_lambda(config)
|
84
|
+
request(Net::HTTP::Post, "/api/#{API_VERSION}/integration/aws/logs/check_async", nil, config, true)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Test if permissions are present to add log-forwarding triggers for the
|
88
|
+
# given services + AWS account. Input is the same as for save_services.
|
89
|
+
# Done async, so can be repeatedly polled in a non-blocking fashion until
|
90
|
+
# the async request completes
|
91
|
+
|
92
|
+
# Returns a status of 'created' when it's checking if the permissions exists in the AWS account.
|
93
|
+
# Returns a status of 'waiting' while checking.
|
94
|
+
# Returns a status of 'checked and ok' if the Lambda exists.
|
95
|
+
# Returns a status of 'error' if the Lambda does not exist.
|
96
|
+
|
97
|
+
# contents of config should be
|
98
|
+
# :account_id => '<AWS_ACCOUNT_ID>'
|
99
|
+
# :services => ['s3', 'elb', 'elbv2', 'cloudfront', 'redshift', 'lambda']
|
100
|
+
def aws_logs_check_services(config)
|
101
|
+
request(Net::HTTP::Post, "/api/#{API_VERSION}/integration/aws/logs/services_async", nil, config, true)
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
|
2
|
+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
|
3
|
+
# Copyright 2011-Present Datadog, Inc.
|
4
|
+
|
5
|
+
require 'dogapi'
|
6
|
+
|
7
|
+
module Dogapi
|
8
|
+
class V1 # for namespacing
|
9
|
+
|
10
|
+
# AzureIntegrationService for user interaction with Azure configs.
|
11
|
+
class AzureIntegrationService < Dogapi::APIService
|
12
|
+
|
13
|
+
API_VERSION = 'v1'
|
14
|
+
|
15
|
+
# Retrieve Azure integration information
|
16
|
+
def azure_integration_list
|
17
|
+
request(Net::HTTP::Get, "/api/#{API_VERSION}/integration/azure", nil, nil, false)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Delete an Azure integration
|
21
|
+
# :config => Hash: integration config.
|
22
|
+
# config = {
|
23
|
+
# :tenant_name => '<TENANT_NAME>',
|
24
|
+
# :client_id => '<CLIENT_ID>'
|
25
|
+
# }
|
26
|
+
#
|
27
|
+
# dog = Dogapi::Client.new(api_key, app_key)
|
28
|
+
#
|
29
|
+
# puts dog.azure_integration_delete(config)
|
30
|
+
def azure_integration_delete(config)
|
31
|
+
request(Net::HTTP::Delete, "/api/#{API_VERSION}/integration/azure", nil, config, true)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Create an Azure integration
|
35
|
+
# :config => Hash: integration config.
|
36
|
+
# config = {
|
37
|
+
# :tenant_name => '<TENANT_NAME>',
|
38
|
+
# :host_filters => 'new:filter',
|
39
|
+
# :client_id => '<CLIENT_ID>',
|
40
|
+
# :client_secret => '<CLIENT_SECRET>'
|
41
|
+
# }
|
42
|
+
#
|
43
|
+
# dog = Dogapi::Client.new(api_key, app_key)
|
44
|
+
#
|
45
|
+
# puts dog.azure_integration_create(config)
|
46
|
+
def azure_integration_create(config)
|
47
|
+
request(Net::HTTP::Post, "/api/#{API_VERSION}/integration/azure", nil, config, true)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Update an Azure integrations host filters
|
51
|
+
# :config => Hash: integration config.
|
52
|
+
# config = {
|
53
|
+
# :tenant_name => '<TENANT_NAME>',
|
54
|
+
# :host_filters => 'new:filter',
|
55
|
+
# :client_id => '<CLIENT_ID>'
|
56
|
+
# }
|
57
|
+
#
|
58
|
+
# dog = Dogapi::Client.new(api_key, app_key)
|
59
|
+
#
|
60
|
+
# puts dog.azure_integration_update_host_filters(config)
|
61
|
+
def azure_integration_update_host_filters(config)
|
62
|
+
request(Net::HTTP::Post, "/api/#{API_VERSION}/integration/azure/host_filters", nil, config, true)
|
63
|
+
end
|
64
|
+
|
65
|
+
# Update a configured Azure account.
|
66
|
+
# :config => Hash: integration config.
|
67
|
+
# config = {
|
68
|
+
# :tenant_name => '<TENANT_NAME>',
|
69
|
+
# :new_tenant_name => '<NEW_TENANT_NAME>',
|
70
|
+
# :host_filters => '<KEY>:<VALUE>,<KEY>:<VALUE>',
|
71
|
+
# :client_id => '<CLIENT_ID>',
|
72
|
+
# :new_client_id => '<NEW_CLIENT_ID>'
|
73
|
+
# }
|
74
|
+
#
|
75
|
+
# dog = Dogapi::Client.new(api_key, app_key)
|
76
|
+
#
|
77
|
+
# puts dog.azure_integration_update(config)
|
78
|
+
def azure_integration_update(config)
|
79
|
+
request(Net::HTTP::Put, "/api/#{API_VERSION}/integration/azure", nil, config, true)
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
end
|
data/lib/dogapi/v1/comment.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
|
2
|
+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
|
3
|
+
# Copyright 2011-Present Datadog, Inc.
|
4
|
+
|
1
5
|
require 'dogapi'
|
2
6
|
|
3
7
|
module Dogapi
|
data/lib/dogapi/v1/dash.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
|
2
|
+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
|
3
|
+
# Copyright 2011-Present Datadog, Inc.
|
4
|
+
|
1
5
|
require 'dogapi'
|
2
6
|
|
3
7
|
module Dogapi
|
@@ -7,23 +11,25 @@ module Dogapi
|
|
7
11
|
|
8
12
|
API_VERSION = 'v1'
|
9
13
|
|
10
|
-
def create_dashboard(title, description, graphs, template_variables = nil)
|
14
|
+
def create_dashboard(title, description, graphs, template_variables = nil, read_only = false)
|
11
15
|
body = {
|
12
16
|
:title => title,
|
13
17
|
:description => description,
|
14
18
|
:graphs => graphs,
|
15
|
-
:template_variables => (template_variables or [])
|
19
|
+
:template_variables => (template_variables or []),
|
20
|
+
:read_only => read_only
|
16
21
|
}
|
17
22
|
|
18
23
|
request(Net::HTTP::Post, "/api/#{API_VERSION}/dash", nil, body, true)
|
19
24
|
end
|
20
25
|
|
21
|
-
def update_dashboard(dash_id, title, description, graphs, template_variables=nil)
|
26
|
+
def update_dashboard(dash_id, title, description, graphs, template_variables = nil, read_only = false)
|
22
27
|
body = {
|
23
28
|
:title => title,
|
24
29
|
:description => description,
|
25
30
|
:graphs => graphs,
|
26
|
-
:template_variables => (template_variables or [])
|
31
|
+
:template_variables => (template_variables or []),
|
32
|
+
:read_only => read_only
|
27
33
|
}
|
28
34
|
|
29
35
|
request(Net::HTTP::Put, "/api/#{API_VERSION}/dash/#{dash_id}", nil, body, true)
|
data/lib/dogapi/v1/dashboard.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
|
2
|
+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
|
3
|
+
# Copyright 2011-Present Datadog, Inc.
|
4
|
+
|
1
5
|
require 'dogapi'
|
2
6
|
|
3
7
|
module Dogapi
|
@@ -24,6 +28,11 @@ module Dogapi
|
|
24
28
|
# e.g. '["user1@domain.com", "user2@domain.com"]'
|
25
29
|
# :template_variables => JSON: List of template variables for this dashboard.
|
26
30
|
# e.g. [{"name": "host", "prefix": "host", "default": "my-host"}]
|
31
|
+
# :template_variable_presets => JSON: List of template variables saved views
|
32
|
+
# e.g. {
|
33
|
+
# "name": "my_template_variable_preset",
|
34
|
+
# "template_variables": [{"name": "host", "prefix": "host", "default": "my-host"}]
|
35
|
+
# }
|
27
36
|
def create_board(title, widgets, layout_type, options)
|
28
37
|
# Required arguments
|
29
38
|
body = {
|
@@ -36,6 +45,7 @@ module Dogapi
|
|
36
45
|
body[:is_read_only] = options[:is_read_only] if options[:is_read_only]
|
37
46
|
body[:notify_list] = options[:notify_list] if options[:notify_list]
|
38
47
|
body[:template_variables] = options[:template_variables] if options[:template_variables]
|
48
|
+
body[:template_variable_presets] = options[:template_variable_presets] if options[:template_variable_presets]
|
39
49
|
|
40
50
|
request(Net::HTTP::Post, "/api/#{API_VERSION}/#{RESOURCE_NAME}", nil, body, true)
|
41
51
|
end
|
@@ -56,6 +66,11 @@ module Dogapi
|
|
56
66
|
# e.g. '["user1@domain.com", "user2@domain.com"]'
|
57
67
|
# :template_variables => JSON: List of template variables for this dashboard.
|
58
68
|
# e.g. [{"name": "host", "prefix": "host", "default": "my-host"}]
|
69
|
+
# :template_variable_presets => JSON: List of template variables saved views
|
70
|
+
# e.g. {
|
71
|
+
# "name": "my_template_variable_preset",
|
72
|
+
# "template_variables": [{"name": "host", "prefix": "host", "default": "my-host"}]
|
73
|
+
# }
|
59
74
|
def update_board(dashboard_id, title, widgets, layout_type, options)
|
60
75
|
# Required arguments
|
61
76
|
body = {
|
@@ -68,6 +83,7 @@ module Dogapi
|
|
68
83
|
body[:is_read_only] = options[:is_read_only] if options[:is_read_only]
|
69
84
|
body[:notify_list] = options[:notify_list] if options[:notify_list]
|
70
85
|
body[:template_variables] = options[:template_variables] if options[:template_variables]
|
86
|
+
body[:template_variable_presets] = options[:template_variable_presets] if options[:template_variable_presets]
|
71
87
|
|
72
88
|
request(Net::HTTP::Put, "/api/#{API_VERSION}/#{RESOURCE_NAME}/#{dashboard_id}", nil, body, true)
|
73
89
|
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License.
|
2
|
+
# This product includes software developed at Datadog (https://www.datadoghq.com/).
|
3
|
+
# Copyright 2011-Present Datadog, Inc.
|
4
|
+
|
1
5
|
require 'dogapi'
|
2
6
|
|
3
7
|
module Dogapi
|