Skip to content

Commit

Permalink
feat(api): Add PATCH zone hold update method (#2240)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and meorphis committed Jan 13, 2025
1 parent 35935d1 commit bf162ce
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 44 deletions.
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ Types:
Methods:

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

## Subscriptions
Expand Down
58 changes: 29 additions & 29 deletions src/resources/zones/holds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ export class Holds extends APIResource {
)._thenUnwrap((obj) => obj.result);
}

/**
* Update the `hold_after` and/or `include_subdomains` values on an existing zone
* hold. The hold is enabled if the `hold_after` date-time value is in the past.
*/
update(params: HoldUpdateParams, options?: Core.RequestOptions): Core.APIPromise<ZoneHold> {
const { zone_id, ...body } = params;
return (
this._client.patch(`/zones/${zone_id}/hold`, { body, ...options }) as Core.APIPromise<{
result: ZoneHold;
}>
)._thenUnwrap((obj) => obj.result);
}

/**
* Stop enforcement of a zone hold on the zone, permanently or temporarily,
* allowing the creation and activation of zones with this zone's hostname.
Expand All @@ -32,19 +45,6 @@ export class Holds extends APIResource {
)._thenUnwrap((obj) => obj.result);
}

/**
* Update the `hold_after` and/or `include_subdomains` values on an existing zone
* hold. The hold is enabled if the `hold_after` date-time value is in the past.
*/
edit(params: HoldEditParams, options?: Core.RequestOptions): Core.APIPromise<ZoneHold> {
const { zone_id, ...body } = params;
return (
this._client.patch(`/zones/${zone_id}/hold`, { body, ...options }) as Core.APIPromise<{
result: ZoneHold;
}>
)._thenUnwrap((obj) => obj.result);
}

/**
* Retrieve whether the zone is subject to a zone hold, and metadata about the
* hold.
Expand Down Expand Up @@ -80,21 +80,7 @@ export interface HoldCreateParams {
include_subdomains?: boolean;
}

export interface HoldDeleteParams {
/**
* Path param: Identifier
*/
zone_id: string;

/**
* Query param: If `hold_after` is provided, the hold will be temporarily disabled,
* then automatically re-enabled by the system at the time specified in this
* RFC3339-formatted timestamp. Otherwise, the hold will be disabled indefinitely.
*/
hold_after?: string;
}

export interface HoldEditParams {
export interface HoldUpdateParams {
/**
* Path param: Identifier
*/
Expand All @@ -118,6 +104,20 @@ export interface HoldEditParams {
include_subdomains?: boolean;
}

export interface HoldDeleteParams {
/**
* Path param: Identifier
*/
zone_id: string;

/**
* Query param: If `hold_after` is provided, the hold will be temporarily disabled,
* then automatically re-enabled by the system at the time specified in this
* RFC3339-formatted timestamp. Otherwise, the hold will be disabled indefinitely.
*/
hold_after?: string;
}

export interface HoldGetParams {
/**
* Identifier
Expand All @@ -129,8 +129,8 @@ export declare namespace Holds {
export {
type ZoneHold as ZoneHold,
type HoldCreateParams as HoldCreateParams,
type HoldUpdateParams as HoldUpdateParams,
type HoldDeleteParams as HoldDeleteParams,
type HoldEditParams as HoldEditParams,
type HoldGetParams as HoldGetParams,
};
}
2 changes: 1 addition & 1 deletion src/resources/zones/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export {
Holds,
type ZoneHold,
type HoldCreateParams,
type HoldUpdateParams,
type HoldDeleteParams,
type HoldEditParams,
type HoldGetParams,
} from './holds';
export { RatePlans, type RatePlanGetResponse, type RatePlanGetParams } from './rate-plans';
Expand Down
11 changes: 9 additions & 2 deletions src/resources/zones/zones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ import {
CustomNameservers,
} from './custom-nameservers';
import * as HoldsAPI from './holds';
import { HoldCreateParams, HoldDeleteParams, HoldEditParams, HoldGetParams, Holds, ZoneHold } from './holds';
import {
HoldCreateParams,
HoldDeleteParams,
HoldGetParams,
HoldUpdateParams,
Holds,
ZoneHold,
} from './holds';
import * as PlansAPI from './plans';
import {
AvailableRatePlan,
Expand Down Expand Up @@ -566,8 +573,8 @@ export declare namespace Zones {
Holds as Holds,
type ZoneHold as ZoneHold,
type HoldCreateParams as HoldCreateParams,
type HoldUpdateParams as HoldUpdateParams,
type HoldDeleteParams as HoldDeleteParams,
type HoldEditParams as HoldEditParams,
type HoldGetParams as HoldGetParams,
};

Expand Down
22 changes: 11 additions & 11 deletions tests/api-resources/zones/holds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('resource holds', () => {
});
});

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

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

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

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

Expand Down

0 comments on commit bf162ce

Please sign in to comment.