Skip to content
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
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 2269
configured_endpoints: 2272
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-a6c352830d1270d0abb5bb983058ea21815e1bb7d2e163965335dcb0e706f057.yml
openapi_spec_hash: d440b6377c255296d9fdc0b89e59b511
config_hash: 86a9b8037b215f0a9c5c69239f9c6cfd
openapi_spec_hash: f60cc2af36bbe305cda4bc0ad0617ff6
config_hash: 0148d517bb02129e9e259f11db3933eb
3 changes: 3 additions & 0 deletions scripts/detect-breaking-changes
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ TEST_PATHS=(
tests/api-resources/organizations/organization-profile.test.ts
tests/api-resources/organizations/logs/logs.test.ts
tests/api-resources/organizations/logs/audit.test.ts
tests/api-resources/organizations/billing/billing.test.ts
tests/api-resources/organizations/billing/usage.test.ts
tests/api-resources/origin-ca-certificates.test.ts
tests/api-resources/ips.test.ts
tests/api-resources/memberships.test.ts
Expand Down Expand Up @@ -279,6 +281,7 @@ TEST_PATHS=(
tests/api-resources/audit-logs.test.ts
tests/api-resources/billing/billing.test.ts
tests/api-resources/billing/profiles.test.ts
tests/api-resources/billing/usage.test.ts
tests/api-resources/brand-protection/brand-protection.test.ts
tests/api-resources/brand-protection/queries.test.ts
tests/api-resources/brand-protection/matches.test.ts
Expand Down
12 changes: 12 additions & 0 deletions src/resources/organizations/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,15 @@ Types:
Methods:

- <code title="get /organizations/{organization_id}/logs/audit">client.organizations.logs.audit.<a href="./src/resources/organizations/logs/audit.ts">list</a>(organizationId, { ...params }) -> AuditListResponsesCursorPaginationAfter</code>

## Billing

### Usage

Types:

- <code><a href="./src/resources/organizations/billing/usage.ts">UsageGetResponse</a></code>

Methods:

- <code title="get /organizations/{organization_id}/billable/usage">client.organizations.billing.usage.<a href="./src/resources/organizations/billing/usage.ts">get</a>(organizationId, { ...params }) -> UsageGetResponse</code>
3 changes: 3 additions & 0 deletions src/resources/organizations/billing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export * from './billing/index';
15 changes: 15 additions & 0 deletions src/resources/organizations/billing/billing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../../../resource';
import * as UsageAPI from './usage';
import { Usage, UsageGetParams, UsageGetResponse } from './usage';

export class Billing extends APIResource {
usage: UsageAPI.Usage = new UsageAPI.Usage(this._client);
}

Billing.Usage = Usage;

export declare namespace Billing {
export { Usage as Usage, type UsageGetResponse as UsageGetResponse, type UsageGetParams as UsageGetParams };
}
4 changes: 4 additions & 0 deletions src/resources/organizations/billing/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { Billing } from './billing';
export { Usage, type UsageGetResponse, type UsageGetParams } from './usage';
270 changes: 270 additions & 0 deletions src/resources/organizations/billing/usage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import { APIResource } from '../../../resource';
import { isRequestOptions } from '../../../core';
import * as Core from '../../../core';

export class Usage extends APIResource {
/**
* Returns cost and usage data for all accounts within an organization, aligned
* with the [FinOps FOCUS v1.3](https://focus.finops.org/focus-specification/v1-3/)
* Cost and Usage dataset specification.
*
* Each record represents one billable metric for one account on one day. This
* includes all metered usage, including usage that falls within free-tier
* allowances and may result in zero cost. The response includes usage for every
* account belonging to the specified organization.
*
* **Note:** Cost and pricing fields are not yet populated and will be absent from
* responses until billing integration is complete.
*
* When `from` and `to` are omitted, defaults to the start of the current month
* through today. The maximum date range is 31 days.
*/
get(
organizationId: string,
query?: UsageGetParams,
options?: Core.RequestOptions,
): Core.APIPromise<UsageGetResponse>;
get(organizationId: string, options?: Core.RequestOptions): Core.APIPromise<UsageGetResponse>;
get(
organizationId: string,
query: UsageGetParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<UsageGetResponse> {
if (isRequestOptions(query)) {
return this.get(organizationId, {}, query);
}
return (
this._client.get(`/organizations/${organizationId}/billable/usage`, {
query,
...options,
}) as Core.APIPromise<{ result: UsageGetResponse }>
)._thenUnwrap((obj) => obj.result);
}
}

/**
* Contains the array of cost and usage records.
*/
export type UsageGetResponse = Array<UsageGetResponse.UsageGetResponseItem>;

export namespace UsageGetResponse {
/**
* A single cost and usage record for a metered product within a specific charge
* period, aligned with the FinOps FOCUS v1.3 specification.
*/
export interface UsageGetResponseItem {
/**
* Public identifier of the Cloudflare account (account tag).
*/
BillingAccountId: string;

/**
* Display name of the Cloudflare account.
*/
BillingAccountName: string;

/**
* Highest-level classification of a charge based on the nature of how it gets
* billed. Currently only "Usage" is supported.
*/
ChargeCategory: 'Usage';

/**
* Self-contained summary of the charge's purpose and price.
*/
ChargeDescription: string;

/**
* Indicates how often a charge occurs. Currently only "Usage-Based" is supported.
*/
ChargeFrequency: 'Usage-Based';

/**
* Exclusive end of the time interval during which the usage was consumed.
*/
ChargePeriodEnd: string;

/**
* Inclusive start of the time interval during which the usage was consumed.
*/
ChargePeriodStart: string;

/**
* Measured usage amount within the charge period. Reflects raw metered consumption
* before pricing transformations.
*/
ConsumedQuantity: number;

/**
* Unit of measure for the consumed quantity (e.g., "GB", "Requests",
* "vCPU-Hours").
*/
ConsumedUnit: string;

/**
* Name of the entity providing the underlying infrastructure or platform.
*/
HostProviderName: string;

/**
* Name of the entity responsible for invoicing for the services consumed.
*/
InvoiceIssuerName: string;

/**
* Name of the entity that made the services available for purchase.
*/
ServiceProviderName: string;

/**
* The display name of the billable metric. Cloudflare extension; replaces FOCUS
* SkuMeter.
*/
x_BillableMetricName: string;

/**
* A charge serving as the basis for invoicing, inclusive of all reduced rates and
* discounts while excluding the amortization of upfront charges (one-time or
* recurring).
*/
BilledCost?: number | null;

/**
* Currency that a charge was billed in (ISO 4217).
*/
BillingCurrency?: string | null;

/**
* Exclusive end of the billing cycle that contains this usage record.
*/
BillingPeriodEnd?: string | null;

/**
* Inclusive start of the billing cycle that contains this usage record.
*/
BillingPeriodStart?: string | null;

/**
* Indicates whether the row represents a correction to one or more charges
* invoiced in a previous billing period.
*/
ChargeClass?: 'Correction' | null;

/**
* Cost calculated by multiplying ContractedUnitPrice and the corresponding
* PricingQuantity.
*/
ContractedCost?: number | null;

/**
* The agreed-upon unit price for a single PricingUnit of the associated billable
* metric, inclusive of negotiated discounts, if present, while excluding any other
* discounts.
*/
ContractedUnitPrice?: number | null;

/**
* The amortized cost of the charge after applying all reduced rates, discounts,
* and the applicable portion of relevant, prepaid purchases (one-time or
* recurring) that covered the charge.
*/
EffectiveCost?: number | null;

/**
* Cost calculated by multiplying ListUnitPrice and the corresponding
* PricingQuantity.
*/
ListCost?: number | null;

/**
* Suggested provider-published unit price for a single PricingUnit of the
* associated billable metric, exclusive of any discounts.
*/
ListUnitPrice?: number | null;

/**
* Volume of a given service used or purchased, based on the PricingUnit.
*/
PricingQuantity?: number | null;

/**
* Provider-specified measurement unit for determining unit prices, indicating how
* the provider rates measured usage after applying pricing rules like block
* pricing.
*/
PricingUnit?: string | null;

/**
* Provider-assigned identifier for an isolated geographic area where a service is
* provided.
*/
RegionId?: string | null;

/**
* Name of an isolated geographic area where a service is provided.
*/
RegionName?: string | null;

/**
* Unique identifier assigned to a grouping of services. For Cloudflare, this is
* the subscription or contract ID.
*/
SubAccountId?: string;

/**
* Name assigned to a grouping of services. For Cloudflare, this is the
* subscription or contract display name.
*/
SubAccountName?: string;

/**
* The unique identifier for the billable metric in the Cloudflare catalog.
* Cloudflare extension; replaces FOCUS SkuId.
*/
x_BillableMetricId?: string;

/**
* The product family the charge belongs to (e.g., "R2", "Workers"). Cloudflare
* extension; replaces FOCUS ServiceName.
*/
x_ProductFamilyName?: string;

/**
* The identifier for the Cloudflare zone (zone tag). Cloudflare extension.
*/
x_ZoneId?: string | null;

/**
* The display name of the Cloudflare zone. Cloudflare extension.
*/
x_ZoneName?: string | null;
}
}

export interface UsageGetParams {
/**
* Start date for the usage query (ISO 8601). Required if `to` is set. When omitted
* along with `to`, defaults to the start of the current month. Filters by charge
* period (when consumption happened), not billing period. The maximum date range
* is 31 days.
*/
from?: string;

/**
* Filter results by billable metric id (e.g., workers_standard_requests).
*/
metric?: string;

/**
* End date for the usage query (ISO 8601). Required if `from` is set. When omitted
* along with `from`, defaults to today. Filters by charge period (when consumption
* happened), not billing period. The maximum date range is 31 days.
*/
to?: string;
}

export declare namespace Usage {
export { type UsageGetResponse as UsageGetResponse, type UsageGetParams as UsageGetParams };
}
1 change: 1 addition & 0 deletions src/resources/organizations/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { Billing } from './billing/index';
export { Logs } from './logs/index';
export {
OrganizationProfileResource,
Expand Down
6 changes: 6 additions & 0 deletions src/resources/organizations/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
OrganizationProfileResource,
OrganizationProfileUpdateParams,
} from './organization-profile';
import * as BillingAPI from './billing/billing';
import { Billing } from './billing/billing';
import * as LogsAPI from './logs/logs';
import { Logs } from './logs/logs';
import { SinglePage } from '../../pagination';
Expand All @@ -17,6 +19,7 @@ export class Organizations extends APIResource {
organizationProfile: OrganizationProfileAPI.OrganizationProfileResource =
new OrganizationProfileAPI.OrganizationProfileResource(this._client);
logs: LogsAPI.Logs = new LogsAPI.Logs(this._client);
billing: BillingAPI.Billing = new BillingAPI.Billing(this._client);

/**
* Create a new organization for a user. (Currently in Public Beta - see
Expand Down Expand Up @@ -300,6 +303,7 @@ export namespace OrganizationListParams {
Organizations.OrganizationsSinglePage = OrganizationsSinglePage;
Organizations.OrganizationProfileResource = OrganizationProfileResource;
Organizations.Logs = Logs;
Organizations.Billing = Billing;

export declare namespace Organizations {
export {
Expand All @@ -318,4 +322,6 @@ export declare namespace Organizations {
};

export { Logs as Logs };

export { Billing as Billing };
}
Loading
Loading