Skip to content

Commit bf162ce

Browse files
stainless-app[bot]meorphis
authored andcommitted
feat(api): Add PATCH zone hold update method (#2240)
1 parent 35935d1 commit bf162ce

File tree

5 files changed

+51
-44
lines changed

5 files changed

+51
-44
lines changed

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ Types:
376376
Methods:
377377

378378
- <code title="post /zones/{zone_id}/hold">client.zones.holds.<a href="./src/resources/zones/holds.ts">create</a>({ ...params }) -> ZoneHold</code>
379+
- <code title="patch /zones/{zone_id}/hold">client.zones.holds.<a href="./src/resources/zones/holds.ts">update</a>({ ...params }) -> ZoneHold</code>
379380
- <code title="delete /zones/{zone_id}/hold">client.zones.holds.<a href="./src/resources/zones/holds.ts">delete</a>({ ...params }) -> ZoneHold</code>
380-
- <code title="patch /zones/{zone_id}/hold">client.zones.holds.<a href="./src/resources/zones/holds.ts">edit</a>({ ...params }) -> ZoneHold</code>
381381
- <code title="get /zones/{zone_id}/hold">client.zones.holds.<a href="./src/resources/zones/holds.ts">get</a>({ ...params }) -> ZoneHold</code>
382382

383383
## Subscriptions

src/resources/zones/holds.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ export class Holds extends APIResource {
1818
)._thenUnwrap((obj) => obj.result);
1919
}
2020

21+
/**
22+
* Update the `hold_after` and/or `include_subdomains` values on an existing zone
23+
* hold. The hold is enabled if the `hold_after` date-time value is in the past.
24+
*/
25+
update(params: HoldUpdateParams, options?: Core.RequestOptions): Core.APIPromise<ZoneHold> {
26+
const { zone_id, ...body } = params;
27+
return (
28+
this._client.patch(`/zones/${zone_id}/hold`, { body, ...options }) as Core.APIPromise<{
29+
result: ZoneHold;
30+
}>
31+
)._thenUnwrap((obj) => obj.result);
32+
}
33+
2134
/**
2235
* Stop enforcement of a zone hold on the zone, permanently or temporarily,
2336
* allowing the creation and activation of zones with this zone's hostname.
@@ -32,19 +45,6 @@ export class Holds extends APIResource {
3245
)._thenUnwrap((obj) => obj.result);
3346
}
3447

35-
/**
36-
* Update the `hold_after` and/or `include_subdomains` values on an existing zone
37-
* hold. The hold is enabled if the `hold_after` date-time value is in the past.
38-
*/
39-
edit(params: HoldEditParams, options?: Core.RequestOptions): Core.APIPromise<ZoneHold> {
40-
const { zone_id, ...body } = params;
41-
return (
42-
this._client.patch(`/zones/${zone_id}/hold`, { body, ...options }) as Core.APIPromise<{
43-
result: ZoneHold;
44-
}>
45-
)._thenUnwrap((obj) => obj.result);
46-
}
47-
4848
/**
4949
* Retrieve whether the zone is subject to a zone hold, and metadata about the
5050
* hold.
@@ -80,21 +80,7 @@ export interface HoldCreateParams {
8080
include_subdomains?: boolean;
8181
}
8282

83-
export interface HoldDeleteParams {
84-
/**
85-
* Path param: Identifier
86-
*/
87-
zone_id: string;
88-
89-
/**
90-
* Query param: If `hold_after` is provided, the hold will be temporarily disabled,
91-
* then automatically re-enabled by the system at the time specified in this
92-
* RFC3339-formatted timestamp. Otherwise, the hold will be disabled indefinitely.
93-
*/
94-
hold_after?: string;
95-
}
96-
97-
export interface HoldEditParams {
83+
export interface HoldUpdateParams {
9884
/**
9985
* Path param: Identifier
10086
*/
@@ -118,6 +104,20 @@ export interface HoldEditParams {
118104
include_subdomains?: boolean;
119105
}
120106

107+
export interface HoldDeleteParams {
108+
/**
109+
* Path param: Identifier
110+
*/
111+
zone_id: string;
112+
113+
/**
114+
* Query param: If `hold_after` is provided, the hold will be temporarily disabled,
115+
* then automatically re-enabled by the system at the time specified in this
116+
* RFC3339-formatted timestamp. Otherwise, the hold will be disabled indefinitely.
117+
*/
118+
hold_after?: string;
119+
}
120+
121121
export interface HoldGetParams {
122122
/**
123123
* Identifier
@@ -129,8 +129,8 @@ export declare namespace Holds {
129129
export {
130130
type ZoneHold as ZoneHold,
131131
type HoldCreateParams as HoldCreateParams,
132+
type HoldUpdateParams as HoldUpdateParams,
132133
type HoldDeleteParams as HoldDeleteParams,
133-
type HoldEditParams as HoldEditParams,
134134
type HoldGetParams as HoldGetParams,
135135
};
136136
}

src/resources/zones/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export {
2323
Holds,
2424
type ZoneHold,
2525
type HoldCreateParams,
26+
type HoldUpdateParams,
2627
type HoldDeleteParams,
27-
type HoldEditParams,
2828
type HoldGetParams,
2929
} from './holds';
3030
export { RatePlans, type RatePlanGetResponse, type RatePlanGetParams } from './rate-plans';

src/resources/zones/zones.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ import {
1818
CustomNameservers,
1919
} from './custom-nameservers';
2020
import * as HoldsAPI from './holds';
21-
import { HoldCreateParams, HoldDeleteParams, HoldEditParams, HoldGetParams, Holds, ZoneHold } from './holds';
21+
import {
22+
HoldCreateParams,
23+
HoldDeleteParams,
24+
HoldGetParams,
25+
HoldUpdateParams,
26+
Holds,
27+
ZoneHold,
28+
} from './holds';
2229
import * as PlansAPI from './plans';
2330
import {
2431
AvailableRatePlan,
@@ -566,8 +573,8 @@ export declare namespace Zones {
566573
Holds as Holds,
567574
type ZoneHold as ZoneHold,
568575
type HoldCreateParams as HoldCreateParams,
576+
type HoldUpdateParams as HoldUpdateParams,
569577
type HoldDeleteParams as HoldDeleteParams,
570-
type HoldEditParams as HoldEditParams,
571578
type HoldGetParams as HoldGetParams,
572579
};
573580

tests/api-resources/zones/holds.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ describe('resource holds', () => {
2828
});
2929
});
3030

31-
test('delete: only required params', async () => {
32-
const responsePromise = client.zones.holds.delete({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
31+
test('update: only required params', async () => {
32+
const responsePromise = client.zones.holds.update({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
3333
const rawResponse = await responsePromise.asResponse();
3434
expect(rawResponse).toBeInstanceOf(Response);
3535
const response = await responsePromise;
@@ -39,15 +39,16 @@ describe('resource holds', () => {
3939
expect(dataAndResponse.response).toBe(rawResponse);
4040
});
4141

42-
test('delete: required and optional params', async () => {
43-
const response = await client.zones.holds.delete({
42+
test('update: required and optional params', async () => {
43+
const response = await client.zones.holds.update({
4444
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
45-
hold_after: 'hold_after',
45+
hold_after: '2023-01-31T15:56:36+00:00',
46+
include_subdomains: true,
4647
});
4748
});
4849

49-
test('edit: only required params', async () => {
50-
const responsePromise = client.zones.holds.edit({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
50+
test('delete: only required params', async () => {
51+
const responsePromise = client.zones.holds.delete({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' });
5152
const rawResponse = await responsePromise.asResponse();
5253
expect(rawResponse).toBeInstanceOf(Response);
5354
const response = await responsePromise;
@@ -57,11 +58,10 @@ describe('resource holds', () => {
5758
expect(dataAndResponse.response).toBe(rawResponse);
5859
});
5960

60-
test('edit: required and optional params', async () => {
61-
const response = await client.zones.holds.edit({
61+
test('delete: required and optional params', async () => {
62+
const response = await client.zones.holds.delete({
6263
zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
63-
hold_after: '2023-01-31T15:56:36+00:00',
64-
include_subdomains: true,
64+
hold_after: 'hold_after',
6565
});
6666
});
6767

0 commit comments

Comments
 (0)