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
@@ -24,15 +24,15 @@ type User struct {
|
||||
Version uint32 `json:"version,omitempty"`
|
||||
}
|
||||
|
||||
type UsersClient struct {
|
||||
type Client struct {
|
||||
client *api.Client
|
||||
}
|
||||
|
||||
func NewUsersClient(c *api.Client) *UsersClient {
|
||||
return &UsersClient{client: c}
|
||||
func NewClient(c *api.Client) *Client {
|
||||
return &Client{client: c}
|
||||
}
|
||||
|
||||
func (c *UsersClient) Create(ctx context.Context, opt ...Option) (*User, *api.Error, error) {
|
||||
func (c *Client) Create(ctx context.Context, opt ...Option) (*User, *api.Error, error) {
|
||||
opts, apiOpts := getOpts(opt...)
|
||||
if c.client == nil {
|
||||
return nil, nil, fmt.Errorf("nil client")
|
||||
@@ -67,7 +67,7 @@ func (c *UsersClient) Create(ctx context.Context, opt ...Option) (*User, *api.Er
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *UsersClient) Read(ctx context.Context, userId string, opt ...Option) (*User, *api.Error, error) {
|
||||
func (c *Client) Read(ctx context.Context, userId string, opt ...Option) (*User, *api.Error, error) {
|
||||
if userId == "" {
|
||||
return nil, nil, fmt.Errorf("empty userId value passed into Read request")
|
||||
}
|
||||
@@ -107,7 +107,7 @@ func (c *UsersClient) Read(ctx context.Context, userId string, opt ...Option) (*
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *UsersClient) Update(ctx context.Context, userId string, version uint32, opt ...Option) (*User, *api.Error, error) {
|
||||
func (c *Client) Update(ctx context.Context, userId string, version uint32, opt ...Option) (*User, *api.Error, error) {
|
||||
if userId == "" {
|
||||
return nil, nil, fmt.Errorf("empty userId value passed into Update request")
|
||||
}
|
||||
@@ -165,7 +165,7 @@ func (c *UsersClient) Update(ctx context.Context, userId string, version uint32,
|
||||
return target, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *UsersClient) Delete(ctx context.Context, userId string, opt ...Option) (bool, *api.Error, error) {
|
||||
func (c *Client) Delete(ctx context.Context, userId string, opt ...Option) (bool, *api.Error, error) {
|
||||
if userId == "" {
|
||||
return false, nil, fmt.Errorf("empty userId value passed into Delete request")
|
||||
}
|
||||
@@ -208,7 +208,7 @@ func (c *UsersClient) Delete(ctx context.Context, userId string, opt ...Option)
|
||||
return target.Existed, apiErr, nil
|
||||
}
|
||||
|
||||
func (c *UsersClient) List(ctx context.Context, opt ...Option) ([]*User, *api.Error, error) {
|
||||
func (c *Client) List(ctx context.Context, opt ...Option) ([]*User, *api.Error, error) {
|
||||
if c.client == nil {
|
||||
return nil, nil, fmt.Errorf("nil client")
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ func TestUsers_List(t *testing.T) {
|
||||
client := tc.Client()
|
||||
org := iam.TestOrg(t, tc.IamRepo())
|
||||
client.SetScopeId(org.GetPublicId())
|
||||
userClient := users.NewUsersClient(client)
|
||||
userClient := users.NewClient(client)
|
||||
|
||||
ul, apiErr, err := userClient.List(tc.Context())
|
||||
assert.NoError(err)
|
||||
@@ -88,7 +88,7 @@ func TestUser_Crud(t *testing.T) {
|
||||
client := tc.Client()
|
||||
org := iam.TestOrg(t, tc.IamRepo())
|
||||
client.SetScopeId(org.GetPublicId())
|
||||
userClient := users.NewUsersClient(client)
|
||||
userClient := users.NewClient(client)
|
||||
|
||||
checkUser := func(step string, u *users.User, apiErr *api.Error, err error, wantedName string, wantedVersion uint32) {
|
||||
assert.NoError(err, step)
|
||||
@@ -141,7 +141,7 @@ func TestUser_Errors(t *testing.T) {
|
||||
client := tc.Client()
|
||||
org := iam.TestOrg(t, tc.IamRepo())
|
||||
client.SetScopeId(org.GetPublicId())
|
||||
userClient := users.NewUsersClient(client)
|
||||
userClient := users.NewClient(client)
|
||||
|
||||
u, apiErr, err := userClient.Create(tc.Context(), users.WithName("first"))
|
||||
require.NoError(err)
|
||||
|
||||
Reference in new issue
Block a user