Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate enum to union in samples #500

Merged
merged 6 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,17 @@ model LedgerEntry {

// TODO: No way to set "x-ms-enum.name" right now
@doc("Represents an assignable role.")
enum LedgerUserRole {
union LedgerUserRole {
string,

@doc("The administrator role.")
Administrator,
Administrator: "Administrator",

@doc("The contributor role.")
Contributor,
Contributor: "Contributor",

@doc("The reader role.")
Reader,
Reader: "Reader",
}

@resource("users")
Expand All @@ -118,12 +120,14 @@ model ReceiptContents {

// TODO: No way to set "x-ms-enum.name" right now
@doc("State of a ledger query.")
enum LedgerQueryState {
union LedgerQueryState {
string,

@doc("The query is still loading.")
Loading,
Loading: "Loading",

@doc("The query is ready.")
Ready,
Ready: "Ready",
}

@doc("A receipt certifying the transaction at the specified id.")
Expand All @@ -140,12 +144,14 @@ model TransactionReceipt {

// TODO: No way to set "x-ms-enum.name" right now
@doc("Represents the state of the transaction.")
enum TransactionState {
union TransactionState {
string,

@doc("The transaction is committed.")
Committed,
Committed: "Committed",

@doc("The transaction is pending.")
Pending,
Pending: "Pending",
}

@doc("Response returned to a query for the transaction status.")
Expand Down
110 changes: 64 additions & 46 deletions packages/samples/specs/data-plane/formrecognizer/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,17 @@ interface DocumentModels {
}

@doc("Method used to compute string offset and length.")
enum StringIndexType {
union StringIndexType {
string,

@doc("Text elements")
textElements,
textElements: "textElements",

@doc("Unicode code points")
unicodeCodePoint,
unicodeCodePoint: "unicodeCodePoint",

@doc("UTF-16 code units")
utf16CodeUnit,
utf16CodeUnit: "utf16CodeUnit",
}

@doc("Unique model name")
Expand Down Expand Up @@ -243,18 +245,20 @@ model CustomDocumentModelsInfo {
}

@doc("Operation status.")
enum AnalyzeResultOperationStatus {
union AnalyzeResultOperationStatus {
string,

@doc("Operation has not started.")
notStarted,
notStarted: "notStarted",

@doc("Operation is running.")
running,
running: "running",

@doc("Operation has failed.")
failed,
failed: "failed",

@doc("Operation has succeeded.")
succeeded,
succeeded: "succeeded",
}

@resource("analyzeResults")
Expand Down Expand Up @@ -351,12 +355,14 @@ model DocumentPage {
}

@doc("The unit used by the width, height, and boundingBox properties. For images, the unit is \"pixel\". For PDF, the unit is \"inch\".")
enum LengthUnit {
union LengthUnit {
string,

@doc("Unit is pixel.")
pixel,
pixel: "pixel",

@doc("Unit is inch.")
inch,
inch: "inch",
}

@doc("Contiguous region of the concatenated content property, specified as an offset and length.")
Expand Down Expand Up @@ -413,12 +419,14 @@ model DocumentSelectionMark {
scalar Confidence extends float64;

@doc("State of the selection mark.")
enum SelectionMarkState {
union SelectionMarkState {
string,

@doc("Selected.")
selected,
selected: "selected",

@doc("Unselected.")
unselected,
unselected: "unselected",
}

@doc("A table object consisting table cells arranged in a rectangular layout.")
Expand Down Expand Up @@ -467,21 +475,23 @@ model DocumentTableCell {
}

@doc("Table cell kind.")
enum DocumentTableCellKind {
union DocumentTableCellKind {
string,

@doc("Content cell.")
content,
content: "content",

@doc("Row header cell.")
rowHeader,
rowHeader: "rowHeader",

@doc("Column header cell.")
columnHeader,
columnHeader: "columnHeader",

@doc("Stub cell.")
stubHead,
stubHead: "stubHead",

@doc("Blank cell.")
description,
description: "description",
}

@doc("Bounding box on a specific page of the input.")
Expand Down Expand Up @@ -626,48 +636,52 @@ model DocumentField {
}

@doc("Semantic data type of the field value.")
enum DocumentFieldType {
@doc("String value.")
union DocumentFieldType {
string,

@doc("String value.")
string: "string",

@doc("Date value")
date,
date: "date",

@doc("Time value")
time,
time: "time",

@doc("Phone number value")
phoneNumber,
phoneNumber: "phoneNumber",

@doc("Floating point value")
number,
number: "number",

@doc("Integer value")
integer,
integer: "integer",

@doc("Selection mark value.")
selectionMark,
selectionMark: "selectionMark",

@doc("Country code value.")
countryRegion,
countryRegion: "countryRegion",

@doc("Signature value.")
signature,
signature: "signature",

@doc("Array value.")
array,
array: "array",

@doc("Object value.")
object,
object: "object",
}

@doc("Presence of signature.")
enum DocumentSignatureType {
union DocumentSignatureType {
string,

@doc("Document is signed.")
signed,
signed: "signed",

@doc("Document is unsigned.")
unsigned,
unsigned: "unsigned",
}

@doc("A content line object consisting of an adjacent sequence of content elements, such as words and selection marks.")
Expand Down Expand Up @@ -781,33 +795,37 @@ model OperationInfo {
}

@doc("Operation status.")
enum OperationStatus {
union OperationStatus {
string,

@doc("Operation has not started yet.")
notStarted,
notStarted: "notStarted",

@doc("Operation is running.")
running,
running: "running",

@doc("Operation failed.")
failed,
failed: "failed",

@doc("Operation succeeded.")
succeeded,
succeeded: "succeeded",

@doc("Operation was canceled.")
canceled,
canceled: "canceled",
}

@doc("Type of operation")
enum OperationKind {
union OperationKind {
string,

@doc("Operation to build a new custom model.")
documentModelBuild,
documentModelBuild: "documentModelBuild",

@doc("Operation to compose a new custom model.")
documentModelCompose,
documentModelCompose: "documentModelCompose",

@doc("Operation to copy a custom model.")
documentModelCopyTo,
documentModelCopyTo: "documentModelCopyTo",
}

@doc("The response for the getOperation operation.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,17 @@ model Project {
}

@doc("Represents the project kind.")
enum ProjectKind {
union ProjectKind {
string,
timotheeguerin marked this conversation as resolved.
Show resolved Hide resolved

@doc("For building a classification model to classify text using your own data. Each file will have only one label. For example, file 1 is classified as A and file 2 is classified as B.")
CustomSingleLabelClassification,
CustomSingleLabelClassification: "CustomSingleLabelClassification",

@doc("For building a classification model to classify text using your own data. Each file can have one or many labels. For example, file 1 is classified as A, B, and C and file 2 is classified as B and C.")
CustomMultiLabelClassification,
CustomMultiLabelClassification: "CustomMultiLabelClassification",

@doc("For building an extraction model to identify your domain categories using your own data.")
CustomEntityRecognition,
CustomEntityRecognition: "CustomEntityRecognition",
}

@doc("Represents the settings used to define the project behavior.")
Expand Down Expand Up @@ -132,27 +134,29 @@ model Job {
}

@doc("Represents the job status.")
enum JobStatus {
union JobStatus {
string,

@doc("The job has not started yet.")
notStarted,
notStarted: "notStarted",

@doc("The job is running.")
running,
running: "running",

@doc("The job has completed successfully.")
succeeded,
succeeded: "succeeded",

@doc("The job has failed.")
failed,
failed: "failed",

@doc("The job has been cancelled.")
cancelled,
cancelled: "cancelled",

@doc("The job is cancelling.")
cancelling,
cancelling: "cancelling",

@doc("The job is partially completed.")
partiallyCompleted,
partiallyCompleted: "partiallyCompleted",
}

@doc("Represents a warning that was encountered while executing the request.")
Expand Down
Loading
Loading