github.com/Files-com/files-sdk-go/v3@v3.1.81/publicipaddress.go (about) 1 package files_sdk 2 3 import ( 4 "encoding/json" 5 6 lib "github.com/Files-com/files-sdk-go/v3/lib" 7 ) 8 9 type PublicIpAddress struct { 10 IpAddress string `json:"ip_address,omitempty" path:"ip_address,omitempty" url:"ip_address,omitempty"` 11 ServerName string `json:"server_name,omitempty" path:"server_name,omitempty" url:"server_name,omitempty"` 12 FtpEnabled *bool `json:"ftp_enabled,omitempty" path:"ftp_enabled,omitempty" url:"ftp_enabled,omitempty"` 13 SftpEnabled *bool `json:"sftp_enabled,omitempty" path:"sftp_enabled,omitempty" url:"sftp_enabled,omitempty"` 14 } 15 16 // Identifier no path or id 17 18 type PublicIpAddressCollection []PublicIpAddress 19 20 func (p *PublicIpAddress) UnmarshalJSON(data []byte) error { 21 type publicIpAddress PublicIpAddress 22 var v publicIpAddress 23 if err := json.Unmarshal(data, &v); err != nil { 24 return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{}) 25 } 26 27 *p = PublicIpAddress(v) 28 return nil 29 } 30 31 func (p *PublicIpAddressCollection) UnmarshalJSON(data []byte) error { 32 type publicIpAddresss PublicIpAddressCollection 33 var v publicIpAddresss 34 if err := json.Unmarshal(data, &v); err != nil { 35 return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{}) 36 } 37 38 *p = PublicIpAddressCollection(v) 39 return nil 40 } 41 42 func (p *PublicIpAddressCollection) ToSlice() *[]interface{} { 43 ret := make([]interface{}, len(*p)) 44 for i, v := range *p { 45 ret[i] = v 46 } 47 48 return &ret 49 }