Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2025-01-31 15:03:08.670889",
"spec_repo_commit": "b01f90f4"
"regenerated": "2025-02-03 15:47:59.399270",
"spec_repo_commit": "d6014add"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-01-31 15:03:08.686755",
"spec_repo_commit": "b01f90f4"
"regenerated": "2025-02-03 15:47:59.415140",
"spec_repo_commit": "d6014add"
}
}
}
93 changes: 93 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10524,6 +10524,99 @@ components:
- $ref: '#/components/schemas/EntityV3Datastore'
- $ref: '#/components/schemas/EntityV3Queue'
- $ref: '#/components/schemas/EntityV3System'
- $ref: '#/components/schemas/EntityV3API'
EntityV3API:
additionalProperties: false
description: Schema for API entities.
properties:
apiVersion:
$ref: '#/components/schemas/EntityV3APIVersion'
datadog:
$ref: '#/components/schemas/EntityV3APIDatadog'
extensions:
additionalProperties: {}
description: Custom extensions. This is the free-formed field to send client-side
metadata. No Datadog features are affected by this field.
type: object
integrations:
$ref: '#/components/schemas/EntityV3Integrations'
kind:
$ref: '#/components/schemas/EntityV3APIKind'
metadata:
$ref: '#/components/schemas/EntityV3Metadata'
spec:
$ref: '#/components/schemas/EntityV3APISpec'
required:
- apiVersion
- kind
- metadata
type: object
EntityV3APIDatadog:
additionalProperties: false
description: Datadog product integrations for the API entity.
properties:
codeLocations:
$ref: '#/components/schemas/EntityV3DatadogCodeLocations'
events:
$ref: '#/components/schemas/EntityV3DatadogEvents'
logs:
$ref: '#/components/schemas/EntityV3DatadogLogs'
performanceData:
$ref: '#/components/schemas/EntityV3DatadogPerformance'
pipelines:
$ref: '#/components/schemas/EntityV3DatadogPipelines'
type: object
EntityV3APIKind:
description: The definition of Entity V3 API Kind object.
enum:
- api
example: api
type: string
x-enum-varnames:
- API
EntityV3APISpec:
additionalProperties: false
description: The definition of Entity V3 API Spec object.
properties:
implementedBy:
description: Services which implemented the API.
items:
type: string
type: array
interface:
$ref: '#/components/schemas/EntityV3APISpecInterface'
lifecycle:
description: The lifecycle state of the component.
minLength: 1
type: string
tier:
description: The importance of the component.
minLength: 1
type: string
type:
description: The type of API.
type: string
type: object
EntityV3APISpecInterface:
additionalProperties: false
description: The API definition.
oneOf:
- $ref: '#/components/schemas/EntityV3APISpecInterfaceFileRef'
- $ref: '#/components/schemas/EntityV3APISpecInterfaceDefinition'
EntityV3APISpecInterfaceDefinition:
additionalProperties: false
description: The definition of `EntityV3APISpecInterfaceDefinition` object.
properties:
definition:
description: The API definition.
type: object
EntityV3APISpecInterfaceFileRef:
additionalProperties: false
description: The definition of `EntityV3APISpecInterfaceFileRef` object.
properties:
fileRef:
description: The reference to the API definition file.
type: string
EntityV3APIVersion:
description: The schema version of entity type. The field is known as schema-version
in the previous version.
Expand Down
32 changes: 32 additions & 0 deletions api/datadogV2/model_entity_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type EntityV3 struct {
EntityV3Datastore *EntityV3Datastore
EntityV3Queue *EntityV3Queue
EntityV3System *EntityV3System
EntityV3API *EntityV3API

// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject interface{}
Expand All @@ -39,6 +40,11 @@ func EntityV3SystemAsEntityV3(v *EntityV3System) EntityV3 {
return EntityV3{EntityV3System: v}
}

// EntityV3APIAsEntityV3 is a convenience function that returns EntityV3API wrapped in EntityV3.
func EntityV3APIAsEntityV3(v *EntityV3API) EntityV3 {
return EntityV3{EntityV3API: v}
}

// UnmarshalJSON turns data into one of the pointers in the struct.
func (obj *EntityV3) UnmarshalJSON(data []byte) error {
var err error
Expand Down Expand Up @@ -111,12 +117,30 @@ func (obj *EntityV3) UnmarshalJSON(data []byte) error {
obj.EntityV3System = nil
}

// try to unmarshal data into EntityV3API
err = datadog.Unmarshal(data, &obj.EntityV3API)
if err == nil {
if obj.EntityV3API != nil && obj.EntityV3API.UnparsedObject == nil {
jsonEntityV3API, _ := datadog.Marshal(obj.EntityV3API)
if string(jsonEntityV3API) == "{}" { // empty struct
obj.EntityV3API = nil
} else {
match++
}
} else {
obj.EntityV3API = nil
}
} else {
obj.EntityV3API = nil
}

if match != 1 { // more than 1 match
// reset to nil
obj.EntityV3Service = nil
obj.EntityV3Datastore = nil
obj.EntityV3Queue = nil
obj.EntityV3System = nil
obj.EntityV3API = nil
return datadog.Unmarshal(data, &obj.UnparsedObject)
}
return nil // exactly one match
Expand All @@ -140,6 +164,10 @@ func (obj EntityV3) MarshalJSON() ([]byte, error) {
return datadog.Marshal(&obj.EntityV3System)
}

if obj.EntityV3API != nil {
return datadog.Marshal(&obj.EntityV3API)
}

if obj.UnparsedObject != nil {
return datadog.Marshal(obj.UnparsedObject)
}
Expand All @@ -164,6 +192,10 @@ func (obj *EntityV3) GetActualInstance() interface{} {
return obj.EntityV3System
}

if obj.EntityV3API != nil {
return obj.EntityV3API
}

// all schemas are nil
return nil
}
Loading