Skip to content

Additional rules to inject openapi type #2420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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-02-18 20:22:46.542723",
"spec_repo_commit": "c8707cdc"
"regenerated": "2025-02-18 22:25:34.103145",
"spec_repo_commit": "98988fd6"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-02-18 20:22:46.599032",
"spec_repo_commit": "c8707cdc"
"regenerated": "2025-02-18 22:25:34.118419",
"spec_repo_commit": "98988fd6"
}
}
}
12 changes: 12 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,7 @@ components:
type: array
required:
- exclude_only
type: object
AWSNamespaceFiltersIncludeOnly:
description: Include only these namespaces.
properties:
Expand All @@ -1543,6 +1544,7 @@ components:
type: array
required:
- include_only
type: object
AWSNamespaceTagFilter:
description: 'AWS Metrics Collection tag filters list. Defaults to `[]`.

Expand Down Expand Up @@ -1676,6 +1678,7 @@ components:
type: boolean
required:
- include_all
type: object
AWSRegionsIncludeOnly:
description: Include only these regions.
properties:
Expand All @@ -1689,6 +1692,7 @@ components:
type: array
required:
- include_only
type: object
AWSResourcesConfig:
description: AWS Resources Collection config.
properties:
Expand Down Expand Up @@ -10934,13 +10938,15 @@ components:
definition:
description: The API definition.
type: object
type: object
EntityV3APISpecInterfaceFileRef:
additionalProperties: false
description: The definition of `EntityV3APISpecInterfaceFileRef` object.
properties:
fileRef:
description: The reference to the API definition file.
type: string
type: object
EntityV3APIVersion:
description: The schema version of entity type. The field is known as schema-version
in the previous version.
Expand Down Expand Up @@ -11206,6 +11212,7 @@ components:
type: string
required:
- name
type: object
EntityV3MetadataContactsItems:
additionalProperties: false
description: The definition of Entity V3 Metadata Contacts Items object.
Expand Down Expand Up @@ -20228,6 +20235,7 @@ components:
$ref: '#/components/schemas/OktaAccountUpdateRequestAttributes'
type:
$ref: '#/components/schemas/OktaAccountType'
type: object
OktaAccountsResponse:
description: The expected response schema when getting Okta accounts.
properties:
Expand Down Expand Up @@ -25939,6 +25947,7 @@ components:
description: The version of the rule.
format: int64
type: integer
type: object
SecurityMonitoringSignalRuleResponseQuery:
description: Query for matching rule on signals.
properties:
Expand Down Expand Up @@ -26475,6 +26484,7 @@ components:
description: The version of the rule.
format: int64
type: integer
type: object
SecurityMonitoringStandardRuleTestPayload:
description: The payload of a rule to test
properties:
Expand Down Expand Up @@ -32266,6 +32276,7 @@ components:
type: boolean
required:
- include_all
type: object
XRayServicesIncludeOnly:
description: Include only these services. Defaults to `[]`.
nullable: true
Expand All @@ -32280,6 +32291,7 @@ components:
type: array
required:
- include_only
type: object
XRayServicesList:
description: AWS X-Ray services to collect traces from. Defaults to `include_only`.
oneOf:
Expand Down
7 changes: 6 additions & 1 deletion examples/v2/software-catalog/UpsertCatalogEntity.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from datadog_api_client.v2.model.entity_v3_datadog_pipelines import EntityV3DatadogPipelines
from datadog_api_client.v2.model.entity_v3_integrations import EntityV3Integrations
from datadog_api_client.v2.model.entity_v3_metadata import EntityV3Metadata
from datadog_api_client.v2.model.entity_v3_metadata_additional_owners_items import EntityV3MetadataAdditionalOwnersItems
from datadog_api_client.v2.model.entity_v3_metadata_contacts_items import EntityV3MetadataContactsItems
from datadog_api_client.v2.model.entity_v3_metadata_links_items import EntityV3MetadataLinksItems
from datadog_api_client.v2.model.entity_v3_service import EntityV3Service
Expand Down Expand Up @@ -52,7 +53,11 @@
),
kind=EntityV3ServiceKind.SERVICE,
metadata=EntityV3Metadata(
additional_owners=[],
additional_owners=[
EntityV3MetadataAdditionalOwnersItems(
name="",
),
],
contacts=[
EntityV3MetadataContactsItems(
contact="https://slack/",
Expand Down
12 changes: 9 additions & 3 deletions src/datadog_api_client/v2/model/entity_v3_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@


if TYPE_CHECKING:
from datadog_api_client.v2.model.entity_v3_metadata_additional_owners_items import (
EntityV3MetadataAdditionalOwnersItems,
)
from datadog_api_client.v2.model.entity_v3_metadata_contacts_items import EntityV3MetadataContactsItems
from datadog_api_client.v2.model.entity_v3_metadata_links_items import EntityV3MetadataLinksItems

Expand All @@ -41,11 +44,14 @@ def additional_properties_type(_):

@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.entity_v3_metadata_additional_owners_items import (
EntityV3MetadataAdditionalOwnersItems,
)
from datadog_api_client.v2.model.entity_v3_metadata_contacts_items import EntityV3MetadataContactsItems
from datadog_api_client.v2.model.entity_v3_metadata_links_items import EntityV3MetadataLinksItems

return {
"additional_owners": ([bool, date, datetime, dict, float, int, list, str, UUID, none_type],),
"additional_owners": ([EntityV3MetadataAdditionalOwnersItems],),
"contacts": ([EntityV3MetadataContactsItems],),
"description": (str,),
"display_name": (str,),
Expand Down Expand Up @@ -92,7 +98,7 @@ def openapi_types(_):
def __init__(
self_,
name: str,
additional_owners: Union[List[Any], UnsetType] = unset,
additional_owners: Union[List[EntityV3MetadataAdditionalOwnersItems], UnsetType] = unset,
contacts: Union[List[EntityV3MetadataContactsItems], UnsetType] = unset,
description: Union[str, UnsetType] = unset,
display_name: Union[str, UnsetType] = unset,
Expand All @@ -109,7 +115,7 @@ def __init__(
The definition of Entity V3 Metadata object.

:param additional_owners: The additional owners of the entity, usually a team.
:type additional_owners: [bool, date, datetime, dict, float, int, list, str, UUID, none_type], optional
:type additional_owners: [EntityV3MetadataAdditionalOwnersItems], optional

:param contacts: A list of contacts for the entity.
:type contacts: [EntityV3MetadataContactsItems], optional
Expand Down
27 changes: 7 additions & 20 deletions src/datadog_api_client/v2/model/okta_account_update_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,37 @@
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations

from typing import Any, TYPE_CHECKING
from typing import TYPE_CHECKING

from datadog_api_client.model_utils import (
ModelNormal,
cached_property,
date,
datetime,
none_type,
UUID,
)


if TYPE_CHECKING:
pass
from datadog_api_client.v2.model.okta_account_update_request_data import OktaAccountUpdateRequestData


class OktaAccountUpdateRequest(ModelNormal):
@cached_property
def openapi_types(_):
from datadog_api_client.v2.model.okta_account_update_request_data import OktaAccountUpdateRequestData

return {
"data": (
bool,
date,
datetime,
dict,
float,
int,
list,
str,
UUID,
none_type,
),
"data": (OktaAccountUpdateRequestData,),
}

attribute_map = {
"data": "data",
}

def __init__(self_, data: Any, **kwargs):
def __init__(self_, data: OktaAccountUpdateRequestData, **kwargs):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Code Quality Violation

Suggested change
def __init__(self_, data: OktaAccountUpdateRequestData, **kwargs):
def __init__(self, data: OktaAccountUpdateRequestData, **kwargs):
first parameter of a class function should be self (...read more)

In a class method (that is not a class method nor a static method), the first argument must be self by convention.

Learn More

View in Datadog  Leave us feedback  Documentation

"""
Payload schema when updating an Okta account.

:param data: Data object for updating an Okta account.
:type data: bool, date, datetime, dict, float, int, list, str, UUID, none_type
:type data: OktaAccountUpdateRequestData
"""
super().__init__(kwargs)

Expand Down
4 changes: 2 additions & 2 deletions tests/v2/features/okta_integration.feature
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ Feature: Okta Integration
Scenario: Update Okta account returns "Bad Request" response
Given new "UpdateOktaAccount" request
And request contains "account_id" parameter from "REPLACE.ME"
And body with value {}
And body with value {"data": {"attributes": {"auth_method": "oauth", "domain": "https://dev-test.okta.com/"}, "type": "okta-accounts"}}
When the request is sent
Then the response status is 400 Bad Request

@generated @skip @team:DataDog/saas-integrations
Scenario: Update Okta account returns "Not Found" response
Given new "UpdateOktaAccount" request
And request contains "account_id" parameter from "REPLACE.ME"
And body with value {}
And body with value {"data": {"attributes": {"auth_method": "oauth", "domain": "https://dev-test.okta.com/"}, "type": "okta-accounts"}}
When the request is sent
Then the response status is 404 Not Found

Expand Down
4 changes: 2 additions & 2 deletions tests/v2/features/software_catalog.feature
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ Feature: Software Catalog
@generated @skip @team:DataDog/service-catalog
Scenario: Create or update entities returns "ACCEPTED" response
Given new "UpsertCatalogEntity" request
And body with value {"apiVersion": "v3", "datadog": {"codeLocations": [{"paths": []}], "events": [{}], "logs": [{}], "performanceData": {"tags": []}, "pipelines": {"fingerprints": []}}, "integrations": {"opsgenie": {"serviceURL": "https://www.opsgenie.com/service/shopping-cart"}, "pagerduty": {"serviceURL": "https://www.pagerduty.com/service-directory/Pshopping-cart"}}, "kind": "service", "metadata": {"additionalOwners": [], "contacts": [{"contact": "https://slack/", "type": "slack"}], "id": "4b163705-23c0-4573-b2fb-f6cea2163fcb", "inheritFrom": "application:default/myapp", "links": [{"name": "mylink", "type": "link", "url": "https://mylink"}], "name": "myService", "namespace": "default", "tags": ["this:tag", "that:tag"]}, "spec": {"dependsOn": [], "languages": []}}
And body with value {"apiVersion": "v3", "datadog": {"codeLocations": [{"paths": []}], "events": [{}], "logs": [{}], "performanceData": {"tags": []}, "pipelines": {"fingerprints": []}}, "integrations": {"opsgenie": {"serviceURL": "https://www.opsgenie.com/service/shopping-cart"}, "pagerduty": {"serviceURL": "https://www.pagerduty.com/service-directory/Pshopping-cart"}}, "kind": "service", "metadata": {"additionalOwners": [{"name": ""}], "contacts": [{"contact": "https://slack/", "type": "slack"}], "id": "4b163705-23c0-4573-b2fb-f6cea2163fcb", "inheritFrom": "application:default/myapp", "links": [{"name": "mylink", "type": "link", "url": "https://mylink"}], "name": "myService", "namespace": "default", "tags": ["this:tag", "that:tag"]}, "spec": {"dependsOn": [], "languages": []}}
When the request is sent
Then the response status is 202 ACCEPTED

@generated @skip @team:DataDog/service-catalog
Scenario: Create or update entities returns "Bad Request" response
Given new "UpsertCatalogEntity" request
And body with value {"apiVersion": "v3", "datadog": {"codeLocations": [{"paths": []}], "events": [{}], "logs": [{}], "performanceData": {"tags": []}, "pipelines": {"fingerprints": []}}, "integrations": {"opsgenie": {"serviceURL": "https://www.opsgenie.com/service/shopping-cart"}, "pagerduty": {"serviceURL": "https://www.pagerduty.com/service-directory/Pshopping-cart"}}, "kind": "service", "metadata": {"additionalOwners": [], "contacts": [{"contact": "https://slack/", "type": "slack"}], "id": "4b163705-23c0-4573-b2fb-f6cea2163fcb", "inheritFrom": "application:default/myapp", "links": [{"name": "mylink", "type": "link", "url": "https://mylink"}], "name": "myService", "namespace": "default", "tags": ["this:tag", "that:tag"]}, "spec": {"dependsOn": [], "languages": []}}
And body with value {"apiVersion": "v3", "datadog": {"codeLocations": [{"paths": []}], "events": [{}], "logs": [{}], "performanceData": {"tags": []}, "pipelines": {"fingerprints": []}}, "integrations": {"opsgenie": {"serviceURL": "https://www.opsgenie.com/service/shopping-cart"}, "pagerduty": {"serviceURL": "https://www.pagerduty.com/service-directory/Pshopping-cart"}}, "kind": "service", "metadata": {"additionalOwners": [{"name": ""}], "contacts": [{"contact": "https://slack/", "type": "slack"}], "id": "4b163705-23c0-4573-b2fb-f6cea2163fcb", "inheritFrom": "application:default/myapp", "links": [{"name": "mylink", "type": "link", "url": "https://mylink"}], "name": "myService", "namespace": "default", "tags": ["this:tag", "that:tag"]}, "spec": {"dependsOn": [], "languages": []}}
When the request is sent
Then the response status is 400 Bad Request

Expand Down