|
| 1 | +# Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
| 2 | +# This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 3 | +# Copyright 2019-Present Datadog, Inc. |
| 4 | +from __future__ import annotations |
| 5 | + |
| 6 | +from typing import Any, Dict, Union |
| 7 | + |
| 8 | +from datadog_api_client.api_client import ApiClient, Endpoint as _Endpoint |
| 9 | +from datadog_api_client.configuration import Configuration |
| 10 | +from datadog_api_client.model_utils import ( |
| 11 | + UnsetType, |
| 12 | + unset, |
| 13 | +) |
| 14 | +from datadog_api_client.v2.model.terraform_backend_list_response import TerraformBackendListResponse |
| 15 | +from datadog_api_client.v2.model.terraform_backend_response import TerraformBackendResponse |
| 16 | +from datadog_api_client.v2.model.terraform_backend_create_request import TerraformBackendCreateRequest |
| 17 | +from datadog_api_client.v2.model.terraform_backend_update_request import TerraformBackendUpdateRequest |
| 18 | + |
| 19 | + |
| 20 | +class TerraformStateFilesApi: |
| 21 | + """ |
| 22 | + Configure synchronization of Terraform state files from S3 buckets and inspect synchronization status. |
| 23 | + """ |
| 24 | + |
| 25 | + def __init__(self, api_client=None): |
| 26 | + if api_client is None: |
| 27 | + api_client = ApiClient(Configuration()) |
| 28 | + self.api_client = api_client |
| 29 | + |
| 30 | + self._create_terraform_backend_sync_config_endpoint = _Endpoint( |
| 31 | + settings={ |
| 32 | + "response_type": (TerraformBackendResponse,), |
| 33 | + "auth": ["apiKeyAuth", "appKeyAuth"], |
| 34 | + "endpoint_path": "/api/v2/iac-api/terraform/backends", |
| 35 | + "operation_id": "create_terraform_backend_sync_config", |
| 36 | + "http_method": "POST", |
| 37 | + "version": "v2", |
| 38 | + }, |
| 39 | + params_map={ |
| 40 | + "body": { |
| 41 | + "required": True, |
| 42 | + "openapi_types": (TerraformBackendCreateRequest,), |
| 43 | + "location": "body", |
| 44 | + }, |
| 45 | + }, |
| 46 | + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, |
| 47 | + api_client=api_client, |
| 48 | + ) |
| 49 | + |
| 50 | + self._delete_terraform_backend_sync_config_endpoint = _Endpoint( |
| 51 | + settings={ |
| 52 | + "response_type": None, |
| 53 | + "auth": ["apiKeyAuth", "appKeyAuth"], |
| 54 | + "endpoint_path": "/api/v2/iac-api/terraform/backends/{id}", |
| 55 | + "operation_id": "delete_terraform_backend_sync_config", |
| 56 | + "http_method": "DELETE", |
| 57 | + "version": "v2", |
| 58 | + }, |
| 59 | + params_map={ |
| 60 | + "id": { |
| 61 | + "required": True, |
| 62 | + "openapi_types": (str,), |
| 63 | + "attribute": "id", |
| 64 | + "location": "path", |
| 65 | + }, |
| 66 | + }, |
| 67 | + headers_map={ |
| 68 | + "accept": ["*/*"], |
| 69 | + }, |
| 70 | + api_client=api_client, |
| 71 | + ) |
| 72 | + |
| 73 | + self._list_terraform_backend_sync_configs_endpoint = _Endpoint( |
| 74 | + settings={ |
| 75 | + "response_type": (TerraformBackendListResponse,), |
| 76 | + "auth": ["apiKeyAuth", "appKeyAuth"], |
| 77 | + "endpoint_path": "/api/v2/iac-api/terraform/backends", |
| 78 | + "operation_id": "list_terraform_backend_sync_configs", |
| 79 | + "http_method": "GET", |
| 80 | + "version": "v2", |
| 81 | + }, |
| 82 | + params_map={ |
| 83 | + "account_id": { |
| 84 | + "openapi_types": (str,), |
| 85 | + "attribute": "account_id", |
| 86 | + "location": "query", |
| 87 | + }, |
| 88 | + }, |
| 89 | + headers_map={ |
| 90 | + "accept": ["application/json"], |
| 91 | + }, |
| 92 | + api_client=api_client, |
| 93 | + ) |
| 94 | + |
| 95 | + self._update_terraform_backend_sync_config_endpoint = _Endpoint( |
| 96 | + settings={ |
| 97 | + "response_type": (TerraformBackendResponse,), |
| 98 | + "auth": ["apiKeyAuth", "appKeyAuth"], |
| 99 | + "endpoint_path": "/api/v2/iac-api/terraform/backends/{id}", |
| 100 | + "operation_id": "update_terraform_backend_sync_config", |
| 101 | + "http_method": "PATCH", |
| 102 | + "version": "v2", |
| 103 | + }, |
| 104 | + params_map={ |
| 105 | + "id": { |
| 106 | + "required": True, |
| 107 | + "openapi_types": (str,), |
| 108 | + "attribute": "id", |
| 109 | + "location": "path", |
| 110 | + }, |
| 111 | + "body": { |
| 112 | + "required": True, |
| 113 | + "openapi_types": (TerraformBackendUpdateRequest,), |
| 114 | + "location": "body", |
| 115 | + }, |
| 116 | + }, |
| 117 | + headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, |
| 118 | + api_client=api_client, |
| 119 | + ) |
| 120 | + |
| 121 | + def create_terraform_backend_sync_config( |
| 122 | + self, |
| 123 | + body: TerraformBackendCreateRequest, |
| 124 | + ) -> TerraformBackendResponse: |
| 125 | + """Create a Terraform backend sync configuration. |
| 126 | +
|
| 127 | + Create a Terraform backend sync configuration for an AWS account, region, and set of S3 buckets. |
| 128 | +
|
| 129 | + :type body: TerraformBackendCreateRequest |
| 130 | + :rtype: TerraformBackendResponse |
| 131 | + """ |
| 132 | + kwargs: Dict[str, Any] = {} |
| 133 | + kwargs["body"] = body |
| 134 | + |
| 135 | + return self._create_terraform_backend_sync_config_endpoint.call_with_http_info(**kwargs) |
| 136 | + |
| 137 | + def delete_terraform_backend_sync_config( |
| 138 | + self, |
| 139 | + id: str, |
| 140 | + ) -> None: |
| 141 | + """Delete a Terraform backend sync configuration. |
| 142 | +
|
| 143 | + Delete a Terraform backend sync configuration and its synchronized state files. |
| 144 | +
|
| 145 | + :param id: Terraform backend sync configuration ID. |
| 146 | + :type id: str |
| 147 | + :rtype: None |
| 148 | + """ |
| 149 | + kwargs: Dict[str, Any] = {} |
| 150 | + kwargs["id"] = id |
| 151 | + |
| 152 | + return self._delete_terraform_backend_sync_config_endpoint.call_with_http_info(**kwargs) |
| 153 | + |
| 154 | + def list_terraform_backend_sync_configs( |
| 155 | + self, |
| 156 | + *, |
| 157 | + account_id: Union[str, UnsetType] = unset, |
| 158 | + ) -> TerraformBackendListResponse: |
| 159 | + """List Terraform backend sync configurations. |
| 160 | +
|
| 161 | + List Terraform backend sync configurations, optionally filtered by AWS account ID. |
| 162 | +
|
| 163 | + :param account_id: AWS account ID used to filter configurations. Omit to list all configurations for the organization. |
| 164 | + :type account_id: str, optional |
| 165 | + :rtype: TerraformBackendListResponse |
| 166 | + """ |
| 167 | + kwargs: Dict[str, Any] = {} |
| 168 | + if account_id is not unset: |
| 169 | + kwargs["account_id"] = account_id |
| 170 | + |
| 171 | + return self._list_terraform_backend_sync_configs_endpoint.call_with_http_info(**kwargs) |
| 172 | + |
| 173 | + def update_terraform_backend_sync_config( |
| 174 | + self, |
| 175 | + id: str, |
| 176 | + body: TerraformBackendUpdateRequest, |
| 177 | + ) -> TerraformBackendResponse: |
| 178 | + """Update a Terraform backend sync configuration. |
| 179 | +
|
| 180 | + Replace the complete set of buckets in a Terraform backend sync configuration. The account and region cannot be changed. The resource ID in the request body must match the path ID; a mismatch returns 409 Conflict. |
| 181 | +
|
| 182 | + :param id: Terraform backend sync configuration ID. |
| 183 | + :type id: str |
| 184 | + :type body: TerraformBackendUpdateRequest |
| 185 | + :rtype: TerraformBackendResponse |
| 186 | + """ |
| 187 | + kwargs: Dict[str, Any] = {} |
| 188 | + kwargs["id"] = id |
| 189 | + |
| 190 | + kwargs["body"] = body |
| 191 | + |
| 192 | + return self._update_terraform_backend_sync_config_endpoint.call_with_http_info(**kwargs) |
0 commit comments