diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 397d1a8cdc..307c8607be 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -14293,6 +14293,151 @@ components: test_level: $ref: "#/components/schemas/CIAppTestLevel" type: object + CIAppGitHubAccountAttributes: + description: Attributes describing a GitHub account's CI Visibility opt-in status. + properties: + account: + description: The GitHub account (organization or user) name. + example: datadog + type: string + enabled: + description: Whether CI Visibility is enabled at the account level. + example: true + type: boolean + host: + description: The GitHub host (`github.com` or a GHES hostname) this account belongs to. + example: github.com + type: string + repo_count: + description: The number of repositories known for this account. + example: 12 + format: int64 + type: integer + repositories: + description: The repositories belonging to this account, with their individual opt-in status. + items: + $ref: "#/components/schemas/CIAppGitHubAccountRepository" + type: array + type: object + CIAppGitHubAccountData: + description: Data object for a GitHub account. + properties: + attributes: + $ref: "#/components/schemas/CIAppGitHubAccountAttributes" + id: + description: |- + The account's unique identifier, in the form `/` + (for example `github.com/datadog`). + example: github.com/datadog + type: string + type: + $ref: "#/components/schemas/CIAppGitHubAccountType" + required: + - id + - type + - attributes + type: object + CIAppGitHubAccountRepository: + description: A GitHub repository within a GitHub account, and its CI Visibility opt-in status. + properties: + enabled: + description: Whether CI Visibility is enabled for this repository. + example: true + type: boolean + name: + description: The repository name. + example: shopist + type: string + type: object + CIAppGitHubAccountResponse: + description: Response object containing a single GitHub account's CI Visibility opt-in status. + properties: + data: + $ref: "#/components/schemas/CIAppGitHubAccountData" + required: + - data + type: object + CIAppGitHubAccountType: + description: |- + JSON:API type for the GitHub account resource. + The value must always be `ci_github_account`. + enum: + - ci_github_account + example: ci_github_account + type: string + x-enum-varnames: + - CI_GITHUB_ACCOUNT + CIAppGitHubAccountUpdateRequest: + description: Request object for updating a GitHub account's CI Visibility opt-in status. + properties: + data: + $ref: "#/components/schemas/CIAppGitHubAccountUpdateRequestData" + required: + - data + type: object + CIAppGitHubAccountUpdateRequestAttributes: + description: |- + Attributes for updating a GitHub account's CI Visibility opt-in status. + At least one of `enabled` or `repository.enabled` must be provided. + Account-level and repository-level opt-in changes are independent and may both be supplied in the same request. + properties: + account: + description: The GitHub account (organization or user) name to update, identified by name. + example: datadog + minLength: 1 + type: string + enabled: + description: Whether to enable or disable CI Visibility at the account level. + example: true + type: boolean + host: + description: |- + The GitHub host (`github.com` or a GHES hostname) the account belongs to. Required to disambiguate + when the same account name exists on more than one host. + example: github.com + type: string + repository: + $ref: "#/components/schemas/CIAppGitHubAccountUpdateRequestRepository" + required: + - account + type: object + CIAppGitHubAccountUpdateRequestData: + description: Data object for updating a GitHub account's CI Visibility opt-in status. + properties: + attributes: + $ref: "#/components/schemas/CIAppGitHubAccountUpdateRequestAttributes" + type: + $ref: "#/components/schemas/CIAppGitHubAccountType" + required: + - type + - attributes + type: object + CIAppGitHubAccountUpdateRequestRepository: + description: Repository-level opt-in change to apply, identified by name. + properties: + enabled: + description: Whether to enable or disable CI Visibility for this repository. + example: true + type: boolean + name: + description: The repository name to update. + example: shopist + minLength: 1 + type: string + required: + - name + - enabled + type: object + CIAppGitHubAccountsResponse: + description: Response object containing a list of GitHub accounts and their CI Visibility opt-in status. + properties: + data: + items: + $ref: "#/components/schemas/CIAppGitHubAccountData" + type: array + required: + - data + type: object CIAppGitInfo: description: |- If pipelines are triggered due to actions to a Git repository, then all payloads must contain this. @@ -130420,6 +130565,127 @@ paths: x-unstable: |- **Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/ci/github/accounts: + get: + description: |- + Retrieve the list of GitHub accounts (organizations or users) available to this Datadog organization + through its GitHub App installation, along with each account's and repository's CI Visibility opt-in status. + operationId: ListCIAppGitHubAccounts + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + account: datadog + enabled: true + host: github.com + repo_count: 2 + repositories: + - enabled: true + name: shopist + - enabled: false + name: dd-source + id: github.com/datadog + type: ci_github_account + schema: + $ref: "#/components/schemas/CIAppGitHubAccountsResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/NotAuthorizedResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - integrations_read + summary: List GitHub CI Visibility status + tags: ["CI Visibility GitHub Accounts"] + x-permission: + operator: OR + permissions: + - integrations_read + patch: + description: |- + Enable or disable CI Visibility for a GitHub account, one of its repositories, or both in the same request. + The account (and, optionally, repository) are identified by name. Account-level and repository-level + changes are independent and may both be supplied in the same request. At least one of `enabled` or + `repository.enabled` must be provided. If the account name matches installations on more than one host, + `host` must be supplied to disambiguate, otherwise a 409 is returned. Returns a 404 if the CI Visibility + GitHub integration is not enabled for this organization, or if the given account or repository cannot be + found by name. + operationId: UpdateCIAppGitHubAccount + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + account: datadog + enabled: true + host: github.com + repository: + enabled: true + name: shopist + type: ci_github_account + schema: + $ref: "#/components/schemas/CIAppGitHubAccountUpdateRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + account: datadog + enabled: true + host: github.com + repo_count: 2 + repositories: + - enabled: true + name: shopist + - enabled: false + name: dd-source + id: github.com/datadog + type: ci_github_account + schema: + $ref: "#/components/schemas/CIAppGitHubAccountResponse" + description: OK + "400": + $ref: "#/components/responses/BadRequestResponse" + "403": + $ref: "#/components/responses/NotAuthorizedResponse" + "404": + $ref: "#/components/responses/NotFoundResponse" + "409": + $ref: "#/components/responses/ConflictResponse" + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - ci_provider_settings_write + summary: Update GitHub CI Visibility status + tags: ["CI Visibility GitHub Accounts"] + x-codegen-request-body-name: body + x-permission: + operator: OR + permissions: + - ci_provider_settings_write /api/v2/ci/pipeline: post: description: |- @@ -213105,6 +213371,10 @@ tags: - description: |- Use the Bits AI endpoints to retrieve AI-powered investigations. name: Bits AI + - description: |- + Manage CI Visibility opt-in status for your GitHub accounts and repositories. See the + [CI Visibility GitHub Actions setup page](https://docs.datadoghq.com/continuous_integration/setup_dd_ci_visibility_pipelines/github_actions/) for more information. + name: CI Visibility GitHub Accounts - description: |- Search or aggregate your CI Visibility pipeline events and send them to your Datadog site over HTTP. See the [CI Pipeline Visibility in Datadog page](https://docs.datadoghq.com/continuous_integration/pipelines/) for more information. name: CI Visibility Pipelines diff --git a/docs/datadog_api_client.v2.api.rst b/docs/datadog_api_client.v2.api.rst index c74f2573bf..7d13dd3b80 100644 --- a/docs/datadog_api_client.v2.api.rst +++ b/docs/datadog_api_client.v2.api.rst @@ -137,6 +137,13 @@ datadog\_api\_client.v2.api.change\_management\_api module :members: :show-inheritance: +datadog\_api\_client.v2.api.ci\_visibility\_git\_hub\_accounts\_api module +-------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.api.ci_visibility_git_hub_accounts_api + :members: + :show-inheritance: + datadog\_api\_client.v2.api.ci\_visibility\_pipelines\_api module ----------------------------------------------------------------- diff --git a/docs/datadog_api_client.v2.model.rst b/docs/datadog_api_client.v2.model.rst index dd56032ba7..fb51513e84 100644 --- a/docs/datadog_api_client.v2.model.rst +++ b/docs/datadog_api_client.v2.model.rst @@ -6304,6 +6304,76 @@ datadog\_api\_client.v2.model.ci\_app\_event\_attributes module :members: :show-inheritance: +datadog\_api\_client.v2.model.ci\_app\_git\_hub\_account\_attributes module +--------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ci_app_git_hub_account_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ci\_app\_git\_hub\_account\_data module +--------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ci_app_git_hub_account_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ci\_app\_git\_hub\_account\_repository module +--------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ci_app_git_hub_account_repository + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ci\_app\_git\_hub\_account\_response module +------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ci_app_git_hub_account_response + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ci\_app\_git\_hub\_account\_type module +--------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ci_app_git_hub_account_type + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ci\_app\_git\_hub\_account\_update\_request module +-------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ci_app_git_hub_account_update_request + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ci\_app\_git\_hub\_account\_update\_request\_attributes module +-------------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ci_app_git_hub_account_update_request_attributes + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ci\_app\_git\_hub\_account\_update\_request\_data module +-------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ci_app_git_hub_account_update_request_data + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ci\_app\_git\_hub\_account\_update\_request\_repository module +-------------------------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ci_app_git_hub_account_update_request_repository + :members: + :show-inheritance: + +datadog\_api\_client.v2.model.ci\_app\_git\_hub\_accounts\_response module +-------------------------------------------------------------------------- + +.. automodule:: datadog_api_client.v2.model.ci_app_git_hub_accounts_response + :members: + :show-inheritance: + datadog\_api\_client.v2.model.ci\_app\_git\_info module ------------------------------------------------------- diff --git a/examples/v2/ci-visibility-github-accounts/ListCIAppGitHubAccounts.py b/examples/v2/ci-visibility-github-accounts/ListCIAppGitHubAccounts.py new file mode 100644 index 0000000000..555fbde2ba --- /dev/null +++ b/examples/v2/ci-visibility-github-accounts/ListCIAppGitHubAccounts.py @@ -0,0 +1,13 @@ +""" +List GitHub CI Visibility status returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.ci_visibility_git_hub_accounts_api import CIVisibilityGitHubAccountsApi + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = CIVisibilityGitHubAccountsApi(api_client) + response = api_instance.list_ci_app_git_hub_accounts() + + print(response) diff --git a/examples/v2/ci-visibility-github-accounts/UpdateCIAppGitHubAccount.py b/examples/v2/ci-visibility-github-accounts/UpdateCIAppGitHubAccount.py new file mode 100644 index 0000000000..adddf42296 --- /dev/null +++ b/examples/v2/ci-visibility-github-accounts/UpdateCIAppGitHubAccount.py @@ -0,0 +1,37 @@ +""" +Update GitHub CI Visibility status returns "OK" response +""" + +from datadog_api_client import ApiClient, Configuration +from datadog_api_client.v2.api.ci_visibility_git_hub_accounts_api import CIVisibilityGitHubAccountsApi +from datadog_api_client.v2.model.ci_app_git_hub_account_type import CIAppGitHubAccountType +from datadog_api_client.v2.model.ci_app_git_hub_account_update_request import CIAppGitHubAccountUpdateRequest +from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_attributes import ( + CIAppGitHubAccountUpdateRequestAttributes, +) +from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_data import CIAppGitHubAccountUpdateRequestData +from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_repository import ( + CIAppGitHubAccountUpdateRequestRepository, +) + +body = CIAppGitHubAccountUpdateRequest( + data=CIAppGitHubAccountUpdateRequestData( + attributes=CIAppGitHubAccountUpdateRequestAttributes( + account="datadog", + enabled=True, + host="github.com", + repository=CIAppGitHubAccountUpdateRequestRepository( + enabled=True, + name="shopist", + ), + ), + type=CIAppGitHubAccountType.CI_GITHUB_ACCOUNT, + ), +) + +configuration = Configuration() +with ApiClient(configuration) as api_client: + api_instance = CIVisibilityGitHubAccountsApi(api_client) + response = api_instance.update_ci_app_git_hub_account(body=body) + + print(response) diff --git a/src/datadog_api_client/v2/api/ci_visibility_git_hub_accounts_api.py b/src/datadog_api_client/v2/api/ci_visibility_git_hub_accounts_api.py new file mode 100644 index 0000000000..ad77b022bf --- /dev/null +++ b/src/datadog_api_client/v2/api/ci_visibility_git_hub_accounts_api.py @@ -0,0 +1,95 @@ +# 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 typing import Any, Dict + +from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint +from datadog_api_client.configuration import Configuration +from datadog_api_client.v2.model.ci_app_git_hub_accounts_response import CIAppGitHubAccountsResponse +from datadog_api_client.v2.model.ci_app_git_hub_account_response import CIAppGitHubAccountResponse +from datadog_api_client.v2.model.ci_app_git_hub_account_update_request import CIAppGitHubAccountUpdateRequest + + +class CIVisibilityGitHubAccountsApi: + """ + Manage CI Visibility opt-in status for your GitHub accounts and repositories. See the + `CI Visibility GitHub Actions setup page `_ for more information. + """ + + def __init__(self, api_client=None): + if api_client is None: + api_client = ApiClient(Configuration()) + self.api_client = api_client + + self._list_ci_app_git_hub_accounts_endpoint = _Endpoint( + settings={ + "response_type": (CIAppGitHubAccountsResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/ci/github/accounts", + "operation_id": "list_ci_app_git_hub_accounts", + "http_method": "GET", + "version": "v2", + }, + params_map={}, + headers_map={ + "accept": ["application/json"], + }, + api_client=api_client, + ) + + self._update_ci_app_git_hub_account_endpoint = _Endpoint( + settings={ + "response_type": (CIAppGitHubAccountResponse,), + "auth": ["apiKeyAuth", "appKeyAuth", "AuthZ"], + "endpoint_path": "/api/v2/ci/github/accounts", + "operation_id": "update_ci_app_git_hub_account", + "http_method": "PATCH", + "version": "v2", + }, + params_map={ + "body": { + "required": True, + "openapi_types": (CIAppGitHubAccountUpdateRequest,), + "location": "body", + }, + }, + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, + api_client=api_client, + ) + + def list_ci_app_git_hub_accounts( + self, + ) -> CIAppGitHubAccountsResponse: + """List GitHub CI Visibility status. + + Retrieve the list of GitHub accounts (organizations or users) available to this Datadog organization + through its GitHub App installation, along with each account's and repository's CI Visibility opt-in status. + + :rtype: CIAppGitHubAccountsResponse + """ + kwargs: Dict[str, Any] = {} + return self._list_ci_app_git_hub_accounts_endpoint.call_with_http_info(**kwargs) + + def update_ci_app_git_hub_account( + self, + body: CIAppGitHubAccountUpdateRequest, + ) -> CIAppGitHubAccountResponse: + """Update GitHub CI Visibility status. + + Enable or disable CI Visibility for a GitHub account, one of its repositories, or both in the same request. + The account (and, optionally, repository) are identified by name. Account-level and repository-level + changes are independent and may both be supplied in the same request. At least one of ``enabled`` or + ``repository.enabled`` must be provided. If the account name matches installations on more than one host, + ``host`` must be supplied to disambiguate, otherwise a 409 is returned. Returns a 404 if the CI Visibility + GitHub integration is not enabled for this organization, or if the given account or repository cannot be + found by name. + + :type body: CIAppGitHubAccountUpdateRequest + :rtype: CIAppGitHubAccountResponse + """ + kwargs: Dict[str, Any] = {} + kwargs["body"] = body + + return self._update_ci_app_git_hub_account_endpoint.call_with_http_info(**kwargs) diff --git a/src/datadog_api_client/v2/apis/__init__.py b/src/datadog_api_client/v2/apis/__init__.py index c6b9db7d12..bae78fffbc 100644 --- a/src/datadog_api_client/v2/apis/__init__.py +++ b/src/datadog_api_client/v2/apis/__init__.py @@ -13,6 +13,7 @@ from datadog_api_client.v2.api.audit_api import AuditApi from datadog_api_client.v2.api.authn_mappings_api import AuthNMappingsApi from datadog_api_client.v2.api.bits_ai_api import BitsAIApi +from datadog_api_client.v2.api.ci_visibility_git_hub_accounts_api import CIVisibilityGitHubAccountsApi from datadog_api_client.v2.api.ci_visibility_pipelines_api import CIVisibilityPipelinesApi from datadog_api_client.v2.api.ci_visibility_tests_api import CIVisibilityTestsApi from datadog_api_client.v2.api.csm_agents_api import CSMAgentsApi @@ -156,6 +157,7 @@ "AuditApi", "AuthNMappingsApi", "BitsAIApi", + "CIVisibilityGitHubAccountsApi", "CIVisibilityPipelinesApi", "CIVisibilityTestsApi", "CSMAgentsApi", diff --git a/src/datadog_api_client/v2/model/ci_app_git_hub_account_attributes.py b/src/datadog_api_client/v2/model/ci_app_git_hub_account_attributes.py new file mode 100644 index 0000000000..0c2602e492 --- /dev/null +++ b/src/datadog_api_client/v2/model/ci_app_git_hub_account_attributes.py @@ -0,0 +1,78 @@ +# 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 typing import List, Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.ci_app_git_hub_account_repository import CIAppGitHubAccountRepository + + +class CIAppGitHubAccountAttributes(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ci_app_git_hub_account_repository import CIAppGitHubAccountRepository + + return { + "account": (str,), + "enabled": (bool,), + "host": (str,), + "repo_count": (int,), + "repositories": ([CIAppGitHubAccountRepository],), + } + + attribute_map = { + "account": "account", + "enabled": "enabled", + "host": "host", + "repo_count": "repo_count", + "repositories": "repositories", + } + + def __init__( + self_, + account: Union[str, UnsetType] = unset, + enabled: Union[bool, UnsetType] = unset, + host: Union[str, UnsetType] = unset, + repo_count: Union[int, UnsetType] = unset, + repositories: Union[List[CIAppGitHubAccountRepository], UnsetType] = unset, + **kwargs, + ): + """ + Attributes describing a GitHub account's CI Visibility opt-in status. + + :param account: The GitHub account (organization or user) name. + :type account: str, optional + + :param enabled: Whether CI Visibility is enabled at the account level. + :type enabled: bool, optional + + :param host: The GitHub host ( ``github.com`` or a GHES hostname) this account belongs to. + :type host: str, optional + + :param repo_count: The number of repositories known for this account. + :type repo_count: int, optional + + :param repositories: The repositories belonging to this account, with their individual opt-in status. + :type repositories: [CIAppGitHubAccountRepository], optional + """ + if account is not unset: + kwargs["account"] = account + if enabled is not unset: + kwargs["enabled"] = enabled + if host is not unset: + kwargs["host"] = host + if repo_count is not unset: + kwargs["repo_count"] = repo_count + if repositories is not unset: + kwargs["repositories"] = repositories + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/ci_app_git_hub_account_data.py b/src/datadog_api_client/v2/model/ci_app_git_hub_account_data.py new file mode 100644 index 0000000000..0ee75470b1 --- /dev/null +++ b/src/datadog_api_client/v2/model/ci_app_git_hub_account_data.py @@ -0,0 +1,56 @@ +# 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 typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.ci_app_git_hub_account_attributes import CIAppGitHubAccountAttributes + from datadog_api_client.v2.model.ci_app_git_hub_account_type import CIAppGitHubAccountType + + +class CIAppGitHubAccountData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ci_app_git_hub_account_attributes import CIAppGitHubAccountAttributes + from datadog_api_client.v2.model.ci_app_git_hub_account_type import CIAppGitHubAccountType + + return { + "attributes": (CIAppGitHubAccountAttributes,), + "id": (str,), + "type": (CIAppGitHubAccountType,), + } + + attribute_map = { + "attributes": "attributes", + "id": "id", + "type": "type", + } + + def __init__(self_, attributes: CIAppGitHubAccountAttributes, id: str, type: CIAppGitHubAccountType, **kwargs): + """ + Data object for a GitHub account. + + :param attributes: Attributes describing a GitHub account's CI Visibility opt-in status. + :type attributes: CIAppGitHubAccountAttributes + + :param id: The account's unique identifier, in the form ``/`` + (for example ``github.com/datadog`` ). + :type id: str + + :param type: JSON:API type for the GitHub account resource. + The value must always be ``ci_github_account``. + :type type: CIAppGitHubAccountType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.id = id + self_.type = type diff --git a/src/datadog_api_client/v2/model/ci_app_git_hub_account_repository.py b/src/datadog_api_client/v2/model/ci_app_git_hub_account_repository.py new file mode 100644 index 0000000000..39a60d076d --- /dev/null +++ b/src/datadog_api_client/v2/model/ci_app_git_hub_account_repository.py @@ -0,0 +1,43 @@ +# 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 typing import Union + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +class CIAppGitHubAccountRepository(ModelNormal): + @cached_property + def openapi_types(_): + return { + "enabled": (bool,), + "name": (str,), + } + + attribute_map = { + "enabled": "enabled", + "name": "name", + } + + def __init__(self_, enabled: Union[bool, UnsetType] = unset, name: Union[str, UnsetType] = unset, **kwargs): + """ + A GitHub repository within a GitHub account, and its CI Visibility opt-in status. + + :param enabled: Whether CI Visibility is enabled for this repository. + :type enabled: bool, optional + + :param name: The repository name. + :type name: str, optional + """ + if enabled is not unset: + kwargs["enabled"] = enabled + if name is not unset: + kwargs["name"] = name + super().__init__(kwargs) diff --git a/src/datadog_api_client/v2/model/ci_app_git_hub_account_response.py b/src/datadog_api_client/v2/model/ci_app_git_hub_account_response.py new file mode 100644 index 0000000000..3375c0c45a --- /dev/null +++ b/src/datadog_api_client/v2/model/ci_app_git_hub_account_response.py @@ -0,0 +1,40 @@ +# 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 typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.ci_app_git_hub_account_data import CIAppGitHubAccountData + + +class CIAppGitHubAccountResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ci_app_git_hub_account_data import CIAppGitHubAccountData + + return { + "data": (CIAppGitHubAccountData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: CIAppGitHubAccountData, **kwargs): + """ + Response object containing a single GitHub account's CI Visibility opt-in status. + + :param data: Data object for a GitHub account. + :type data: CIAppGitHubAccountData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/ci_app_git_hub_account_type.py b/src/datadog_api_client/v2/model/ci_app_git_hub_account_type.py new file mode 100644 index 0000000000..f7d0448620 --- /dev/null +++ b/src/datadog_api_client/v2/model/ci_app_git_hub_account_type.py @@ -0,0 +1,36 @@ +# 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 CIAppGitHubAccountType(ModelSimple): + """ + JSON:API type for the GitHub account resource. + The value must always be `ci_github_account`. + + :param value: If omitted defaults to "ci_github_account". Must be one of ["ci_github_account"]. + :type value: str + """ + + allowed_values = { + "ci_github_account", + } + CI_GITHUB_ACCOUNT: ClassVar["CIAppGitHubAccountType"] + + @cached_property + def openapi_types(_): + return { + "value": (str,), + } + + +CIAppGitHubAccountType.CI_GITHUB_ACCOUNT = CIAppGitHubAccountType("ci_github_account") diff --git a/src/datadog_api_client/v2/model/ci_app_git_hub_account_update_request.py b/src/datadog_api_client/v2/model/ci_app_git_hub_account_update_request.py new file mode 100644 index 0000000000..c07d7bc452 --- /dev/null +++ b/src/datadog_api_client/v2/model/ci_app_git_hub_account_update_request.py @@ -0,0 +1,44 @@ +# 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 typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_data import ( + CIAppGitHubAccountUpdateRequestData, + ) + + +class CIAppGitHubAccountUpdateRequest(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_data import ( + CIAppGitHubAccountUpdateRequestData, + ) + + return { + "data": (CIAppGitHubAccountUpdateRequestData,), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: CIAppGitHubAccountUpdateRequestData, **kwargs): + """ + Request object for updating a GitHub account's CI Visibility opt-in status. + + :param data: Data object for updating a GitHub account's CI Visibility opt-in status. + :type data: CIAppGitHubAccountUpdateRequestData + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/model/ci_app_git_hub_account_update_request_attributes.py b/src/datadog_api_client/v2/model/ci_app_git_hub_account_update_request_attributes.py new file mode 100644 index 0000000000..cf09ea94d4 --- /dev/null +++ b/src/datadog_api_client/v2/model/ci_app_git_hub_account_update_request_attributes.py @@ -0,0 +1,83 @@ +# 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 typing import Union, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, + unset, + UnsetType, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_repository import ( + CIAppGitHubAccountUpdateRequestRepository, + ) + + +class CIAppGitHubAccountUpdateRequestAttributes(ModelNormal): + validations = { + "account": { + "min_length": 1, + }, + } + + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_repository import ( + CIAppGitHubAccountUpdateRequestRepository, + ) + + return { + "account": (str,), + "enabled": (bool,), + "host": (str,), + "repository": (CIAppGitHubAccountUpdateRequestRepository,), + } + + attribute_map = { + "account": "account", + "enabled": "enabled", + "host": "host", + "repository": "repository", + } + + def __init__( + self_, + account: str, + enabled: Union[bool, UnsetType] = unset, + host: Union[str, UnsetType] = unset, + repository: Union[CIAppGitHubAccountUpdateRequestRepository, UnsetType] = unset, + **kwargs, + ): + """ + Attributes for updating a GitHub account's CI Visibility opt-in status. + At least one of ``enabled`` or ``repository.enabled`` must be provided. + Account-level and repository-level opt-in changes are independent and may both be supplied in the same request. + + :param account: The GitHub account (organization or user) name to update, identified by name. + :type account: str + + :param enabled: Whether to enable or disable CI Visibility at the account level. + :type enabled: bool, optional + + :param host: The GitHub host ( ``github.com`` or a GHES hostname) the account belongs to. Required to disambiguate + when the same account name exists on more than one host. + :type host: str, optional + + :param repository: Repository-level opt-in change to apply, identified by name. + :type repository: CIAppGitHubAccountUpdateRequestRepository, optional + """ + if enabled is not unset: + kwargs["enabled"] = enabled + if host is not unset: + kwargs["host"] = host + if repository is not unset: + kwargs["repository"] = repository + super().__init__(kwargs) + + self_.account = account diff --git a/src/datadog_api_client/v2/model/ci_app_git_hub_account_update_request_data.py b/src/datadog_api_client/v2/model/ci_app_git_hub_account_update_request_data.py new file mode 100644 index 0000000000..3a0f663127 --- /dev/null +++ b/src/datadog_api_client/v2/model/ci_app_git_hub_account_update_request_data.py @@ -0,0 +1,55 @@ +# 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 typing import TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_attributes import ( + CIAppGitHubAccountUpdateRequestAttributes, + ) + from datadog_api_client.v2.model.ci_app_git_hub_account_type import CIAppGitHubAccountType + + +class CIAppGitHubAccountUpdateRequestData(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_attributes import ( + CIAppGitHubAccountUpdateRequestAttributes, + ) + from datadog_api_client.v2.model.ci_app_git_hub_account_type import CIAppGitHubAccountType + + return { + "attributes": (CIAppGitHubAccountUpdateRequestAttributes,), + "type": (CIAppGitHubAccountType,), + } + + attribute_map = { + "attributes": "attributes", + "type": "type", + } + + def __init__(self_, attributes: CIAppGitHubAccountUpdateRequestAttributes, type: CIAppGitHubAccountType, **kwargs): + """ + Data object for updating a GitHub account's CI Visibility opt-in status. + + :param attributes: Attributes for updating a GitHub account's CI Visibility opt-in status. + At least one of ``enabled`` or ``repository.enabled`` must be provided. + Account-level and repository-level opt-in changes are independent and may both be supplied in the same request. + :type attributes: CIAppGitHubAccountUpdateRequestAttributes + + :param type: JSON:API type for the GitHub account resource. + The value must always be ``ci_github_account``. + :type type: CIAppGitHubAccountType + """ + super().__init__(kwargs) + + self_.attributes = attributes + self_.type = type diff --git a/src/datadog_api_client/v2/model/ci_app_git_hub_account_update_request_repository.py b/src/datadog_api_client/v2/model/ci_app_git_hub_account_update_request_repository.py new file mode 100644 index 0000000000..7c9cc55870 --- /dev/null +++ b/src/datadog_api_client/v2/model/ci_app_git_hub_account_update_request_repository.py @@ -0,0 +1,45 @@ +# 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 ( + ModelNormal, + cached_property, +) + + +class CIAppGitHubAccountUpdateRequestRepository(ModelNormal): + validations = { + "name": { + "min_length": 1, + }, + } + + @cached_property + def openapi_types(_): + return { + "enabled": (bool,), + "name": (str,), + } + + attribute_map = { + "enabled": "enabled", + "name": "name", + } + + def __init__(self_, enabled: bool, name: str, **kwargs): + """ + Repository-level opt-in change to apply, identified by name. + + :param enabled: Whether to enable or disable CI Visibility for this repository. + :type enabled: bool + + :param name: The repository name to update. + :type name: str + """ + super().__init__(kwargs) + + self_.enabled = enabled + self_.name = name diff --git a/src/datadog_api_client/v2/model/ci_app_git_hub_accounts_response.py b/src/datadog_api_client/v2/model/ci_app_git_hub_accounts_response.py new file mode 100644 index 0000000000..c25fbc91b5 --- /dev/null +++ b/src/datadog_api_client/v2/model/ci_app_git_hub_accounts_response.py @@ -0,0 +1,40 @@ +# 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 typing import List, TYPE_CHECKING + +from datadog_api_client.model_utils import ( + ModelNormal, + cached_property, +) + + +if TYPE_CHECKING: + from datadog_api_client.v2.model.ci_app_git_hub_account_data import CIAppGitHubAccountData + + +class CIAppGitHubAccountsResponse(ModelNormal): + @cached_property + def openapi_types(_): + from datadog_api_client.v2.model.ci_app_git_hub_account_data import CIAppGitHubAccountData + + return { + "data": ([CIAppGitHubAccountData],), + } + + attribute_map = { + "data": "data", + } + + def __init__(self_, data: List[CIAppGitHubAccountData], **kwargs): + """ + Response object containing a list of GitHub accounts and their CI Visibility opt-in status. + + :param data: + :type data: [CIAppGitHubAccountData] + """ + super().__init__(kwargs) + + self_.data = data diff --git a/src/datadog_api_client/v2/models/__init__.py b/src/datadog_api_client/v2/models/__init__.py index 6dcd30db0f..1777dde96d 100644 --- a/src/datadog_api_client/v2/models/__init__.py +++ b/src/datadog_api_client/v2/models/__init__.py @@ -926,6 +926,20 @@ CIAppCreatePipelineEventRequestDataType, ) from datadog_api_client.v2.model.ci_app_event_attributes import CIAppEventAttributes +from datadog_api_client.v2.model.ci_app_git_hub_account_attributes import CIAppGitHubAccountAttributes +from datadog_api_client.v2.model.ci_app_git_hub_account_data import CIAppGitHubAccountData +from datadog_api_client.v2.model.ci_app_git_hub_account_repository import CIAppGitHubAccountRepository +from datadog_api_client.v2.model.ci_app_git_hub_account_response import CIAppGitHubAccountResponse +from datadog_api_client.v2.model.ci_app_git_hub_account_type import CIAppGitHubAccountType +from datadog_api_client.v2.model.ci_app_git_hub_account_update_request import CIAppGitHubAccountUpdateRequest +from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_attributes import ( + CIAppGitHubAccountUpdateRequestAttributes, +) +from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_data import CIAppGitHubAccountUpdateRequestData +from datadog_api_client.v2.model.ci_app_git_hub_account_update_request_repository import ( + CIAppGitHubAccountUpdateRequestRepository, +) +from datadog_api_client.v2.model.ci_app_git_hub_accounts_response import CIAppGitHubAccountsResponse from datadog_api_client.v2.model.ci_app_git_info import CIAppGitInfo from datadog_api_client.v2.model.ci_app_group_by_histogram import CIAppGroupByHistogram from datadog_api_client.v2.model.ci_app_group_by_missing import CIAppGroupByMissing @@ -11255,6 +11269,16 @@ "CIAppCreatePipelineEventRequestDataSingleOrArray", "CIAppCreatePipelineEventRequestDataType", "CIAppEventAttributes", + "CIAppGitHubAccountAttributes", + "CIAppGitHubAccountData", + "CIAppGitHubAccountRepository", + "CIAppGitHubAccountResponse", + "CIAppGitHubAccountType", + "CIAppGitHubAccountUpdateRequest", + "CIAppGitHubAccountUpdateRequestAttributes", + "CIAppGitHubAccountUpdateRequestData", + "CIAppGitHubAccountUpdateRequestRepository", + "CIAppGitHubAccountsResponse", "CIAppGitInfo", "CIAppGroupByHistogram", "CIAppGroupByMissing", diff --git a/tests/v2/features/ci_visibility_github_accounts.feature b/tests/v2/features/ci_visibility_github_accounts.feature new file mode 100644 index 0000000000..70ca35b180 --- /dev/null +++ b/tests/v2/features/ci_visibility_github_accounts.feature @@ -0,0 +1,57 @@ +@endpoint(ci-visibility-github-accounts) @endpoint(ci-visibility-github-accounts-v2) +Feature: CI Visibility GitHub Accounts + Manage CI Visibility opt-in status for your GitHub accounts and + repositories. See the [CI Visibility GitHub Actions setup page](https://do + cs.datadoghq.com/continuous_integration/setup_dd_ci_visibility_pipelines/g + ithub_actions/) for more information. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "CIVisibilityGitHubAccounts" API + + @generated @skip @team:DataDog/ci-app-backend + Scenario: List GitHub CI Visibility status returns "Bad Request" response + Given new "ListCIAppGitHubAccounts" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: List GitHub CI Visibility status returns "Not Found" response + Given new "ListCIAppGitHubAccounts" request + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/ci-app-backend + Scenario: List GitHub CI Visibility status returns "OK" response + Given new "ListCIAppGitHubAccounts" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Update GitHub CI Visibility status returns "Bad Request" response + Given new "UpdateCIAppGitHubAccount" request + And body with value {"data": {"attributes": {"account": "datadog", "enabled": true, "host": "github.com", "repository": {"enabled": true, "name": "shopist"}}, "type": "ci_github_account"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Update GitHub CI Visibility status returns "Conflict" response + Given new "UpdateCIAppGitHubAccount" request + And body with value {"data": {"attributes": {"account": "datadog", "enabled": true, "host": "github.com", "repository": {"enabled": true, "name": "shopist"}}, "type": "ci_github_account"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Update GitHub CI Visibility status returns "Not Found" response + Given new "UpdateCIAppGitHubAccount" request + And body with value {"data": {"attributes": {"account": "datadog", "enabled": true, "host": "github.com", "repository": {"enabled": true, "name": "shopist"}}, "type": "ci_github_account"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Update GitHub CI Visibility status returns "OK" response + Given new "UpdateCIAppGitHubAccount" request + And body with value {"data": {"attributes": {"account": "datadog", "enabled": true, "host": "github.com", "repository": {"enabled": true, "name": "shopist"}}, "type": "ci_github_account"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/v2/features/undo.json b/tests/v2/features/undo.json index 9903d959ff..d594288bb8 100644 --- a/tests/v2/features/undo.json +++ b/tests/v2/features/undo.json @@ -1362,6 +1362,18 @@ "type": "idempotent" } }, + "ListCIAppGitHubAccounts": { + "tag": "CI Visibility GitHub Accounts", + "undo": { + "type": "safe" + } + }, + "UpdateCIAppGitHubAccount": { + "tag": "CI Visibility GitHub Accounts", + "undo": { + "type": "idempotent" + } + }, "CreateCIAppPipelineEvent": { "tag": "CI Visibility Pipelines", "undo": {