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
+11
-11
@@ -26,15 +26,15 @@ type Group struct {
|
||||
Members []*Member `json:"members,omitempty"`
|
||||
}
|
||||
|
||||
type GroupsClient struct {
|
||||
type Client struct {
|
||||
client *api.Client
|
||||
}
|
||||
|
||||
func NewGroupsClient(c *api.Client) *GroupsClient {
|
||||
return &GroupsClient{client: c}
|
||||
func NewClient(c *api.Client) *Client {
|
||||
return &Client{client: c}
|
||||
}
|
||||
|
||||
func (c *GroupsClient) Create(ctx context.Context, opt ...Option) (*Group, *api.Error, error) {
|
||||
func (c *Client) Create(ctx context.Context, opt ...Option) (*Group, *api.Error, error) {
|
||||
opts, apiOpts := getOpts(opt...)
|
||||
if c.client == nil {
|
||||
return nil, nil, fmt.Errorf("nil client")
|
||||
@@ -69,7 +69,7 @@ func (c *GroupsClient) Create(ctx context.Context, opt ...Option) (*Group, *api.
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *GroupsClient) Read(ctx context.Context, groupId string, opt ...Option) (*Group, *api.Error, error) {
|
||||
func (c *Client) Read(ctx context.Context, groupId string, opt ...Option) (*Group, *api.Error, error) {
|
||||
if groupId == "" {
|
||||
return nil, nil, fmt.Errorf("empty groupId value passed into Read request")
|
||||
}
|
||||
@@ -109,7 +109,7 @@ func (c *GroupsClient) Read(ctx context.Context, groupId string, opt ...Option)
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *GroupsClient) Update(ctx context.Context, groupId string, version uint32, opt ...Option) (*Group, *api.Error, error) {
|
||||
func (c *Client) Update(ctx context.Context, groupId string, version uint32, opt ...Option) (*Group, *api.Error, error) {
|
||||
if groupId == "" {
|
||||
return nil, nil, fmt.Errorf("empty groupId value passed into Update request")
|
||||
}
|
||||
@@ -167,7 +167,7 @@ func (c *GroupsClient) Update(ctx context.Context, groupId string, version uint3
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *GroupsClient) Delete(ctx context.Context, groupId string, opt ...Option) (bool, *api.Error, error) {
|
||||
func (c *Client) Delete(ctx context.Context, groupId string, opt ...Option) (bool, *api.Error, error) {
|
||||
if groupId == "" {
|
||||
return false, nil, fmt.Errorf("empty groupId value passed into Delete request")
|
||||
}
|
||||
@@ -210,7 +210,7 @@ func (c *GroupsClient) Delete(ctx context.Context, groupId string, opt ...Option
|
||||
return target.Existed, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *GroupsClient) List(ctx context.Context, opt ...Option) ([]*Group, *api.Error, error) {
|
||||
func (c *Client) List(ctx context.Context, opt ...Option) ([]*Group, *api.Error, error) {
|
||||
if c.client == nil {
|
||||
return nil, nil, fmt.Errorf("nil client")
|
||||
}
|
||||
@@ -249,7 +249,7 @@ func (c *GroupsClient) List(ctx context.Context, opt ...Option) ([]*Group, *api.
|
||||
return target.Items, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *GroupsClient) AddMembers(ctx context.Context, groupId string, version uint32, memberIds []string, opt ...Option) (*Group, *api.Error, error) {
|
||||
func (c *Client) AddMembers(ctx context.Context, groupId string, version uint32, memberIds []string, opt ...Option) (*Group, *api.Error, error) {
|
||||
if groupId == "" {
|
||||
return nil, nil, fmt.Errorf("empty groupId value passed into AddMembers request")
|
||||
}
|
||||
@@ -311,7 +311,7 @@ func (c *GroupsClient) AddMembers(ctx context.Context, groupId string, version u
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *GroupsClient) SetMembers(ctx context.Context, groupId string, version uint32, memberIds []string, opt ...Option) (*Group, *api.Error, error) {
|
||||
func (c *Client) SetMembers(ctx context.Context, groupId string, version uint32, memberIds []string, opt ...Option) (*Group, *api.Error, error) {
|
||||
if groupId == "" {
|
||||
return nil, nil, fmt.Errorf("empty groupId value passed into SetMembers request")
|
||||
}
|
||||
@@ -376,7 +376,7 @@ func (c *GroupsClient) SetMembers(ctx context.Context, groupId string, version u
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *GroupsClient) RemoveMembers(ctx context.Context, groupId string, version uint32, memberIds []string, opt ...Option) (*Group, *api.Error, error) {
|
||||
func (c *Client) RemoveMembers(ctx context.Context, groupId string, version uint32, memberIds []string, opt ...Option) (*Group, *api.Error, error) {
|
||||
if groupId == "" {
|
||||
return nil, nil, fmt.Errorf("empty groupId value passed into RemoveMembers request")
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func TestGroup_List(t *testing.T) {
|
||||
|
||||
for _, tt := range cases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
grps := groups.NewGroupsClient(tt.scopeClient)
|
||||
grps := groups.NewClient(tt.scopeClient)
|
||||
pl, apiErr, err := grps.List(tc.Context())
|
||||
assert.NoError(err)
|
||||
assert.Nil(apiErr)
|
||||
@@ -133,17 +133,17 @@ func TestGroup_Crud(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
user1, apiErr, err := users.NewUsersClient(client).Create(tc.Context())
|
||||
user1, apiErr, err := users.NewClient(client).Create(tc.Context())
|
||||
require.NoError(err)
|
||||
require.Nil(apiErr)
|
||||
|
||||
user2, apiErr, err := users.NewUsersClient(client).Create(tc.Context())
|
||||
user2, apiErr, err := users.NewClient(client).Create(tc.Context())
|
||||
require.NoError(err)
|
||||
require.Nil(apiErr)
|
||||
|
||||
for _, tt := range cases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
groupsClient := groups.NewGroupsClient(tt.scopeClient)
|
||||
groupsClient := groups.NewClient(tt.scopeClient)
|
||||
g, apiErr, err := groupsClient.Create(tc.Context(), groups.WithName("foo"))
|
||||
checkGroup("create", g, apiErr, err, "foo", 1, nil)
|
||||
|
||||
@@ -209,7 +209,7 @@ func TestGroup_Errors(t *testing.T) {
|
||||
|
||||
for _, tt := range cases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
groupClient := groups.NewGroupsClient(tt.scopeClient)
|
||||
groupClient := groups.NewClient(tt.scopeClient)
|
||||
|
||||
g, apiErr, err := groupClient.Create(tc.Context(), groups.WithName("first"))
|
||||
require.NoError(err)
|
||||
|
||||
Reference in new issue
Block a user