Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 5002410

Browse files
authored
Merge pull request #110 from tomvachon/feature/cloudsearch
Add CloudSearch
2 parents dd868dc + 0666077 commit 5002410

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

resources/cloudsearch-domains.go

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package resources
2+
3+
import (
4+
"github.com/aws/aws-sdk-go/aws/session"
5+
"github.com/aws/aws-sdk-go/service/cloudsearch"
6+
)
7+
8+
type CloudSearchDomain struct {
9+
svc *cloudsearch.CloudSearch
10+
domainName *string
11+
}
12+
13+
func init() {
14+
register("CloudSearchDomain", ListCloudSearchDomains)
15+
}
16+
17+
func ListCloudSearchDomains(sess *session.Session) ([]Resource, error) {
18+
svc := cloudsearch.New(sess)
19+
20+
params := &cloudsearch.DescribeDomainsInput{}
21+
22+
resp, err := svc.DescribeDomains(params)
23+
if err != nil {
24+
return nil, err
25+
}
26+
27+
resources := make([]Resource, 0)
28+
for _, domain := range resp.DomainStatusList {
29+
resources = append(resources, &CloudSearchDomain{
30+
svc: svc,
31+
domainName: domain.DomainName,
32+
})
33+
}
34+
return resources, nil
35+
}
36+
37+
func (f *CloudSearchDomain) Remove() error {
38+
39+
_, err := f.svc.DeleteDomain(&cloudsearch.DeleteDomainInput{
40+
DomainName: f.domainName,
41+
})
42+
43+
return err
44+
}
45+
46+
func (f *CloudSearchDomain) String() string {
47+
return *f.domainName
48+
}

0 commit comments

Comments
 (0)