forked from rancher/go-rancher
/
generated_audit_log.go
105 lines (79 loc) · 3.1 KB
/
generated_audit_log.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
93
94
95
96
97
98
99
100
101
102
103
104
105
package client
const (
AUDIT_LOG_TYPE = "auditLog"
)
type AuditLog struct {
Resource
AccountId string `json:"accountId,omitempty" yaml:"account_id,omitempty"`
AuthType string `json:"authType,omitempty" yaml:"auth_type,omitempty"`
AuthenticatedAsAccountId string `json:"authenticatedAsAccountId,omitempty" yaml:"authenticated_as_account_id,omitempty"`
AuthenticatedAsIdentityId string `json:"authenticatedAsIdentityId,omitempty" yaml:"authenticated_as_identity_id,omitempty"`
ClientIp string `json:"clientIp,omitempty" yaml:"client_ip,omitempty"`
Created string `json:"created,omitempty" yaml:"created,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
EventType string `json:"eventType,omitempty" yaml:"event_type,omitempty"`
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
RequestObject string `json:"requestObject,omitempty" yaml:"request_object,omitempty"`
ResourceId int64 `json:"resourceId,omitempty" yaml:"resource_id,omitempty"`
ResourceType string `json:"resourceType,omitempty" yaml:"resource_type,omitempty"`
ResponseCode string `json:"responseCode,omitempty" yaml:"response_code,omitempty"`
ResponseObject string `json:"responseObject,omitempty" yaml:"response_object,omitempty"`
}
type AuditLogCollection struct {
Collection
Data []AuditLog `json:"data,omitempty"`
client *AuditLogClient
}
type AuditLogClient struct {
rancherClient *RancherClient
}
type AuditLogOperations interface {
List(opts *ListOpts) (*AuditLogCollection, error)
Create(opts *AuditLog) (*AuditLog, error)
Update(existing *AuditLog, updates interface{}) (*AuditLog, error)
ById(id string) (*AuditLog, error)
Delete(container *AuditLog) error
}
func newAuditLogClient(rancherClient *RancherClient) *AuditLogClient {
return &AuditLogClient{
rancherClient: rancherClient,
}
}
func (c *AuditLogClient) Create(container *AuditLog) (*AuditLog, error) {
resp := &AuditLog{}
err := c.rancherClient.doCreate(AUDIT_LOG_TYPE, container, resp)
return resp, err
}
func (c *AuditLogClient) Update(existing *AuditLog, updates interface{}) (*AuditLog, error) {
resp := &AuditLog{}
err := c.rancherClient.doUpdate(AUDIT_LOG_TYPE, &existing.Resource, updates, resp)
return resp, err
}
func (c *AuditLogClient) List(opts *ListOpts) (*AuditLogCollection, error) {
resp := &AuditLogCollection{}
err := c.rancherClient.doList(AUDIT_LOG_TYPE, opts, resp)
resp.client = c
return resp, err
}
func (cc *AuditLogCollection) Next() (*AuditLogCollection, error) {
if cc != nil && cc.Pagination != nil && cc.Pagination.Next != "" {
resp := &AuditLogCollection{}
err := cc.client.rancherClient.doNext(cc.Pagination.Next, resp)
resp.client = cc.client
return resp, err
}
return nil, nil
}
func (c *AuditLogClient) ById(id string) (*AuditLog, error) {
resp := &AuditLog{}
err := c.rancherClient.doById(AUDIT_LOG_TYPE, id, resp)
if apiError, ok := err.(*ApiError); ok {
if apiError.StatusCode == 404 {
return nil, nil
}
}
return resp, err
}
func (c *AuditLogClient) Delete(container *AuditLog) error {
return c.rancherClient.doResourceDelete(AUDIT_LOG_TYPE, &container.Resource)
}