Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manishmeganathan/go-moibit-client
Golang Client Library for interacting with MOIBit's Decentralized Storage API's
https://github.com/manishmeganathan/go-moibit-client
client-library decentralized-storage golang moibit
Last synced: 29 days ago
JSON representation
Golang Client Library for interacting with MOIBit's Decentralized Storage API's
- Host: GitHub
- URL: https://github.com/manishmeganathan/go-moibit-client
- Owner: manishmeganathan
- License: apache-2.0
- Created: 2022-08-04T07:03:51.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-10T04:46:39.000Z (over 2 years ago)
- Last Synced: 2024-10-18T13:31:06.830Z (3 months ago)
- Topics: client-library, decentralized-storage, golang, moibit
- Language: Go
- Homepage:
- Size: 74.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-moibit-client
Golang Client Library for interacting with MOIBit's Decentralized Storage API's## Types
-Client
-FileDescriptor
-AppDescriptor
-DevDescriptor
## Methods for File/Directory stats
-ListFiles
-FileStatus
-FileVersions
## Methods for Read/Write operations
-ReadFile
-WriteFile
-RemoveFile
-MakeDirectory
## Methods for App/Dev details
-AppDetails
-DevDetails
## Client
Client provides various methods to interact with MOIBit.
``` go
type Client struct {
// contains filtered or unexported fields
}
```
## App Descriptor
App Descriptors holds metadata of an app registered with MOIBit.
```go
type AppDescriptor struct {
IsActive bool `json:"isActive"`
IsRemoved bool `json:"isRemoved"`
// app meta data
AppID string `json:"appID"`
AppName string `json:"appName"`
AppDescription string `json:"appDescription"`
EndUsers interface{} `json:"endUsers"`
// network meta data
NetworkID string `json:"networkID"`
NetworkName string `json:"networkName"`
Replication int `json:"replication"`
CanEncrypt interface{} `json:"canEncrypt"`
EncryptionType int `json:"encryptionType"`
CustomKey interface{} `json:"customKey"`
RecoveryTime int64 `json:"recoveryTime"`
}
```
## File Descriptor
File Descriptor holds metadata of a file.
```go
type FileDescriptor struct {
FileVersionDescriptor // inlined JSONPath string `json:"path"`
IsDirectory bool `json:"isDir"`
Directory string `json:"directory"`
NodeAddress string `json:"nodeAddress"`
}
```
## Dev Descriptor
Dev Descriptor holds metadata of a developer.
```go
type DevDescriptor struct {
Active bool `json:"active"`
Key interface{} `json:"key"`Name string `json:"name"`
Email string `json:"email"`Apps []struct {
IsActive bool `json:"isActive"`
IsRemoved bool `json:"isRemoved"`AppID string `json:"appID"`
AppName string `json:"appName"`Replication int `json:"replication"`
EncryptionType int `json:"encryptionType"`
EncryptionAlgo string `json:"encryptionAlgo"`
RecoveryTime int64 `json:"recoveryTime"`NetworkID string `json:"networkID"`
NetworkName string `json:"networkName"`
} `json:"apps"`Networks interface{} `json:"networks"`
DevPubKey interface{} `json:"devPubKey"`
Encryption interface{} `json:"encryption"`IsActive bool `json:"isActive"`
Creditcard bool `json:"creditcard"`
Canencrypt bool `json:"canencrypt"`
Canreplicate bool `json:"canreplicate"`
Cancreatenetwork bool `json:"cancreatenetwork"`Maxstorage int `json:"maxstorage"`
ReplicationFactor int `json:"replicationFactor"`
Plan int `json:"plan"`
StripeCustomerID string `json:"stripeCustomerID"`
StripeSubscriptionID string `json:"stripeSubscriptionID"`NoOfPremiumNodes int `json:"noOfPremiumNodes"`
NoOfApps int `json:"noOfApps"`
PremiumNodesList interface{} `json:"premiumNodesList"`Credit int `json:"credit"`
FreeTrial bool `json:"freeTrial"`
AnnualSubscription bool `json:"AnnualSubscription"`
FreeTrialJoiningDate int `json:"freeTrialJoiningDate"`
}
```
### ListFiles(path string) ([]FileDescriptor, error)
ListFiles lists the files for a specified path,The files are returned as a slice of FileDescriptor objects.
An error is returned if the API fails or the client cannot authenticate with MOIBit.
```go
func (client *Client) ListFiles(path string) ([]FileDescriptor, error)
```
### FileStatus(path string) (FileDescriptor, error)
FileStatus returns the status of a file at a specified path, The returned FileStatus is empty if the file does not exist, which can be checked with Exists().
An error is returned if the API fails or the client cannot authenticate with MOIBit.
```go
func (client *Client) ListFiles(path string) ([]FileDescriptor, error)
```
### FileVersions(path string) ([]FileVersionDescriptor, error)
FileVersions returns the version information of the file at the given path.
Returns a slice of FileVersionDescriptor objects, one for each version.
```go
func (client *Client) FileVersions(path string) ([]FileVersionDescriptor, error)
```
### ReadFile(path string, version int) ([]byte, error)
ReadFile reads a file from MOIBit at the given path for the given version.
Returns the []byte data of the file and an error.
```go
func (client *Client) ReadFile(path string, version int) ([]byte, error)
```
### WriteFile(data []byte, name string, opts ...WriteOption) (FileDescriptor, error)
WriteFile writes a given file to MOIBit. Accepts the file data as raw bytes and the file name.
It also accepts a variadic number of WriteOption to modify the write request.
Returns a FileDescriptor (and error) containing the status of the file after successful write.
```go
func (client *Client) WriteFile(data []byte, name string, opts ...WriteOption) (FileDescriptor, error)
```
### RemoveFile(path string, version int, opts ...RemoveOption) error
RemoveFile removes a file at the given path of the specified version.
It also accepts a variadic number of RemoveOption to modify the remove request.
- To remove directories, use the path to the directory and pass the RemoveDirectory option.
- To restore files, pass the file path and version to restore with the PerformRestore option.
This call is used to create and assign an activity to a user, this call return an error in the following cases.
```go
func (client *Client) RemoveFile(path string, version int, opts ...RemoveOption) error
```
### MakeDirectory(path string) error
MakeDirectory creates a new directory at the given path which can than be used for storing files.
```go
func (client *Client) MakeDirectory(path string) error
```
### AppDetails() (AppDescriptor, error) {
AppDetails returns the details of the application the client is configured for as a AppDescriptor object
```go
func (client *Client) AppDetails() (AppDescriptor, error)
```
### DevDetails() (DevDescriptor, error) {
DevDetails returns the details of developer user the client is configured for as a DevDescriptor object
```go
func (client *Client) DevDetails() (DevDescriptor, error)
```