Skip to content

Commit d304035

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Adding valid tokens to Splunk and HTTP server source (#3505)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent b93b357 commit d304035

19 files changed

Lines changed: 833 additions & 2 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54251,6 +54251,16 @@ components:
5425154251
description: Name of the environment variable or secret that holds the username (used when `auth_strategy` is `plain`).
5425254252
example: HTTP_AUTH_USERNAME
5425354253
type: string
54254+
valid_tokens:
54255+
description: |-
54256+
A list of tokens that are accepted for authenticating incoming HTTP requests. When set,
54257+
the source rejects any request whose token does not match an enabled entry in this list.
54258+
Cannot be combined with the `plain` auth strategy.
54259+
items:
54260+
$ref: "#/components/schemas/ObservabilityPipelineHttpServerSourceValidToken"
54261+
maxItems: 1000
54262+
minItems: 1
54263+
type: array
5425454264
required:
5425554265
- id
5425654266
- type
@@ -54276,6 +54286,55 @@ components:
5427654286
type: string
5427754287
x-enum-varnames:
5427854288
- HTTP_SERVER
54289+
ObservabilityPipelineHttpServerSourceValidToken:
54290+
description: An accepted token used to authenticate incoming HTTP server requests.
54291+
properties:
54292+
enabled:
54293+
default: true
54294+
description: |-
54295+
Indicates whether this token is currently accepted. Disabled tokens are rejected without
54296+
being removed from the configuration.
54297+
example: true
54298+
type: boolean
54299+
field_to_add:
54300+
$ref: "#/components/schemas/ObservabilityPipelineSourceValidTokenFieldToAdd"
54301+
path_to_token:
54302+
$ref: "#/components/schemas/ObservabilityPipelineHttpServerSourceValidTokenPathToToken"
54303+
token_key:
54304+
description: Name of the environment variable or secret that holds the expected token value.
54305+
example: HTTP_SERVER_TOKEN
54306+
pattern: "^[A-Za-z0-9_]+$"
54307+
type: string
54308+
required:
54309+
- token_key
54310+
type: object
54311+
ObservabilityPipelineHttpServerSourceValidTokenPathToToken:
54312+
description: |-
54313+
Specifies where the worker extracts the token from in the incoming HTTP request.
54314+
This can be either a built-in location (`path` or `address`) or an HTTP header object.
54315+
oneOf:
54316+
- $ref: "#/components/schemas/ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation"
54317+
- $ref: "#/components/schemas/ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader"
54318+
ObservabilityPipelineHttpServerSourceValidTokenPathToTokenHeader:
54319+
description: Extract the token from a specific HTTP request header.
54320+
properties:
54321+
header:
54322+
description: The name of the HTTP header that carries the token.
54323+
example: X-Token
54324+
type: string
54325+
required:
54326+
- header
54327+
type: object
54328+
ObservabilityPipelineHttpServerSourceValidTokenPathToTokenLocation:
54329+
description: Built-in token location on the incoming HTTP request.
54330+
enum:
54331+
- path
54332+
- address
54333+
example: path
54334+
type: string
54335+
x-enum-varnames:
54336+
- PATH
54337+
- ADDRESS
5427954338
ObservabilityPipelineKafkaDestination:
5428054339
description: |-
5428154340
The `kafka` destination sends logs to Apache Kafka topics.
@@ -56299,6 +56358,27 @@ components:
5629956358
type: string
5630056359
x-enum-varnames:
5630156360
- SOCKET
56361+
ObservabilityPipelineSourceValidTokenFieldToAdd:
56362+
description: |-
56363+
An optional metadata field that is attached to every event authenticated by the
56364+
associated token. Both `key` and `value` must match `^[A-Za-z0-9_]+$`.
56365+
properties:
56366+
key:
56367+
description: The metadata field name to add to incoming events.
56368+
example: token_name
56369+
maxLength: 256
56370+
pattern: "^[A-Za-z0-9_]+$"
56371+
type: string
56372+
value:
56373+
description: The metadata field value to add to incoming events.
56374+
example: my_token
56375+
maxLength: 1024
56376+
pattern: "^[A-Za-z0-9_]+$"
56377+
type: string
56378+
required:
56379+
- key
56380+
- value
56381+
type: object
5630256382
ObservabilityPipelineSpec:
5630356383
description: Input schema representing an observability pipeline configuration. Used in create and validate requests.
5630456384
properties:
@@ -56495,6 +56575,15 @@ components:
5649556575
$ref: "#/components/schemas/ObservabilityPipelineTls"
5649656576
type:
5649756577
$ref: "#/components/schemas/ObservabilityPipelineSplunkHecSourceType"
56578+
valid_tokens:
56579+
description: |-
56580+
A list of tokens that are accepted for authenticating incoming HEC requests. When set, the source
56581+
rejects any request whose HEC token does not match an enabled entry in this list.
56582+
items:
56583+
$ref: "#/components/schemas/ObservabilityPipelineSplunkHecSourceValidToken"
56584+
maxItems: 1000
56585+
minItems: 1
56586+
type: array
5649856587
required:
5649956588
- id
5650056589
- type
@@ -56509,6 +56598,26 @@ components:
5650956598
type: string
5651056599
x-enum-varnames:
5651156600
- SPLUNK_HEC
56601+
ObservabilityPipelineSplunkHecSourceValidToken:
56602+
description: An accepted HEC token used to authenticate incoming Splunk HEC requests.
56603+
properties:
56604+
enabled:
56605+
default: true
56606+
description: |-
56607+
Indicates whether this token is currently accepted. Disabled tokens are rejected without
56608+
being removed from the configuration.
56609+
example: true
56610+
type: boolean
56611+
field_to_add:
56612+
$ref: "#/components/schemas/ObservabilityPipelineSourceValidTokenFieldToAdd"
56613+
token_key:
56614+
description: Name of the environment variable or secret that holds the expected HEC token value.
56615+
example: SPLUNK_HEC_TOKEN
56616+
pattern: "^[A-Za-z0-9_]+$"
56617+
type: string
56618+
required:
56619+
- token_key
56620+
type: object
5651256621
ObservabilityPipelineSplunkTcpSource:
5651356622
description: |-
5651456623
The `splunk_tcp` source receives logs from a Splunk Universal Forwarder over TCP.

docs/datadog_api_client.v2.model.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23293,6 +23293,34 @@ datadog\_api\_client.v2.model.observability\_pipeline\_http\_server\_source\_typ
2329323293
:members:
2329423294
:show-inheritance:
2329523295

23296+
datadog\_api\_client.v2.model.observability\_pipeline\_http\_server\_source\_valid\_token module
23297+
------------------------------------------------------------------------------------------------
23298+
23299+
.. automodule:: datadog_api_client.v2.model.observability_pipeline_http_server_source_valid_token
23300+
:members:
23301+
:show-inheritance:
23302+
23303+
datadog\_api\_client.v2.model.observability\_pipeline\_http\_server\_source\_valid\_token\_path\_to\_token module
23304+
-----------------------------------------------------------------------------------------------------------------
23305+
23306+
.. automodule:: datadog_api_client.v2.model.observability_pipeline_http_server_source_valid_token_path_to_token
23307+
:members:
23308+
:show-inheritance:
23309+
23310+
datadog\_api\_client.v2.model.observability\_pipeline\_http\_server\_source\_valid\_token\_path\_to\_token\_header module
23311+
-------------------------------------------------------------------------------------------------------------------------
23312+
23313+
.. automodule:: datadog_api_client.v2.model.observability_pipeline_http_server_source_valid_token_path_to_token_header
23314+
:members:
23315+
:show-inheritance:
23316+
23317+
datadog\_api\_client.v2.model.observability\_pipeline\_http\_server\_source\_valid\_token\_path\_to\_token\_location module
23318+
---------------------------------------------------------------------------------------------------------------------------
23319+
23320+
.. automodule:: datadog_api_client.v2.model.observability_pipeline_http_server_source_valid_token_path_to_token_location
23321+
:members:
23322+
:show-inheritance:
23323+
2329623324
datadog\_api\_client.v2.model.observability\_pipeline\_kafka\_destination module
2329723325
--------------------------------------------------------------------------------
2329823326

@@ -24168,6 +24196,13 @@ datadog\_api\_client.v2.model.observability\_pipeline\_socket\_source\_type modu
2416824196
:members:
2416924197
:show-inheritance:
2417024198

24199+
datadog\_api\_client.v2.model.observability\_pipeline\_source\_valid\_token\_field\_to\_add module
24200+
--------------------------------------------------------------------------------------------------
24201+
24202+
.. automodule:: datadog_api_client.v2.model.observability_pipeline_source_valid_token_field_to_add
24203+
:members:
24204+
:show-inheritance:
24205+
2417124206
datadog\_api\_client.v2.model.observability\_pipeline\_spec module
2417224207
------------------------------------------------------------------
2417324208

@@ -24245,6 +24280,13 @@ datadog\_api\_client.v2.model.observability\_pipeline\_splunk\_hec\_source\_type
2424524280
:members:
2424624281
:show-inheritance:
2424724282

24283+
datadog\_api\_client.v2.model.observability\_pipeline\_splunk\_hec\_source\_valid\_token module
24284+
-----------------------------------------------------------------------------------------------
24285+
24286+
.. automodule:: datadog_api_client.v2.model.observability_pipeline_splunk_hec_source_valid_token
24287+
:members:
24288+
:show-inheritance:
24289+
2424824290
datadog\_api\_client.v2.model.observability\_pipeline\_splunk\_tcp\_source module
2424924291
---------------------------------------------------------------------------------
2425024292

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
"""
2+
Validate an observability pipeline with Splunk HEC source valid_tokens returns "OK" response
3+
"""
4+
5+
from datadog_api_client import ApiClient, Configuration
6+
from datadog_api_client.v2.api.observability_pipelines_api import ObservabilityPipelinesApi
7+
from datadog_api_client.v2.model.observability_pipeline_config import ObservabilityPipelineConfig
8+
from datadog_api_client.v2.model.observability_pipeline_config_processor_group import (
9+
ObservabilityPipelineConfigProcessorGroup,
10+
)
11+
from datadog_api_client.v2.model.observability_pipeline_data_attributes import ObservabilityPipelineDataAttributes
12+
from datadog_api_client.v2.model.observability_pipeline_datadog_logs_destination import (
13+
ObservabilityPipelineDatadogLogsDestination,
14+
)
15+
from datadog_api_client.v2.model.observability_pipeline_datadog_logs_destination_type import (
16+
ObservabilityPipelineDatadogLogsDestinationType,
17+
)
18+
from datadog_api_client.v2.model.observability_pipeline_filter_processor import ObservabilityPipelineFilterProcessor
19+
from datadog_api_client.v2.model.observability_pipeline_filter_processor_type import (
20+
ObservabilityPipelineFilterProcessorType,
21+
)
22+
from datadog_api_client.v2.model.observability_pipeline_source_valid_token_field_to_add import (
23+
ObservabilityPipelineSourceValidTokenFieldToAdd,
24+
)
25+
from datadog_api_client.v2.model.observability_pipeline_spec import ObservabilityPipelineSpec
26+
from datadog_api_client.v2.model.observability_pipeline_spec_data import ObservabilityPipelineSpecData
27+
from datadog_api_client.v2.model.observability_pipeline_splunk_hec_source import ObservabilityPipelineSplunkHecSource
28+
from datadog_api_client.v2.model.observability_pipeline_splunk_hec_source_type import (
29+
ObservabilityPipelineSplunkHecSourceType,
30+
)
31+
from datadog_api_client.v2.model.observability_pipeline_splunk_hec_source_valid_token import (
32+
ObservabilityPipelineSplunkHecSourceValidToken,
33+
)
34+
35+
body = ObservabilityPipelineSpec(
36+
data=ObservabilityPipelineSpecData(
37+
attributes=ObservabilityPipelineDataAttributes(
38+
config=ObservabilityPipelineConfig(
39+
destinations=[
40+
ObservabilityPipelineDatadogLogsDestination(
41+
id="datadog-logs-destination",
42+
inputs=[
43+
"my-processor-group",
44+
],
45+
type=ObservabilityPipelineDatadogLogsDestinationType.DATADOG_LOGS,
46+
),
47+
],
48+
processor_groups=[
49+
ObservabilityPipelineConfigProcessorGroup(
50+
enabled=True,
51+
id="my-processor-group",
52+
include="service:my-service",
53+
inputs=[
54+
"splunk-hec-source",
55+
],
56+
processors=[
57+
ObservabilityPipelineFilterProcessor(
58+
enabled=True,
59+
id="filter-processor",
60+
include="status:error",
61+
type=ObservabilityPipelineFilterProcessorType.FILTER,
62+
),
63+
],
64+
),
65+
],
66+
sources=[
67+
ObservabilityPipelineSplunkHecSource(
68+
id="splunk-hec-source",
69+
type=ObservabilityPipelineSplunkHecSourceType.SPLUNK_HEC,
70+
valid_tokens=[
71+
ObservabilityPipelineSplunkHecSourceValidToken(
72+
token_key="SPLUNK_HEC_TOKEN",
73+
enabled=True,
74+
field_to_add=ObservabilityPipelineSourceValidTokenFieldToAdd(
75+
key="token_name",
76+
value="primary_token",
77+
),
78+
),
79+
ObservabilityPipelineSplunkHecSourceValidToken(
80+
token_key="SPLUNK_HEC_TOKEN_BACKUP",
81+
enabled=False,
82+
),
83+
],
84+
),
85+
],
86+
),
87+
name="Pipeline with Splunk HEC valid_tokens",
88+
),
89+
type="pipelines",
90+
),
91+
)
92+
93+
configuration = Configuration()
94+
with ApiClient(configuration) as api_client:
95+
api_instance = ObservabilityPipelinesApi(api_client)
96+
response = api_instance.validate_pipeline(body=body)
97+
98+
print(response)

0 commit comments

Comments
 (0)