or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

annotations.mdauthentication.mdclient-traits.mdcryptography.mdexceptions.mdhttp-client.mdhttp-policies.mdindex.mdmodels.mdserialization.mdutilities.md

models.mddocs/

0

# Core Models and Types

1

2

Essential data models including Cloud Events, geographic objects, Azure cloud configurations, and common model patterns used across Azure services.

3

4

## Capabilities

5

6

### Cloud Events

7

8

Implementation of the Cloud Events specification for standardized event data representation.

9

10

```java { .api }

11

/**

12

* Represents a CloudEvent conforming to the CloudEvents specification.

13

*/

14

class CloudEvent {

15

/**

16

* Creates a CloudEvent.

17

* @param source Identifies the context in which an event happened

18

* @param type The type of event related to the originating occurrence

19

*/

20

public CloudEvent(String source, String type);

21

22

/**

23

* Creates a CloudEvent.

24

* @param source Identifies the context in which an event happened

25

* @param type The type of event related to the originating occurrence

26

* @param data Event payload data

27

* @param dataContentType Content type of the data value

28

* @param subject The subject of the event in the context of the event producer

29

*/

30

public CloudEvent(String source, String type, BinaryData data, String dataContentType, String subject);

31

32

/**

33

* Gets the event ID.

34

* @return Event identifier

35

*/

36

public String getId();

37

38

/**

39

* Gets the source of the event.

40

* @return Event source

41

*/

42

public String getSource();

43

44

/**

45

* Gets the type of the event.

46

* @return Event type

47

*/

48

public String getType();

49

50

/**

51

* Gets the data content type.

52

* @return Content type of the event data

53

*/

54

public String getDataContentType();

55

56

/**

57

* Gets the data schema URL.

58

* @return Schema URL for the event data

59

*/

60

public String getDataSchema();

61

62

/**

63

* Gets the subject of the event.

64

* @return Event subject

65

*/

66

public String getSubject();

67

68

/**

69

* Gets the time the event was generated.

70

* @return Event timestamp

71

*/

72

public OffsetDateTime getTime();

73

74

/**

75

* Gets the event data as BinaryData.

76

* @return Event payload data

77

*/

78

public BinaryData getData();

79

80

/**

81

* Gets extension attributes.

82

* @return Map of extension attributes

83

*/

84

public Map<String, Object> getExtensionAttributes();

85

86

/**

87

* Sets the subject of the event.

88

* @param subject Event subject

89

* @return Updated CloudEvent

90

*/

91

public CloudEvent setSubject(String subject);

92

93

/**

94

* Sets the data schema URL.

95

* @param dataSchema Schema URL

96

* @return Updated CloudEvent

97

*/

98

public CloudEvent setDataSchema(String dataSchema);

99

100

/**

101

* Sets the time of the event.

102

* @param time Event timestamp

103

* @return Updated CloudEvent

104

*/

105

public CloudEvent setTime(OffsetDateTime time);

106

107

/**

108

* Sets the event data.

109

* @param data Event payload data

110

* @return Updated CloudEvent

111

*/

112

public CloudEvent setData(BinaryData data);

113

114

/**

115

* Sets the data content type.

116

* @param dataContentType Content type of the data

117

* @return Updated CloudEvent

118

*/

119

public CloudEvent setDataContentType(String dataContentType);

120

121

/**

122

* Adds an extension attribute.

123

* @param name Extension attribute name

124

* @param value Extension attribute value

125

* @return Updated CloudEvent

126

*/

127

public CloudEvent addExtensionAttribute(String name, Object value);

128

}

129

```

130

131

### CloudEventDataFormat Enum

132

133

Enumeration of supported data formats for Cloud Events.

134

135

```java { .api }

136

/**

137

* The format that the event data is encoded in.

138

*/

139

enum CloudEventDataFormat {

140

/**

141

* Event data is in JSON format.

142

*/

143

JSON,

144

145

/**

146

* Event data is in XML format.

147

*/

148

XML,

149

150

/**

151

* Event data is in plain text format.

152

*/

153

TEXT,

154

155

/**

156

* Event data is in binary format.

157

*/

158

BYTES;

159

160

/**

161

* Creates a CloudEventDataFormat from a string value.

162

* @param value String representation of the format

163

* @return Corresponding CloudEventDataFormat

164

*/

165

public static CloudEventDataFormat fromString(String value);

166

}

167

```

168

169

### Azure Cloud Environments

170

171

Enumeration of Azure cloud environments with their specific endpoints and configurations.

172

173

```java { .api }

174

/**

175

* An enumeration of available Azure clouds.

176

*/

177

enum AzureCloud {

178

/**

179

* Azure global cloud.

180

*/

181

AZURE,

182

183

/**

184

* Azure operated by 21Vianet in China.

185

*/

186

AZURE_CHINA,

187

188

/**

189

* Azure Germany cloud.

190

*/

191

AZURE_GERMANY,

192

193

/**

194

* Azure US Government cloud.

195

*/

196

AZURE_US_GOVERNMENT;

197

198

/**

199

* Gets the Azure Active Directory endpoint for this cloud.

200

* @return AAD endpoint URL

201

*/

202

public String getActiveDirectoryEndpoint();

203

204

/**

205

* Gets the Azure Resource Manager endpoint for this cloud.

206

* @return ARM endpoint URL

207

*/

208

public String getResourceManagerEndpoint();

209

210

/**

211

* Gets the Microsoft Graph endpoint for this cloud.

212

* @return Microsoft Graph endpoint URL

213

*/

214

public String getMicrosoftGraphEndpoint();

215

216

/**

217

* Gets the Key Vault DNS suffix for this cloud.

218

* @return Key Vault DNS suffix

219

*/

220

public String getKeyVaultDnsSuffix();

221

222

/**

223

* Gets the Storage endpoint suffix for this cloud.

224

* @return Storage endpoint suffix

225

*/

226

public String getStorageEndpointSuffix();

227

228

/**

229

* Gets the SQL Database DNS suffix for this cloud.

230

* @return SQL Database DNS suffix

231

*/

232

public String getSqlDatabaseDnsSuffix();

233

}

234

```

235

236

### Geographic Objects

237

238

Base classes and implementations for representing geographic data structures.

239

240

```java { .api }

241

/**

242

* Abstract base class for all geographic objects.

243

*/

244

abstract class GeoObject {

245

/**

246

* Gets the GeoJSON type of the object.

247

* @return GeoJSON type

248

*/

249

public abstract String getType();

250

251

/**

252

* Gets the bounding box of the geographic object.

253

* @return Bounding box or null if not set

254

*/

255

public GeoBoundingBox getBoundingBox();

256

257

/**

258

* Sets the bounding box of the geographic object.

259

* @param boundingBox Bounding box to set

260

* @return Updated GeoObject

261

*/

262

public GeoObject setBoundingBox(GeoBoundingBox boundingBox);

263

264

/**

265

* Gets additional properties.

266

* @return Map of additional properties

267

*/

268

public Map<String, Object> getAdditionalProperties();

269

270

/**

271

* Sets additional properties.

272

* @param additionalProperties Map of properties to set

273

* @return Updated GeoObject

274

*/

275

public GeoObject setAdditionalProperties(Map<String, Object> additionalProperties);

276

}

277

278

/**

279

* Represents a geometric point.

280

*/

281

class GeoPoint extends GeoObject {

282

/**

283

* Creates a GeoPoint.

284

* @param position The position coordinates

285

*/

286

public GeoPoint(GeoPosition position);

287

288

/**

289

* Creates a GeoPoint.

290

* @param longitude Longitude coordinate

291

* @param latitude Latitude coordinate

292

*/

293

public GeoPoint(double longitude, double latitude);

294

295

/**

296

* Creates a GeoPoint.

297

* @param longitude Longitude coordinate

298

* @param latitude Latitude coordinate

299

* @param altitude Altitude coordinate

300

*/

301

public GeoPoint(double longitude, double latitude, Double altitude);

302

303

/**

304

* Gets the position of the point.

305

* @return Position coordinates

306

*/

307

public GeoPosition getCoordinates();

308

309

@Override

310

public String getType() {

311

return "Point";

312

}

313

}

314

315

/**

316

* Represents a line string geometry.

317

*/

318

class GeoLineString extends GeoObject {

319

/**

320

* Creates a GeoLineString.

321

* @param positions List of positions forming the line

322

*/

323

public GeoLineString(List<GeoPosition> positions);

324

325

/**

326

* Gets the positions that form the line string.

327

* @return List of positions

328

*/

329

public List<GeoPosition> getCoordinates();

330

331

@Override

332

public String getType() {

333

return "LineString";

334

}

335

}

336

337

/**

338

* Represents a polygon geometry.

339

*/

340

class GeoPolygon extends GeoObject {

341

/**

342

* Creates a GeoPolygon.

343

* @param exteriorRing The exterior boundary of the polygon

344

*/

345

public GeoPolygon(GeoLinearRing exteriorRing);

346

347

/**

348

* Creates a GeoPolygon.

349

* @param exteriorRing The exterior boundary of the polygon

350

* @param holes Interior holes in the polygon

351

*/

352

public GeoPolygon(GeoLinearRing exteriorRing, List<GeoLinearRing> holes);

353

354

/**

355

* Gets the exterior ring of the polygon.

356

* @return Exterior linear ring

357

*/

358

public GeoLinearRing getExteriorRing();

359

360

/**

361

* Gets the holes (interior rings) of the polygon.

362

* @return List of interior linear rings

363

*/

364

public List<GeoLinearRing> getHoles();

365

366

/**

367

* Gets the coordinates as a list of linear rings.

368

* @return List of linear rings (first is exterior, rest are holes)

369

*/

370

public List<List<GeoPosition>> getCoordinates();

371

372

@Override

373

public String getType() {

374

return "Polygon";

375

}

376

}

377

378

/**

379

* Represents a collection of geographic objects.

380

*/

381

class GeoCollection extends GeoObject {

382

/**

383

* Creates a GeoCollection.

384

* @param geometries List of geometric objects in the collection

385

*/

386

public GeoCollection(List<GeoObject> geometries);

387

388

/**

389

* Gets the geometries in the collection.

390

* @return List of geometric objects

391

*/

392

public List<GeoObject> getGeometries();

393

394

@Override

395

public String getType() {

396

return "GeometryCollection";

397

}

398

}

399

```

400

401

### Geographic Position and Supporting Types

402

403

```java { .api }

404

/**

405

* Represents a position with longitude, latitude, and optional altitude.

406

*/

407

class GeoPosition {

408

/**

409

* Creates a GeoPosition.

410

* @param longitude Longitude coordinate

411

* @param latitude Latitude coordinate

412

*/

413

public GeoPosition(double longitude, double latitude);

414

415

/**

416

* Creates a GeoPosition.

417

* @param longitude Longitude coordinate

418

* @param latitude Latitude coordinate

419

* @param altitude Altitude coordinate

420

*/

421

public GeoPosition(double longitude, double latitude, Double altitude);

422

423

/**

424

* Gets the longitude.

425

* @return Longitude coordinate

426

*/

427

public double getLongitude();

428

429

/**

430

* Gets the latitude.

431

* @return Latitude coordinate

432

*/

433

public double getLatitude();

434

435

/**

436

* Gets the altitude.

437

* @return Altitude coordinate or null if not set

438

*/

439

public Double getAltitude();

440

441

/**

442

* Gets all coordinates as an array.

443

* @return Array of coordinates [longitude, latitude, altitude?]

444

*/

445

public double[] getCoordinates();

446

}

447

448

/**

449

* Represents a linear ring (closed line string).

450

*/

451

class GeoLinearRing {

452

/**

453

* Creates a GeoLinearRing.

454

* @param positions List of positions forming the ring (must be closed)

455

*/

456

public GeoLinearRing(List<GeoPosition> positions);

457

458

/**

459

* Gets the positions forming the linear ring.

460

* @return List of positions

461

*/

462

public List<GeoPosition> getCoordinates();

463

}

464

465

/**

466

* Represents a bounding box for geographic objects.

467

*/

468

class GeoBoundingBox {

469

/**

470

* Creates a GeoBoundingBox.

471

* @param west Western boundary

472

* @param south Southern boundary

473

* @param east Eastern boundary

474

* @param north Northern boundary

475

*/

476

public GeoBoundingBox(double west, double south, double east, double north);

477

478

/**

479

* Creates a GeoBoundingBox with altitude.

480

* @param west Western boundary

481

* @param south Southern boundary

482

* @param minAltitude Minimum altitude

483

* @param east Eastern boundary

484

* @param north Northern boundary

485

* @param maxAltitude Maximum altitude

486

*/

487

public GeoBoundingBox(double west, double south, double minAltitude,

488

double east, double north, double maxAltitude);

489

490

/**

491

* Gets the western boundary.

492

* @return Western longitude

493

*/

494

public double getWest();

495

496

/**

497

* Gets the southern boundary.

498

* @return Southern latitude

499

*/

500

public double getSouth();

501

502

/**

503

* Gets the eastern boundary.

504

* @return Eastern longitude

505

*/

506

public double getEast();

507

508

/**

509

* Gets the northern boundary.

510

* @return Northern latitude

511

*/

512

public double getNorth();

513

514

/**

515

* Gets the minimum altitude.

516

* @return Minimum altitude or null if not set

517

*/

518

public Double getMinAltitude();

519

520

/**

521

* Gets the maximum altitude.

522

* @return Maximum altitude or null if not set

523

*/

524

public Double getMaxAltitude();

525

}

526

```

527

528

### Multi-Geometry Types

529

530

```java { .api }

531

/**

532

* Represents multiple points.

533

*/

534

class GeoMultiPoint extends GeoObject {

535

/**

536

* Creates a GeoMultiPoint.

537

* @param points List of points

538

*/

539

public GeoMultiPoint(List<GeoPoint> points);

540

541

/**

542

* Gets the points in the multi-point.

543

* @return List of points

544

*/

545

public List<GeoPoint> getPoints();

546

547

/**

548

* Gets the coordinates as a list of positions.

549

* @return List of positions

550

*/

551

public List<GeoPosition> getCoordinates();

552

553

@Override

554

public String getType() {

555

return "MultiPoint";

556

}

557

}

558

559

/**

560

* Represents multiple line strings.

561

*/

562

class GeoMultiLineString extends GeoObject {

563

/**

564

* Creates a GeoMultiLineString.

565

* @param lineStrings List of line strings

566

*/

567

public GeoMultiLineString(List<GeoLineString> lineStrings);

568

569

/**

570

* Gets the line strings in the multi-line string.

571

* @return List of line strings

572

*/

573

public List<GeoLineString> getLineStrings();

574

575

/**

576

* Gets the coordinates as a list of position lists.

577

* @return List of position lists

578

*/

579

public List<List<GeoPosition>> getCoordinates();

580

581

@Override

582

public String getType() {

583

return "MultiLineString";

584

}

585

}

586

587

/**

588

* Represents multiple polygons.

589

*/

590

class GeoMultiPolygon extends GeoObject {

591

/**

592

* Creates a GeoMultiPolygon.

593

* @param polygons List of polygons

594

*/

595

public GeoMultiPolygon(List<GeoPolygon> polygons);

596

597

/**

598

* Gets the polygons in the multi-polygon.

599

* @return List of polygons

600

*/

601

public List<GeoPolygon> getPolygons();

602

603

/**

604

* Gets the coordinates as a nested list structure.

605

* @return List of polygon coordinate lists

606

*/

607

public List<List<List<GeoPosition>>> getCoordinates();

608

609

@Override

610

public String getType() {

611

return "MultiPolygon";

612

}

613

}

614

```

615

616

### Collection Classes

617

618

```java { .api }

619

/**

620

* Represents an array of geographic objects.

621

*/

622

class GeoArray {

623

/**

624

* Creates a GeoArray.

625

* @param geoObjects List of geographic objects

626

*/

627

public GeoArray(List<GeoObject> geoObjects);

628

629

/**

630

* Gets the geographic objects in the array.

631

* @return List of geographic objects

632

*/

633

public List<GeoObject> getGeoObjects();

634

635

/**

636

* Gets the number of objects in the array.

637

* @return Array size

638

*/

639

public int size();

640

641

/**

642

* Gets the object at the specified index.

643

* @param index Array index

644

* @return Geographic object at index

645

*/

646

public GeoObject get(int index);

647

}

648

649

/**

650

* Collection of GeoPoint objects.

651

*/

652

class GeoPointCollection {

653

/**

654

* Creates a GeoPointCollection.

655

* @param points List of points

656

*/

657

public GeoPointCollection(List<GeoPoint> points);

658

659

/**

660

* Gets the points in the collection.

661

* @return List of points

662

*/

663

public List<GeoPoint> getPoints();

664

}

665

666

/**

667

* Collection of GeoLineString objects.

668

*/

669

class GeoLineStringCollection {

670

/**

671

* Creates a GeoLineStringCollection.

672

* @param lineStrings List of line strings

673

*/

674

public GeoLineStringCollection(List<GeoLineString> lineStrings);

675

676

/**

677

* Gets the line strings in the collection.

678

* @return List of line strings

679

*/

680

public List<GeoLineString> getLineStrings();

681

}

682

683

/**

684

* Collection of GeoPolygon objects.

685

*/

686

class GeoPolygonCollection {

687

/**

688

* Creates a GeoPolygonCollection.

689

* @param polygons List of polygons

690

*/

691

public GeoPolygonCollection(List<GeoPolygon> polygons);

692

693

/**

694

* Gets the polygons in the collection.

695

* @return List of polygons

696

*/

697

public List<GeoPolygon> getPolygons();

698

}

699

```

700

701

## Usage Examples

702

703

### Working with Cloud Events

704

705

```java

706

import com.azure.core.models.CloudEvent;

707

import com.azure.core.util.BinaryData;

708

import java.time.OffsetDateTime;

709

import java.util.Map;

710

711

// Create a basic Cloud Event

712

CloudEvent event = new CloudEvent("https://example.com/source", "User.Created");

713

714

// Add event data

715

User newUser = new User("Alice", "alice@example.com");

716

BinaryData userData = BinaryData.fromObject(newUser);

717

718

CloudEvent userEvent = new CloudEvent("https://api.example.com/users", "User.Created")

719

.setSubject("users/alice")

720

.setData(userData)

721

.setDataContentType("application/json")

722

.setTime(OffsetDateTime.now())

723

.addExtensionAttribute("correlationId", "12345")

724

.addExtensionAttribute("priority", "high");

725

726

// Access event properties

727

System.out.println("Event ID: " + userEvent.getId());

728

System.out.println("Source: " + userEvent.getSource());

729

System.out.println("Type: " + userEvent.getType());

730

System.out.println("Subject: " + userEvent.getSubject());

731

System.out.println("Time: " + userEvent.getTime());

732

733

// Work with event data

734

BinaryData eventData = userEvent.getData();

735

User deserializedUser = eventData.toObject(User.class);

736

737

// Access extension attributes

738

Map<String, Object> extensions = userEvent.getExtensionAttributes();

739

String correlationId = (String) extensions.get("correlationId");

740

```

741

742

### Geographic Data Operations

743

744

```java

745

import com.azure.core.models.*;

746

747

// Create geographic points

748

GeoPoint point1 = new GeoPoint(-122.3, 47.6); // Seattle

749

GeoPoint point2 = new GeoPoint(-74.0, 40.7); // New York

750

GeoPoint point3 = new GeoPoint(-87.6, 41.9); // Chicago

751

752

// Create a line string connecting cities

753

List<GeoPosition> positions = List.of(

754

new GeoPosition(-122.3, 47.6), // Seattle

755

new GeoPosition(-87.6, 41.9), // Chicago

756

new GeoPosition(-74.0, 40.7) // New York

757

);

758

GeoLineString route = new GeoLineString(positions);

759

760

// Create a polygon representing a region

761

List<GeoPosition> exteriorRing = List.of(

762

new GeoPosition(-122.0, 47.0),

763

new GeoPosition(-122.0, 48.0),

764

new GeoPosition(-121.0, 48.0),

765

new GeoPosition(-121.0, 47.0),

766

new GeoPosition(-122.0, 47.0) // Close the ring

767

);

768

GeoLinearRing ring = new GeoLinearRing(exteriorRing);

769

GeoPolygon region = new GeoPolygon(ring);

770

771

// Create a multi-point for multiple locations

772

GeoMultiPoint cities = new GeoMultiPoint(List.of(point1, point2, point3));

773

774

// Set bounding box

775

GeoBoundingBox boundingBox = new GeoBoundingBox(-125.0, 45.0, -120.0, 50.0);

776

region.setBoundingBox(boundingBox);

777

778

// Create a geometry collection

779

GeoCollection collection = new GeoCollection(List.of(point1, route, region));

780

```

781

782

### Working with Azure Cloud Configurations

783

784

```java

785

import com.azure.core.models.AzureCloud;

786

787

// Get endpoints for different Azure clouds

788

AzureCloud publicCloud = AzureCloud.AZURE;

789

String aadEndpoint = publicCloud.getActiveDirectoryEndpoint();

790

String armEndpoint = publicCloud.getResourceManagerEndpoint();

791

String graphEndpoint = publicCloud.getMicrosoftGraphEndpoint();

792

793

System.out.println("AAD Endpoint: " + aadEndpoint);

794

System.out.println("ARM Endpoint: " + armEndpoint);

795

System.out.println("Graph Endpoint: " + graphEndpoint);

796

797

// Work with different cloud environments

798

AzureCloud govCloud = AzureCloud.AZURE_US_GOVERNMENT;

799

String govStorageSuffix = govCloud.getStorageEndpointSuffix();

800

String govKeyVaultSuffix = govCloud.getKeyVaultDnsSuffix();

801

802

// Configure services based on cloud environment

803

switch (publicCloud) {

804

case AZURE:

805

// Configure for public cloud

806

break;

807

case AZURE_CHINA:

808

// Configure for China cloud

809

break;

810

case AZURE_US_GOVERNMENT:

811

// Configure for US Government cloud

812

break;

813

case AZURE_GERMANY:

814

// Configure for Germany cloud

815

break;

816

}

817

```

818

819

### Complex Geographic Structures

820

821

```java

822

import com.azure.core.models.*;

823

824

// Create a complex polygon with holes

825

List<GeoPosition> exterior = List.of(

826

new GeoPosition(0, 0),

827

new GeoPosition(10, 0),

828

new GeoPosition(10, 10),

829

new GeoPosition(0, 10),

830

new GeoPosition(0, 0)

831

);

832

833

List<GeoPosition> hole1 = List.of(

834

new GeoPosition(2, 2),

835

new GeoPosition(4, 2),

836

new GeoPosition(4, 4),

837

new GeoPosition(2, 4),

838

new GeoPosition(2, 2)

839

);

840

841

List<GeoPosition> hole2 = List.of(

842

new GeoPosition(6, 6),

843

new GeoPosition(8, 6),

844

new GeoPosition(8, 8),

845

new GeoPosition(6, 8),

846

new GeoPosition(6, 6)

847

);

848

849

GeoLinearRing exteriorRing = new GeoLinearRing(exterior);

850

List<GeoLinearRing> holes = List.of(

851

new GeoLinearRing(hole1),

852

new GeoLinearRing(hole2)

853

);

854

855

GeoPolygon complexPolygon = new GeoPolygon(exteriorRing, holes);

856

857

// Work with 3D coordinates (altitude)

858

GeoPosition point3D = new GeoPosition(-122.3, 47.6, 100.0); // Seattle at 100m altitude

859

GeoPoint elevatedPoint = new GeoPoint(point3D);

860

861

// Create bounding box with altitude

862

GeoBoundingBox bbox3D = new GeoBoundingBox(-123.0, 47.0, 0.0, -122.0, 48.0, 200.0);

863

elevatedPoint.setBoundingBox(bbox3D);

864

```

865

866

### Working with Event Extensions

867

868

```java

869

import com.azure.core.models.CloudEvent;

870

import java.util.Map;

871

872

// Create event with custom extensions

873

CloudEvent event = new CloudEvent("https://ecommerce.example.com", "Order.Placed")

874

.addExtensionAttribute("customerid", "cust-12345")

875

.addExtensionAttribute("ordervalue", 299.99)

876

.addExtensionAttribute("paymentmethod", "credit-card")

877

.addExtensionAttribute("region", "us-west-2");

878

879

// Access extension attributes

880

Map<String, Object> extensions = event.getExtensionAttributes();

881

String customerId = (String) extensions.get("customerid");

882

Double orderValue = (Double) extensions.get("ordervalue");

883

884

// Iterate over all extensions

885

extensions.forEach((key, value) -> {

886

System.out.println("Extension " + key + ": " + value);

887

});

888

889

// Check if specific extension exists

890

if (extensions.containsKey("priority")) {

891

String priority = (String) extensions.get("priority");

892

System.out.println("Event priority: " + priority);

893

}

894

```