Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rebuild project due to oas spec rename #196

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
lint:
name: lint
runs-on: ubuntu-latest
if: github.repository == 'orbcorp/orb-node'


steps:
- uses: actions/checkout@v4
Expand All @@ -31,7 +31,6 @@ jobs:
test:
name: test
runs-on: ubuntu-latest
if: github.repository == 'orbcorp/orb-node'

steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 90
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb-0b1c2d4534e85da8966d80448ccc6bf4db184f0d5642478af14ba4c9eeadafed.yml
configured_endpoints: 89
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-762f50aa6ea13f42e719339aa5cb31233984499720a7be832182357f949927a1.yml
5 changes: 2 additions & 3 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ Methods:
- <code title="get /alerts">client.alerts.<a href="./src/resources/alerts.ts">list</a>({ ...params }) -> AlertsPage</code>
- <code title="post /alerts/customer_id/{customer_id}">client.alerts.<a href="./src/resources/alerts.ts">createForCustomer</a>(customerId, { ...params }) -> Alert</code>
- <code title="post /alerts/external_customer_id/{external_customer_id}">client.alerts.<a href="./src/resources/alerts.ts">createForExternalCustomer</a>(externalCustomerId, { ...params }) -> Alert</code>
- <code title="post /alerts/plan_id/{plan_id}">client.alerts.<a href="./src/resources/alerts.ts">createForPlan</a>(planId, { ...params }) -> Alert</code>
- <code title="post /alerts/subscription_id/{subscription_id}">client.alerts.<a href="./src/resources/alerts.ts">createForSubscription</a>(subscriptionId, { ...params }) -> Alert</code>
- <code title="post /alerts/{alert_configuration_id}/disable">client.alerts.<a href="./src/resources/alerts.ts">disable</a>(alertConfigurationId, { ...params }) -> Alert</code>
- <code title="post /alerts/{alert_configuration_id}/enable">client.alerts.<a href="./src/resources/alerts.ts">enable</a>(alertConfigurationId, { ...params }) -> Alert</code>
- <code title="post /alerts/{alert_configuration_id}/disable">client.alerts.<a href="./src/resources/alerts.ts">disable</a>(alertConfigurationId) -> Alert</code>
- <code title="post /alerts/{alert_configuration_id}/enable">client.alerts.<a href="./src/resources/alerts.ts">enable</a>(alertConfigurationId) -> Alert</code>
3 changes: 0 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,7 @@ export namespace Orb {
export import AlertListParams = API.AlertListParams;
export import AlertCreateForCustomerParams = API.AlertCreateForCustomerParams;
export import AlertCreateForExternalCustomerParams = API.AlertCreateForExternalCustomerParams;
export import AlertCreateForPlanParams = API.AlertCreateForPlanParams;
export import AlertCreateForSubscriptionParams = API.AlertCreateForSubscriptionParams;
export import AlertDisableParams = API.AlertDisableParams;
export import AlertEnableParams = API.AlertEnableParams;

export import BillingCycleRelativeDate = API.BillingCycleRelativeDate;
export import Discount = API.Discount;
Expand Down
130 changes: 4 additions & 126 deletions src/resources/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,6 @@ export class Alerts extends APIResource {
return this._client.post(`/alerts/external_customer_id/${externalCustomerId}`, { body, ...options });
}

/**
* This endpoint is used to create alerts at the plan level. Plan level alerts are
* automatically propagated to all subscriptions associated with the plan. These
* alerts are scoped to a specific plan version; if no version is specified, the
* active plan version is used.
*
* Plan level alerts can be of two types: `usage_exceeded` or `cost_exceeded`. A
* `usage_exceeded` alert is scoped to a particular metric and is triggered when
* the usage of that metric exceeds predefined thresholds during the current
* billing cycle. A `cost_exceeded` alert is triggered when the total amount due
* during the current billing cycle surpasses predefined thresholds.
* `cost_exceeded` alerts do not include burndown of pre-purchase credits. Each
* plan can have one `cost_exceeded` alert and one `usage_exceeded` alert per
* metric that is a part of the plan.
*/
createForPlan(
planId: string,
body: AlertCreateForPlanParams,
options?: Core.RequestOptions,
): Core.APIPromise<Alert> {
return this._client.post(`/alerts/plan_id/${planId}`, { body, ...options });
}

/**
* This endpoint is used to create alerts at the subscription level.
*
Expand All @@ -124,49 +101,15 @@ export class Alerts extends APIResource {
/**
* This endpoint can be used to disable an alert.
*/
disable(
alertConfigurationId: string,
params?: AlertDisableParams,
options?: Core.RequestOptions,
): Core.APIPromise<Alert>;
disable(alertConfigurationId: string, options?: Core.RequestOptions): Core.APIPromise<Alert>;
disable(
alertConfigurationId: string,
params: AlertDisableParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<Alert> {
if (isRequestOptions(params)) {
return this.disable(alertConfigurationId, {}, params);
}
const { subscription_id } = params;
return this._client.post(`/alerts/${alertConfigurationId}/disable`, {
query: { subscription_id },
...options,
});
disable(alertConfigurationId: string, options?: Core.RequestOptions): Core.APIPromise<Alert> {
return this._client.post(`/alerts/${alertConfigurationId}/disable`, options);
}

/**
* This endpoint can be used to enable an alert.
*/
enable(
alertConfigurationId: string,
params?: AlertEnableParams,
options?: Core.RequestOptions,
): Core.APIPromise<Alert>;
enable(alertConfigurationId: string, options?: Core.RequestOptions): Core.APIPromise<Alert>;
enable(
alertConfigurationId: string,
params: AlertEnableParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<Alert> {
if (isRequestOptions(params)) {
return this.enable(alertConfigurationId, {}, params);
}
const { subscription_id } = params;
return this._client.post(`/alerts/${alertConfigurationId}/enable`, {
query: { subscription_id },
...options,
});
enable(alertConfigurationId: string, options?: Core.RequestOptions): Core.APIPromise<Alert> {
return this._client.post(`/alerts/${alertConfigurationId}/enable`, options);
}
}

Expand Down Expand Up @@ -277,16 +220,6 @@ export interface AlertListParams extends PageParams {
*/
external_customer_id?: string | null;

/**
* Fetch alerts scoped to this plan_id
*/
plan_id?: string | null;

/**
* If provided alongside plan_id, only the alerts that are scoped to the specified plan_version will be returned.
*/
plan_version?: number | null;

/**
* Fetch alerts scoped to this subscription_id
*/
Expand Down Expand Up @@ -357,44 +290,6 @@ export namespace AlertCreateForExternalCustomerParams {
}
}

export interface AlertCreateForPlanParams {
/**
* The thresholds for the alert.
*/
thresholds: Array<AlertCreateForPlanParams.Threshold>;

/**
* The thresholds that define the values at which the alert will be triggered.
*/
type: string;

/**
* The metric to track usage for.
*/
metric_id?: string | null;

/**
* The plan version to create alerts for. If not specified, the default will be the
* plan's active plan version.
*/
plan_version?: number | null;
}

export namespace AlertCreateForPlanParams {
/**
* Thresholds are used to define the conditions under which an alert will be
* triggered.
*/
export interface Threshold {
/**
* The value at which an alert will fire. For credit balance alerts, the alert will
* fire at or below this value. For usage and cost alerts, the alert will fire at
* or above this value.
*/
value: number;
}
}

export interface AlertCreateForSubscriptionParams {
/**
* The thresholds for the alert.
Expand Down Expand Up @@ -427,28 +322,11 @@ export namespace AlertCreateForSubscriptionParams {
}
}

export interface AlertDisableParams {
/**
* Used to update the status of a plan alert scoped to this subscription_id
*/
subscription_id?: string | null;
}

export interface AlertEnableParams {
/**
* Used to update the status of a plan alert scoped to this subscription_id
*/
subscription_id?: string | null;
}

export namespace Alerts {
export import Alert = AlertsAPI.Alert;
export import AlertsPage = AlertsAPI.AlertsPage;
export import AlertListParams = AlertsAPI.AlertListParams;
export import AlertCreateForCustomerParams = AlertsAPI.AlertCreateForCustomerParams;
export import AlertCreateForExternalCustomerParams = AlertsAPI.AlertCreateForExternalCustomerParams;
export import AlertCreateForPlanParams = AlertsAPI.AlertCreateForPlanParams;
export import AlertCreateForSubscriptionParams = AlertsAPI.AlertCreateForSubscriptionParams;
export import AlertDisableParams = AlertsAPI.AlertDisableParams;
export import AlertEnableParams = AlertsAPI.AlertEnableParams;
}
3 changes: 0 additions & 3 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ export {
AlertListParams,
AlertCreateForCustomerParams,
AlertCreateForExternalCustomerParams,
AlertCreateForPlanParams,
AlertCreateForSubscriptionParams,
AlertDisableParams,
AlertEnableParams,
AlertsPage,
Alerts,
} from './alerts';
Expand Down
39 changes: 0 additions & 39 deletions tests/api-resources/alerts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ describe('resource alerts', () => {
customer_id: 'string',
external_customer_id: 'string',
limit: 0,
plan_id: 'string',
plan_version: 0,
subscription_id: 'string',
},
{ path: '/_stainless_unknown_path' },
Expand Down Expand Up @@ -109,29 +107,6 @@ describe('resource alerts', () => {
});
});

test('createForPlan: only required params', async () => {
const responsePromise = orb.alerts.createForPlan('string', {
thresholds: [{ value: 0 }, { value: 0 }, { value: 0 }],
type: 'string',
});
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
const response = await responsePromise;
expect(response).not.toBeInstanceOf(Response);
const dataAndResponse = await responsePromise.withResponse();
expect(dataAndResponse.data).toBe(response);
expect(dataAndResponse.response).toBe(rawResponse);
});

test('createForPlan: required and optional params', async () => {
const response = await orb.alerts.createForPlan('string', {
thresholds: [{ value: 0 }, { value: 0 }, { value: 0 }],
type: 'string',
metric_id: 'string',
plan_version: 0,
});
});

test('createForSubscription: only required params', async () => {
const responsePromise = orb.alerts.createForSubscription('string', {
thresholds: [{ value: 0 }, { value: 0 }, { value: 0 }],
Expand Down Expand Up @@ -172,13 +147,6 @@ describe('resource alerts', () => {
);
});

test('disable: request options and params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
orb.alerts.disable('string', { subscription_id: 'string' }, { path: '/_stainless_unknown_path' }),
).rejects.toThrow(Orb.NotFoundError);
});

test('enable', async () => {
const responsePromise = orb.alerts.enable('string');
const rawResponse = await responsePromise.asResponse();
Expand All @@ -196,11 +164,4 @@ describe('resource alerts', () => {
Orb.NotFoundError,
);
});

test('enable: request options and params are passed correctly', async () => {
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
await expect(
orb.alerts.enable('string', { subscription_id: 'string' }, { path: '/_stainless_unknown_path' }),
).rejects.toThrow(Orb.NotFoundError);
});
});