github.com/Files-com/files-sdk-go/v2@v2.1.2/sftphostkey.go (about) 1 package files_sdk 2 3 import ( 4 "encoding/json" 5 6 lib "github.com/Files-com/files-sdk-go/v2/lib" 7 ) 8 9 type SftpHostKey struct { 10 Id int64 `json:"id,omitempty" path:"id,omitempty" url:"id,omitempty"` 11 Name string `json:"name,omitempty" path:"name,omitempty" url:"name,omitempty"` 12 FingerprintMd5 string `json:"fingerprint_md5,omitempty" path:"fingerprint_md5,omitempty" url:"fingerprint_md5,omitempty"` 13 FingerprintSha256 string `json:"fingerprint_sha256,omitempty" path:"fingerprint_sha256,omitempty" url:"fingerprint_sha256,omitempty"` 14 PrivateKey string `json:"private_key,omitempty" path:"private_key,omitempty" url:"private_key,omitempty"` 15 } 16 17 func (s SftpHostKey) Identifier() interface{} { 18 return s.Id 19 } 20 21 type SftpHostKeyCollection []SftpHostKey 22 23 type SftpHostKeyListParams struct { 24 ListParams 25 } 26 27 type SftpHostKeyFindParams struct { 28 Id int64 `url:"-,omitempty" required:"false" json:"-,omitempty" path:"id"` 29 } 30 31 type SftpHostKeyCreateParams struct { 32 Name string `url:"name,omitempty" required:"false" json:"name,omitempty" path:"name"` 33 PrivateKey string `url:"private_key,omitempty" required:"false" json:"private_key,omitempty" path:"private_key"` 34 } 35 36 type SftpHostKeyUpdateParams struct { 37 Id int64 `url:"-,omitempty" required:"false" json:"-,omitempty" path:"id"` 38 Name string `url:"name,omitempty" required:"false" json:"name,omitempty" path:"name"` 39 PrivateKey string `url:"private_key,omitempty" required:"false" json:"private_key,omitempty" path:"private_key"` 40 } 41 42 type SftpHostKeyDeleteParams struct { 43 Id int64 `url:"-,omitempty" required:"false" json:"-,omitempty" path:"id"` 44 } 45 46 func (s *SftpHostKey) UnmarshalJSON(data []byte) error { 47 type sftpHostKey SftpHostKey 48 var v sftpHostKey 49 if err := json.Unmarshal(data, &v); err != nil { 50 return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{}) 51 } 52 53 *s = SftpHostKey(v) 54 return nil 55 } 56 57 func (s *SftpHostKeyCollection) UnmarshalJSON(data []byte) error { 58 type sftpHostKeys SftpHostKeyCollection 59 var v sftpHostKeys 60 if err := json.Unmarshal(data, &v); err != nil { 61 return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{}) 62 } 63 64 *s = SftpHostKeyCollection(v) 65 return nil 66 } 67 68 func (s *SftpHostKeyCollection) ToSlice() *[]interface{} { 69 ret := make([]interface{}, len(*s)) 70 for i, v := range *s { 71 ret[i] = v 72 } 73 74 return &ret 75 }