Skip to content

Commit c725d79

Browse files
Merge branch 'develop' into feature/STORIF-310
2 parents 61ce28a + 86b631c commit c725d79

74 files changed

Lines changed: 3081 additions & 544 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/api-v4": Upcoming Features
3+
---
4+
5+
Reserved IPs: Added new API endpoints ([#13517](https://github.com/linode/manager/pull/13517))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
export * from './images';
22

3+
export * from './sharegroups';
4+
35
export * from './types';

packages/api-v4/src/networking/networking.ts

Lines changed: 108 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
allocateIPSchema,
33
assignAddressesSchema,
4+
reserveIPSchema,
45
shareAddressesSchema,
56
updateIPSchema,
67
} from '@linode/validation/lib/networking.schema';
@@ -14,14 +15,16 @@ import Request, {
1415
setXFilter,
1516
} from '../request';
1617

17-
import type { Filter, ResourcePage as Page, Params } from '../types';
18+
import type { Filter, ResourcePage as Page, Params, PriceType } from '../types';
1819
import type {
20+
AllocateIPPayload,
1921
CreateIPv6RangePayload,
2022
IPAddress,
2123
IPAssignmentPayload,
2224
IPRange,
2325
IPRangeInformation,
2426
IPSharingPayload,
27+
ReserveIPPayload,
2528
} from './types';
2629

2730
/**
@@ -52,16 +55,24 @@ export const getIP = (address: string) =>
5255
* Sets RDNS on an IP Address. Forward DNS must already be set up for reverse
5356
* DNS to be applied. If you set the RDNS to null for public IPv4 addresses,
5457
* it will be reset to the default members.linode.com RDNS value.
58+
* Also setting “reserved” field to true converts an Ephemeral IP to an Reserved IP.
59+
* setting “reserved” field set to false converts a Reserved IP to an Ephemeral IP.
60+
* An Ephemeral IP is an IP that’s assigned to a Linode but not reserved.
5561
*
5662
* @param address { string } The address to operate on.
5763
* @param rdns { string } The reverse DNS assigned to this address. For public
5864
* IPv4 addresses, this will be set to a default value provided by Linode if not
5965
* explicitly set.
66+
* @param reserved { boolean } Whether to reserve the IP address.
6067
*/
61-
export const updateIP = (address: string, rdns: null | string = null) =>
68+
export const updateIP = (
69+
address: string,
70+
rdns: null | string = null,
71+
reserved?: boolean,
72+
) =>
6273
Request<IPAddress>(
6374
setURL(`${API_ROOT}/networking/ips/${encodeURIComponent(address)}`),
64-
setData({ rdns }, updateIPSchema),
75+
setData({ rdns, reserved }, updateIPSchema),
6576
setMethod('PUT'),
6677
);
6778

@@ -77,8 +88,11 @@ export const updateIP = (address: string, rdns: null | string = null) =>
7788
* address.
7889
* @param payload.linode_id { number } The ID of a Linode you you have access to
7990
* that this address will be allocated to.
91+
* @param payload.reserved { boolean } Whether to reserve the IP address.
92+
* @param payload.region { string } The ID of the Region in which this address * will be allocated.
93+
* Required when reserving an IP address, not required when allocating an ephemeral IP address.
8094
*/
81-
export const allocateIp = (payload: any) =>
95+
export const allocateIp = (payload: AllocateIPPayload) =>
8296
Request<IPAddress>(
8397
setURL(`${API_ROOT}/networking/ips/`),
8498
setData(payload, allocateIPSchema),
@@ -194,3 +208,93 @@ export const createIPv6Range = (payload: CreateIPv6RangePayload) => {
194208
setData(payload),
195209
);
196210
};
211+
212+
// Reserve IP queries
213+
/**
214+
* getReservedIps
215+
*
216+
* Returns a paginated list of all Reserved IP addresses on this account.
217+
*/
218+
export const getReservedIPs = (params?: Params, filters?: Filter) =>
219+
Request<Page<IPAddress>>(
220+
setMethod('GET'),
221+
setParams(params),
222+
setXFilter(filters),
223+
setURL(`${BETA_API_ROOT}/networking/reserved/ips`),
224+
);
225+
226+
/**
227+
* Returns information about a single Reserved IP Address on your Account.
228+
*
229+
* @param address { string } The address to operate on.
230+
*/
231+
export const getReservedIP = (address: string) =>
232+
Request<IPAddress>(
233+
setURL(
234+
`${BETA_API_ROOT}/networking/reserved/ips/${encodeURIComponent(address)}`,
235+
),
236+
setMethod('GET'),
237+
);
238+
239+
/**
240+
* Tags associated with the reserved IP can be updated.
241+
* The tags associated with the reserved IP will be completely replaced with the values specified in the request body,
242+
* rather than just adding additional tags to what’s already there
243+
*
244+
* @param address { string } The address to operate on.
245+
* @param tags { string[] | null } The tags to associate with this reserved IP. If null, all tags will be removed.
246+
*/
247+
export const updateReservedIP = (
248+
address: string,
249+
tags: null | string[] = null,
250+
) =>
251+
Request<IPAddress>(
252+
setURL(
253+
`${BETA_API_ROOT}/networking/reserved/ips/${encodeURIComponent(address)}`,
254+
),
255+
setData({ tags }),
256+
setMethod('PUT'),
257+
);
258+
259+
/**
260+
* Makes one of the IP address available in the provided region as reserved.
261+
* Only IPv4 addresses may be reserved through this endpoint.
262+
*
263+
* @param payload { Object }
264+
* @param payload.region { string } The ID of the Region in which these
265+
* assignments are to take place. All IPs and Linodes must exist in this Region.
266+
* @param payload.tags { string[] } A list of tags to associate with this reserved IP.
267+
*/
268+
export const reserveIP = (payload: ReserveIPPayload) =>
269+
Request<IPAddress>(
270+
setURL(`${BETA_API_ROOT}/networking/reserved/ips`),
271+
setData(payload, reserveIPSchema),
272+
setMethod('POST'),
273+
);
274+
275+
/**
276+
* unReserveIP
277+
*
278+
* Unreserves an IP address, making it available for general use.
279+
* Any Tag associations will be removed when the IP address is un-reserved via this endpoint.
280+
*
281+
*/
282+
export const unReserveIP = (ipAddress: string) =>
283+
Request<object>(
284+
setURL(
285+
`${BETA_API_ROOT}/networking/reserved/ips/${encodeURIComponent(ipAddress)}`,
286+
),
287+
setMethod('DELETE'),
288+
);
289+
290+
/**
291+
* getReservedIPsTypes
292+
*
293+
* Returns a paginated list of available Reserved IP types; used for pricing.
294+
*/
295+
export const getReservedIPsTypes = (params?: Params) =>
296+
Request<Page<PriceType>>(
297+
setURL(`${API_ROOT}/networking/reserved/ips/types`),
298+
setMethod('GET'),
299+
setParams(params),
300+
);

packages/api-v4/src/networking/types.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
1+
export interface AssignedEntity {
2+
id: number;
3+
label: string;
4+
type: string;
5+
url: string;
6+
}
7+
18
export interface IPAddress {
29
address: string;
10+
assigned_entity: AssignedEntity | null;
311
gateway: null | string;
412
interface_id: null | number;
5-
linode_id: number;
13+
linode_id: null | number;
614
prefix: number;
715
public: boolean;
816
rdns: null | string;
917
region: string;
18+
reserved: boolean;
1019
subnet_mask: string;
20+
tags: string[];
1121
type: string;
1222
vpc_nat_1_1?: null | {
1323
address: string;
@@ -16,6 +26,14 @@ export interface IPAddress {
1626
};
1727
}
1828

29+
export interface AllocateIPPayload {
30+
linode_id?: number;
31+
public: boolean;
32+
region?: string;
33+
reserved?: boolean;
34+
type: string;
35+
}
36+
1937
export interface IPRangeBaseData {
2038
prefix: number;
2139
range: string;
@@ -51,3 +69,8 @@ export interface CreateIPv6RangePayload {
5169
prefix_length: IPv6Prefix;
5270
route_target?: string;
5371
}
72+
73+
export interface ReserveIPPayload {
74+
region: string;
75+
tags?: string[];
76+
}

packages/api-v4/src/nodebalancers/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ export interface CreateNodeBalancerPayload {
253253
client_udp_sess_throttle?: number;
254254
configs: CreateNodeBalancerConfig[];
255255
firewall_id?: number;
256+
ipv4?: string; // must be a reserved unassigned IP owned by the customer.
256257
label?: string;
257258
region?: string;
258259
tags?: string[];

packages/api-v4/src/tags/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ export interface Tag {
33
}
44

55
export interface TagRequest {
6+
domains?: number[];
67
label: string;
78
linodes?: number[];
9+
nodebalancers?: number[];
10+
reserved_ipv4_addresses?: string[];
11+
volumes?: number[];
812
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Upcoming Features
3+
---
4+
5+
Implement owned groups landing page content ([#13506](https://github.com/linode/manager/pull/13506))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Upcoming Features
3+
---
4+
5+
Reserved IPs - Add new endpoints, types and Queries ([#13517](https://github.com/linode/manager/pull/13517))
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Upcoming Features
3+
---
4+
5+
Implement Empty Landing State for Reserve IP ([#13521](https://github.com/linode/manager/pull/13521))

0 commit comments

Comments
 (0)