-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathauth_totp_wizard.go
121 lines (105 loc) · 4.1 KB
/
auth_totp_wizard.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package odoo
// AuthTotpWizard represents auth_totp.wizard model.
type AuthTotpWizard struct {
Code *String `xmlrpc:"code,omitempty"`
CreateDate *Time `xmlrpc:"create_date,omitempty"`
CreateUid *Many2One `xmlrpc:"create_uid,omitempty"`
DisplayName *String `xmlrpc:"display_name,omitempty"`
Id *Int `xmlrpc:"id,omitempty"`
Qrcode *String `xmlrpc:"qrcode,omitempty"`
Secret *String `xmlrpc:"secret,omitempty"`
Url *String `xmlrpc:"url,omitempty"`
UserId *Many2One `xmlrpc:"user_id,omitempty"`
WriteDate *Time `xmlrpc:"write_date,omitempty"`
WriteUid *Many2One `xmlrpc:"write_uid,omitempty"`
}
// AuthTotpWizards represents array of auth_totp.wizard model.
type AuthTotpWizards []AuthTotpWizard
// AuthTotpWizardModel is the odoo model name.
const AuthTotpWizardModel = "auth_totp.wizard"
// Many2One convert AuthTotpWizard to *Many2One.
func (aw *AuthTotpWizard) Many2One() *Many2One {
return NewMany2One(aw.Id.Get(), "")
}
// CreateAuthTotpWizard creates a new auth_totp.wizard model and returns its id.
func (c *Client) CreateAuthTotpWizard(aw *AuthTotpWizard) (int64, error) {
ids, err := c.CreateAuthTotpWizards([]*AuthTotpWizard{aw})
if err != nil {
return -1, err
}
if len(ids) == 0 {
return -1, nil
}
return ids[0], nil
}
// CreateAuthTotpWizard creates a new auth_totp.wizard model and returns its id.
func (c *Client) CreateAuthTotpWizards(aws []*AuthTotpWizard) ([]int64, error) {
var vv []interface{}
for _, v := range aws {
vv = append(vv, v)
}
return c.Create(AuthTotpWizardModel, vv, nil)
}
// UpdateAuthTotpWizard updates an existing auth_totp.wizard record.
func (c *Client) UpdateAuthTotpWizard(aw *AuthTotpWizard) error {
return c.UpdateAuthTotpWizards([]int64{aw.Id.Get()}, aw)
}
// UpdateAuthTotpWizards updates existing auth_totp.wizard records.
// All records (represented by ids) will be updated by aw values.
func (c *Client) UpdateAuthTotpWizards(ids []int64, aw *AuthTotpWizard) error {
return c.Update(AuthTotpWizardModel, ids, aw, nil)
}
// DeleteAuthTotpWizard deletes an existing auth_totp.wizard record.
func (c *Client) DeleteAuthTotpWizard(id int64) error {
return c.DeleteAuthTotpWizards([]int64{id})
}
// DeleteAuthTotpWizards deletes existing auth_totp.wizard records.
func (c *Client) DeleteAuthTotpWizards(ids []int64) error {
return c.Delete(AuthTotpWizardModel, ids)
}
// GetAuthTotpWizard gets auth_totp.wizard existing record.
func (c *Client) GetAuthTotpWizard(id int64) (*AuthTotpWizard, error) {
aws, err := c.GetAuthTotpWizards([]int64{id})
if err != nil {
return nil, err
}
return &((*aws)[0]), nil
}
// GetAuthTotpWizards gets auth_totp.wizard existing records.
func (c *Client) GetAuthTotpWizards(ids []int64) (*AuthTotpWizards, error) {
aws := &AuthTotpWizards{}
if err := c.Read(AuthTotpWizardModel, ids, nil, aws); err != nil {
return nil, err
}
return aws, nil
}
// FindAuthTotpWizard finds auth_totp.wizard record by querying it with criteria.
func (c *Client) FindAuthTotpWizard(criteria *Criteria) (*AuthTotpWizard, error) {
aws := &AuthTotpWizards{}
if err := c.SearchRead(AuthTotpWizardModel, criteria, NewOptions().Limit(1), aws); err != nil {
return nil, err
}
return &((*aws)[0]), nil
}
// FindAuthTotpWizards finds auth_totp.wizard records by querying it
// and filtering it with criteria and options.
func (c *Client) FindAuthTotpWizards(criteria *Criteria, options *Options) (*AuthTotpWizards, error) {
aws := &AuthTotpWizards{}
if err := c.SearchRead(AuthTotpWizardModel, criteria, options, aws); err != nil {
return nil, err
}
return aws, nil
}
// FindAuthTotpWizardIds finds records ids by querying it
// and filtering it with criteria and options.
func (c *Client) FindAuthTotpWizardIds(criteria *Criteria, options *Options) ([]int64, error) {
return c.Search(AuthTotpWizardModel, criteria, options)
}
// FindAuthTotpWizardId finds record id by querying it with criteria.
func (c *Client) FindAuthTotpWizardId(criteria *Criteria, options *Options) (int64, error) {
ids, err := c.Search(AuthTotpWizardModel, criteria, options)
if err != nil {
return -1, err
}
return ids[0], nil
}