81 lines
1.8 KiB
Go
81 lines
1.8 KiB
Go
package ac
|
|
|
|
type client struct {
|
|
adapterId string
|
|
clusterId string
|
|
clusterUrl string
|
|
tokenUrl string
|
|
stateUrl string
|
|
user string
|
|
password string
|
|
orgId string
|
|
endPoint string
|
|
token string
|
|
clusterIdAC string
|
|
baseEndpoint string
|
|
acStatus map[string]string
|
|
}
|
|
|
|
func (c *client) Token(options ClientOptions) (Token, error) {
|
|
token, _ := newToken(c, &options)
|
|
return token, nil
|
|
}
|
|
|
|
func (c *client) Job(options JobOptions) (Job, error) {
|
|
|
|
job, _ := newJob(c, &options)
|
|
return job, nil
|
|
}
|
|
|
|
func (c *client) GetClientInfo() (ClientOptions, error) {
|
|
clientInfo := ClientOptions{
|
|
AdapterId: c.adapterId,
|
|
ClusterId: c.clusterId,
|
|
ClusterUrl: c.clusterUrl,
|
|
TokenUrl: c.tokenUrl,
|
|
StateUrl: c.stateUrl,
|
|
User: c.user,
|
|
Password: c.password,
|
|
OrgId: c.orgId,
|
|
EndPoint: c.endPoint,
|
|
Token: c.token,
|
|
ClusterIdAC: c.clusterIdAC,
|
|
BaseEndpoint: c.baseEndpoint,
|
|
}
|
|
return clientInfo, nil
|
|
}
|
|
|
|
func newClient(options ClientOptions) (Client, error) {
|
|
status := map[string]string{
|
|
"statQ": "Pending",
|
|
"statR": "Running",
|
|
"statE": "Pending",
|
|
"statC": "Completed",
|
|
"statH": "Pending",
|
|
"statS": "Pending",
|
|
"statW": "Pending",
|
|
"statX": "Other",
|
|
}
|
|
|
|
c := &client{
|
|
adapterId: options.AdapterId,
|
|
clusterId: options.ClusterId,
|
|
clusterUrl: options.ClusterUrl,
|
|
tokenUrl: options.TokenUrl,
|
|
stateUrl: options.StateUrl,
|
|
user: options.User,
|
|
password: options.Password,
|
|
orgId: options.OrgId,
|
|
endPoint: options.EndPoint,
|
|
token: "",
|
|
clusterIdAC: options.ClusterIdAC,
|
|
baseEndpoint: options.BaseEndpoint,
|
|
acStatus: status,
|
|
}
|
|
t, _ := newToken(c, &options)
|
|
|
|
tokenString := t.GetToken(options)
|
|
c.token = tokenString
|
|
return c, nil
|
|
}
|