Skip to content
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
4 changes: 0 additions & 4 deletions specification/ai/Azure.AI.Projects/client.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,3 @@ using Azure.ClientGenerator.Core;
// input parameter that calls either on these two.
@@access(Azure.AI.Projects.Connections.get, Access.internal);
@@access(Azure.AI.Projects.Connections.getWithCredentials, Access.internal);

// For some reason for Python the emitter creates an empty ServicePatternsOperations operation
// class. Mark it as internal here. Apply to all languages just in case.
//@@access(Azure.AI.Projects.ServicePatterns, Access.internal); <== this did not work. It makes all methods internal.
8 changes: 4 additions & 4 deletions specification/ai/Azure.AI.Projects/datasets/routes.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ alias ListDatasetVersionsParameters = {};
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "We are using service specific operation templates"
@added(Versions.v2025_05_01)
interface Datasets
extends ServicePatterns.VersionedOperations<
extends VersionedOperations<
DatasetVersion,
ListDatasetVersionsParameters,
ListDatasetVersionsParameters
> {
@doc("Start a new or get an existing pending upload of a dataset for a specific version.")
@Rest.action("startPendingUpload")
startPendingUploadVersion is ServicePatterns.VersionedResourceActionWithBody<
startPendingUploadVersion is VersionedResourceActionWithBody<
DatasetVersion,
PendingUploadRequest,
PendingUploadResponse
Expand All @@ -35,7 +35,7 @@ interface Datasets
@Rest.actionSeparator("/")
@Rest.action("startPendingUpload")
@Http.post
startPendingUpload is ServicePatterns.UnversionedResourceAction<
startPendingUpload is UnversionedResourceAction<
DatasetVersion,
PendingUploadRequest,
PendingUploadResponse
Expand All @@ -48,7 +48,7 @@ interface Datasets
@post
@Rest.action("credentials")
@Rest.actionSeparator("/")
getCredentials is ServicePatterns.VersionedResourceActionNoBody<
getCredentials is VersionedResourceActionNoBody<
DatasetVersion,
AssetCredentialResponse
>;
Expand Down
2 changes: 1 addition & 1 deletion specification/ai/Azure.AI.Projects/indexes/routes.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ alias ListIndexVersionParameters = {};
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "We are using service specific operation templates"
@added(Versions.v2025_05_01)
interface Indexes
extends ServicePatterns.VersionedOperations<
extends VersionedOperations<
Index,
ListIndexVersionParameters,
ListIndexVersionParameters
Expand Down
261 changes: 132 additions & 129 deletions specification/ai/Azure.AI.Projects/servicepatterns.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -2,162 +2,165 @@ import "@typespec/http";
import "@typespec/rest";
import "@azure-tools/typespec-azure-core";

namespace Azure.AI.Projects.ServicePatterns {
@Rest.autoRoute
interface VersionedOperations<
TEntityType extends Reflection.Model,
TListLatestParameters extends Reflection.Model = {},
TListVersionsParameters extends Reflection.Model = {}
> {
#suppress "@azure-tools/typespec-azure-core/verb-conflict" "We are using the resource action as a building block."
@doc("List all versions of the given {name}", TEntityType)
@Rest.action("versions")
@Rest.actionSeparator("/")
@Http.get
listVersions is BuildingBlocks.CoreOps.ResourceAction<
TEntityType,
TListVersionsParameters,
Azure.Core.Page<TEntityType>
>;
namespace Azure.AI.Projects;

@doc("List the latest version of each {name}", TEntityType)
@Rest.listsResource(TEntityType)
listLatest is Azure.Core.Foundations.ResourceList<
TEntityType,
TListLatestParameters,
Azure.Core.Page<TEntityType>
>;
alias CoreOps = Azure.Core.StandardResourceOperations;

@doc("Get the specific version of the {name}", TEntityType)
getVersion is Azure.Core.Foundations.ResourceOperation<
TEntityType,
{
@doc("The specific version id of the {name} to retrieve.", TEntityType)
@Rest.segment("versions")
@Http.path
version: string;
},
Azure.Core.Foundations.ResourceOkResponse<TEntityType>
>;
/*
alias RepeatableCoreOps = Azure.Core.ResourceOperations<Azure.Core.Traits.SupportsRepeatableRequests &
Azure.Core.Traits.SupportsClientRequestId &
Azure.Core.Traits.NoConditionalRequests>;
*/

@doc("Delete the specific version of the {name}", TEntityType)
@Http.delete
deleteVersion is Azure.Core.Foundations.ResourceOperation<
TEntityType,
{
@doc("The version of the {name} to delete.", TEntityType)
@Rest.segment("versions")
@Http.path
version: string;
},
Http.NoContentResponse
>;

/* Reenable this once the service supports "unversioned" operations
@doc(
"Create a new {name}. The version id will be generated by the service.",
TEntityType
)
@Rest.actionSeparator("/")
@Rest.action("versions")
@Http.post
create is BuildingBlocks.RepeatableCoreOps.ResourceAction<
TEntityType,
{
@doc("The definition of the {name} to create", TEntityType)
@Http.bodyRoot
body: TEntityType;
},
TEntityType
>;
*/

@doc(
"Create a new or update an existing {name} with the given version id",
TEntityType
)
@Http.patch
createOrUpdateVersion is Azure.Core.Foundations.ResourceOperation<
TEntityType,
{
@doc("The definition of the {name} to create or update", TEntityType)
@Http.bodyRoot
body: TEntityType;

@doc("Content type for patch")
@Http.header("Content-Type")
contentType: "application/merge-patch+json";
@Rest.autoRoute
interface VersionedOperations<
TEntityType extends Reflection.Model,
TListLatestParameters extends Reflection.Model = {},
TListVersionsParameters extends Reflection.Model = {}
> {
#suppress "@azure-tools/typespec-azure-core/verb-conflict" "We are using the resource action as a building block."
@doc("List all versions of the given {name}", TEntityType)
@Rest.action("versions")
@Rest.actionSeparator("/")
@Http.get
listVersions is CoreOps.ResourceAction<
TEntityType,
TListVersionsParameters,
Azure.Core.Page<TEntityType>
>;

@doc(
"The specific version id of the {name} to create or replace.",
TEntityType
)
@Rest.segment("versions")
@Http.path
version: string;
},
Azure.Core.Foundations.ResourceCreatedOrOkResponse<TEntityType>
>;
}
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Suppress `Operation should be defined using a signature from the Azure.Core namespace.`"
@doc("List the latest version of each {name}", TEntityType)
@Rest.listsResource(TEntityType)
listLatest is Azure.Core.Foundations.ResourceList<
TEntityType,
TListLatestParameters,
Azure.Core.Page<TEntityType>
>;

@Rest.action
op VersionedResourceActionWithBody<
TEntityType extends Reflection.Model,
TParams,
TResponse
> is Azure.Core.Foundations.ResourceOperation<
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Suppress `Operation should be defined using a signature from the Azure.Core namespace.`"
@doc("Get the specific version of the {name}", TEntityType)
getVersion is Azure.Core.Foundations.ResourceOperation<
TEntityType,
{
@doc("Parameters for the action")
@Http.bodyRoot
body: TParams;

@doc("The specific version id of the {name} to operate on.", TEntityType)
@doc("The specific version id of the {name} to retrieve.", TEntityType)
@Rest.segment("versions")
@Http.path
version: string;
},
TResponse
Azure.Core.Foundations.ResourceOkResponse<TEntityType>
>;

@Rest.action
op VersionedResourceActionNoBody<
TEntityType extends Reflection.Model,
TResponse
> is Azure.Core.Foundations.ResourceOperation<
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Suppress `Operation should be defined using a signature from the Azure.Core namespace.`"
@doc("Delete the specific version of the {name}", TEntityType)
@Http.delete
deleteVersion is Azure.Core.Foundations.ResourceOperation<
TEntityType,
{
@doc("The specific version id of the {name} to operate on.", TEntityType)
@doc("The version of the {name} to delete.", TEntityType)
@Rest.segment("versions")
@Http.path
version: string;
},
TResponse
Http.NoContentResponse
>;

/* Reenable this once the service supports "unversioned" operations
@Rest.action
op UnversionedResourceAction<
TEntityType extends Reflection.Model,
TParams,
TResponse
> is Azure.Core.Foundations.ResourceOperation<
@doc(
"Create a new {name}. The version id will be generated by the service.",
TEntityType
)
@Rest.actionSeparator("/")
@Rest.action("versions")
@Http.post
create is RepeatableCoreOps.ResourceAction<
TEntityType,
{
@doc("Parameters for the action")
@doc("The definition of the {name} to create", TEntityType)
@Http.bodyRoot
body: TParams;
body: TEntityType;
},
TResponse
TEntityType
>;
*/

namespace BuildingBlocks {
alias CoreOps = Azure.Core.StandardResourceOperations;
/*
alias RepeatableCoreOps = Azure.Core.ResourceOperations<Azure.Core.Traits.SupportsRepeatableRequests &
Azure.Core.Traits.SupportsClientRequestId &
Azure.Core.Traits.NoConditionalRequests>;
*/
}
#suppress "@azure-tools/typespec-azure-core/use-standard-operations" "Suppress `Operation should be defined using a signature from the Azure.Core namespace.`"
@doc(
"Create a new or update an existing {name} with the given version id",
TEntityType
)
@Http.patch
createOrUpdateVersion is Azure.Core.Foundations.ResourceOperation<
TEntityType,
{
@doc("The definition of the {name} to create or update", TEntityType)
@Http.bodyRoot
body: TEntityType;

@doc("Content type for patch")
@Http.header("Content-Type")
contentType: "application/merge-patch+json";

@doc(
"The specific version id of the {name} to create or replace.",
TEntityType
)
@Rest.segment("versions")
@Http.path
version: string;
},
Azure.Core.Foundations.ResourceCreatedOrOkResponse<TEntityType>
>;
}

@Rest.action
op VersionedResourceActionWithBody<
TEntityType extends Reflection.Model,
TParams,
TResponse
> is Azure.Core.Foundations.ResourceOperation<
TEntityType,
{
@doc("Parameters for the action")
@Http.bodyRoot
body: TParams;

@doc("The specific version id of the {name} to operate on.", TEntityType)
@Rest.segment("versions")
@Http.path
version: string;
},
TResponse
>;

@Rest.action
op VersionedResourceActionNoBody<
TEntityType extends Reflection.Model,
TResponse
> is Azure.Core.Foundations.ResourceOperation<
TEntityType,
{
@doc("The specific version id of the {name} to operate on.", TEntityType)
@Rest.segment("versions")
@Http.path
version: string;
},
TResponse
>;

/* Reenable this once the service supports "unversioned" operations
@Rest.action
op UnversionedResourceAction<
TEntityType extends Reflection.Model,
TParams,
TResponse
> is Azure.Core.Foundations.ResourceOperation<
TEntityType,
{
@doc("Parameters for the action")
@Http.bodyRoot
body: TParams;
},
TResponse
>;
*/
Loading