or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

database-accounts.mdindex.mdmongodb-resources.mdmonitoring-metrics.mdmulti-api-resources.mdnetworking-security.mdrestore-operations.mdservice-management.mdsql-resources.md

multi-api-resources.mddocs/

0

# Multi-API Resource Management

1

2

Management operations for Table API, Cassandra API, and Gremlin API resources. These APIs provide specialized data models and query capabilities while leveraging Cosmos DB's global distribution and enterprise features.

3

4

## Table API Resources

5

6

### Table Management

7

8

Manage Azure Table API tables with throughput configuration and scaling options.

9

10

```python { .api }

11

def list_tables(

12

self,

13

resource_group_name: str,

14

account_name: str

15

) -> ItemPaged[TableGetResults]:

16

"""

17

List tables in a Cosmos DB account with Table API.

18

19

Parameters:

20

- resource_group_name: Name of the resource group

21

- account_name: Name of the Cosmos DB account

22

23

Returns:

24

ItemPaged[TableGetResults]: Paginated list of tables

25

"""

26

27

def get_table(

28

self,

29

resource_group_name: str,

30

account_name: str,

31

table_name: str

32

) -> TableGetResults:

33

"""

34

Get properties of a table.

35

36

Parameters:

37

- resource_group_name: Name of the resource group

38

- account_name: Name of the Cosmos DB account

39

- table_name: Name of the table

40

41

Returns:

42

TableGetResults: Table properties and configuration

43

"""

44

45

def begin_create_update_table(

46

self,

47

resource_group_name: str,

48

account_name: str,

49

table_name: str,

50

create_update_table_parameters: TableCreateUpdateParameters

51

) -> LROPoller[TableGetResults]:

52

"""

53

Create or update a table (Long Running Operation).

54

55

Parameters:

56

- resource_group_name: Name of the resource group

57

- account_name: Name of the Cosmos DB account

58

- table_name: Name of the table to create/update

59

- create_update_table_parameters: Table configuration parameters

60

61

Returns:

62

LROPoller[TableGetResults]: Poller for monitoring operation progress

63

"""

64

65

def begin_delete_table(

66

self,

67

resource_group_name: str,

68

account_name: str,

69

table_name: str

70

) -> LROPoller[None]:

71

"""

72

Delete a table (Long Running Operation).

73

74

Parameters:

75

- resource_group_name: Name of the resource group

76

- account_name: Name of the Cosmos DB account

77

- table_name: Name of the table to delete

78

79

Returns:

80

LROPoller[None]: Poller for monitoring operation progress

81

"""

82

83

def get_table_throughput(

84

self,

85

resource_group_name: str,

86

account_name: str,

87

table_name: str

88

) -> ThroughputSettingsGetResults:

89

"""

90

Get throughput settings for a table.

91

92

Parameters:

93

- resource_group_name: Name of the resource group

94

- account_name: Name of the Cosmos DB account

95

- table_name: Name of the table

96

97

Returns:

98

ThroughputSettingsGetResults: Current throughput configuration

99

"""

100

101

def begin_update_table_throughput(

102

self,

103

resource_group_name: str,

104

account_name: str,

105

table_name: str,

106

update_throughput_parameters: ThroughputSettingsUpdateParameters

107

) -> LROPoller[ThroughputSettingsGetResults]:

108

"""

109

Update throughput settings for a table (Long Running Operation).

110

111

Parameters:

112

- resource_group_name: Name of the resource group

113

- account_name: Name of the Cosmos DB account

114

- table_name: Name of the table

115

- update_throughput_parameters: New throughput configuration

116

117

Returns:

118

LROPoller[ThroughputSettingsGetResults]: Poller for monitoring operation progress

119

"""

120

```

121

122

## Cassandra API Resources

123

124

### Cassandra Keyspace Management

125

126

Manage Cassandra keyspaces with throughput and replication settings.

127

128

```python { .api }

129

def list_cassandra_keyspaces(

130

self,

131

resource_group_name: str,

132

account_name: str

133

) -> ItemPaged[CassandraKeyspaceGetResults]:

134

"""

135

List Cassandra keyspaces in a Cosmos DB account.

136

137

Parameters:

138

- resource_group_name: Name of the resource group

139

- account_name: Name of the Cosmos DB account

140

141

Returns:

142

ItemPaged[CassandraKeyspaceGetResults]: Paginated list of keyspaces

143

"""

144

145

def get_cassandra_keyspace(

146

self,

147

resource_group_name: str,

148

account_name: str,

149

keyspace_name: str

150

) -> CassandraKeyspaceGetResults:

151

"""

152

Get properties of a Cassandra keyspace.

153

154

Parameters:

155

- resource_group_name: Name of the resource group

156

- account_name: Name of the Cosmos DB account

157

- keyspace_name: Name of the Cassandra keyspace

158

159

Returns:

160

CassandraKeyspaceGetResults: Keyspace properties and configuration

161

"""

162

163

def begin_create_update_cassandra_keyspace(

164

self,

165

resource_group_name: str,

166

account_name: str,

167

keyspace_name: str,

168

create_update_cassandra_keyspace_parameters: CassandraKeyspaceCreateUpdateParameters

169

) -> LROPoller[CassandraKeyspaceGetResults]:

170

"""

171

Create or update a Cassandra keyspace (Long Running Operation).

172

173

Parameters:

174

- resource_group_name: Name of the resource group

175

- account_name: Name of the Cosmos DB account

176

- keyspace_name: Name of the keyspace to create/update

177

- create_update_cassandra_keyspace_parameters: Keyspace configuration parameters

178

179

Returns:

180

LROPoller[CassandraKeyspaceGetResults]: Poller for monitoring operation progress

181

"""

182

183

def begin_delete_cassandra_keyspace(

184

self,

185

resource_group_name: str,

186

account_name: str,

187

keyspace_name: str

188

) -> LROPoller[None]:

189

"""

190

Delete a Cassandra keyspace (Long Running Operation).

191

192

Parameters:

193

- resource_group_name: Name of the resource group

194

- account_name: Name of the Cosmos DB account

195

- keyspace_name: Name of the keyspace to delete

196

197

Returns:

198

LROPoller[None]: Poller for monitoring operation progress

199

"""

200

```

201

202

### Cassandra Table Management

203

204

Manage Cassandra tables with schema, clustering keys, and partition configuration.

205

206

```python { .api }

207

def list_cassandra_tables(

208

self,

209

resource_group_name: str,

210

account_name: str,

211

keyspace_name: str

212

) -> ItemPaged[CassandraTableGetResults]:

213

"""

214

List Cassandra tables in a keyspace.

215

216

Parameters:

217

- resource_group_name: Name of the resource group

218

- account_name: Name of the Cosmos DB account

219

- keyspace_name: Name of the Cassandra keyspace

220

221

Returns:

222

ItemPaged[CassandraTableGetResults]: Paginated list of tables

223

"""

224

225

def get_cassandra_table(

226

self,

227

resource_group_name: str,

228

account_name: str,

229

keyspace_name: str,

230

table_name: str

231

) -> CassandraTableGetResults:

232

"""

233

Get properties of a Cassandra table.

234

235

Parameters:

236

- resource_group_name: Name of the resource group

237

- account_name: Name of the Cosmos DB account

238

- keyspace_name: Name of the Cassandra keyspace

239

- table_name: Name of the Cassandra table

240

241

Returns:

242

CassandraTableGetResults: Table properties including schema and configuration

243

"""

244

245

def begin_create_update_cassandra_table(

246

self,

247

resource_group_name: str,

248

account_name: str,

249

keyspace_name: str,

250

table_name: str,

251

create_update_cassandra_table_parameters: CassandraTableCreateUpdateParameters

252

) -> LROPoller[CassandraTableGetResults]:

253

"""

254

Create or update a Cassandra table (Long Running Operation).

255

256

Parameters:

257

- resource_group_name: Name of the resource group

258

- account_name: Name of the Cosmos DB account

259

- keyspace_name: Name of the Cassandra keyspace

260

- table_name: Name of the table to create/update

261

- create_update_cassandra_table_parameters: Table configuration parameters

262

263

Returns:

264

LROPoller[CassandraTableGetResults]: Poller for monitoring operation progress

265

"""

266

267

def get_cassandra_table_throughput(

268

self,

269

resource_group_name: str,

270

account_name: str,

271

keyspace_name: str,

272

table_name: str

273

) -> ThroughputSettingsGetResults:

274

"""

275

Get throughput settings for a Cassandra table.

276

277

Parameters:

278

- resource_group_name: Name of the resource group

279

- account_name: Name of the Cosmos DB account

280

- keyspace_name: Name of the Cassandra keyspace

281

- table_name: Name of the Cassandra table

282

283

Returns:

284

ThroughputSettingsGetResults: Current throughput configuration

285

"""

286

```

287

288

## Gremlin API Resources

289

290

### Gremlin Database Management

291

292

Manage Gremlin databases for graph workloads with throughput configuration.

293

294

```python { .api }

295

def list_gremlin_databases(

296

self,

297

resource_group_name: str,

298

account_name: str

299

) -> ItemPaged[GremlinDatabaseGetResults]:

300

"""

301

List Gremlin databases in a Cosmos DB account.

302

303

Parameters:

304

- resource_group_name: Name of the resource group

305

- account_name: Name of the Cosmos DB account

306

307

Returns:

308

ItemPaged[GremlinDatabaseGetResults]: Paginated list of Gremlin databases

309

"""

310

311

def get_gremlin_database(

312

self,

313

resource_group_name: str,

314

account_name: str,

315

database_name: str

316

) -> GremlinDatabaseGetResults:

317

"""

318

Get properties of a Gremlin database.

319

320

Parameters:

321

- resource_group_name: Name of the resource group

322

- account_name: Name of the Cosmos DB account

323

- database_name: Name of the Gremlin database

324

325

Returns:

326

GremlinDatabaseGetResults: Gremlin database properties and configuration

327

"""

328

329

def begin_create_update_gremlin_database(

330

self,

331

resource_group_name: str,

332

account_name: str,

333

database_name: str,

334

create_update_gremlin_database_parameters: GremlinDatabaseCreateUpdateParameters

335

) -> LROPoller[GremlinDatabaseGetResults]:

336

"""

337

Create or update a Gremlin database (Long Running Operation).

338

339

Parameters:

340

- resource_group_name: Name of the resource group

341

- account_name: Name of the Cosmos DB account

342

- database_name: Name of the database to create/update

343

- create_update_gremlin_database_parameters: Database configuration parameters

344

345

Returns:

346

LROPoller[GremlinDatabaseGetResults]: Poller for monitoring operation progress

347

"""

348

349

def begin_delete_gremlin_database(

350

self,

351

resource_group_name: str,

352

account_name: str,

353

database_name: str

354

) -> LROPoller[None]:

355

"""

356

Delete a Gremlin database (Long Running Operation).

357

358

Parameters:

359

- resource_group_name: Name of the resource group

360

- account_name: Name of the Cosmos DB account

361

- database_name: Name of the database to delete

362

363

Returns:

364

LROPoller[None]: Poller for monitoring operation progress

365

"""

366

```

367

368

### Gremlin Graph Management

369

370

Manage Gremlin graphs with partitioning and indexing for graph workloads.

371

372

```python { .api }

373

def list_gremlin_graphs(

374

self,

375

resource_group_name: str,

376

account_name: str,

377

database_name: str

378

) -> ItemPaged[GremlinGraphGetResults]:

379

"""

380

List Gremlin graphs in a database.

381

382

Parameters:

383

- resource_group_name: Name of the resource group

384

- account_name: Name of the Cosmos DB account

385

- database_name: Name of the Gremlin database

386

387

Returns:

388

ItemPaged[GremlinGraphGetResults]: Paginated list of graphs

389

"""

390

391

def get_gremlin_graph(

392

self,

393

resource_group_name: str,

394

account_name: str,

395

database_name: str,

396

graph_name: str

397

) -> GremlinGraphGetResults:

398

"""

399

Get properties of a Gremlin graph.

400

401

Parameters:

402

- resource_group_name: Name of the resource group

403

- account_name: Name of the Cosmos DB account

404

- database_name: Name of the Gremlin database

405

- graph_name: Name of the Gremlin graph

406

407

Returns:

408

GremlinGraphGetResults: Graph properties including partition key and indexing policy

409

"""

410

411

def begin_create_update_gremlin_graph(

412

self,

413

resource_group_name: str,

414

account_name: str,

415

database_name: str,

416

graph_name: str,

417

create_update_gremlin_graph_parameters: GremlinGraphCreateUpdateParameters

418

) -> LROPoller[GremlinGraphGetResults]:

419

"""

420

Create or update a Gremlin graph (Long Running Operation).

421

422

Parameters:

423

- resource_group_name: Name of the resource group

424

- account_name: Name of the Cosmos DB account

425

- database_name: Name of the Gremlin database

426

- graph_name: Name of the graph to create/update

427

- create_update_gremlin_graph_parameters: Graph configuration parameters

428

429

Returns:

430

LROPoller[GremlinGraphGetResults]: Poller for monitoring operation progress

431

"""

432

433

def get_gremlin_graph_throughput(

434

self,

435

resource_group_name: str,

436

account_name: str,

437

database_name: str,

438

graph_name: str

439

) -> ThroughputSettingsGetResults:

440

"""

441

Get throughput settings for a Gremlin graph.

442

443

Parameters:

444

- resource_group_name: Name of the resource group

445

- account_name: Name of the Cosmos DB account

446

- database_name: Name of the Gremlin database

447

- graph_name: Name of the Gremlin graph

448

449

Returns:

450

ThroughputSettingsGetResults: Current throughput configuration

451

"""

452

```

453

454

## Usage Examples

455

456

### Creating a Table API Table

457

458

```python

459

from azure.mgmt.cosmosdb import CosmosDBManagementClient

460

from azure.mgmt.cosmosdb.models import TableCreateUpdateParameters, TableResource, CreateUpdateOptions

461

from azure.identity import DefaultAzureCredential

462

463

client = CosmosDBManagementClient(DefaultAzureCredential(), "subscription-id")

464

465

# Create Table API table

466

table_params = TableCreateUpdateParameters(

467

resource=TableResource(id="customers"),

468

options=CreateUpdateOptions(throughput=400)

469

)

470

471

poller = client.table_resources.begin_create_update_table(

472

"my-resource-group",

473

"my-cosmos-account",

474

"customers",

475

table_params

476

)

477

478

table = poller.result()

479

print(f"Created table: {table.name}")

480

```

481

482

### Creating a Cassandra Keyspace and Table

483

484

```python

485

from azure.mgmt.cosmosdb.models import (

486

CassandraKeyspaceCreateUpdateParameters,

487

CassandraKeyspaceResource,

488

CassandraTableCreateUpdateParameters,

489

CassandraTableResource,

490

CassandraSchema,

491

Column,

492

CassandraPartitionKey,

493

ClusterKey

494

)

495

496

# Create keyspace

497

keyspace_params = CassandraKeyspaceCreateUpdateParameters(

498

resource=CassandraKeyspaceResource(id="inventory"),

499

options=CreateUpdateOptions(throughput=600)

500

)

501

502

poller = client.cassandra_resources.begin_create_update_cassandra_keyspace(

503

"my-resource-group",

504

"my-cosmos-account",

505

"inventory",

506

keyspace_params

507

)

508

keyspace = poller.result()

509

510

# Create table with schema

511

table_resource = CassandraTableResource(

512

id="products",

513

schema=CassandraSchema(

514

columns=[

515

Column(name="product_id", type="uuid"),

516

Column(name="category", type="text"),

517

Column(name="name", type="text"),

518

Column(name="price", type="decimal"),

519

Column(name="created_at", type="timestamp")

520

],

521

partition_keys=[

522

CassandraPartitionKey(name="category")

523

],

524

cluster_keys=[

525

ClusterKey(name="created_at", order_by="DESC")

526

]

527

)

528

)

529

530

table_params = CassandraTableCreateUpdateParameters(

531

resource=table_resource,

532

options=CreateUpdateOptions(throughput=400)

533

)

534

535

poller = client.cassandra_resources.begin_create_update_cassandra_table(

536

"my-resource-group",

537

"my-cosmos-account",

538

"inventory",

539

"products",

540

table_params

541

)

542

table = poller.result()

543

544

print(f"Created Cassandra table: {table.name} with partition key: {table.resource.schema.partition_keys[0].name}")

545

```

546

547

### Creating a Gremlin Graph

548

549

```python

550

from azure.mgmt.cosmosdb.models import (

551

GremlinDatabaseCreateUpdateParameters,

552

GremlinDatabaseResource,

553

GremlinGraphCreateUpdateParameters,

554

GremlinGraphResource,

555

ContainerPartitionKey,

556

IndexingPolicy

557

)

558

559

# Create Gremlin database

560

database_params = GremlinDatabaseCreateUpdateParameters(

561

resource=GremlinDatabaseResource(id="social"),

562

options=CreateUpdateOptions(throughput=800)

563

)

564

565

poller = client.gremlin_resources.begin_create_update_gremlin_database(

566

"my-resource-group",

567

"my-cosmos-account",

568

"social",

569

database_params

570

)

571

database = poller.result()

572

573

# Create graph with partition key

574

graph_resource = GremlinGraphResource(

575

id="friendships",

576

partition_key=ContainerPartitionKey(

577

paths=["/userId"],

578

kind="Hash"

579

),

580

indexing_policy=IndexingPolicy(

581

indexing_mode="Consistent",

582

automatic=True

583

)

584

)

585

586

graph_params = GremlinGraphCreateUpdateParameters(

587

resource=graph_resource,

588

options=CreateUpdateOptions(throughput=400)

589

)

590

591

poller = client.gremlin_resources.begin_create_update_gremlin_graph(

592

"my-resource-group",

593

"my-cosmos-account",

594

"social",

595

"friendships",

596

graph_params

597

)

598

graph = poller.result()

599

600

print(f"Created Gremlin graph: {graph.name} with partition key: {graph.resource.partition_key.paths}")

601

```

602

603

## Key Types

604

605

```python { .api }

606

# Table API Types

607

class TableGetResults:

608

"""Table API table properties and configuration."""

609

id: str

610

name: str

611

type: str

612

resource: TableGetPropertiesResource

613

options: TableGetPropertiesOptions

614

615

class TableResource:

616

"""Table API table resource definition."""

617

id: str # Table name

618

619

# Cassandra API Types

620

class CassandraKeyspaceGetResults:

621

"""Cassandra keyspace properties and configuration."""

622

id: str

623

name: str

624

type: str

625

resource: CassandraKeyspaceGetPropertiesResource

626

options: CassandraKeyspaceGetPropertiesOptions

627

628

class CassandraKeyspaceResource:

629

"""Cassandra keyspace resource definition."""

630

id: str # Keyspace name

631

632

class CassandraTableGetResults:

633

"""Cassandra table properties and configuration."""

634

id: str

635

name: str

636

type: str

637

resource: CassandraTableGetPropertiesResource

638

options: CassandraTableGetPropertiesOptions

639

640

class CassandraTableResource:

641

"""Cassandra table resource definition."""

642

id: str # Table name

643

schema: CassandraSchema # Table schema definition

644

645

class CassandraSchema:

646

"""Cassandra table schema definition."""

647

columns: List[Column] # Column definitions

648

partition_keys: List[CassandraPartitionKey] # Partition key columns

649

cluster_keys: List[ClusterKey] # Clustering key columns

650

651

class Column:

652

"""Cassandra table column definition."""

653

name: str # Column name

654

type: str # Column data type (text, int, uuid, timestamp, etc.)

655

656

class CassandraPartitionKey:

657

"""Cassandra partition key definition."""

658

name: str # Column name for partitioning

659

660

class ClusterKey:

661

"""Cassandra clustering key definition."""

662

name: str # Column name for clustering

663

order_by: str # Sort order ("ASC" or "DESC")

664

665

# Gremlin API Types

666

class GremlinDatabaseGetResults:

667

"""Gremlin database properties and configuration."""

668

id: str

669

name: str

670

type: str

671

resource: GremlinDatabaseGetPropertiesResource

672

options: GremlinDatabaseGetPropertiesOptions

673

674

class GremlinDatabaseResource:

675

"""Gremlin database resource definition."""

676

id: str # Database name

677

678

class GremlinGraphGetResults:

679

"""Gremlin graph properties and configuration."""

680

id: str

681

name: str

682

type: str

683

resource: GremlinGraphGetPropertiesResource

684

options: GremlinGraphGetPropertiesOptions

685

686

class GremlinGraphResource:

687

"""Gremlin graph resource definition."""

688

id: str # Graph name

689

partition_key: ContainerPartitionKey # Partition key for the graph

690

indexing_policy: IndexingPolicy # Indexing policy for vertices and edges

691

conflict_resolution_policy: ConflictResolutionPolicy # Conflict resolution settings

692

unique_key_policy: UniqueKeyPolicy # Unique key constraints

693

```