|
| 1 | +package bigdatacloud |
| 2 | + |
| 3 | +type ErrData struct { |
| 4 | + StatusCode int `json:"status_code"` |
| 5 | + Status int64 `json:"status"` |
| 6 | + Description string `json:"description"` |
| 7 | +} |
| 8 | + |
| 9 | +func (r *ErrData) SetStatusCode(code int) { |
| 10 | + r.StatusCode = code |
| 11 | +} |
| 12 | + |
| 13 | +func (r ErrData) HasError() bool { |
| 14 | + return r.StatusCode >= 400 |
| 15 | +} |
| 16 | + |
| 17 | +// IPResponse is a response data of IP Geolocation APIs. |
| 18 | +// ref: https://www.bigdatacloud.com/ip-geolocation-apis |
| 19 | +type IPResponse struct { |
| 20 | + ErrData |
| 21 | + |
| 22 | + IP string `json:"ip"` |
| 23 | + LocalityLanguageRequested string `json:"localityLanguageRequested"` |
| 24 | + IsReachableGlobally bool `json:"isReachableGlobally"` |
| 25 | + Country Country `json:"country"` |
| 26 | + Location Location `json:"location"` |
| 27 | + LastUpdated string `json:"lastUpdated"` |
| 28 | + Network Network `json:"network"` |
| 29 | + Confidence string `json:"confidence"` |
| 30 | + ConfidenceArea []Area `json:"confidenceArea"` |
| 31 | + SecurityThreat string `json:"securityThreat"` |
| 32 | + HazardReport HazardReport `json:"hazardReport"` |
| 33 | +} |
| 34 | + |
| 35 | +type Country struct { |
| 36 | + ISOAlpha2 string `json:"isoAlpha2"` |
| 37 | + ISOAlpha3 string `json:"isoAlpha3"` |
| 38 | + M49Code int64 `json:"m49Code"` |
| 39 | + Name string `json:"name"` |
| 40 | + ISOName string `json:"isoName"` |
| 41 | + ISONameFull string `json:"isoNameFull"` |
| 42 | + ISOAdminLanguages []ISOAdminLanguage `json:"isoAdminLanguages"` |
| 43 | + UNRegion string `json:"unRegion"` |
| 44 | + Currency Currency `json:"currency"` |
| 45 | + WBRegion WBRegion `json:"wbRegion"` |
| 46 | + WBIncomeLevel WBIncomeLevel `json:"wbIncomeLevel"` |
| 47 | + CallingCode string `json:"callingCode"` |
| 48 | + CountryFlagEmoji string `json:"countryFlagEmoji"` |
| 49 | + WikidataID string `json:"wikidataId"` |
| 50 | + GeonameID int64 `json:"geonameId"` |
| 51 | + Continents []Continent `json:"continents"` |
| 52 | +} |
| 53 | + |
| 54 | +type ISOAdminLanguage struct { |
| 55 | + ISOAlpha3 string `json:"isoAlpha3"` |
| 56 | + ISOAlpha2 string `json:"isoAlpha2"` |
| 57 | + ISOName string `json:"isoName"` |
| 58 | + NativeName string `json:"nativeName"` |
| 59 | +} |
| 60 | + |
| 61 | +type Currency struct { |
| 62 | + NumericCode int64 `json:"numericCode"` |
| 63 | + Code string `json:"code"` |
| 64 | + Name string `json:"name"` |
| 65 | + MinorUnits int64 `json:"minorUnits"` |
| 66 | +} |
| 67 | + |
| 68 | +type WBRegion struct { |
| 69 | + ID string `json:"id"` |
| 70 | + ISO2code string `json:"iso2code"` |
| 71 | + Value string `json:"value"` |
| 72 | +} |
| 73 | + |
| 74 | +type WBIncomeLevel struct { |
| 75 | + ID string `json:"id"` |
| 76 | + ISO2code string `json:"iso2code"` |
| 77 | + Value string `json:"value"` |
| 78 | +} |
| 79 | + |
| 80 | +type Continent struct { |
| 81 | + Continent string `json:"continent"` |
| 82 | + ContinentCode string `json:"continentCode"` |
| 83 | +} |
| 84 | + |
| 85 | +type Location struct { |
| 86 | + Continent string `json:"continent"` |
| 87 | + ContinentCode string `json:"continentCode"` |
| 88 | + ISOPrincipalSubdivision string `json:"isoPrincipalSubdivision"` |
| 89 | + ISOPrincipalSubdivisionCode string `json:"isoPrincipalSubdivisionCode"` |
| 90 | + City string `json:"city"` |
| 91 | + LocalityName string `json:"localityName"` |
| 92 | + PostCode string `json:"postcode"` |
| 93 | + Latitude float64 `json:"latitude"` |
| 94 | + Longitude float64 `json:"longitude"` |
| 95 | + PlusCode string `json:"plusCode"` |
| 96 | + TimeZone TimeZone `json:"timeZone"` |
| 97 | + LocalityInfo LocalityInfo `json:"localityInfo"` |
| 98 | +} |
| 99 | + |
| 100 | +type TimeZone struct { |
| 101 | + IANATimeID string `json:"ianaTimeId"` |
| 102 | + DisplayName string `json:"displayName"` |
| 103 | + EffectiveTimeZoneFull string `json:"effectiveTimeZoneFull"` |
| 104 | + EffectiveTimeZoneShort string `json:"effectiveTimeZoneShort"` |
| 105 | + UTCOffsetSeconds int64 `json:"utcOffsetSeconds"` |
| 106 | + UTCOffset string `json:"utcOffset"` |
| 107 | + IsDaylightSavingTime bool `json:"isDaylightSavingTime"` |
| 108 | + LocalTime string `json:"localTime"` |
| 109 | +} |
| 110 | + |
| 111 | +type LocalityInfo struct { |
| 112 | + Administrative []LocalityInfoData `json:"administrative"` |
| 113 | + Informative []LocalityInfoData `json:"informative"` |
| 114 | +} |
| 115 | + |
| 116 | +type LocalityInfoData struct { |
| 117 | + Order int64 `json:"order"` |
| 118 | + AdminLevel int64 `json:"adminLevel"` |
| 119 | + Name string `json:"name"` |
| 120 | + Description string `json:"description"` |
| 121 | + ISOName string `json:"isoName"` |
| 122 | + ISOCode string `json:"isoCode"` |
| 123 | + WikidataID string `json:"wikidataId"` |
| 124 | + GeonameID int64 `json:"geonameId"` |
| 125 | +} |
| 126 | + |
| 127 | +type Network struct { |
| 128 | + Registry string `json:"registry"` |
| 129 | + RegistryStatus string `json:"registryStatus"` |
| 130 | + RegisteredCountry string `json:"registeredCountry"` |
| 131 | + RegisteredCountryName string `json:"registeredCountryName"` |
| 132 | + Organisation string `json:"organisation"` |
| 133 | + IsReachableGlobally bool `json:"isReachableGlobally"` |
| 134 | + IsBogon bool `json:"isBogon"` |
| 135 | + BGPPrefix string `json:"bgpPrefix"` |
| 136 | + BGPPrefixNetworkAddress string `json:"bgpPrefixNetworkAddress"` |
| 137 | + BGPPrefixLastAddress string `json:"bgpPrefixLastAddress"` |
| 138 | + TotalAddresses int64 `json:"totalAddresses"` |
| 139 | + Carriers []Carrier `json:"carriers"` |
| 140 | + ViaCarriers []Carrier `json:"viaCarriers"` |
| 141 | +} |
| 142 | + |
| 143 | +type Carrier struct { |
| 144 | + ASN string `json:"asn"` |
| 145 | + ASNNumeric int64 `json:"asnNumeric"` |
| 146 | + Organisation string `json:"organisation"` |
| 147 | + Name string `json:"name"` |
| 148 | + TotalIpv4Addresses int64 `json:"totalIpv4Addresses"` |
| 149 | + TotalIpv4Prefixes int64 `json:"totalIpv4Prefixes"` |
| 150 | + TotalIpv4BogonPrefixes int64 `json:"totalIpv4BogonPrefixes"` |
| 151 | + Rank int64 `json:"rank"` |
| 152 | + RankText string `json:"rankText"` |
| 153 | +} |
| 154 | + |
| 155 | +type Area struct { |
| 156 | + Latitude float64 `json:"latitude"` |
| 157 | + Longitude float64 `json:"longitude"` |
| 158 | +} |
| 159 | + |
| 160 | +type HazardReport struct { |
| 161 | + IsKnownAsTorServer bool `json:"isKnownAsTorServer"` |
| 162 | + IsKnownAsVPN bool `json:"isKnownAsVpn"` |
| 163 | + IsKnownAsProxy bool `json:"isKnownAsProxy"` |
| 164 | + IsSpamhausDrop bool `json:"isSpamhausDrop"` |
| 165 | + IsSpamhausEdrop bool `json:"isSpamhausEdrop"` |
| 166 | + IsSpamhausAsnDrop bool `json:"isSpamhausAsnDrop"` |
| 167 | + IsBlacklistedUceprotect bool `json:"isBlacklistedUceprotect"` |
| 168 | + IsBlacklistedBlocklistDe bool `json:"isBlacklistedBlocklistDe"` |
| 169 | + IsKnownAsMailServer bool `json:"isKnownAsMailServer"` |
| 170 | + IsKnownAsPublicRouter bool `json:"isKnownAsPublicRouter"` |
| 171 | + IsBogon bool `json:"isBogon"` |
| 172 | + IsUnreachable bool `json:"isUnreachable"` |
| 173 | + HostingLikelihood int64 `json:"hostingLikelihood"` // [0 - 10] |
| 174 | + IsHostingASN bool `json:"isHostingAsn"` |
| 175 | + IsCellular bool `json:"isCellular"` |
| 176 | +} |
0 commit comments