-
Notifications
You must be signed in to change notification settings - Fork 14
/
iam_apikey.go
92 lines (76 loc) · 2.58 KB
/
iam_apikey.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package egoscale
// APIKeyType holds the type of the API key
type APIKeyType string
const (
// APIKeyTypeUnrestricted is unrestricted
APIKeyTypeUnrestricted APIKeyType = "unrestricted"
// APIKeyTypeRestricted is restricted
APIKeyTypeRestricted APIKeyType = "restricted"
)
// APIKey represents an API key
type APIKey struct {
Name string `json:"name"`
Key string `json:"key"`
Secret string `json:"secret,omitempty"`
Operations []string `json:"operations,omitempty"`
Resources []string `json:"resources,omitempty"`
Type APIKeyType `json:"type"`
}
// CreateAPIKey represents an API key creation
type CreateAPIKey struct {
Name string `json:"name"`
Operations string `json:"operations,omitempty"`
Resources string `json:"resources,omitempty"`
_ bool `name:"createApiKey" description:"Create an API key."`
}
// Response returns the struct to unmarshal
func (CreateAPIKey) Response() interface{} {
return new(APIKey)
}
// ListAPIKeys represents a search for API keys
type ListAPIKeys struct {
_ bool `name:"listApiKeys" description:"List API keys."`
}
// ListAPIKeysResponse represents a list of API keys
type ListAPIKeysResponse struct {
Count int `json:"count"`
APIKeys []APIKey `json:"apikey"`
}
// Response returns the struct to unmarshal
func (ListAPIKeys) Response() interface{} {
return new(ListAPIKeysResponse)
}
// ListAPIKeyOperations represents a search for operations for the current API key
type ListAPIKeyOperations struct {
_ bool `name:"listApiKeyOperations" description:"List operations allowed for the current API key."`
}
// ListAPIKeyOperationsResponse represents a list of operations for the current API key
type ListAPIKeyOperationsResponse struct {
Operations []string `json:"operations"`
}
// Response returns the struct to unmarshal
func (ListAPIKeyOperations) Response() interface{} {
return new(ListAPIKeyOperationsResponse)
}
// GetAPIKey get an API key
type GetAPIKey struct {
Key string `json:"key"`
_ bool `name:"getApiKey" description:"Get an API key."`
}
// Response returns the struct to unmarshal
func (GetAPIKey) Response() interface{} {
return new(APIKey)
}
// RevokeAPIKey represents a revocation of an API key
type RevokeAPIKey struct {
Key string `json:"key"`
_ bool `name:"revokeApiKey" description:"Revoke an API key."`
}
// RevokeAPIKeyResponse represents the response to an API key revocation
type RevokeAPIKeyResponse struct {
Success bool `json:"success"`
}
// Response returns the struct to unmarshal
func (RevokeAPIKey) Response() interface{} {
return new(RevokeAPIKeyResponse)
}