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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
41 changes: 20 additions & 21 deletions gendoc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package main

import (
"fmt"
"go/parser"
"go/token"
"os"
"path/filepath"
"reflect"
Expand All @@ -16,6 +14,7 @@ import (
"github.com/fatih/color"
"github.com/hashicorp/hcl/v2/hclwrite"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"

cloud "github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud"
)

Expand All @@ -28,9 +27,10 @@ const (
)

var (
hclMatch = regexp.MustCompile("(?si)([^`]+)?```(hcl)?(.*?)```")
usageMatch = regexp.MustCompile(`(?s)(?m)^([^ \n].*?)(?:\n{2}|$)(.*)`)
bigSymbol = regexp.MustCompile("([\u007F-\uffff])")
hclMatch = regexp.MustCompile("(?si)([^`]+)?```(hcl)?(.*?)```")
usageMatch = regexp.MustCompile(`(?s)(?m)^([^ \n].*?)(?:\n{2}|$)(.*)`)
bigSymbol = regexp.MustCompile("([\u007F-\uffff])")
productNameRegexp = regexp.MustCompile(`^.*\((.*)\)$`)
)

func main() {
Expand Down Expand Up @@ -59,15 +59,16 @@ func main() {

// genIdx generating index for resource
func genIdx(filePath string) (prods []Product) {
filename := "provider.go"
filename := "provider.md"

message("[START]get description from file: %s\n", filename)

description, err := getFileDescription(filepath.Join(filePath, filename))
raw, err := os.ReadFile(filepath.Join(filePath, filename))
if err != nil {
message("[SKIP!]get description failed, skip: %s", err)
return
}
description := string(raw)

description = strings.TrimSpace(description)
if description == "" {
Expand Down Expand Up @@ -132,14 +133,24 @@ func genDoc(product, dtype, fpath, name string, resource *schema.Resource) {
"import": "",
}

filename := fmt.Sprintf("%s_%s_%s.go", dtype, cloudMarkShort, data["resource"])
productDir := strings.ToLower(product)
groups := productNameRegexp.FindStringSubmatch(productDir)
if groups != nil {
productDir = groups[1]
}
if productDir == "provider data sources" {
productDir = "common"
}

filename := fmt.Sprintf("%s/%s_%s_%s.md", productDir, dtype, cloudMarkShort, data["resource"])
message("[START]get description from file: %s\n", filename)

description, err := getFileDescription(filepath.Join(fpath, filename))
raw, err := os.ReadFile(filepath.Join(fpath, filename))
if err != nil {
message("[FAIL!]get description failed: %s", err)
os.Exit(1)
}
description := string(raw)

description = strings.TrimSpace(description)
if description == "" {
Expand Down Expand Up @@ -334,18 +345,6 @@ func getAttributes(step int, k string, v *schema.Schema) []string {
return attributes
}

// getFileDescription get description from go file
func getFileDescription(fname string) (string, error) {
fset := token.NewFileSet()

parsedAst, err := parser.ParseFile(fset, fname, nil, parser.ParseComments)
if err != nil {
return "", err
}

return parsedAst.Doc.Text(), nil
}

// getSubStruct get sub structure from go file
func getSubStruct(step int, k string, v *schema.Schema) []string {
var subStructs []string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Use this data source to query detailed information of antiddos basic_device_status

Example Usage

```hcl
data "tencentcloud_antiddos_basic_device_status" "basic_device_status" {
ip_list = [
"127.0.0.1"
]
filter_region = 1
}
```
14 changes: 14 additions & 0 deletions tencentcloud/antiddos/data_source_tc_antiddos_bgp_biz_trend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Use this data source to query detailed information of antiddos bgp_biz_trend

Example Usage

```hcl
data "tencentcloud_antiddos_bgp_biz_trend" "bgp_biz_trend" {
business = "bgp-multip"
start_time = "2023-11-22 09:25:00"
end_time = "2023-11-22 10:25:00"
metric_name = "intraffic"
instance_id = "bgp-00000ry7"
flag = 0
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Use this data source to query detailed information of antiddos list_listener

Example Usage

```hcl
data "tencentcloud_antiddos_list_listener" "list_listener" {
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Use this data source to query detailed information of antiddos overview_attack_trend

Example Usage

```hcl
data "tencentcloud_antiddos_overview_attack_trend" "overview_attack_trend" {
type = "ddos"
dimension = "attackcount"
period = 86400
start_time = "2023-11-21 10:28:31"
end_time = "2023-11-22 10:28:31"
}
```
11 changes: 11 additions & 0 deletions tencentcloud/apigateway/data_source_tc_api_gateway_api_app_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Use this data source to query detailed information of apiGateway api_app_api

Example Usage

```hcl
data "tencentcloud_api_gateway_api_app_api" "example" {
service_id = "service-nxz6yync"
api_id = "api-0cvmf4x4"
api_region = "ap-guangzhou"
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Use this data source to query detailed information of apigateway api_app_services

Example Usage

```hcl
data "tencentcloud_api_gateway_api_app_service" "example" {
service_id = tencentcloud_api_gateway_api.example.service_id
api_region = "ap-guangzhou"
}

resource "tencentcloud_api_gateway_service" "example" {
service_name = "tf_example"
protocol = "http&https"
service_desc = "desc."
net_type = ["INNER", "OUTER"]
ip_version = "IPv4"
}

resource "tencentcloud_api_gateway_api" "example" {
service_id = tencentcloud_api_gateway_service.example.id
api_name = "tf_example"
api_desc = "my hello api update"
auth_type = "APP"
protocol = "HTTP"
enable_cors = true
request_config_path = "/user/info"
request_config_method = "POST"
request_parameters {
name = "email"
position = "QUERY"
type = "string"
desc = "desc."
default_value = "test@qq.com"
required = true
}
service_config_type = "HTTP"
service_config_timeout = 10
service_config_url = "http://www.tencent.com"
service_config_path = "/user"
service_config_method = "POST"
response_type = "XML"
response_success_example = "<note>success</note>"
response_fail_example = "<note>fail</note>"
response_error_codes {
code = 500
msg = "system error"
desc = "system error code"
converted_code = 5000
need_convert = true
}
}
```
10 changes: 10 additions & 0 deletions tencentcloud/apigateway/data_source_tc_api_gateway_api_apps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Use this data source to query list information of api_gateway api_app

Example Usage

```hcl
data "tencentcloud_api_gateway_api_apps" "test" {
api_app_id = ["app-rj8t6zx3"]
api_app_name = ["app_test"]
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Use this data source to query list information of api_gateway api_doc
Example Usage
```hcl
data "tencentcloud_api_gateway_api_docs" "my_api_doc" {
}
```
18 changes: 18 additions & 0 deletions tencentcloud/apigateway/data_source_tc_api_gateway_api_keys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Use this data source to query API gateway access keys.

Example Usage

```hcl
resource "tencentcloud_api_gateway_api_key" "test" {
secret_name = "my_api_key"
status = "on"
}

data "tencentcloud_api_gateway_api_keys" "name" {
secret_name = tencentcloud_api_gateway_api_key.test.secret_name
}

data "tencentcloud_api_gateway_api_keys" "id" {
api_key_id = tencentcloud_api_gateway_api_key.test.id
}
```
11 changes: 11 additions & 0 deletions tencentcloud/apigateway/data_source_tc_api_gateway_api_plugins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Use this data source to query detailed information of apiGateway api_plugins

Example Usage

```hcl
data "tencentcloud_api_gateway_api_plugins" "example" {
api_id = "api-0cvmf4x4"
service_id = "service-nxz6yync"
environment_name = "test"
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Use this data source to query detailed information of apigateway api_usage_plan

Example Usage

```hcl
data "tencentcloud_api_gateway_api_usage_plans" "example" {
service_id = tencentcloud_api_gateway_usage_plan_attachment.example.service_id
}

resource "tencentcloud_api_gateway_usage_plan" "example" {
usage_plan_name = "tf_example"
usage_plan_desc = "desc."
max_request_num = 100
max_request_num_pre_sec = 10
}

resource "tencentcloud_api_gateway_service" "example" {
service_name = "tf_example"
protocol = "http&https"
service_desc = "desc."
net_type = ["INNER", "OUTER"]
ip_version = "IPv4"
}

resource "tencentcloud_api_gateway_api" "example" {
service_id = tencentcloud_api_gateway_service.example.id
api_name = "tf_example"
api_desc = "my hello api update"
auth_type = "SECRET"
protocol = "HTTP"
enable_cors = true
request_config_path = "/user/info"
request_config_method = "POST"
request_parameters {
name = "email"
position = "QUERY"
type = "string"
desc = "desc."
default_value = "test@qq.com"
required = true
}
service_config_type = "HTTP"
service_config_timeout = 10
service_config_url = "http://www.tencent.com"
service_config_path = "/user"
service_config_method = "POST"
response_type = "XML"
response_success_example = "<note>success</note>"
response_fail_example = "<note>fail</note>"
response_error_codes {
code = 500
msg = "system error"
desc = "system error code"
converted_code = 5000
need_convert = true
}
}

resource "tencentcloud_api_gateway_usage_plan_attachment" "example" {
usage_plan_id = tencentcloud_api_gateway_usage_plan.example.id
service_id = tencentcloud_api_gateway_service.example.id
environment = "release"
bind_type = "API"
api_id = tencentcloud_api_gateway_api.example.id
}
```
42 changes: 42 additions & 0 deletions tencentcloud/apigateway/data_source_tc_api_gateway_apis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Use this data source to query API gateway APIs.

Example Usage

```hcl
resource "tencentcloud_api_gateway_service" "service" {
service_name = "ck"
protocol = "http&https"
service_desc = "your nice service"
net_type = ["INNER", "OUTER"]
ip_version = "IPv4"
}

resource "tencentcloud_api_gateway_api" "api" {
service_id = tencentcloud_api_gateway_service.service.id
api_name = "hello"
api_desc = "my hello api"
auth_type = "NONE"
protocol = "HTTP"
enable_cors = true
request_config_path = "/user/info"
request_config_method = "GET"
service_config_type = "HTTP"
service_config_timeout = 15
service_config_url = "http://www.qq.com"
service_config_path = "/user"
service_config_method = "GET"
response_type = "HTML"
response_success_example = "success"
response_fail_example = "fail"
}

data "tencentcloud_api_gateway_apis" "id" {
service_id = tencentcloud_api_gateway_service.service.id
api_id = tencentcloud_api_gateway_api.api.id
}

data "tencentcloud_api_gateway_apis" "name" {
service_id = tencentcloud_api_gateway_service.service.id
api_name = tencentcloud_api_gateway_api.api.api_name
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Use this data source to query detailed information of apiGateway bind_api_apps_status

Example Usage

```hcl
data "tencentcloud_api_gateway_bind_api_apps_status" "example" {
service_id = "service-nxz6yync"
api_ids = ["api-0cvmf4x4", "api-jvqlzolk"]
filters {
name = "ApiAppId"
values = ["app-krljp4wn"]
}
}
```
Loading