-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dataarts/apis): add new resource to query apis under catalog
- Loading branch information
1 parent
3e9b564
commit 2a810ef
Showing
4 changed files
with
508 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
--- | ||
subcategory: "DataArts Studio" | ||
layout: "huaweicloud" | ||
page_title: "HuaweiCLoud: huaweicloud_dataarts_dataservice_catalog_apis" | ||
description: |- | ||
Use this data source to get the list of Data Service APIs under a specified catalog within HuaweiCloud. | ||
--- | ||
|
||
# huaweicloud_dataarts_dataservice_catalog_apis | ||
|
||
Use this data source to get the list of Data Service APIs under a specified catalog within HuaweiCloud. | ||
|
||
## Example Usage | ||
|
||
```hcl | ||
variable "workspace_id" {} | ||
variable "catalog_id" {} | ||
data "huaweicloud_dataarts_dataservice_catalog_apis" "test" { | ||
workspace_id = var.workspace_id | ||
dlm_type = "EXCLUSIVE" | ||
catalog_id = var.catalog_id | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
|
||
* `region` - (Optional, String) Specifies the region in which to query the data source. | ||
If omitted, the provider-level region will be used. | ||
|
||
* `workspace_id` - (Required, String) Specifies the ID of workspace where the APIs are located. | ||
|
||
* `dlm_type` - (Optional, String) Specifies the type of DLM engine. | ||
The valid values are as follows: | ||
+ **SHARED**: The shared data service. | ||
+ **EXCLUSIVE**: The exclusive data service. | ||
|
||
Defaults to **SHARED**. | ||
|
||
* `catalog_id` - (Optional, String) Specifies the ID of the catalog to which the APIs belong. | ||
|
||
## Attribute Reference | ||
|
||
In addition to all arguments above, the following attributes are exported: | ||
|
||
* `id` - The data source ID. | ||
|
||
* `apis` - All API summaries that under the specified catalog. | ||
The [apis](#dataservice_api_summaries_under_catalog) structure is documented below. | ||
|
||
<a name="dataservice_api_summaries_under_catalog"></a> | ||
The `apis` block supports: | ||
|
||
* `id` - The API ID, in UUID format. | ||
|
||
* `name` - The API name. | ||
|
||
* `description` - The description of the API. | ||
|
||
* `group_id` - The ID of the group to which the shared API belongs. | ||
|
||
* `status` - The status of the shared API. | ||
+ **API_STATUS_CREATED**: API has been created. | ||
+ **API_STATUS_PUBLISH_WAIT_REVIEW**: Release review status. | ||
+ **API_STATUS_PUBLISH_REJECT**: Rejection status. | ||
+ **API_STATUS_PUBLISHED**: Released status. | ||
+ **API_STATUS_WAITING_STOP**: Disable review status. | ||
+ **API_STATUS_STOPPED**: Disabled status. | ||
+ **API_STATUS_RECOVER_WAIT_REVIEW**: Recover review status. | ||
+ **API_STATUS_WAITING_OFFLINE**: Offline review status. | ||
+ **API_STATUS_OFFLINE**: Already offline. | ||
+ **API_STATUS_OFFLINE_WAIT_REVIEW**: Offline pending review status. | ||
|
||
* `debug_status` - The debug status of the shared API. | ||
+ **API_DEBUG_WAITING**: Waiting for debugging. | ||
+ **API_DEBUG_FAILED**: Debugging failed. | ||
+ **API_DEBUG_SUCCESS**: Debugging successful. | ||
|
||
* `publish_messages` - All publish messages of the exclusive API. | ||
The [publish_messages](#datasource_api_publish_messages_under_catalog) structure is documented below. | ||
|
||
* `type` - The API type. | ||
+ **API_SPECIFIC_TYPE_CONFIGURATION**: Configuration API | ||
+ **API_SPECIFIC_TYPE_SCRIPT**: Script API | ||
+ **API_SPECIFIC_TYPE_REGISTER**: Registration API | ||
|
||
* `manager` - The API reviewer. | ||
|
||
* `created_at` - The creation time of the API, in RFC3339 format. | ||
|
||
* `authorization_status` - The authorization status of the API. | ||
+ **NO_AUTHORIZATION_REQUIRED**: No authorization required. | ||
+ **UNAUTHORIZED**: Unauthorized. | ||
+ **AUTHORIZED**: Authorized. | ||
|
||
<a name="datasource_api_publish_messages_under_catalog"></a> | ||
The `publish_messages` block supports: | ||
|
||
* `id` - The publish ID, in UUID format. | ||
|
||
* `instance_id` - The ID of the instance used to publish the exclusive API. | ||
|
||
* `instance_name` - The name of the instance used to publish the exclusive API. | ||
|
||
* `api_status` - The publish status of the exclusive API. | ||
+ **API_STATUS_CREATED**: API has been created. | ||
+ **API_STATUS_PUBLISH_WAIT_REVIEW**: Release review status. | ||
+ **API_STATUS_PUBLISH_REJECT**: Rejection status. | ||
+ **API_STATUS_PUBLISHED**: Released status. | ||
+ **API_STATUS_WAITING_STOP**: Disable review status. | ||
+ **API_STATUS_STOPPED**: Disabled status. | ||
+ **API_STATUS_RECOVER_WAIT_REVIEW**: Recover review status. | ||
+ **API_STATUS_WAITING_OFFLINE**: Offline review status. | ||
+ **API_STATUS_OFFLINE**: Already offline. | ||
+ **API_STATUS_OFFLINE_WAIT_REVIEW**: Offline pending review status. | ||
|
||
* `api_debug` - The debug status of the exclusive API. | ||
+ **API_DEBUG_WAITING**: Waiting for debugging. | ||
+ **API_DEBUG_FAILED**: Debugging failed. | ||
+ **API_DEBUG_SUCCESS**: Debugging successful. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
...ces/acceptance/dataarts/data_source_huaweicloud_dataarts_dataservice_catalog_apis_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package dataarts | ||
|
||
import ( | ||
"fmt" | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/huaweicloud/terraform-provider-huaweicloud/huaweicloud/services/acceptance" | ||
) | ||
|
||
// Query exclusive API that they are not published. | ||
func TestAccDataSourceDataServiceCatalogApis_basic(t *testing.T) { | ||
var ( | ||
rName = "data.huaweicloud_dataarts_dataservice_catalog_apis.test" | ||
dc = acceptance.InitDataSourceCheck(rName) | ||
) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
acceptance.TestAccPreCheck(t) | ||
acceptance.TestAccPreCheckDataArtsWorkSpaceID(t) | ||
acceptance.TestAccPreCheckDataArtsReviewerName(t) | ||
acceptance.TestAccPreCheckDataArtsConnectionID(t) | ||
acceptance.TestAccPreCheckDataArtsRelatedDliQueueName(t) | ||
}, | ||
ProviderFactories: acceptance.TestAccProviderFactories, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccDataSourceDataServiceCatalogApis_basic(), | ||
Check: resource.ComposeTestCheckFunc( | ||
dc.CheckResourceExists(), | ||
resource.TestMatchResourceAttr(rName, "apis.#", regexp.MustCompile(`^[1-9]([0-9]*)?$`)), | ||
resource.TestCheckResourceAttrSet(rName, "apis.0.id"), | ||
resource.TestCheckResourceAttrSet(rName, "apis.0.name"), | ||
resource.TestCheckResourceAttrSet(rName, "apis.0.description"), | ||
resource.TestCheckResourceAttrSet(rName, "apis.0.type"), | ||
resource.TestCheckResourceAttrSet(rName, "apis.0.manager"), | ||
resource.TestMatchResourceAttr(rName, "apis.0.created_at", | ||
regexp.MustCompile(`^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}?(Z|([+-]\d{2}:\d{2}))$`)), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccDataSourceDataServiceCatalogApis_basic() string { | ||
name := acceptance.RandomAccResourceName() | ||
|
||
return fmt.Sprintf(` | ||
resource "huaweicloud_dli_database" "test" { | ||
name = "%[1]s" | ||
} | ||
resource "huaweicloud_dli_table" "test" { | ||
database_name = huaweicloud_dli_database.test.name | ||
name = "%[1]s" | ||
data_location = "DLI" | ||
columns { | ||
name = "configuration" | ||
type = "string" | ||
description = "The configuration for automatic creation, in JSON format" | ||
} | ||
} | ||
// Under root path. | ||
resource "huaweicloud_dataarts_dataservice_catalog" "test" { | ||
workspace_id = "%[2]s" | ||
dlm_type = "EXCLUSIVE" | ||
name = "%[1]s" | ||
} | ||
resource "huaweicloud_dataarts_dataservice_api" "test" { | ||
count = 2 | ||
workspace_id = "%[2]s" | ||
dlm_type = "EXCLUSIVE" | ||
type = "API_SPECIFIC_TYPE_CONFIGURATION" | ||
catalog_id = huaweicloud_dataarts_dataservice_catalog.test.id | ||
name = format("%[1]s_%%d", count.index) | ||
description = "Created by terraform script" | ||
auth_type = "NONE" | ||
manager = "%[3]s" | ||
path = format("/%[1]s/%%d", count.index) | ||
protocol = "PROTOCOL_TYPE_HTTPS" | ||
request_type = "REQUEST_TYPE_GET" | ||
visibility = "PROJECT" | ||
datasource_config { | ||
type = "DLI" | ||
connection_id = "%[4]s" | ||
database = huaweicloud_dli_database.test.name | ||
datatable = huaweicloud_dli_table.test.name | ||
queue = "%[5]s" | ||
response_params { | ||
name = "configuration" | ||
type = "REQUEST_PARAMETER_TYPE_STRING" | ||
field = "configuration" | ||
} | ||
} | ||
} | ||
data "huaweicloud_dataarts_dataservice_catalog_apis" "test" { | ||
depends_on = [ | ||
huaweicloud_dataarts_dataservice_api.test | ||
] | ||
workspace_id = "%[2]s" | ||
dlm_type = "EXCLUSIVE" | ||
catalog_id = huaweicloud_dataarts_dataservice_catalog.test.id | ||
} | ||
`, name, | ||
acceptance.HW_DATAARTS_WORKSPACE_ID, | ||
acceptance.HW_DATAARTS_REVIEWER_NAME, | ||
acceptance.HW_DATAARTS_CONNECTION_ID, | ||
acceptance.HW_DATAARTS_DLI_QUEUE_NAME) | ||
} |
Oops, something went wrong.