-
Notifications
You must be signed in to change notification settings - Fork 11
/
opensearch_auth_settings.go
40 lines (34 loc) · 1.2 KB
/
opensearch_auth_settings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package mdb
import (
"context"
"fmt"
"github.com/cloudquery/plugin-sdk/v4/schema"
"github.com/cloudquery/plugin-sdk/v4/transformers"
"github.com/yandex-cloud/cq-source-yc/client"
"github.com/yandex-cloud/go-genproto/yandex/cloud/mdb/opensearch/v1"
)
func OpenSearchAuthSettings() *schema.Table {
return &schema.Table{
Name: "yc_mdb_opensearch_auth_settings",
Description: `https://cloud.yandex.ru/docs/managed-opensearch/api-ref/grpc/cluster_service#AuthSettings`,
Resolver: fetchOpenSearchAuthSettings,
Transform: client.TransformWithStruct(&opensearch.AuthSettings{}, transformers.WithUnwrapStructFields("Saml")),
Columns: schema.ColumnList{
client.CloudIdColumn,
clusterIdColumn,
},
}
}
func fetchOpenSearchAuthSettings(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
c := meta.(*client.Client)
cluster, ok := parent.Item.(*opensearch.Cluster)
if !ok {
return fmt.Errorf("parent is not type of *opensearch.Cluster: %+v", cluster)
}
resp, err := c.SDK.MDB().OpenSearch().Cluster().GetAuthSettings(ctx, &opensearch.GetAuthSettingsRequest{ClusterId: cluster.Id})
if err != nil {
return err
}
res <- resp
return nil
}