diff --git a/auth.go b/auth.go index 062ce12..6e31cb6 100644 --- a/auth.go +++ b/auth.go @@ -1,14 +1,14 @@ package sdk import ( - "github.com/clawio/authentication/service" - "github.com/clawio/codes" + "github.com/clawio/clawiod/codes" + "github.com/clawio/clawiod/services/authentication" ) type ( - // AuthService is the interface that deals with the calls to an authentication service. + // AuthService is the interface that deals with the calls to an authentication authentication. AuthService interface { - Authenticate(username, password string) (string, *codes.Response, error) + Token(username, password string) (string, *codes.Response, error) } authService struct { @@ -17,19 +17,19 @@ type ( } ) -// Authenticate authenticates a user using a username and a password. -func (s *authService) Authenticate(username, password string) (string, *codes.Response, error) { - authNRequest := &service.AuthenticateRequest{ +// Token gets an access token after authenticating the user with username and password. +func (s *authService) Token(username, password string) (string, *codes.Response, error) { + tokenRequest := &authentication.TokenRequest{ Username: username, Password: password} - req, err := s.client.newRequest("POST", "token", authNRequest) + req, err := s.client.newRequest("POST", "token", tokenRequest) if err != nil { return "", nil, err } - authNResponse := &service.AuthenticateResponse{} - resp, err := s.client.do(req, authNResponse, true) + tokenResponse := &authentication.TokenResponse{} + resp, err := s.client.do(req, tokenResponse, true) if err != nil { return "", resp, err } - return authNResponse.AccessToken, resp, nil + return tokenResponse.AccessToken, resp, nil } diff --git a/client.go b/client.go index aabca15..e03f245 100644 --- a/client.go +++ b/client.go @@ -8,7 +8,7 @@ import ( "net/http" "net/url" - "github.com/clawio/codes" + "github.com/clawio/clawiod/codes" ) // A client manages communication with the ClawIO API. diff --git a/data.go b/data.go index 23933cf..b5b944c 100644 --- a/data.go +++ b/data.go @@ -4,7 +4,7 @@ import ( "io" "path" - "github.com/clawio/codes" + "github.com/clawio/clawiod/codes" ) // DataService is the interface that specifies the methods to call a data service. diff --git a/metadata.go b/metadata.go index 6ef8743..128f98b 100644 --- a/metadata.go +++ b/metadata.go @@ -3,13 +3,14 @@ package sdk import ( "path" - "github.com/clawio/codes" - "github.com/clawio/entities" + "github.com/clawio/clawiod/codes" + "github.com/clawio/clawiod/entities" ) // MetaDataService is the interface that specifies the methods to call a metaData service. type MetaDataService interface { Init() (*codes.Response, error) + CreateTree(pathSpec string) (*codes.Response, error) ExamineObject(pathSpec string) (*entities.ObjectInfo, *codes.Response, error) ListTree(pathSpec string) ([]*entities.ObjectInfo, *codes.Response, error) DeleteObject(pathSpec string) (*codes.Response, error) @@ -60,6 +61,7 @@ func (s *metaDataService) ListTree(pathSpec string) ([]*entities.ObjectInfo, *co } return oinfos, resp, nil } + func (s *metaDataService) DeleteObject(pathSpec string) (*codes.Response, error) { pathSpec = path.Join("/", pathSpec) req, err := s.client.newRequest("DELETE", "delete"+pathSpec, nil) @@ -69,6 +71,15 @@ func (s *metaDataService) DeleteObject(pathSpec string) (*codes.Response, error) return s.client.do(req, nil, true) } +func (s *metaDataService) CreateTree(pathSpec string) (*codes.Response, error) { + pathSpec = path.Join("/", pathSpec) + req, err := s.client.newRequest("POST", "createtree"+pathSpec, nil) + if err != nil { + return nil, err + } + return s.client.do(req, nil, true) +} + func (s *metaDataService) MoveObject(sourcePathSpec, targetPathSpec string) (*codes.Response, error) { sourcePathSpec = path.Join("/", sourcePathSpec) targetPathSpec = path.Join("/", targetPathSpec)