Skip to content

Commit

Permalink
admin model structure
Browse files Browse the repository at this point in the history
  • Loading branch information
CreatureDev committed Apr 27, 2023
1 parent dbe0dd2 commit 9cbb47c
Show file tree
Hide file tree
Showing 39 changed files with 369 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package admin
package data

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package admin
package data

type CanDeleteResponse struct {
CanDelete int `json:"can_delete"`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package admin
package data

type CrawlShardsRequest struct {
PublicKey bool `json:"public_key,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package admin
package data

type CrawlShardsResponse struct {
CompleteShards string `json:"complete_shards,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package admin
package data

import "github.com/xyield/xrpl-go/model/client/common"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package admin
package data

type DownloadShardResponse struct {
Message string `json:"message"`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package admin
package data

import "github.com/xyield/xrpl-go/model/client/common"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package admin
package data

type LedgerCleanerResponse struct {
Message string `json:"message"`
Expand Down
12 changes: 12 additions & 0 deletions model/client/admin/data/ledger_request_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package data

import "github.com/xyield/xrpl-go/model/client/common"

type LedgerRequestRequest struct {
LedgerIndex common.LedgerIndex `json:"ledger_index,omitempty"`
LedgerHash common.LedgerHash `json:"ledger_hash,omitempty"`
}

func (*LedgerRequest) Method() string {
return "ledger_request"
}
20 changes: 20 additions & 0 deletions model/client/admin/data/ledger_request_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package data

import (
"github.com/xyield/xrpl-go/model/client/common"
"github.com/xyield/xrpl-go/model/client/ledger"
)

type LedgerRequestResponse struct {
ledger.LedgerHeader
LedgerRequest
Acquiring LedgerRequest `json:"acquiring"`
}

type LedgerRequest struct {
Hash common.LedgerHash `json:"hash,omitempty"`
HaveHeader bool `json:"have_header"`
HaveState bool `json:"have_state,omitempty"`
HaveTransactions bool `json:"have_transactions,omitempty"`
NeededStateHashes []string `json:"needed_state_hashes,omitempty"`
}
6 changes: 6 additions & 0 deletions model/client/admin/data/log_level_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package data

type LogLevelRequest struct {
Severity string `json:"severity,omitempty"`
Partition string `json:"partition,omitempty"`
}
5 changes: 5 additions & 0 deletions model/client/admin/data/log_level_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package data

type LogLevelResponse struct {
Levels map[string]string `json:"levels,omitempty"`
}
8 changes: 8 additions & 0 deletions model/client/admin/data/logrotate_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package data

type LogrotateRequest struct {
}

func (*LogrotateRequest) Method() string {
return "logrotate"
}
5 changes: 5 additions & 0 deletions model/client/admin/data/logrotate_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package data

type LogrotateResponse struct {
Message string `json:"message"`
}
5 changes: 5 additions & 0 deletions model/client/admin/data/node_to_shard_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package data

type NodeToShardRequest struct {
Action string `json:"action"`
}
5 changes: 5 additions & 0 deletions model/client/admin/data/node_to_shard_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package data

type NodeToShardResponse struct {
Message string `json:"message"`
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package admin
package key

type ValidationCreateRequest struct {
Secret string `json:"secret,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package admin
package key

type ValidationCreateResponse struct {
ValidationKey string `json:"validation_key"`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package admin
package key

type WalletProposeRequest struct {
KeyType string `json:"key_type"`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package admin
package key

import "github.com/xyield/xrpl-go/model/transactions/types"

Expand Down
6 changes: 6 additions & 0 deletions model/client/admin/peer/connect_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package peer

type ConnectRequest struct {
IP string `json:"ip"`
Port int `json:"port,omitempty"`
}
5 changes: 5 additions & 0 deletions model/client/admin/peer/connect_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package peer

type ConnectResponse struct {
Message string `json:"message"`
}
6 changes: 6 additions & 0 deletions model/client/admin/peer/peer_reservation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package peer

type PeerReservation struct {
Node string `json:"node"`
Description string `json:"description,omitempty"`
}
10 changes: 10 additions & 0 deletions model/client/admin/peer/peer_reservations_add_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package peer

type PeerReservationAddRequest struct {
PublicKey string `json:"public_key"`
Description string `json:"description,omitempty"`
}

func (*PeerReservationAddRequest) Method() string {
return "peer_reservations_add"
}
5 changes: 5 additions & 0 deletions model/client/admin/peer/peer_reservations_add_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package peer

type PeerReservationsAddResponse struct {
Previous *PeerReservation `json:"previous,omitempty"`
}
9 changes: 9 additions & 0 deletions model/client/admin/peer/peer_reservations_del_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package peer

type PeerReservationDelRequest struct {
PublicKey string `json:"public_key"`
}

func (*PeerReservationDelRequest) Method() string {
return "peer_reservations_del"
}
5 changes: 5 additions & 0 deletions model/client/admin/peer/peer_reservations_del_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package peer

type PeerReservationsDelResponse struct {
Previous PeerReservation `json:"previous"`
}
8 changes: 8 additions & 0 deletions model/client/admin/peer/peer_reservations_list_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package peer

type PeerReservationsListRequest struct {
}

func (*PeerReservationsListRequest) Method() string {
return "peer_reservations_list"
}
5 changes: 5 additions & 0 deletions model/client/admin/peer/peer_reservations_list_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package peer

type PeerReservationsListResponse struct {
Reservations []PeerReservation `json:"reservations"`
}
8 changes: 8 additions & 0 deletions model/client/admin/peer/peers_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package peer

type PeersRequest struct {
}

func (*PeersRequest) Method() string {
return "peers"
}
36 changes: 36 additions & 0 deletions model/client/admin/peer/peers_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package peer

type PeersResponse struct {
Cluster Cluster `json:"cluster"`
Peers []Peer `json:"peers"`
}

type Cluster struct {
Tag string `json:"tag,omitempty"`
Fee int `json:"fee,omitempty"`
Age int `json:"age,omitempty"`
}

type Peer struct {
Address string `json:"address"`
Cluster bool `json:"cluster,omitempty"`
Name string `json:"name,omitempty"`
CompleteLedgers string `json:"complete_ledgers"`
Inbound bool `json:"inbound,omitempty"`
Latency int `json:"latency"`
Ledger string `json:"ledger"`
Load int `json:"load"`
Metrics Metrics `json:"metrics"`
PublicKey string `json:"public_key,omitempty"`
Sanity string `json:"sanity,omitempty"`
Status string `json:"status,omitempty"`
Uptime uint `json:"uptime"`
Version string `json:"version"`
}

type Metrics struct {
AvgBpsRecv string `json:"avg_bps_recv"`
AvgBpsSent string `json:"avg_bps_sent"`
TotalBytesRecv string `json:"total_bytes_recv"`
TotalBytesSent string `json:"total_bytes_sent"`
}
8 changes: 8 additions & 0 deletions model/client/admin/server/ledger_accept_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package server

type LedgerAcceptRequest struct {
}

func (*LedgerAcceptRequest) Method() string {
return "leder_accept"
}
7 changes: 7 additions & 0 deletions model/client/admin/server/ledger_accept_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package server

import "github.com/xyield/xrpl-go/model/client/common"

type LedgerAcceptResponse struct {
LedgerCurrentIndex common.LedgerIndex `json:"ledger_current_index"`
}
8 changes: 8 additions & 0 deletions model/client/admin/server/stop_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package server

type StopRequest struct {
}

func (*StopRequest) Method() string {
return "stop"
}
5 changes: 5 additions & 0 deletions model/client/admin/server/stop_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package server

type StopResponse struct {
Message string `json:"message"`
}
49 changes: 49 additions & 0 deletions model/client/admin/signing/sign_for_request.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package signing

import (
"encoding/json"

"github.com/xyield/xrpl-go/model/transactions"
"github.com/xyield/xrpl-go/model/transactions/types"
)

type SignForRequest struct {
Account types.Address `json:"account"`
TxJson transactions.Tx `json:"tx_json"`
Secret string `json:"secret,omitempty"`
Seed string `json:"seed,omitempty"`
SeedHex string `json:"seed_hex,omitempty"`
Passphrase string `json:"passphrase,omitempty"`
KeyType string `json:"key_type,omitempty"`
}

func (*SignForRequest) Method() string {
return "sign"
}

func (r *SignForRequest) UnmarshalJSON(data []byte) error {
type srHelper struct {
Account types.Address `json:"account"`
TxJson json.RawMessage `json:"tx_json"`
Secret string `json:"secret,omitempty"`
Seed string `json:"seed,omitempty"`
SeedHex string `json:"seed_hex,omitempty"`
Passphrase string `json:"passphrase,omitempty"`
KeyType string `json:"key_type,omitempty"`
}
var h srHelper
err := json.Unmarshal(data, &h)
*r = SignForRequest{
Account: h.Account,
Secret: h.Secret,
Seed: h.Seed,
SeedHex: h.SeedHex,
Passphrase: h.Passphrase,
KeyType: h.KeyType,
}
if err != nil {
return err
}
r.TxJson, err = transactions.UnmarshalTx(h.TxJson)
return err
}
27 changes: 27 additions & 0 deletions model/client/admin/signing/sign_for_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package signing

import (
"encoding/json"

"github.com/xyield/xrpl-go/model/transactions"
)

type SignForResponse struct {
TxBlob string `json:"tx_blob"`
TxJson transactions.Tx `json:"tx_json"`
}

func (r *SignForResponse) UnmarshalJSON(data []byte) error {
type srHelper struct {
TxBlob string `json:"tx_blob"`
TxJson json.RawMessage `json:"tx_json"`
}
var h srHelper
err := json.Unmarshal(data, &h)
if err != nil {
return nil
}
r.TxBlob = h.TxBlob
r.TxJson, err = transactions.UnmarshalTx(h.TxJson)
return err
}
Loading

0 comments on commit 9cbb47c

Please sign in to comment.