-
Notifications
You must be signed in to change notification settings - Fork 25
/
authentication_service.go
37 lines (30 loc) · 1.09 KB
/
authentication_service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package authentication
import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/constants"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/services/api"
"github.com/dghubble/sling"
)
// AuthenticationService handles communication with Authentication-related methods of the Octopus API.
type AuthenticationService struct {
loginInitiatedPath string
services.Service
}
// NewAuthenticationService returns an AuthenticationService with a preconfigured client.
func NewAuthenticationService(sling *sling.Sling, uriTemplate string, loginInitiatedPath string) *AuthenticationService {
return &AuthenticationService{
loginInitiatedPath: loginInitiatedPath,
Service: services.NewService(constants.ServiceAuthenticationService, sling, uriTemplate),
}
}
func (s *AuthenticationService) Get() (*Authentication, error) {
path, err := services.GetPath(s)
if err != nil {
return nil, err
}
resp, err := api.ApiGet(s.GetClient(), new(Authentication), path)
if err != nil {
return nil, err
}
return resp.(*Authentication), nil
}