mirror of
https://github.com/ente-io/ente.git
synced 2025-05-22 11:20:30 +00:00
[cli] Add API to get authenticator data
This commit is contained in:
parent
6b831378ba
commit
cda7dda3cb
41
cli/internal/api/authenticator.go
Normal file
41
cli/internal/api/authenticator.go
Normal file
@ -0,0 +1,41 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/ente-io/cli/internal/api/models"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func (c *Client) GetAuthKey(ctx context.Context) (*models.AuthKey, error) {
|
||||
var res models.AuthKey
|
||||
r, err := c.restClient.R().
|
||||
SetContext(ctx).
|
||||
SetResult(&res).
|
||||
Get("/authenticator/key")
|
||||
if r.IsError() {
|
||||
return nil, &ApiError{
|
||||
StatusCode: r.StatusCode(),
|
||||
Message: r.String(),
|
||||
}
|
||||
}
|
||||
return &res, err
|
||||
}
|
||||
|
||||
func (c *Client) GetDiff(ctx context.Context, sinceTime int64, limit int64) ([]models.AuthEntity, error) {
|
||||
var res struct {
|
||||
Diff []models.AuthEntity `json:"diff"`
|
||||
}
|
||||
r, err := c.restClient.R().
|
||||
SetContext(ctx).
|
||||
SetQueryParam("sinceTime", strconv.FormatInt(sinceTime, 10)).
|
||||
SetQueryParam("limit", strconv.FormatInt(limit, 10)).
|
||||
SetResult(&res).
|
||||
Get("/authenticator/entity/diff")
|
||||
if r.IsError() {
|
||||
return nil, &ApiError{
|
||||
StatusCode: r.StatusCode(),
|
||||
Message: r.String(),
|
||||
}
|
||||
}
|
||||
return res.Diff, err
|
||||
}
|
16
cli/internal/api/models/authenticator.go
Normal file
16
cli/internal/api/models/authenticator.go
Normal file
@ -0,0 +1,16 @@
|
||||
package models
|
||||
|
||||
type AuthKey struct {
|
||||
UserID int64 `json:"userID" binding:"required"`
|
||||
EncryptedKey string `json:"encryptedKey" binding:"required"`
|
||||
Header string `json:"header" binding:"required"`
|
||||
}
|
||||
|
||||
type AuthEntity struct {
|
||||
ID string `json:"id" binding:"required"`
|
||||
EncryptedKey *string `json:"encryptedKey"`
|
||||
Header *string `json:"header"`
|
||||
IsDeleted bool `json:"isDeleted" binding:"required"`
|
||||
CreatedAt int64 `json:"createdAt" binding:"required"`
|
||||
UpdatedAt int64 `json:"updatedAt" binding:"required"`
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user