UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

79 lines 3.91 kB
"use strict"; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AddressingServiceBindingsSinglePage = exports.Bindings = void 0; const resource_1 = require("cloudflare/resource"); const BindingsAPI = __importStar(require("cloudflare/resources/addressing/prefixes/bgp/bindings")); const pagination_1 = require("cloudflare/pagination"); class Bindings extends resource_1.APIResource { /** * Creates a new Service Binding, routing traffic to IPs within the given CIDR to a * service running on Cloudflare's network. **Note:** This API may only be used on * prefixes currently configured with a Magic Transit service binding, and only * allows creating service bindings for the Cloudflare CDN or Cloudflare Spectrum. */ create(prefixId, params, options) { const { account_id, ...body } = params; return this._client.post(`/accounts/${account_id}/addressing/prefixes/${prefixId}/bindings`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List the Cloudflare services this prefix is currently bound to. Traffic sent to * an address within an IP prefix will be routed to the Cloudflare service of the * most-specific Service Binding matching the address. **Example:** binding * `192.0.2.0/24` to Cloudflare Magic Transit and `192.0.2.1/32` to the Cloudflare * CDN would route traffic for `192.0.2.1` to the CDN, and traffic for all other * IPs in the prefix to Cloudflare Magic Transit. */ list(prefixId, params, options) { const { account_id } = params; return this._client.getAPIList(`/accounts/${account_id}/addressing/prefixes/${prefixId}/bindings`, AddressingServiceBindingsSinglePage, options); } /** * Delete a Service Binding */ delete(prefixId, bindingId, params, options) { const { account_id } = params; return this._client.delete(`/accounts/${account_id}/addressing/prefixes/${prefixId}/bindings/${bindingId}`, options)._thenUnwrap((obj) => obj.result); } /** * Fetch a single Service Binding */ get(prefixId, bindingId, params, options) { const { account_id } = params; return this._client.get(`/accounts/${account_id}/addressing/prefixes/${prefixId}/bindings/${bindingId}`, options)._thenUnwrap((obj) => obj.result); } } exports.Bindings = Bindings; class AddressingServiceBindingsSinglePage extends pagination_1.SinglePage { } exports.AddressingServiceBindingsSinglePage = AddressingServiceBindingsSinglePage; (function (Bindings) { Bindings.AddressingServiceBindingsSinglePage = BindingsAPI.AddressingServiceBindingsSinglePage; })(Bindings = exports.Bindings || (exports.Bindings = {})); //# sourceMappingURL=bindings.js.map