Separate accounts/host catalogs/host sets into their own packages (#311)
This commit is contained in:
1 parent
936c970635
commit
17ecb6f2ce
64 files changed
+2298
-2265
No files matched your search
+14
-14
@@ -29,15 +29,15 @@ type Role struct {
|
||||
Grants []*Grant `json:"grants,omitempty"`
|
||||
}
|
||||
|
||||
type RolesClient struct {
|
||||
type Client struct {
|
||||
client *api.Client
|
||||
}
|
||||
|
||||
func NewRolesClient(c *api.Client) *RolesClient {
|
||||
return &RolesClient{client: c}
|
||||
func NewClient(c *api.Client) *Client {
|
||||
return &Client{client: c}
|
||||
}
|
||||
|
||||
func (c *RolesClient) Create(ctx context.Context, opt ...Option) (*Role, *api.Error, error) {
|
||||
func (c *Client) Create(ctx context.Context, opt ...Option) (*Role, *api.Error, error) {
|
||||
opts, apiOpts := getOpts(opt...)
|
||||
if c.client == nil {
|
||||
return nil, nil, fmt.Errorf("nil client")
|
||||
@@ -72,7 +72,7 @@ func (c *RolesClient) Create(ctx context.Context, opt ...Option) (*Role, *api.Er
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *RolesClient) Read(ctx context.Context, roleId string, opt ...Option) (*Role, *api.Error, error) {
|
||||
func (c *Client) Read(ctx context.Context, roleId string, opt ...Option) (*Role, *api.Error, error) {
|
||||
if roleId == "" {
|
||||
return nil, nil, fmt.Errorf("empty roleId value passed into Read request")
|
||||
}
|
||||
@@ -112,7 +112,7 @@ func (c *RolesClient) Read(ctx context.Context, roleId string, opt ...Option) (*
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *RolesClient) Update(ctx context.Context, roleId string, version uint32, opt ...Option) (*Role, *api.Error, error) {
|
||||
func (c *Client) Update(ctx context.Context, roleId string, version uint32, opt ...Option) (*Role, *api.Error, error) {
|
||||
if roleId == "" {
|
||||
return nil, nil, fmt.Errorf("empty roleId value passed into Update request")
|
||||
}
|
||||
@@ -170,7 +170,7 @@ func (c *RolesClient) Update(ctx context.Context, roleId string, version uint32,
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *RolesClient) Delete(ctx context.Context, roleId string, opt ...Option) (bool, *api.Error, error) {
|
||||
func (c *Client) Delete(ctx context.Context, roleId string, opt ...Option) (bool, *api.Error, error) {
|
||||
if roleId == "" {
|
||||
return false, nil, fmt.Errorf("empty roleId value passed into Delete request")
|
||||
}
|
||||
@@ -213,7 +213,7 @@ func (c *RolesClient) Delete(ctx context.Context, roleId string, opt ...Option)
|
||||
return target.Existed, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *RolesClient) List(ctx context.Context, opt ...Option) ([]*Role, *api.Error, error) {
|
||||
func (c *Client) List(ctx context.Context, opt ...Option) ([]*Role, *api.Error, error) {
|
||||
if c.client == nil {
|
||||
return nil, nil, fmt.Errorf("nil client")
|
||||
}
|
||||
@@ -252,7 +252,7 @@ func (c *RolesClient) List(ctx context.Context, opt ...Option) ([]*Role, *api.Er
|
||||
return target.Items, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *RolesClient) AddGrants(ctx context.Context, roleId string, version uint32, grantStrings []string, opt ...Option) (*Role, *api.Error, error) {
|
||||
func (c *Client) AddGrants(ctx context.Context, roleId string, version uint32, grantStrings []string, opt ...Option) (*Role, *api.Error, error) {
|
||||
if roleId == "" {
|
||||
return nil, nil, fmt.Errorf("empty roleId value passed into AddGrants request")
|
||||
}
|
||||
@@ -314,7 +314,7 @@ func (c *RolesClient) AddGrants(ctx context.Context, roleId string, version uint
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *RolesClient) AddPrincipals(ctx context.Context, roleId string, version uint32, principalIds []string, opt ...Option) (*Role, *api.Error, error) {
|
||||
func (c *Client) AddPrincipals(ctx context.Context, roleId string, version uint32, principalIds []string, opt ...Option) (*Role, *api.Error, error) {
|
||||
if roleId == "" {
|
||||
return nil, nil, fmt.Errorf("empty roleId value passed into AddPrincipals request")
|
||||
}
|
||||
@@ -376,7 +376,7 @@ func (c *RolesClient) AddPrincipals(ctx context.Context, roleId string, version
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *RolesClient) SetGrants(ctx context.Context, roleId string, version uint32, grantStrings []string, opt ...Option) (*Role, *api.Error, error) {
|
||||
func (c *Client) SetGrants(ctx context.Context, roleId string, version uint32, grantStrings []string, opt ...Option) (*Role, *api.Error, error) {
|
||||
if roleId == "" {
|
||||
return nil, nil, fmt.Errorf("empty roleId value passed into SetGrants request")
|
||||
}
|
||||
@@ -441,7 +441,7 @@ func (c *RolesClient) SetGrants(ctx context.Context, roleId string, version uint
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *RolesClient) SetPrincipals(ctx context.Context, roleId string, version uint32, principalIds []string, opt ...Option) (*Role, *api.Error, error) {
|
||||
func (c *Client) SetPrincipals(ctx context.Context, roleId string, version uint32, principalIds []string, opt ...Option) (*Role, *api.Error, error) {
|
||||
if roleId == "" {
|
||||
return nil, nil, fmt.Errorf("empty roleId value passed into SetPrincipals request")
|
||||
}
|
||||
@@ -506,7 +506,7 @@ func (c *RolesClient) SetPrincipals(ctx context.Context, roleId string, version
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *RolesClient) RemoveGrants(ctx context.Context, roleId string, version uint32, grantStrings []string, opt ...Option) (*Role, *api.Error, error) {
|
||||
func (c *Client) RemoveGrants(ctx context.Context, roleId string, version uint32, grantStrings []string, opt ...Option) (*Role, *api.Error, error) {
|
||||
if roleId == "" {
|
||||
return nil, nil, fmt.Errorf("empty roleId value passed into RemoveGrants request")
|
||||
}
|
||||
@@ -568,7 +568,7 @@ func (c *RolesClient) RemoveGrants(ctx context.Context, roleId string, version u
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *RolesClient) RemovePrincipals(ctx context.Context, roleId string, version uint32, principalIds []string, opt ...Option) (*Role, *api.Error, error) {
|
||||
func (c *Client) RemovePrincipals(ctx context.Context, roleId string, version uint32, principalIds []string, opt ...Option) (*Role, *api.Error, error) {
|
||||
if roleId == "" {
|
||||
return nil, nil, fmt.Errorf("empty roleId value passed into RemovePrincipals request")
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func TestCustom(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
user, apiErr, err := users.NewUsersClient(client).Create(tc.Context())
|
||||
user, apiErr, err := users.NewClient(client).Create(tc.Context())
|
||||
require.NoError(err)
|
||||
require.Nil(apiErr)
|
||||
|
||||
@@ -69,12 +69,12 @@ func TestCustom(t *testing.T) {
|
||||
|
||||
for _, tt := range cases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
g, apiErr, err := groups.NewGroupsClient(tt.scopeClient).Create(tc.Context())
|
||||
g, apiErr, err := groups.NewClient(tt.scopeClient).Create(tc.Context())
|
||||
require.NoError(err)
|
||||
require.Nil(apiErr)
|
||||
require.NotNil(g)
|
||||
|
||||
rc := roles.NewRolesClient(tt.scopeClient)
|
||||
rc := roles.NewClient(tt.scopeClient)
|
||||
var version uint32 = 1
|
||||
|
||||
r, apiErr, err := rc.Create(tc.Context(), roles.WithName("foo"))
|
||||
@@ -162,7 +162,7 @@ func TestRole_List(t *testing.T) {
|
||||
|
||||
for _, tt := range cases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
roleClient := roles.NewRolesClient(tt.scopeClient)
|
||||
roleClient := roles.NewClient(tt.scopeClient)
|
||||
p1, apiErr, err := roleClient.List(tc.Context())
|
||||
require.NoError(err)
|
||||
assert.Nil(apiErr)
|
||||
@@ -257,7 +257,7 @@ func TestRole_Crud(t *testing.T) {
|
||||
|
||||
for _, tt := range cases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
roleClient := roles.NewRolesClient(tt.scopeClient)
|
||||
roleClient := roles.NewClient(tt.scopeClient)
|
||||
g, apiErr, err := roleClient.Create(tc.Context(), roles.WithName("foo"))
|
||||
checkRole("create", g, apiErr, err, "foo", 1)
|
||||
|
||||
@@ -316,7 +316,7 @@ func TestRole_Errors(t *testing.T) {
|
||||
|
||||
for _, tt := range cases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
roleClient := roles.NewRolesClient(tt.scopeClient)
|
||||
roleClient := roles.NewClient(tt.scopeClient)
|
||||
u, apiErr, err := roleClient.Create(tc.Context(), roles.WithName("first"))
|
||||
require.NoError(err)
|
||||
assert.Nil(apiErr)
|
||||
|
||||
Reference in new issue
Block a user