-
Notifications
You must be signed in to change notification settings - Fork 6
/
results.go
66 lines (56 loc) · 1.71 KB
/
results.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package certificates
import (
"github.com/huaweicloud/terraform-provider-hcs/huaweicloudstack/sdk/huaweicloud"
"github.com/huaweicloud/terraform-provider-hcs/huaweicloudstack/sdk/huaweicloud/pagination"
)
type Certificate struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Type string `json:"type"`
Domain string `json:"domain"`
PrivateKey string `json:"private_key"`
Certificate string `json:"certificate"`
CreateTime string `json:"create_time"`
UpdateTime string `json:"update_time"`
ExpireTime string `json:"expire_time"`
}
// CertificatePage is the page returned by a pager when traversing over a
// collection of certificates.
type CertificatePage struct {
pagination.SinglePageBase
}
// ExtractCertificates accepts a Page struct, specifically a CertificatePage struct,
// and extracts the elements into a slice of Certificate structs. In other words,
// a generic collection is mapped into a relevant slice.
func ExtractCertificates(r pagination.Page) ([]Certificate, error) {
var s struct {
Certificates []Certificate `json:"certificates"`
}
err := (r.(CertificatePage)).ExtractInto(&s)
return s.Certificates, err
}
type commonResult struct {
golangsdk.Result
}
func (r commonResult) Extract() (*Certificate, error) {
var s struct {
Certificate *Certificate `json:"certificate"`
}
err := r.ExtractInto(&s)
return s.Certificate, err
}
type CreateResult struct {
commonResult
}
// GetResult represents the result of a get operation.
type GetResult struct {
commonResult
}
type UpdateResult struct {
commonResult
}
// DeleteResult represents the result of a delete operation.
type DeleteResult struct {
golangsdk.ErrResult
}