or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

index.mdv2-legacy-api.mdv3-adaptive-mt.mdv3-automl-translation.mdv3-data-structures.mdv3-glossary-management.mdv3-request-response-types.mdv3-translation-services.md

v3-data-structures.mddocs/

0

# V3 Data Structures and Enums

1

2

Core data structures, enums, and configuration objects used throughout the Google Cloud Translation API V3. These types define the fundamental data models for glossaries, adaptive MT, AutoML, and common configurations.

3

4

## Core Import

5

6

```python

7

from google.cloud import translate_v3

8

```

9

10

## Common Data Structures

11

12

### File and Storage Types

13

14

```python { .api }

15

class FileInputSource:

16

"""

17

Input source for files.

18

19

Attributes:

20

mime_type (str): MIME type of input file (required)

21

gcs_source (GcsInputSource): Google Cloud Storage source

22

content (bytes): File content as bytes

23

display_name (str): Display name for the file

24

"""

25

26

class GcsInputSource:

27

"""

28

Google Cloud Storage input source.

29

30

Attributes:

31

input_uri (str): GCS URI (gs://bucket/path) (required)

32

"""

33

34

class GcsOutputDestination:

35

"""

36

Google Cloud Storage output destination.

37

38

Attributes:

39

output_uri_prefix (str): GCS URI prefix for output files (required)

40

"""

41

```

42

43

### Glossary Data Structures

44

45

```python { .api }

46

class Glossary:

47

"""

48

Translation glossary resource.

49

50

Attributes:

51

name (str): Resource name (projects/{project}/locations/{location}/glossaries/{glossary})

52

language_pair (LanguagePair): Language pair for bilateral glossary

53

language_codes_set (LanguageCodesSet): Language codes for multilingual glossary

54

input_config (GlossaryInputConfig): Input configuration (required for creation)

55

entry_count (int): Number of entries in glossary (output only)

56

submit_time (Timestamp): Glossary creation time (output only)

57

end_time (Timestamp): Glossary completion time (output only)

58

display_name (str): Human-readable display name

59

"""

60

61

class LanguagePair:

62

"""

63

Language pair for bilateral glossary.

64

65

Attributes:

66

source_language_code (str): Source language code (BCP-47) (required)

67

target_language_code (str): Target language code (BCP-47) (required)

68

"""

69

70

class LanguageCodesSet:

71

"""

72

Language codes set for multilingual glossary.

73

74

Attributes:

75

language_codes (list): List of language codes (BCP-47) (required)

76

"""

77

78

class GlossaryEntry:

79

"""

80

Glossary entry with term mappings.

81

82

Attributes:

83

name (str): Resource name (output only)

84

terms_set (GlossaryTermsSet): Set of terms for multilingual entry

85

terms_pair (GlossaryTermsPair): Pair of terms for bilateral entry

86

description (str): Description of the entry

87

"""

88

89

class GlossaryTermsSet:

90

"""

91

Set of terms for multilingual glossary entry.

92

93

Attributes:

94

terms (dict): Mapping of language code to term (required)

95

"""

96

97

class GlossaryTermsPair:

98

"""

99

Pair of terms for bilateral glossary entry.

100

101

Attributes:

102

source_term (GlossaryTerm): Source language term (required)

103

target_term (GlossaryTerm): Target language term (required)

104

"""

105

106

class GlossaryTerm:

107

"""

108

Individual glossary term.

109

110

Attributes:

111

language_code (str): Language code (BCP-47) (required)

112

text (str): Term text (required)

113

"""

114

```

115

116

### Adaptive MT Data Structures

117

118

```python { .api }

119

class AdaptiveMtDataset:

120

"""

121

Adaptive MT dataset resource.

122

123

Attributes:

124

name (str): Resource name (projects/{project}/locations/{location}/adaptiveMtDatasets/{dataset})

125

display_name (str): Human-readable display name

126

source_language_code (str): Source language code (BCP-47) (required)

127

target_language_code (str): Target language code (BCP-47) (required)

128

example_count (int): Number of examples in dataset (output only)

129

create_time (Timestamp): Dataset creation time (output only)

130

update_time (Timestamp): Dataset last update time (output only)

131

"""

132

133

class AdaptiveMtFile:

134

"""

135

Adaptive MT file resource.

136

137

Attributes:

138

name (str): Resource name (output only)

139

display_name (str): Human-readable display name

140

entry_count (int): Number of entries in file (output only)

141

create_time (Timestamp): File creation time (output only)

142

update_time (Timestamp): File last update time (output only)

143

"""

144

145

class AdaptiveMtSentence:

146

"""

147

Adaptive MT sentence pair.

148

149

Attributes:

150

name (str): Resource name (output only)

151

source_sentence (str): Source language sentence (required)

152

target_sentence (str): Target language sentence (required)

153

create_time (Timestamp): Sentence creation time (output only)

154

update_time (Timestamp): Sentence last update time (output only)

155

"""

156

157

class AdaptiveMtTranslation:

158

"""

159

Adaptive MT translation result.

160

161

Attributes:

162

translated_text (str): Translated text

163

"""

164

```

165

166

### AutoML Data Structures

167

168

```python { .api }

169

class Dataset:

170

"""

171

AutoML translation dataset resource.

172

173

Attributes:

174

name (str): Resource name (projects/{project}/locations/{location}/datasets/{dataset})

175

display_name (str): Human-readable display name

176

source_language_code (str): Source language code (BCP-47) (required)

177

target_language_code (str): Target language code (BCP-47) (required)

178

example_count (int): Total number of examples (output only)

179

train_example_count (int): Number of training examples (output only)

180

validate_example_count (int): Number of validation examples (output only)

181

test_example_count (int): Number of test examples (output only)

182

create_time (Timestamp): Dataset creation time (output only)

183

update_time (Timestamp): Dataset last update time (output only)

184

state (DatasetState): Current dataset state (output only)

185

"""

186

187

class Model:

188

"""

189

AutoML translation model resource.

190

191

Attributes:

192

name (str): Resource name (projects/{project}/locations/{location}/models/{model})

193

display_name (str): Human-readable display name

194

dataset (str): Training dataset resource name (required)

195

source_language_code (str): Source language code (BCP-47) (output only)

196

target_language_code (str): Target language code (BCP-47) (output only)

197

train_example_count (int): Training examples used (output only)

198

validate_example_count (int): Validation examples used (output only)

199

test_example_count (int): Test examples used (output only)

200

create_time (Timestamp): Model creation time (output only)

201

update_time (Timestamp): Model last update time (output only)

202

state (ModelState): Current model state (output only)

203

"""

204

205

class Example:

206

"""

207

Training example for AutoML dataset.

208

209

Attributes:

210

name (str): Resource name (output only)

211

source_text (str): Source language text (required)

212

target_text (str): Target language text (required)

213

usage (ExampleUsage): Usage type (TRAIN, VALIDATION, TEST) (required)

214

"""

215

216

class DatasetInputConfig:

217

"""

218

Dataset input configuration.

219

220

Attributes:

221

input_files (list): List of input file configurations (required)

222

"""

223

224

class DatasetOutputConfig:

225

"""

226

Dataset output configuration.

227

228

Attributes:

229

gcs_destination (GcsOutputDestination): Google Cloud Storage destination (required)

230

"""

231

```

232

233

## Enums and Constants

234

235

### Operation and State Enums

236

237

```python { .api }

238

class OperationState:

239

"""

240

Long-running operation states.

241

242

Values:

243

OPERATION_STATE_UNSPECIFIED = 0 # State unspecified

244

OPERATION_STATE_RUNNING = 1 # Operation is running

245

OPERATION_STATE_SUCCEEDED = 2 # Operation succeeded

246

OPERATION_STATE_FAILED = 3 # Operation failed

247

OPERATION_STATE_CANCELLING = 4 # Operation is being cancelled

248

OPERATION_STATE_CANCELLED = 5 # Operation was cancelled

249

"""

250

251

class DatasetState:

252

"""

253

AutoML dataset states.

254

255

Values:

256

DATASET_STATE_UNSPECIFIED = 0 # Dataset state unspecified

257

CREATING = 1 # Dataset is being created

258

ACTIVE = 2 # Dataset is active and ready

259

DELETING = 3 # Dataset is being deleted

260

"""

261

262

class ModelState:

263

"""

264

AutoML model states.

265

266

Values:

267

MODEL_STATE_UNSPECIFIED = 0 # Model state unspecified

268

CREATING = 1 # Model is being created/trained

269

ACTIVE = 2 # Model is active and ready

270

DELETING = 3 # Model is being deleted

271

FAILED = 4 # Model creation/training failed

272

"""

273

274

class ExampleUsage:

275

"""

276

Training example usage types.

277

278

Values:

279

EXAMPLE_USAGE_UNSPECIFIED = 0 # Usage unspecified

280

TRAIN = 1 # Training example

281

VALIDATION = 2 # Validation example

282

TEST = 3 # Test example

283

"""

284

```

285

286

### Metadata Structures

287

288

```python { .api }

289

class CreateGlossaryMetadata:

290

"""

291

Metadata for glossary creation operation.

292

293

Attributes:

294

name (str): Glossary resource name

295

state (OperationState): Current operation state

296

submit_time (Timestamp): Operation submit time

297

"""

298

299

class UpdateGlossaryMetadata:

300

"""

301

Metadata for glossary update operation.

302

303

Attributes:

304

name (str): Glossary resource name

305

state (OperationState): Current operation state

306

submit_time (Timestamp): Operation submit time

307

"""

308

309

class DeleteGlossaryMetadata:

310

"""

311

Metadata for glossary deletion operation.

312

313

Attributes:

314

name (str): Glossary resource name

315

state (OperationState): Current operation state

316

submit_time (Timestamp): Operation submit time

317

"""

318

319

class CreateDatasetMetadata:

320

"""

321

Metadata for dataset creation operation.

322

323

Attributes:

324

name (str): Dataset resource name

325

state (OperationState): Current operation state

326

submit_time (Timestamp): Operation submit time

327

"""

328

329

class DeleteDatasetMetadata:

330

"""

331

Metadata for dataset deletion operation.

332

333

Attributes:

334

name (str): Dataset resource name

335

state (OperationState): Current operation state

336

submit_time (Timestamp): Operation submit time

337

"""

338

339

class CreateModelMetadata:

340

"""

341

Metadata for model creation operation.

342

343

Attributes:

344

name (str): Model resource name

345

state (OperationState): Current operation state

346

submit_time (Timestamp): Operation submit time

347

"""

348

349

class DeleteModelMetadata:

350

"""

351

Metadata for model deletion operation.

352

353

Attributes:

354

name (str): Model resource name

355

state (OperationState): Current operation state

356

submit_time (Timestamp): Operation submit time

357

"""

358

359

class ImportDataMetadata:

360

"""

361

Metadata for data import operation.

362

363

Attributes:

364

state (OperationState): Current operation state

365

submit_time (Timestamp): Operation submit time

366

"""

367

368

class ExportDataMetadata:

369

"""

370

Metadata for data export operation.

371

372

Attributes:

373

state (OperationState): Current operation state

374

submit_time (Timestamp): Operation submit time

375

"""

376

```

377

378

### Response Structures for Batch Operations

379

380

```python { .api }

381

class BatchTransferResourcesResponse:

382

"""

383

Response for batch resource transfer operation.

384

385

Attributes:

386

transferred_resources (list): List of transferred resource names

387

"""

388

389

class ImportAdaptiveMtFileResponse:

390

"""

391

Response for adaptive MT file import operation.

392

393

Attributes:

394

adaptive_mt_file_count (int): Number of files imported

395

adaptive_mt_sentence_count (int): Number of sentences imported

396

"""

397

```

398

399

## Pagination Support Types

400

401

Many list operations support pagination through dedicated pager classes that handle automatic page iteration:

402

403

### Synchronous Pagers

404

405

```python { .api }

406

class ListGlossariesPager:

407

"""Pager for ListGlossaries operation."""

408

409

class ListGlossaryEntriesPager:

410

"""Pager for ListGlossaryEntries operation."""

411

412

class ListDatasetsPager:

413

"""Pager for ListDatasets operation."""

414

415

class ListModelsPager:

416

"""Pager for ListModels operation."""

417

418

class ListExamplesPager:

419

"""Pager for ListExamples operation."""

420

421

class ListAdaptiveMtDatasetsPager:

422

"""Pager for ListAdaptiveMtDatasets operation."""

423

424

class ListAdaptiveMtFilesPager:

425

"""Pager for ListAdaptiveMtFiles operation."""

426

427

class ListAdaptiveMtSentencesPager:

428

"""Pager for ListAdaptiveMtSentences operation."""

429

```

430

431

### Asynchronous Pagers

432

433

```python { .api }

434

class ListGlossariesAsyncPager:

435

"""Async pager for ListGlossaries operation."""

436

437

class ListGlossaryEntriesAsyncPager:

438

"""Async pager for ListGlossaryEntries operation."""

439

440

class ListDatasetsAsyncPager:

441

"""Async pager for ListDatasets operation."""

442

443

class ListModelsAsyncPager:

444

"""Async pager for ListModels operation."""

445

446

class ListExamplesAsyncPager:

447

"""Async pager for ListExamples operation."""

448

449

class ListAdaptiveMtDatasetsAsyncPager:

450

"""Async pager for ListAdaptiveMtDatasets operation."""

451

452

class ListAdaptiveMtFilesAsyncPager:

453

"""Async pager for ListAdaptiveMtFiles operation."""

454

455

class ListAdaptiveMtSentencesAsyncPager:

456

"""Async pager for ListAdaptiveMtSentences operation."""

457

```

458

459

## Usage Examples

460

461

### Working with Glossary Data Structures

462

463

```python

464

from google.cloud import translate_v3

465

466

# Create a bilateral glossary entry

467

glossary_entry = translate_v3.GlossaryEntry()

468

glossary_entry.terms_pair = translate_v3.GlossaryTermsPair()

469

glossary_entry.terms_pair.source_term = translate_v3.GlossaryTerm(

470

language_code="en",

471

text="machine learning"

472

)

473

glossary_entry.terms_pair.target_term = translate_v3.GlossaryTerm(

474

language_code="es",

475

text="aprendizaje automático"

476

)

477

478

# Create a multilingual glossary entry

479

multilingual_entry = translate_v3.GlossaryEntry()

480

multilingual_entry.terms_set = translate_v3.GlossaryTermsSet()

481

multilingual_entry.terms_set.terms = {

482

"en": "artificial intelligence",

483

"es": "inteligencia artificial",

484

"fr": "intelligence artificielle"

485

}

486

```

487

488

### Working with Dataset and Model Structures

489

490

```python

491

from google.cloud import translate_v3

492

493

# Create dataset configuration

494

dataset = translate_v3.Dataset()

495

dataset.display_name = "My Translation Dataset"

496

dataset.source_language_code = "en"

497

dataset.target_language_code = "es"

498

499

# Create model configuration

500

model = translate_v3.Model()

501

model.display_name = "My Custom Translation Model"

502

model.dataset = "projects/my-project/locations/us-central1/datasets/my-dataset"

503

```