Skip to content

Commit da04ae5

Browse files
Add connection.is_anycast to the response model
1 parent 13769db commit da04ae5

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9+
### Added
10+
- New field `Connection.isAnycast()` (JSON `connection.is_anycast`): whether the IP address is announced via anycast, i.e. simultaneously from multiple locations.
911

1012
## [7.0.0] - 2026-07-13
1113
### Changed

‎src/main/java/co/ipregistry/api/client/model/Connection.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ public Connection() {
5050
@JsonProperty("domain")
5151
private String domain;
5252

53+
/**
54+
* Whether the IP address is announced via anycast, i.e. simultaneously from multiple locations.
55+
*/
56+
@JsonProperty("is_anycast")
57+
private boolean anycast;
58+
5359
/**
5460
* The name of the organization or ISP that owns the IP address.
5561
*/
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright 2019 Ipregistry (https://ipregistry.co).
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package co.ipregistry.api.client.model;
17+
18+
19+
import tools.jackson.databind.ObjectMapper;
20+
import org.junit.jupiter.api.Assertions;
21+
import org.junit.jupiter.api.Test;
22+
23+
24+
class ConnectionTest {
25+
26+
private static final ObjectMapper MAPPER = new ObjectMapper();
27+
28+
@Test
29+
void testDeserializeFullPayload() {
30+
final Connection connection = MAPPER.readValue("{\n" +
31+
" \"asn\" : 15169,\n" +
32+
" \"domain\" : \"google.com\",\n" +
33+
" \"is_anycast\" : true,\n" +
34+
" \"organization\" : \"Google LLC\",\n" +
35+
" \"route\" : \"8.8.8.0/24\",\n" +
36+
" \"type\" : \"hosting\"\n" +
37+
" }", Connection.class);
38+
39+
Assertions.assertEquals(15169L, connection.getAsn());
40+
Assertions.assertEquals("google.com", connection.getDomain());
41+
Assertions.assertTrue(connection.isAnycast());
42+
Assertions.assertEquals("Google LLC", connection.getOrganization());
43+
Assertions.assertEquals("8.8.8.0/24", connection.getRoute());
44+
Assertions.assertEquals(ConnectionType.HOSTING, connection.getType());
45+
}
46+
47+
@Test
48+
void testIsAnycastFalse() {
49+
final Connection connection = MAPPER.readValue("{\"is_anycast\" : false}", Connection.class);
50+
51+
Assertions.assertFalse(connection.isAnycast());
52+
}
53+
54+
@Test
55+
void testIsAnycastDefaultsToFalseWhenAbsent() {
56+
final Connection connection = MAPPER.readValue("{\"asn\" : 15169}", Connection.class);
57+
58+
Assertions.assertFalse(connection.isAnycast());
59+
}
60+
61+
}

0 commit comments

Comments
 (0)