Separate accounts/host catalogs/host sets into their own packages (#311)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-08-27 20:43:33 -04:00
1 parent 936c970635
commit 17ecb6f2ce
64 files changed
+2298 -2265

No files matched your search

+5 -5
View File
@@ -25,8 +25,8 @@ func TestAuthTokens_List(t *testing.T) {
defer tc.Shutdown()
client := tc.Client()
tokens := authtokens.NewAuthTokensClient(client)
methods := authmethods.NewAuthMethodsClient(client)
tokens := authtokens.NewClient(client)
methods := authmethods.NewClient(client)
atl, apiErr, err := tokens.List(tc.Context())
require.NoError(err)
@@ -92,8 +92,8 @@ func TestAuthToken_Crud(t *testing.T) {
defer tc.Shutdown()
client := tc.Client()
tokens := authtokens.NewAuthTokensClient(client)
methods := authmethods.NewAuthMethodsClient(client)
tokens := authtokens.NewClient(client)
methods := authmethods.NewClient(client)
want, apiErr, err := methods.Authenticate(tc.Context(), amId, "user", "passpass")
require.NoError(err)
@@ -127,7 +127,7 @@ func TestAuthToken_Errors(t *testing.T) {
defer tc.Shutdown()
client := tc.Client()
tokens := authtokens.NewAuthTokensClient(client)
tokens := authtokens.NewClient(client)
_, apiErr, err := tokens.Read(tc.Context(), authtoken.AuthTokenPrefix+"_doesntexis")
require.NoError(err)
+6 -6
View File
@@ -23,15 +23,15 @@ type AuthToken struct {
ExpirationTime time.Time `json:"expiration_time,omitempty"`
}
type AuthTokensClient struct {
type Client struct {
client *api.Client
}
func NewAuthTokensClient(c *api.Client) *AuthTokensClient {
return &AuthTokensClient{client: c}
func NewClient(c *api.Client) *Client {
return &Client{client: c}
}
func (c *AuthTokensClient) Read(ctx context.Context, authTokenId string, opt ...Option) (*AuthToken, *api.Error, error) {
func (c *Client) Read(ctx context.Context, authTokenId string, opt ...Option) (*AuthToken, *api.Error, error) {
if authTokenId == "" {
return nil, nil, fmt.Errorf("empty authTokenId value passed into Read request")
}
@@ -71,7 +71,7 @@ func (c *AuthTokensClient) Read(ctx context.Context, authTokenId string, opt ...
return target, apiErr, nil
}
func (c *AuthTokensClient) Delete(ctx context.Context, authTokenId string, opt ...Option) (bool, *api.Error, error) {
func (c *Client) Delete(ctx context.Context, authTokenId string, opt ...Option) (bool, *api.Error, error) {
if authTokenId == "" {
return false, nil, fmt.Errorf("empty authTokenId value passed into Delete request")
}
@@ -114,7 +114,7 @@ func (c *AuthTokensClient) Delete(ctx context.Context, authTokenId string, opt .
return target.Existed, apiErr, nil
}
func (c *AuthTokensClient) List(ctx context.Context, opt ...Option) ([]*AuthToken, *api.Error, error) {
func (c *Client) List(ctx context.Context, opt ...Option) ([]*AuthToken, *api.Error, error) {
if c.client == nil {
return nil, nil, fmt.Errorf("nil client")
}