Skip to content

Commit

Permalink
feat: OpenAPI spec update via Stainless API (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Mar 5, 2024
1 parent a5d05d5 commit 71186a5
Show file tree
Hide file tree
Showing 470 changed files with 2,450 additions and 482 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ The full API of this library can be found in [api.md](api.md).
```js
import Cloudflare from 'cloudflare';

const cloudflare = new Cloudflare();
const cloudflare = new Cloudflare({
apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted
apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted
});

async function main() {
const zoneCreateResponse = await cloudflare.zones.create({
Expand All @@ -46,7 +49,10 @@ This library includes TypeScript definitions for all request params and response
```ts
import Cloudflare from 'cloudflare';

const cloudflare = new Cloudflare();
const cloudflare = new Cloudflare({
apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted
apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted
});

async function main() {
const params: Cloudflare.ZoneCreateParams = {
Expand Down
17 changes: 17 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,23 @@ export class Cloudflare extends Core.APIClient {
const apiKeyAuth = this.apiKeyAuth(opts);
const apiTokenAuth = this.apiTokenAuth(opts);
const userServiceKeyAuth = this.userServiceKeyAuth(opts);

if (
apiEmailAuth != null &&
!Core.isEmptyObj(apiEmailAuth) &&
apiKeyAuth != null &&
!Core.isEmptyObj(apiKeyAuth)
) {
return { ...apiEmailAuth, ...apiKeyAuth };
}

if (apiTokenAuth != null && !Core.isEmptyObj(apiTokenAuth)) {
return apiTokenAuth;
}

if (userServiceKeyAuth != null && !Core.isEmptyObj(userServiceKeyAuth)) {
return userServiceKeyAuth;
}
return {};
}

Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/accounts/accounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource accounts', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/accounts/members.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource members', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/accounts/roles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource roles', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/acm/total-tls.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource totalTLS', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/addressing/address-maps/accounts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource accounts', () => {
// skipped: tests are disabled for the time being
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource addressMaps', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/addressing/address-maps/ips.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource ips', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/addressing/address-maps/zones.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource zones', () => {
// skipped: tests are disabled for the time being
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource downloads', () => {
// skipped: tests are disabled for the time being
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource loaDocuments', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/addressing/prefixes/bgp/bindings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource bindings', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/addressing/prefixes/bgp/prefixes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource prefixes', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/addressing/prefixes/bgp/statuses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource statuses', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/addressing/prefixes/delegations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource delegations', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/addressing/prefixes/prefixes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource prefixes', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/addressing/services.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource services', () => {
// skipped: tests are disabled for the time being
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource eligible', () => {
// skipped: tests are disabled for the time being
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource pagerduty', () => {
// skipped: tests are disabled for the time being
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource webhooks', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/alerting/v3/histories.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource histories', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/alerting/v3/policies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource policies', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/alerting/v3/v3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource v3', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/argo/smart-routing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource smartRouting', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/argo/tiered-caching.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource tieredCaching', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/audit-logs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource auditLogs', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/available-plans.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource availablePlans', () => {
// skipped: tests are disabled for the time being
Expand Down
6 changes: 5 additions & 1 deletion tests/api-resources/available-rate-plans.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
import Cloudflare from 'cloudflare';
import { Response } from 'node-fetch';

const cloudflare = new Cloudflare({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
const cloudflare = new Cloudflare({
apiKey: '144c9defac04969c7bfad8efaa8ea194',
apiEmail: 'user@example.com',
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
});

describe('resource availableRatePlans', () => {
// skipped: tests are disabled for the time being
Expand Down
Loading

0 comments on commit 71186a5

Please sign in to comment.