nettoyage
gestion d'erreur
This commit is contained in:
parent
2dd8c960d1
commit
61c15fae6b
160
arlo.go
160
arlo.go
@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Jeffrey Walter <jeffreydwalter@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package arlo
|
||||
|
||||
import (
|
||||
@ -46,74 +30,111 @@ func NewArlo() (arlo *Arlo) {
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Arlo) get(url string, result interface{}) error {
|
||||
var errorResponse ErrorResponse
|
||||
resp, err := a.client.R().
|
||||
SetResult(result).
|
||||
SetError(&errorResponse).
|
||||
Get(url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.IsError() {
|
||||
return fmt.Errorf(errorResponse.Reason)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Arlo) post(url string, body interface{}, result interface{}, xcloudId string) error {
|
||||
var errorResponse ErrorResponse
|
||||
request := a.client.R().
|
||||
SetBody(body).
|
||||
SetResult(result).
|
||||
SetError(&errorResponse)
|
||||
if xcloudId != "" {
|
||||
request.SetHeader("xcloudId", xcloudId)
|
||||
}
|
||||
resp, err := request.Post(url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.IsError() {
|
||||
return fmt.Errorf(errorResponse.Reason)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Arlo) put(url string, result interface{}, xcloudId string) error {
|
||||
var errorResponse ErrorResponse
|
||||
request := a.client.R().
|
||||
SetResult(result).
|
||||
SetError(&errorResponse)
|
||||
if xcloudId != "" {
|
||||
request.SetHeader("xcloudId", xcloudId)
|
||||
}
|
||||
resp, err := request.Put(url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if resp.IsError() {
|
||||
return fmt.Errorf(errorResponse.Reason)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Arlo) Login(ctx context.Context, user string, pass string) error {
|
||||
var loginResponse LoginResponse
|
||||
_, err := a.client.R().
|
||||
SetBody(map[string]string{
|
||||
"email": user,
|
||||
"password": pass,
|
||||
}).
|
||||
SetResult(&loginResponse). // or SetResult(AuthSuccess{}).
|
||||
Post(LoginV2Uri)
|
||||
|
||||
err := a.post(LoginV2Uri, map[string]string{
|
||||
"email": user,
|
||||
"password": pass,
|
||||
}, &loginResponse, "")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to login: %v", err)
|
||||
return fmt.Errorf("posting login request: %v", err)
|
||||
}
|
||||
if !loginResponse.Success {
|
||||
return fmt.Errorf("failed to login")
|
||||
return fmt.Errorf("no success but no error")
|
||||
}
|
||||
|
||||
// Cache the auth token.
|
||||
a.client.SetHeader("Authorization", loginResponse.Data.Token)
|
||||
// Save the account info with the arlo struct.
|
||||
a.Account = loginResponse.Data
|
||||
// Get the devices, which also caches them on the arlo object.
|
||||
if _, err := a.GetDevices(ctx); err != nil {
|
||||
return fmt.Errorf("getting devices: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Arlo) Logout() error {
|
||||
|
||||
var response Status
|
||||
_, err := a.client.R().
|
||||
SetResult(&response).
|
||||
Put(LogoutUri)
|
||||
var response BaseResponse
|
||||
err := a.put(LogoutUri, &response, "")
|
||||
if err != nil {
|
||||
return fmt.Errorf("logging out: %v", err)
|
||||
return err
|
||||
}
|
||||
if response.Success == false {
|
||||
return fmt.Errorf("logging out: %s", response.Reason)
|
||||
if !response.Success {
|
||||
return fmt.Errorf("no success but no error")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Arlo) GetSession() (*Session, error) {
|
||||
var response SessionResponse
|
||||
_, err := a.client.R().
|
||||
SetResult(&response).
|
||||
Get(SessionUri)
|
||||
err := a.get(SessionUri, &response)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("getting session: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
if response.Success == false {
|
||||
return nil, fmt.Errorf("getting session: %s", response.Reason)
|
||||
if !response.Success {
|
||||
return nil, fmt.Errorf("no success but no error")
|
||||
}
|
||||
return &response.Data, nil
|
||||
}
|
||||
|
||||
func (a *Arlo) GetDevices(ctx context.Context) (*Devices, error) {
|
||||
var response DeviceResponse
|
||||
_, err := a.client.R().
|
||||
SetResult(&response).
|
||||
Get(fmt.Sprintf(DevicesUri, time.Now().Format("20060102")))
|
||||
err := a.get(fmt.Sprintf(DevicesUri, time.Now().Format("20060102")), &response)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("getting devices: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
if !response.Success {
|
||||
return nil, fmt.Errorf("failed to get devices")
|
||||
return nil, fmt.Errorf("no success but no error")
|
||||
}
|
||||
if len(response.Data) == 0 {
|
||||
return nil, fmt.Errorf("no device found")
|
||||
@ -149,45 +170,12 @@ func (a *Arlo) GetDevices(ctx context.Context) (*Devices, error) {
|
||||
// GetProfile returns the user profile for the currently logged in user.
|
||||
func (a *Arlo) GetProfile() (*UserProfile, error) {
|
||||
var response UserProfileResponse
|
||||
_, err := a.client.R().
|
||||
SetResult(&response).
|
||||
Get(ProfileUri)
|
||||
|
||||
err := a.get(ProfileUri, &response)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("getting user profile: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
if response.Success == false {
|
||||
return nil, fmt.Errorf("getting user profile: %s", response.Reason)
|
||||
if !response.Success {
|
||||
return nil, fmt.Errorf("no success but no error")
|
||||
}
|
||||
return &response.Data, nil
|
||||
}
|
||||
|
||||
//// UpdateDisplayOrder sets the display order according to the order defined in the DeviceOrder given.
|
||||
//func (a *Arlo) UpdateDisplayOrder(d DeviceOrder) error {
|
||||
// resp, err := a.post(CameraOrderUri, "", d, nil)
|
||||
// return checkRequest(resp, err, "failed to display order")
|
||||
//}
|
||||
//
|
||||
//// UpdateProfile takes a first and last name, and updates the user profile with that information.
|
||||
//func (a *Arlo) UpdateProfile(firstName, lastName string) error {
|
||||
// body := map[string]string{"firstName": firstName, "lastName": lastName}
|
||||
// resp, err := a.put(ProfileUri, "", body, nil)
|
||||
// return checkRequest(resp, err, "failed to update profile")
|
||||
//}
|
||||
//
|
||||
//func (a *Arlo) UpdatePassword(pass string) error {
|
||||
// body := map[string]string{"currentPassword": a.pass, "newPassword": pass}
|
||||
// resp, err := a.post(UpdatePasswordUri, "", body, nil)
|
||||
// if err := checkRequest(resp, err, "failed to update password"); err != nil {
|
||||
// return err
|
||||
// }
|
||||
//
|
||||
// a.pass = pass
|
||||
//
|
||||
// return nil
|
||||
//}
|
||||
//
|
||||
//func (a *Arlo) UpdateFriends(f Friend) error {
|
||||
// resp, err := a.put(FriendsUri, "", f, nil)
|
||||
// return checkRequest(resp, err, "failed to update friends")
|
||||
//}
|
||||
|
107
basestation.go
107
basestation.go
@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Jeffrey Walter <jeffreydwalter@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package arlo
|
||||
|
||||
import (
|
||||
@ -108,6 +92,14 @@ type Rule struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
|
||||
type CalendarMode struct {
|
||||
Active bool `json:"active"`
|
||||
Schedule []struct {
|
||||
ModeID string `json:"modeId"`
|
||||
StartTime int `json:"startTime"`
|
||||
} `json:"schedule"`
|
||||
}
|
||||
|
||||
// Basestations is a slice of Basestation objects.
|
||||
type Basestations []*Basestation
|
||||
|
||||
@ -217,16 +209,13 @@ forLoop:
|
||||
}
|
||||
|
||||
func (b *Basestation) Unsubscribe() error {
|
||||
var response Status
|
||||
_, err := b.arlo.client.R().
|
||||
SetResult(&response).
|
||||
SetHeader("xcloudId", b.XCloudId).
|
||||
Put(UnsubscribeUri)
|
||||
var response BaseResponse
|
||||
err := b.arlo.put(UnsubscribeUri, &response, b.XCloudId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unsubscribing from event stream: %v", err)
|
||||
return err
|
||||
}
|
||||
if response.Success == false {
|
||||
return fmt.Errorf("unsubscribing from event stream: %s", response.Reason)
|
||||
if !response.Success {
|
||||
return fmt.Errorf("no success but no error")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -240,34 +229,19 @@ func (b *Basestation) Disconnect() error {
|
||||
}
|
||||
|
||||
// Ping makes a call to the subscriptions endpoint. The Arlo event stream requires this message to be sent every 30s.
|
||||
func (b *Basestation) Ping() error {
|
||||
payload := EventStreamPayload{
|
||||
Action: "set",
|
||||
Resource: fmt.Sprintf("subscriptions/%s_%s", b.UserId, TransIdPrefix),
|
||||
PublishResponse: false,
|
||||
Properties: map[string][1]string{"devices": {b.DeviceId}},
|
||||
From: fmt.Sprintf("%s_%s", b.UserId, TransIdPrefix),
|
||||
To: b.DeviceId,
|
||||
}
|
||||
|
||||
if _, err := b.makeEventStreamRequest(payload); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Basestation) NotifyEventStream(payload EventStreamPayload) error {
|
||||
var response Status
|
||||
_, err := b.arlo.client.R().
|
||||
SetBody(payload).
|
||||
SetResult(&response).
|
||||
SetHeader("xcloudId", b.XCloudId).
|
||||
Post(fmt.Sprintf(NotifyUri, b.DeviceId))
|
||||
var response ErrorResponse
|
||||
err := b.arlo.post(fmt.Sprintf(NotifyUri, b.DeviceId), payload, &response, b.XCloudId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("notifying event stream: %v", err)
|
||||
return err
|
||||
}
|
||||
if response.Success == false {
|
||||
return fmt.Errorf("notifying event stream: %s", response.Reason)
|
||||
if !response.Success {
|
||||
if response.Reason != "" {
|
||||
return fmt.Errorf(response.Reason)
|
||||
} else {
|
||||
return fmt.Errorf("no success but no error")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -294,6 +268,14 @@ func (b *Basestation) makeRequest(action string, resource string, publishRespons
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Basestation) Ping() error {
|
||||
err := b.makeRequest("set", fmt.Sprintf("subscriptions/%s_%s", b.UserId, TransIdPrefix), false, map[string][1]string{"devices": {b.DeviceId}}, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting basestation %s state: %v", b.DeviceName, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Basestation) GetState() (*BaseStationState, error) {
|
||||
var state BaseStationState
|
||||
err := b.makeRequest("get", "basestation", false, nil, &state)
|
||||
@ -321,16 +303,13 @@ func (b *Basestation) GetRules() ([]Rule, error) {
|
||||
return resp.Rules, nil
|
||||
}
|
||||
|
||||
func (b *Basestation) GetCalendarMode() (response *EventStreamResponse, err error) {
|
||||
payload := EventStreamPayload{
|
||||
Action: "get",
|
||||
Resource: "schedule",
|
||||
PublishResponse: false,
|
||||
From: fmt.Sprintf("%s_%s", b.UserId, TransIdPrefix),
|
||||
To: b.DeviceId,
|
||||
func (b *Basestation) GetCalendarMode() (*CalendarMode, error) {
|
||||
var calendarMode CalendarMode
|
||||
err := b.makeRequest("get", "schedule", false, nil, &calendarMode)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("getting calendar mode: %v", err)
|
||||
}
|
||||
|
||||
return b.makeEventStreamRequest(payload)
|
||||
return &calendarMode, nil
|
||||
}
|
||||
|
||||
// SetCalendarMode toggles calendar mode.
|
||||
@ -385,16 +364,12 @@ func (b *Basestation) SetCustomMode(mode string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Basestation) DeleteMode(mode string) (response *EventStreamResponse, err error) {
|
||||
payload := EventStreamPayload{
|
||||
Action: "delete",
|
||||
Resource: fmt.Sprintf("modes/%s", mode),
|
||||
PublishResponse: true,
|
||||
From: fmt.Sprintf("%s_%s", b.UserId, TransIdPrefix),
|
||||
To: b.DeviceId,
|
||||
func (b *Basestation) DeleteMode(mode string) error {
|
||||
err := b.makeRequest("delete", fmt.Sprintf("modes/%s", mode), true, nil, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("deleting mode %s: %v", mode, err)
|
||||
}
|
||||
|
||||
return b.makeEventStreamRequest(payload)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Basestation) Arm() error {
|
||||
|
16
camera.go
16
camera.go
@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Jeffrey Walter <jeffreydwalter@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package arlo
|
||||
|
||||
import (
|
||||
|
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.lehouerou.net/laurent/arlo-go"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -19,7 +20,12 @@ func main() {
|
||||
}
|
||||
|
||||
for _, b := range a.Basestations {
|
||||
err := b.SetCustomMode("mode3")
|
||||
_, err := b.GetModes()
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
log.Info("ok")
|
||||
err = b.DeleteMode("mode5")
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
|
16
const.go
16
const.go
@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Jeffrey Walter <jeffreydwalter@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package arlo
|
||||
|
||||
const (
|
||||
|
16
devices.go
16
devices.go
@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Jeffrey Walter <jeffreydwalter@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package arlo
|
||||
|
||||
// A Device is the device data, this can be a camera, basestation, arloq, etc.
|
||||
|
@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Jeffrey Walter <jeffreydwalter@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package arlo
|
||||
|
||||
import (
|
||||
|
16
library.go
16
library.go
@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Jeffrey Walter <jeffreydwalter@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package arlo
|
||||
|
||||
// LibraryMetaData is the library meta data.
|
||||
|
19
lights.go
19
lights.go
@ -1,19 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Jeffrey Walter <jeffreydwalter@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package arlo
|
||||
|
||||
// TODO: Add support for "lights" type of devices.
|
77
responses.go
77
responses.go
@ -1,71 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Jeffrey Walter <jeffreydwalter@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package arlo
|
||||
|
||||
// URL is part of the Status message fragment returned by most calls to the Arlo API.
|
||||
// URL is only populated when Success is false.
|
||||
type Data struct {
|
||||
Message string `json:"message,omitempty"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
// Status is the message fragment returned from most http calls to the Arlo API.
|
||||
type Status struct {
|
||||
Data `json:"URL,omitempty"`
|
||||
type BaseResponse struct {
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
|
||||
// LoginResponse is an intermediate struct used when parsing data from the Login() call.
|
||||
type ErrorDetail struct {
|
||||
Message string `json:"message"`
|
||||
Reason string `json:"reason"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
type ErrorResponse struct {
|
||||
BaseResponse
|
||||
ErrorDetail `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
Data Account
|
||||
Status
|
||||
BaseResponse
|
||||
Data Account `json:"data"`
|
||||
}
|
||||
|
||||
type SessionResponse struct {
|
||||
Data Session
|
||||
Status
|
||||
BaseResponse
|
||||
Data Session `json:"data"`
|
||||
}
|
||||
|
||||
type UserProfileResponse struct {
|
||||
Data UserProfile
|
||||
Status
|
||||
BaseResponse
|
||||
Data UserProfile `json:"data"`
|
||||
}
|
||||
|
||||
// DeviceResponse is an intermediate struct used when parsing data from the GetDevices() call.
|
||||
type DeviceResponse struct {
|
||||
Data Devices
|
||||
Status
|
||||
BaseResponse
|
||||
Data Devices `json:"data"`
|
||||
}
|
||||
|
||||
// LibraryMetaDataResponse is an intermediate struct used when parsing data from the GetLibraryMetaData() call.
|
||||
type LibraryMetaDataResponse struct {
|
||||
Data LibraryMetaData
|
||||
Status
|
||||
BaseResponse
|
||||
Data LibraryMetaData `json:"data"`
|
||||
}
|
||||
|
||||
type LibraryResponse struct {
|
||||
Data Library
|
||||
Status
|
||||
BaseResponse
|
||||
Data Library `json:"data"`
|
||||
}
|
||||
|
||||
type CvrPlaylistResponse struct {
|
||||
Data CvrPlaylist
|
||||
Status
|
||||
BaseResponse
|
||||
Data CvrPlaylist `json:"data"`
|
||||
}
|
||||
|
||||
type Stream struct {
|
||||
@ -73,13 +56,13 @@ type Stream struct {
|
||||
}
|
||||
|
||||
type StreamResponse struct {
|
||||
Data Stream
|
||||
Status
|
||||
BaseResponse
|
||||
Data Stream `json:"data"`
|
||||
}
|
||||
|
||||
type RecordingResponse struct {
|
||||
Data Stream
|
||||
Status
|
||||
BaseResponse
|
||||
Data Stream `json:"data"`
|
||||
}
|
||||
|
||||
type EventStreamResponse struct {
|
||||
|
16
types.go
16
types.go
@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Jeffrey Walter <jeffreydwalter@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package arlo
|
||||
|
||||
/*
|
||||
|
16
util.go
16
util.go
@ -1,19 +1,3 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Jeffrey Walter <jeffreydwalter@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
||||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package arlo
|
||||
|
||||
import (
|
||||
|
Loading…
Reference in New Issue
Block a user