Documentation ¶
Index ¶
- Constants
- func GetLatchURL(queryString string) *url.URL
- func NewLatchError(code int32, message string) error
- type Latch
- func (l *Latch) AddOperation(parentId string, name string, twoFactor string, lockOnRequest string) (response *LatchAddOperationResponse, err error)
- func (l *Latch) DeleteOperation(operationId string) (err error)
- func (l *Latch) History(accountId string, from t.Time, to t.Time) (response *LatchHistoryResponse, err error)
- func (l *Latch) Lock(accountId string) (err error)
- func (l *Latch) LockOperation(accountId string, operationId string) (err error)
- func (l *Latch) OperationStatus(accountId string, operationId string, nootp bool, silent bool) (response *LatchStatusResponse, err error)
- func (l *Latch) Pair(token string) (response *LatchPairResponse, err error)
- func (l *Latch) ShowOperation(operationId string) (response *LatchShowOperationResponse, err error)
- func (l *Latch) Status(accountId string, nootp bool, silent bool) (response *LatchStatusResponse, err error)
- func (l *Latch) StatusRequest(query string) (response *LatchStatusResponse, err error)
- func (l *Latch) Unlock(accountId string) (err error)
- func (l *Latch) UnlockOperation(accountId string, operationId string) (err error)
- func (l *Latch) Unpair(accountId string) (err error)
- func (l *Latch) UpdateOperation(operationId string, name string, twoFactor string, lockOnRequest string) (err error)
- type LatchAPI
- type LatchAddApplicationResponse
- type LatchAddOperationResponse
- type LatchApplication
- type LatchApplicationInfo
- type LatchClientVersion
- type LatchError
- type LatchErrorResponse
- type LatchHistoryEntry
- type LatchHistoryResponse
- func (l *LatchHistoryResponse) Application() LatchApplication
- func (l *LatchHistoryResponse) ClientVersion() []LatchClientVersion
- func (l *LatchHistoryResponse) History() []LatchHistoryEntry
- func (l *LatchHistoryResponse) HistoryCount() int
- func (l *LatchHistoryResponse) LastSeen() int64
- func (l *LatchHistoryResponse) Unmarshal(Json string) (err error)
- type LatchOperation
- type LatchOperationStatus
- type LatchPairResponse
- type LatchRequest
- func (l *LatchRequest) GetAuthenticationHeaders() (headers map[string]string)
- func (l *LatchRequest) GetAuthorizationHeader() string
- func (l *LatchRequest) GetFormattedDate() string
- func (l *LatchRequest) GetHttpRequest() *http.Request
- func (l *LatchRequest) GetRequestSignature() string
- func (l *LatchRequest) GetSerializedHeaders() string
- func (l *LatchRequest) GetSerializedParams() string
- func (l *LatchRequest) GetSignedRequestSignature() string
- type LatchResponse
- type LatchShowApplicationsResponse
- type LatchShowOperationResponse
- type LatchStatusResponse
- func (l *LatchStatusResponse) GetParentOperation() (operation LatchOperationStatus)
- func (l *LatchStatusResponse) Operations() map[string]LatchOperationStatus
- func (l *LatchStatusResponse) Status() string
- func (l *LatchStatusResponse) TwoFactor() LatchTwoFactor
- func (l *LatchStatusResponse) Unmarshal(Json string) (err error)
- type LatchSubscriptionResponse
- func (l *LatchSubscriptionResponse) Applications() LatchSubscriptionUsage
- func (l *LatchSubscriptionResponse) ID() string
- func (l *LatchSubscriptionResponse) Operations() map[string]LatchSubscriptionUsage
- func (l *LatchSubscriptionResponse) Unmarshal(Json string) (err error)
- func (l *LatchSubscriptionResponse) Users() LatchSubscriptionUsage
- type LatchSubscriptionUsage
- type LatchTwoFactor
- type LatchUser
- func (l *LatchUser) AddApplication(applicationInfo *LatchApplicationInfo) (response *LatchAddApplicationResponse, err error)
- func (l *LatchUser) DeleteApplication(applicationId string) (err error)
- func (l *LatchUser) ShowApplications() (response *LatchShowApplicationsResponse, err error)
- func (l *LatchUser) Subscription() (response *LatchSubscriptionResponse, err error)
- func (l *LatchUser) UpdateApplication(appID string, applicationInfo *LatchApplicationInfo) (err error)
Constants ¶
const ( //Latch related constants API_URL = "https://latch.elevenpaths.com" API_PATH = "/api" API_VERSION = "1.0" API_CHECK_STATUS_ACTION = "status" API_PAIR_ACTION = "pair" API_PAIR_WITH_ID_ACTION = "pairWithId" API_UNPAIR_ACTION = "unpair" API_LOCK_ACTION = "lock" API_UNLOCK_ACTION = "unlock" API_HISTORY_ACTION = "history" API_OPERATION_ACTION = "operation" API_APPLICATION_ACTION = "application" API_SUBSCRIPTION_ACTION = "subscription" API_NOOTP_SUFFIX = "nootp" API_SILENT_SUFFIX = "silent" API_AUTHENTICATION_METHOD = "11PATHS" API_AUTHORIZATION_HEADER_NAME = "Authorization" API_DATE_HEADER_NAME = "X-11Paths-Date" API_AUTHORIZATION_HEADER_FIELD_SEPARATOR = " " API_X_11PATHS_HEADER_PREFIX = "X-11Paths-" API_X_11PATHS_HEADER_SEPARATOR = ":" API_UTC_STRING_FORMAT = "2006-01-02 15:04:05" //format layout as defined here: http://golang.org/pkg/time/#pkg-constants //Possible values for the Two factor and Lock on request options //NOT_SET is used in the UpdateOperation() method to leave the existing value MANDATORY = "MANDATORY" OPT_IN = "OPT_IN" DISABLED = "DISABLED" NOT_SET = "" //Possible status values for the latch LATCH_STATUS_ON = "on" LATCH_STATUS_OFF = "off" //HTTP methods HTTP_METHOD_POST = "POST" HTTP_METHOD_GET = "GET" HTTP_METHOD_PUT = "PUT" HTTP_METHOD_DELETE = "DELETE" //User agent HTTP_USER_AGENT = "Golatch 1.0" )
Variables ¶
This section is empty.
Functions ¶
func GetLatchURL ¶
Gets the complete url for a request
Types ¶
type Latch ¶
func (*Latch) AddOperation ¶
func (l *Latch) AddOperation(parentId string, name string, twoFactor string, lockOnRequest string) (response *LatchAddOperationResponse, err error)
Adds a new operation
func (*Latch) DeleteOperation ¶
Deletes an existing operation
func (*Latch) History ¶
func (l *Latch) History(accountId string, from t.Time, to t.Time) (response *LatchHistoryResponse, err error)
Gets the account's history between the from and to dates
func (*Latch) LockOperation ¶
Locks an operation, given it's account ID and oeration ID
func (*Latch) OperationStatus ¶
func (l *Latch) OperationStatus(accountId string, operationId string, nootp bool, silent bool) (response *LatchStatusResponse, err error)
Gets the status of an operation, given it's account ID and operation ID If nootp is true, the one time password won't be included in the response If silent is true Latch will not send push notifications to the client (requires SILVER, GOLD or PLATINUM subscription)
func (*Latch) Pair ¶
func (l *Latch) Pair(token string) (response *LatchPairResponse, err error)
Pairs an account with the provided pairing token
func (*Latch) ShowOperation ¶
func (l *Latch) ShowOperation(operationId string) (response *LatchShowOperationResponse, err error)
Shows operations information If operationId is empty this function will retrieve all the operations of the app
func (*Latch) Status ¶
func (l *Latch) Status(accountId string, nootp bool, silent bool) (response *LatchStatusResponse, err error)
Gets the status of an account, given it's account ID If nootp is true, the one time password won't be included in the response If silent is true Latch will not send push notifications to the client (requires SILVER, GOLD or PLATINUM subscription)
func (*Latch) StatusRequest ¶
func (l *Latch) StatusRequest(query string) (response *LatchStatusResponse, err error)
Performs a status request (application or operation) against the query URL provided Returns a LatchStatusResponse struct on success
func (*Latch) UnlockOperation ¶
Unlocks an operation, given it's account ID and oeration ID
type LatchAPI ¶
type LatchAPI struct { Proxy *url.URL OnRequestStart func(request *LatchRequest) OnResponseReceive func(request *LatchRequest, response *http.Response, responseBody string) }
func (*LatchAPI) DoRequest ¶
func (l *LatchAPI) DoRequest(request *LatchRequest, responseType LatchResponse) (response *LatchResponse, err error)
type LatchAddApplicationResponse ¶
type LatchAddApplicationResponse struct { Data struct { AppID string `json:"applicationId"` Secret string `json:"secret"` } `json:"data"` }
func (*LatchAddApplicationResponse) AppID ¶
func (l *LatchAddApplicationResponse) AppID() string
func (*LatchAddApplicationResponse) Secret ¶
func (l *LatchAddApplicationResponse) Secret() string
func (*LatchAddApplicationResponse) Unmarshal ¶
func (l *LatchAddApplicationResponse) Unmarshal(Json string) (err error)
type LatchAddOperationResponse ¶
type LatchAddOperationResponse struct { Data struct { OperationId string `json:"operationId"` } `json:"data"` }
func (*LatchAddOperationResponse) OperationId ¶
func (l *LatchAddOperationResponse) OperationId() string
func (*LatchAddOperationResponse) Unmarshal ¶
func (l *LatchAddOperationResponse) Unmarshal(Json string) (err error)
type LatchApplication ¶
type LatchApplication struct { Status string `json:"status"` PairedOn int64 `json:"pairedOn"` LatchApplicationInfo }
type LatchApplicationInfo ¶
type LatchApplicationInfo struct { Name string `json:"name"` Description string `json:"description"` Secret string `json:"secret"` ImageURL string `json:"imageURL"` ContactPhone string `json:"contactPhone"` ContactEmail string `json:"contactEmail"` TwoFactor string `json:"two_factor"` LockOnRequest string `json:"lock_on_request"` Operations map[string]LatchOperation `json:"operations"` }
type LatchClientVersion ¶
type LatchError ¶
func (*LatchError) Error ¶
func (e *LatchError) Error() string
Implementation of the error interface
type LatchErrorResponse ¶
type LatchErrorResponse struct {
Err LatchError `json:"error"`
}
func (*LatchErrorResponse) Unmarshal ¶
func (l *LatchErrorResponse) Unmarshal(Json string) error
type LatchHistoryEntry ¶
type LatchHistoryResponse ¶
type LatchHistoryResponse struct { AppID string Data struct { Application LatchApplication `json:"application"` LastSeen int64 `json:"lastSeen"` ClientVersion []LatchClientVersion `json:"clientVersion"` HistoryCount int `json:"count"` History []LatchHistoryEntry `json:"history"` } `json:"data"` }
func (*LatchHistoryResponse) Application ¶
func (l *LatchHistoryResponse) Application() LatchApplication
func (*LatchHistoryResponse) ClientVersion ¶
func (l *LatchHistoryResponse) ClientVersion() []LatchClientVersion
func (*LatchHistoryResponse) History ¶
func (l *LatchHistoryResponse) History() []LatchHistoryEntry
func (*LatchHistoryResponse) HistoryCount ¶
func (l *LatchHistoryResponse) HistoryCount() int
func (*LatchHistoryResponse) LastSeen ¶
func (l *LatchHistoryResponse) LastSeen() int64
func (*LatchHistoryResponse) Unmarshal ¶
func (l *LatchHistoryResponse) Unmarshal(Json string) (err error)
type LatchOperation ¶
type LatchOperationStatus ¶
type LatchOperationStatus struct { Status string `json:"status"` TwoFactor LatchTwoFactor `json:"two_factor"` Operations map[string]LatchOperationStatus `json:"operations"` }
type LatchPairResponse ¶
type LatchPairResponse struct { Data struct { AccountId string `json:"accountId"` } `json:"data"` }
func (*LatchPairResponse) AccountId ¶
func (l *LatchPairResponse) AccountId() string
func (*LatchPairResponse) Unmarshal ¶
func (l *LatchPairResponse) Unmarshal(Json string) error
type LatchRequest ¶
type LatchRequest struct { AppID string SecretKey string HttpMethod string URL *url.URL XHeaders map[string]string Params url.Values Date time.Time }
func NewLatchRequest ¶
func NewLatchRequest(appID string, secretKey string, httpMethod string, url *url.URL, xHeaders map[string]string, params url.Values, date time.Time) *LatchRequest
Returns a new LatchRequest initialized with the parameters provided
func (*LatchRequest) GetAuthenticationHeaders ¶
func (l *LatchRequest) GetAuthenticationHeaders() (headers map[string]string)
Gets the authentication headers (Authorization and Date)
func (*LatchRequest) GetAuthorizationHeader ¶
func (l *LatchRequest) GetAuthorizationHeader() string
Gets the Authorization header
func (*LatchRequest) GetFormattedDate ¶
func (l *LatchRequest) GetFormattedDate() string
Gets the current UTC Date/Time as a string formatted using the layout specified in const(API_UTC_STRING_FORMAT)
func (*LatchRequest) GetHttpRequest ¶
func (l *LatchRequest) GetHttpRequest() *http.Request
Gets the HTTP request for this Latch Request
func (*LatchRequest) GetRequestSignature ¶
func (l *LatchRequest) GetRequestSignature() string
Gets the request signature
func (*LatchRequest) GetSerializedHeaders ¶
func (l *LatchRequest) GetSerializedHeaders() string
Gets the serialized request headers (xHeaders) to use in the request signature
func (*LatchRequest) GetSerializedParams ¶
func (l *LatchRequest) GetSerializedParams() string
Gets the serialized request headers (xHeaders) to use in the request signature
func (*LatchRequest) GetSignedRequestSignature ¶
func (l *LatchRequest) GetSignedRequestSignature() string
Gets the signed request signature using HMAC-SHA1 (base64-encoded)
type LatchResponse ¶
type LatchShowApplicationsResponse ¶
type LatchShowApplicationsResponse struct { Data struct { Applications map[string]LatchApplicationInfo `json:"operations"` } `json:"data"` }
func (*LatchShowApplicationsResponse) Applications ¶
func (l *LatchShowApplicationsResponse) Applications() map[string]LatchApplicationInfo
func (*LatchShowApplicationsResponse) Unmarshal ¶
func (l *LatchShowApplicationsResponse) Unmarshal(Json string) (err error)
type LatchShowOperationResponse ¶
type LatchShowOperationResponse struct { Data struct { Operations map[string]LatchOperation `json:"operations"` } `json:"data"` }
func (*LatchShowOperationResponse) FirstOperation ¶
func (l *LatchShowOperationResponse) FirstOperation() (operationId string, operation LatchOperation)
func (*LatchShowOperationResponse) Operations ¶
func (l *LatchShowOperationResponse) Operations() (operations map[string]LatchOperation)
func (*LatchShowOperationResponse) Unmarshal ¶
func (l *LatchShowOperationResponse) Unmarshal(Json string) (err error)
type LatchStatusResponse ¶
type LatchStatusResponse struct { Data struct { Operations map[string]LatchOperationStatus `json:"operations"` } `json:"data"` }
func (*LatchStatusResponse) GetParentOperation ¶
func (l *LatchStatusResponse) GetParentOperation() (operation LatchOperationStatus)
func (*LatchStatusResponse) Operations ¶
func (l *LatchStatusResponse) Operations() map[string]LatchOperationStatus
func (*LatchStatusResponse) Status ¶
func (l *LatchStatusResponse) Status() string
func (*LatchStatusResponse) TwoFactor ¶
func (l *LatchStatusResponse) TwoFactor() LatchTwoFactor
func (*LatchStatusResponse) Unmarshal ¶
func (l *LatchStatusResponse) Unmarshal(Json string) (err error)
type LatchSubscriptionResponse ¶
type LatchSubscriptionResponse struct { Data struct { Subscription struct { ID string `json:"id"` Applications LatchSubscriptionUsage `json:"applications"` Operations map[string]LatchSubscriptionUsage `json:"operations"` Users LatchSubscriptionUsage `json:"users"` } `json:"subscription"` } `json:"data"` }
func (*LatchSubscriptionResponse) Applications ¶
func (l *LatchSubscriptionResponse) Applications() LatchSubscriptionUsage
func (*LatchSubscriptionResponse) ID ¶
func (l *LatchSubscriptionResponse) ID() string
func (*LatchSubscriptionResponse) Operations ¶
func (l *LatchSubscriptionResponse) Operations() map[string]LatchSubscriptionUsage
func (*LatchSubscriptionResponse) Unmarshal ¶
func (l *LatchSubscriptionResponse) Unmarshal(Json string) (err error)
func (*LatchSubscriptionResponse) Users ¶
func (l *LatchSubscriptionResponse) Users() LatchSubscriptionUsage
type LatchSubscriptionUsage ¶
type LatchTwoFactor ¶
type LatchUser ¶
Struct to use the Latch User API
func NewLatchUser ¶
Constructs a new LatchUser struct
func (*LatchUser) AddApplication ¶
func (l *LatchUser) AddApplication(applicationInfo *LatchApplicationInfo) (response *LatchAddApplicationResponse, err error)
Adds a new application
func (*LatchUser) DeleteApplication ¶
Deletes an existing application
func (*LatchUser) ShowApplications ¶
func (l *LatchUser) ShowApplications() (response *LatchShowApplicationsResponse, err error)
Shows existing applications
func (*LatchUser) Subscription ¶
func (l *LatchUser) Subscription() (response *LatchSubscriptionResponse, err error)
Gets the user's subscription information
func (*LatchUser) UpdateApplication ¶
func (l *LatchUser) UpdateApplication(appID string, applicationInfo *LatchApplicationInfo) (err error)
Updates application information