Share via


Offer class

Use to read or replace an existing Offer by id.

See Offers to query or read all offers.

Properties

client
id
url

Returns a reference URL to the resource. Used for linking in Permissions.

Methods

read(RequestOptions)

Read the OfferDefinition for the given Offer.

Example

import { CosmosClient } from "@azure/cosmos";

const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });

const { resource: offer } = await client.offer("<offer-id>").read();
replace(OfferDefinition, RequestOptions)

Replace the given Offer with the specified OfferDefinition.

Example

replace offer with a new offer definition with updated throughput

import { CosmosClient } from "@azure/cosmos";

const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const { resource: offer } = await client.offer("<offer-id>").read();
// @ts-preservewhitespace
offer.content.offerThroughput = 1000;
await client.offer("<offer-id>").replace(offer);

Property Details

client

client: CosmosClient

Property Value

id

id: string

Property Value

string

url

Returns a reference URL to the resource. Used for linking in Permissions.

string url

Property Value

string

Method Details

read(RequestOptions)

Read the OfferDefinition for the given Offer.

Example

import { CosmosClient } from "@azure/cosmos";

const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });

const { resource: offer } = await client.offer("<offer-id>").read();
function read(options?: RequestOptions): Promise<OfferResponse>

Parameters

options
RequestOptions

Returns

Promise<OfferResponse>

replace(OfferDefinition, RequestOptions)

Replace the given Offer with the specified OfferDefinition.

Example

replace offer with a new offer definition with updated throughput

import { CosmosClient } from "@azure/cosmos";

const endpoint = "https://your-account.documents.azure.com";
const key = "<database account masterkey>";
const client = new CosmosClient({ endpoint, key });
const { resource: offer } = await client.offer("<offer-id>").read();
// @ts-preservewhitespace
offer.content.offerThroughput = 1000;
await client.offer("<offer-id>").replace(offer);
function replace(body: OfferDefinition, options?: RequestOptions): Promise<OfferResponse>

Parameters

body
OfferDefinition

The specified OfferDefinition

options
RequestOptions

Returns

Promise<OfferResponse>