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
426 changes: 419 additions & 7 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions examples/v2/status-pages/CreateEmailAccessPolicy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
Create an email access policy returns "Created" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.status_pages_api import StatusPagesApi
from datadog_api_client.v2.model.access_policy_effect import AccessPolicyEffect
from datadog_api_client.v2.model.create_status_page_email_access_policy_request import (
CreateStatusPageEmailAccessPolicyRequest,
)
from datadog_api_client.v2.model.create_status_page_email_access_policy_request_data import (
CreateStatusPageEmailAccessPolicyRequestData,
)
from datadog_api_client.v2.model.create_status_page_email_access_policy_request_data_attributes import (
CreateStatusPageEmailAccessPolicyRequestDataAttributes,
)
from datadog_api_client.v2.model.status_page_email_access_policy_type import StatusPageEmailAccessPolicyType

# there is a valid "private_status_page" in the system
PRIVATE_STATUS_PAGE_DATA_ID = environ["PRIVATE_STATUS_PAGE_DATA_ID"]

body = CreateStatusPageEmailAccessPolicyRequest(
data=CreateStatusPageEmailAccessPolicyRequestData(
attributes=CreateStatusPageEmailAccessPolicyRequestDataAttributes(
effect=AccessPolicyEffect.ALLOW,
pattern="@example.com",
),
type=StatusPageEmailAccessPolicyType.EMAIL_ACCESS_POLICIES,
),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = StatusPagesApi(api_client)
response = api_instance.create_email_access_policy(page_id=PRIVATE_STATUS_PAGE_DATA_ID, body=body)

print(response)
22 changes: 22 additions & 0 deletions examples/v2/status-pages/DeleteEmailAccessPolicy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
Delete an email access policy returns "No Content" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.status_pages_api import StatusPagesApi

# there is a valid "private_status_page" in the system
PRIVATE_STATUS_PAGE_DATA_ID = environ["PRIVATE_STATUS_PAGE_DATA_ID"]

# there is a valid "email_access_policy" in the system
EMAIL_ACCESS_POLICY_DATA_ID = environ["EMAIL_ACCESS_POLICY_DATA_ID"]

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = StatusPagesApi(api_client)
api_instance.delete_email_access_policy(
page_id=PRIVATE_STATUS_PAGE_DATA_ID,
policy_id=EMAIL_ACCESS_POLICY_DATA_ID,
)
20 changes: 20 additions & 0 deletions examples/v2/status-pages/ListEmailAccessPolicies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
List email access policies returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.status_pages_api import StatusPagesApi

# there is a valid "private_status_page" in the system
PRIVATE_STATUS_PAGE_DATA_ID = environ["PRIVATE_STATUS_PAGE_DATA_ID"]

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = StatusPagesApi(api_client)
response = api_instance.list_email_access_policies(
page_id=PRIVATE_STATUS_PAGE_DATA_ID,
)

print(response)
173 changes: 171 additions & 2 deletions src/datadog_api_client/v2/api/status_pages_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
from datadog_api_client.v2.model.degradation_array import DegradationArray
from datadog_api_client.v2.model.maintenance_array import MaintenanceArray
from datadog_api_client.v2.model.patch_status_page_request import PatchStatusPageRequest
from datadog_api_client.v2.model.status_page_email_access_policy_array_response import (
StatusPageEmailAccessPolicyArrayResponse,
)
from datadog_api_client.v2.model.status_page_email_access_policy_response import StatusPageEmailAccessPolicyResponse
from datadog_api_client.v2.model.create_status_page_email_access_policy_request import (
CreateStatusPageEmailAccessPolicyRequest,
)
from datadog_api_client.v2.model.status_pages_component_array import StatusPagesComponentArray
from datadog_api_client.v2.model.status_pages_component import StatusPagesComponent
from datadog_api_client.v2.model.create_component_request import CreateComponentRequest
Expand Down Expand Up @@ -214,6 +221,37 @@ def __init__(self, api_client=None):
api_client=api_client,
)

self._create_email_access_policy_endpoint = _Endpoint(
settings={
"response_type": (StatusPageEmailAccessPolicyResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/statuspages/{page_id}/access_policies/email",
"operation_id": "create_email_access_policy",
"http_method": "POST",
"version": "v2",
},
params_map={
"page_id": {
"required": True,
"openapi_types": (UUID,),
"attribute": "page_id",
"location": "path",
},
"include": {
"openapi_types": (str,),
"attribute": "include",
"location": "query",
},
"body": {
"required": True,
"openapi_types": (CreateStatusPageEmailAccessPolicyRequest,),
"location": "body",
},
},
headers_map={"accept": ["application/json"], "content_type": ["application/json"]},
api_client=api_client,
)

self._create_maintenance_endpoint = _Endpoint(
settings={
"response_type": (Maintenance,),
Expand Down Expand Up @@ -393,6 +431,35 @@ def __init__(self, api_client=None):
api_client=api_client,
)

self._delete_email_access_policy_endpoint = _Endpoint(
settings={
"response_type": None,
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/statuspages/{page_id}/access_policies/email/{policy_id}",
"operation_id": "delete_email_access_policy",
"http_method": "DELETE",
"version": "v2",
},
params_map={
"page_id": {
"required": True,
"openapi_types": (UUID,),
"attribute": "page_id",
"location": "path",
},
"policy_id": {
"required": True,
"openapi_types": (UUID,),
"attribute": "policy_id",
"location": "path",
},
},
headers_map={
"accept": ["*/*"],
},
api_client=api_client,
)

self._delete_maintenance_template_endpoint = _Endpoint(
settings={
"response_type": None,
Expand Down Expand Up @@ -794,6 +861,34 @@ def __init__(self, api_client=None):
api_client=api_client,
)

self._list_email_access_policies_endpoint = _Endpoint(
settings={
"response_type": (StatusPageEmailAccessPolicyArrayResponse,),
"auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"],
"endpoint_path": "/api/v2/statuspages/{page_id}/access_policies/email",
"operation_id": "list_email_access_policies",
"http_method": "GET",
"version": "v2",
},
params_map={
"page_id": {
"required": True,
"openapi_types": (UUID,),
"attribute": "page_id",
"location": "path",
},
"include": {
"openapi_types": (str,),
"attribute": "include",
"location": "query",
},
},
headers_map={
"accept": ["application/json"],
},
api_client=api_client,
)

self._list_maintenances_endpoint = _Endpoint(
settings={
"response_type": (MaintenanceArray,),
Expand Down Expand Up @@ -1407,6 +1502,34 @@ def create_degradation_template(

return self._create_degradation_template_endpoint.call_with_http_info(**kwargs)

def create_email_access_policy(
self,
page_id: UUID,
body: CreateStatusPageEmailAccessPolicyRequest,
*,
include: Union[str, UnsetType] = unset,
) -> StatusPageEmailAccessPolicyResponse:
"""Create an email access policy.

Creates an email access policy for a private status page.

:param page_id: The ID of the private status page.
:type page_id: UUID
:type body: CreateStatusPageEmailAccessPolicyRequest
:param include: Comma-separated list of resources to include. Supported values: created_by_user, status_page.
:type include: str, optional
:rtype: StatusPageEmailAccessPolicyResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["page_id"] = page_id

if include is not unset:
kwargs["include"] = include

kwargs["body"] = body

return self._create_email_access_policy_endpoint.call_with_http_info(**kwargs)

def create_maintenance(
self,
page_id: UUID,
Expand Down Expand Up @@ -1558,6 +1681,28 @@ def delete_degradation_template(

return self._delete_degradation_template_endpoint.call_with_http_info(**kwargs)

def delete_email_access_policy(
self,
page_id: UUID,
policy_id: UUID,
) -> None:
"""Delete an email access policy.

Deletes an email access policy from a private status page.

:param page_id: The ID of the private status page.
:type page_id: UUID
:param policy_id: The ID of the email access policy.
:type policy_id: UUID
:rtype: None
"""
kwargs: Dict[str, Any] = {}
kwargs["page_id"] = page_id

kwargs["policy_id"] = policy_id

return self._delete_email_access_policy_endpoint.call_with_http_info(**kwargs)

def delete_maintenance_template(
self,
page_id: UUID,
Expand Down Expand Up @@ -1907,6 +2052,30 @@ def list_degradation_templates(

return self._list_degradation_templates_endpoint.call_with_http_info(**kwargs)

def list_email_access_policies(
self,
page_id: UUID,
*,
include: Union[str, UnsetType] = unset,
) -> StatusPageEmailAccessPolicyArrayResponse:
"""List email access policies.

Lists the email access policies for a private status page.

:param page_id: The ID of the private status page.
:type page_id: UUID
:param include: Comma-separated list of resources to include. Supported values: created_by_user, status_page.
:type include: str, optional
:rtype: StatusPageEmailAccessPolicyArrayResponse
"""
kwargs: Dict[str, Any] = {}
kwargs["page_id"] = page_id

if include is not unset:
kwargs["include"] = include

return self._list_email_access_policies_endpoint.call_with_http_info(**kwargs)

def list_maintenances(
self,
*,
Expand Down Expand Up @@ -2060,7 +2229,7 @@ def publish_status_page(
) -> None:
"""Publish status page.

Publishes a status page. For pages of type ``public`` , makes the status page available on the public internet and requires the ``status_pages_public_page_publish`` permission. For pages of type ``internal`` , makes the status page available under the ``status-pages/$domain_prefix/view`` route within the Datadog organization and requires the ``status_pages_internal_page_publish`` permission.
Publishes a status page. For pages of type ``public`` , makes the status page available on the public internet and requires the ``status_pages_public_page_publish`` permission. For pages of type ``internal`` , makes the status page available under the ``status-pages/$domain_prefix/view`` route within the Datadog organization and requires the ``status_pages_internal_page_publish`` permission. For pages of type ``private`` , makes the status page available to users authorized by its email access policies and requires the ``status_pages_private_page_publish`` permission. A private status page must have at least one email access policy before it can be published.

:param page_id: The ID of the status page.
:type page_id: UUID
Expand Down Expand Up @@ -2104,7 +2273,7 @@ def unpublish_status_page(
) -> None:
"""Unpublish status page.

Unpublishes a status page. For pages of type ``public`` , removes the status page from the public internet and requires the ``status_pages_public_page_publish`` permission. For pages of type ``internal`` , removes the ``status-pages/$domain_prefix/view`` route from the Datadog organization and requires the ``status_pages_internal_page_publish`` permission.
Unpublishes a status page. For pages of type ``public`` , removes the status page from the public internet and requires the ``status_pages_public_page_publish`` permission. For pages of type ``internal`` , removes the ``status-pages/$domain_prefix/view`` route from the Datadog organization and requires the ``status_pages_internal_page_publish`` permission. For pages of type ``private`` , removes access to the private status page and requires the ``status_pages_private_page_publish`` permission.

:param page_id: The ID of the status page.
:type page_id: UUID
Expand Down
38 changes: 38 additions & 0 deletions src/datadog_api_client/v2/model/access_policy_effect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019-Present Datadog, Inc.
from __future__ import annotations


from datadog_api_client.model_utils import (
ModelSimple,
cached_property,
)

from typing import ClassVar


class AccessPolicyEffect(ModelSimple):
"""
The effect applied when an email address matches the policy. Deny policies take precedence over allow policies.

:param value: Must be one of ["allow", "deny"].
:type value: str
"""

allowed_values = {
"allow",
"deny",
}
ALLOW: ClassVar["AccessPolicyEffect"]
DENY: ClassVar["AccessPolicyEffect"]

@cached_property
def openapi_types(_):
return {
"value": (str,),
}


AccessPolicyEffect.ALLOW = AccessPolicyEffect("allow")
AccessPolicyEffect.DENY = AccessPolicyEffect("deny")
Loading
Loading