-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for logs pipelines CRUD methods (#252)
* feat(dogapi): add logs pipeline resource and CRUD methods * Try to pin crack to 0.4.4 * Typo in crack version * Try hard lock * Update lib/dogapi/v1/logs_pipeline.rb Co-authored-by: Hippolyte HENRY <zippolyte@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
111 additions
and
0 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
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,41 @@ | ||
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License. | ||
# This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
# Copyright 2011-Present Datadog, Inc. | ||
|
||
module Dogapi | ||
class V1 # for namespacing | ||
class LogsPipelineService < Dogapi::APIService | ||
API_VERSION = 'v1' | ||
|
||
def create_logs_pipeline(name, filter, options = {}) | ||
body = { | ||
'name' => name, | ||
'filter' => filter | ||
}.merge options | ||
|
||
request(Net::HTTP::Post, "/api/#{API_VERSION}/logs/config/pipelines", nil, body, true) | ||
end | ||
|
||
def get_logs_pipeline(pipeline_id) | ||
request(Net::HTTP::Get, "/api/#{API_VERSION}/logs/config/pipelines/#{pipeline_id}", nil, nil, false) | ||
end | ||
|
||
def get_all_logs_pipelines | ||
request(Net::HTTP::Get, "/api/#{API_VERSION}/logs/config/pipelines", nil, nil, false) | ||
end | ||
|
||
def update_logs_pipeline(pipeline_id, name, filter, options = {}) | ||
body = { | ||
'name' => name, | ||
'filter' => filter | ||
}.merge options | ||
|
||
request(Net::HTTP::Put, "/api/#{API_VERSION}/logs/config/pipelines/#{pipeline_id}", nil, body, true) | ||
end | ||
|
||
def delete_logs_pipeline(pipeline_id) | ||
request(Net::HTTP::Delete, "/api/#{API_VERSION}/logs/config/pipelines/#{pipeline_id}", nil, nil, false) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Unless explicitly stated otherwise all files in this repository are licensed under the BSD-3-Clause License. | ||
# This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
# Copyright 2011-Present Datadog, Inc. | ||
|
||
require_relative '../spec_helper' | ||
|
||
describe Dogapi::Client do | ||
LOGS_PIPELINE_ID = '42' | ||
LOGS_PIPELINE_NAME = 'my logs pipeline'.freeze | ||
LOGS_PIPELINE_FILTER = { 'query' => 'source:my-app' }.freeze | ||
|
||
describe '#create_logs_pipeline' do | ||
it_behaves_like 'an api method with options', | ||
:create_logs_pipeline, [LOGS_PIPELINE_NAME, LOGS_PIPELINE_FILTER], | ||
:post, '/logs/config/pipelines', 'name' => LOGS_PIPELINE_NAME, | ||
'filter' => LOGS_PIPELINE_FILTER | ||
end | ||
|
||
describe '#get_logs_pipeline' do | ||
it_behaves_like 'an api method', | ||
:get_logs_pipeline, [LOGS_PIPELINE_ID], | ||
:get, "/logs/config/pipelines/#{LOGS_PIPELINE_ID}" | ||
end | ||
|
||
describe '#get_all_logs_pipelines' do | ||
it_behaves_like 'an api method', | ||
:get_all_logs_pipelines, [], | ||
:get, '/logs/config/pipelines' | ||
end | ||
|
||
describe '#update_logs_pipeline' do | ||
it_behaves_like 'an api method with options', | ||
:update_logs_pipeline, [LOGS_PIPELINE_ID, LOGS_PIPELINE_NAME, LOGS_PIPELINE_FILTER], | ||
:put, "/logs/config/pipelines/#{LOGS_PIPELINE_ID}", 'name' => LOGS_PIPELINE_NAME, | ||
'filter' => LOGS_PIPELINE_FILTER | ||
end | ||
|
||
describe '#delete_logs_pipeline' do | ||
it_behaves_like 'an api method', | ||
:delete_logs_pipeline, [LOGS_PIPELINE_ID], | ||
:delete, "/logs/config/pipelines/#{LOGS_PIPELINE_ID}" | ||
end | ||
end |