Skip to content

Library Tour

The @azure-tools/typespec-azure-core library defines the following artifacts:

Models

The @azure-tools/typespec-azure-core library defines the following models:

ModelNotes
Page<TResource>Model for a paged resource. <TResource> is the model description of the item.
PagedResultMetadataContains the metadata associated with a Page<TResource>.
RequestParameter<T>For long-running operations, identifies that a continuation operation request parameter is pulled from the original request. <T> is the property name on the original request.
ResponseProperty<T>For long-running operations, identifies that a continuation operation request parameter is pulled from the response of the previous request. <T> is the property name on the previous response.
LongRunningStatesIdentifies the long-running states associated with a long-running operation.
OperationLinkMetadataContains the metadata associated with an operation link.

Operations

The @azure-tools/typespec-azure-core library defines these standard operation templates as basic building blocks that you can expose. You can use is to compose the operations to meet the exact needs of your APIs.

For all of these operation templates, TResource is the resource model and TCustom allows customization of the operation parameters or response. TCustom, if provided, must extend the Azure.Core.Foundations.CustomizationFields model, which looks like:

/** The expected shape of model types passed to the TCustom parameter of operation signatures. */
model CustomizationFields {
/** An object containing custom parameters that will be included in the operation. */
parameters?: object;
/** An object containing custom properties that will be included in the response. */
response?: object;
}
OperationNotes
ResourceCreateOrUpdate<TResource, TCustom>Resource PATCH operation.
ResourceCreateOrReplace<TResource, TCustom>Resource PUT operation.
ResourceCreateWithServiceProvidedName<TResource, TCustom>Resource POST operation.
ResourceRead<TResource, TCustom>Resource GET operation.
ResourceDelete<TResource, TCustom>Resource DELETE operation.
ResourceList<TResource, TCustom>Resource LIST operation with server-driven paging.
NonPagedResourceList<TResource, TCustom>Resource LIST operation without paging.
ResourceAction<TResource, TParams, TResponse>Perform a custom action on a specific resource.
ResourceCollectionAction<TResource, TParams, TResponse>Perform a custom action on a collection of resources.
LongRunningResourceCreateOrReplace<TResource, TCustom>Long-running resource PUT operation.
LongRunningResourceCreateOrUpdate<TResource, TCustom>Long-running resource PATCH operation.
LongRunningResourceCreateWithServiceProvidedName<TResource, TCustom>Long-running resource POST operation.
LongRunningResourceDelete<TResource, TCustom>Long-running resource DELETE operation.

Decorators

The @azure-tools/typespec-azure-core library defines the following decorators:

DeclaratorScopeUsage
@pagedResultmodelsindicates model describes a paged result.
@itemsmodel propertiesindicates model property that stores the items within a paged result.
@nextLinkmodel propertiesindicates model property that contains the continuation information for the next page.
@nextPageOperationoperationsindicates operation that will be called for subsequent page requests.
@lroStatusenums and model propertiesindicates model or model property that represents long-running operation status.
@lroSucceededenum membersindicates enum member that corresponds to the long-running operation succeeded status.
@lroCanceledenum membersindicates enum member that corresponds to the long-running operation canceled status.
@lroFailedenum membersindicates enum member that corresponds to the long-running operation failed status.
@pollingLocationmodel propertiesindicates model property that contains the location to poll for operation state.
@finalLocationmodel propertiesindicates model property that contains the final location for the operation result.
@operationLinkoperationsindicates operation that is linked to the decorated operation by virtue of its linkType.
@pollingOperationoperationsindicates an operation is a polling operation for a long-running operation.
@finalOperationoperationsindicates an operation is the final operation for a long-running operation.

API

The @azure-tools/typespec-azure-core library defines the following API functions that emitter authors can use for development:

NameEntityReturnsDescription
getPagedResultmodels and operationsPagedResultMetadata?Returns the PagedResultMetadata if associated with a model or operation return type.
getItemsmodel propertiesbooleanReturns true if the model property is annotated with @items.
getNextLinkmodel propertiesbooleanReturns true if the model property is annotated with @nextLink.
getLongRunningStatesenums, models and model propertiesLongRunningStates?Returns the LongRunningStates associated with an entity.
isLroSucceededStateenum membersbooleanReturns true if the enum member represents a “succeeded” state.
isLroCanceledStateenum membersbooleanReturns true if the enum member represents a “canceled” state.
isLroFailedStateenum membersbooleanReturns true if the enum member represents a “failed” state.
isPollingLocationmodel propertiesbooleanReturns true if the model property is annotated with @pollingLocation.
isFinalLocationmodel propertiesbooleanReturns true if the model property is annotated with @finalLocation.
getOperationLinkoperationsOperationLinkMetadata?Returns the OperationLinkMetadata for an operation with a specific linkType.
getOperationLinksoperationsMap<string, OperationLinkMetadata>?Returns a Map of OperationLinkMetadata objects for an Operation where the key is the linkType.