github.com/GoogleCloudPlatform/terraformer@v0.8.18/providers/tencentcloud/cfs.go (about)

     1  // Copyright 2021 The Terraformer Authors.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package tencentcloud
    16  
    17  import (
    18  	"github.com/GoogleCloudPlatform/terraformer/terraformutils"
    19  	cfs "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cfs/v20190719"
    20  	"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
    21  )
    22  
    23  type CfsGenerator struct {
    24  	TencentCloudService
    25  }
    26  
    27  func (g *CfsGenerator) InitResources() error {
    28  	args := g.GetArgs()
    29  	region := args["region"].(string)
    30  	credential := args["credential"].(common.Credential)
    31  	profile := NewTencentCloudClientProfile()
    32  	client, err := cfs.NewClient(&credential, region, profile)
    33  	if err != nil {
    34  		return err
    35  	}
    36  
    37  	request := cfs.NewDescribeCfsFileSystemsRequest()
    38  	response, err := client.DescribeCfsFileSystems(request)
    39  	if err != nil {
    40  		return err
    41  	}
    42  
    43  	for _, instance := range response.Response.FileSystems {
    44  		resource := terraformutils.NewResource(
    45  			*instance.FileSystemId,
    46  			*instance.FsName+"_"+*instance.FileSystemId,
    47  			"tencentcloud_cfs_file_system",
    48  			"tencentcloud",
    49  			map[string]string{},
    50  			[]string{},
    51  			map[string]interface{}{},
    52  		)
    53  		g.Resources = append(g.Resources, resource)
    54  	}
    55  
    56  	return nil
    57  }