-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
allan
committed
Jan 27, 2023
1 parent
1911eda
commit 402b3cc
Showing
6 changed files
with
68 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,51 @@ | ||
package haivision | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"gopkg.in/validator.v2" | ||
) | ||
|
||
/* | ||
Requests | ||
POST /api/session | ||
{ | ||
"username" : "[user name]", | ||
"password" : "[password]" | ||
} | ||
{ | ||
"username" : "[user name]", | ||
"password" : "[password]" | ||
} | ||
Response | ||
{ | ||
"response": { | ||
"type": "Session", | ||
"message": "Session successfully started for haiadmin", | ||
"sessionID": "[Session ID]", | ||
"lastLoginDate": 1536777877871, | ||
"numLoginFailures": 0 | ||
} | ||
} | ||
*/ | ||
// POST | ||
func (o *Haivision) InitSession(username string, password string) error { | ||
return nil | ||
{ | ||
"response": { | ||
"type": "Session", | ||
"message": "Session successfully started for haiadmin", | ||
"sessionID": "[Session ID]", | ||
"lastLoginDate": 1536777877871, | ||
"numLoginFailures": 0 | ||
} | ||
} | ||
*/ | ||
func (o *Haivision) InitSession(username string, password string) (*ResponseInitSession, error) { | ||
var requestBody RequestInitSession | ||
// | ||
if errs := validator.Validate(requestBody); errs != nil { | ||
// values not valid, deal with errors here | ||
return nil, errs | ||
} | ||
resp, err := o.restyPost(SESSION, requestBody) | ||
if err != nil { | ||
return nil, err | ||
} | ||
var obj ResponseInitSession | ||
if err := json.Unmarshal(resp.Body(), &obj); err != nil { | ||
return nil, err | ||
} | ||
return &obj, nil | ||
} | ||
|
||
// GET | ||
// GET | ||
func (o *Haivision) GetDeviceInfo() error { | ||
return nil | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,19 @@ | ||
package haivision | ||
|
||
/*{ | ||
"response": { | ||
"type": "Session", | ||
"message": "Session successfully started for haiadmin", | ||
"sessionID": "[Session ID]", | ||
"lastLoginDate": 1536777877871, | ||
"numLoginFailures": 0 | ||
} | ||
}*/ | ||
|
||
type ResponseInitSession struct { | ||
Type string `json:"type" validate:"nonzero"` | ||
Message string `json:"message" validate:"nonzero"` | ||
SessionID string `json:"sessionID" validate:"nonzero"` | ||
LastLoginDate int64 `json:"lastLoginDate" validate:"nonzero"` | ||
NumLoginFailures int `json:"numLoginFailures" validate:"nonzero"` | ||
} |