Skip to content

Commit 1acc91c

Browse files
authored
Merge 07a63ad into cb79e79
2 parents cb79e79 + 07a63ad commit 1acc91c

File tree

217 files changed

+13952
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+13952
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import "@azure-tools/typespec-client-generator-core";
2+
import "./main.tsp";
3+
4+
using Azure.ClientGenerator.Core;
5+
6+
@@clientName(Azure.AI.Projects, "AIProjectClient");
7+
8+
// Shorter method names for SDK datasets operations
9+
@@clientName(Azure.AI.Projects.Datasets.listLatest, "list");
10+
@@clientName(Azure.AI.Projects.Datasets.getVersion, "get");
11+
@@clientName(Azure.AI.Projects.Datasets.deleteVersion, "delete");
12+
@@clientName(Azure.AI.Projects.Datasets.createOrUpdateVersion,
13+
"createOrUpdate"
14+
);
15+
@@clientName(Azure.AI.Projects.Datasets.startPendingUploadVersion,
16+
"pendingUpload"
17+
);
18+
19+
// Shorter method names for SDK Index operations
20+
@@clientName(Azure.AI.Projects.Indexes.listLatest, "list");
21+
@@clientName(Azure.AI.Projects.Indexes.getVersion, "get");
22+
@@clientName(Azure.AI.Projects.Indexes.deleteVersion, "delete");
23+
@@clientName(Azure.AI.Projects.Indexes.createOrUpdateVersion, "createOrUpdate");
24+
25+
// In Python, the emitter changes "keys" to "keys_property", since there is already
26+
// a "keys" method in the generated code due to usage of MutableMapping. Call it credential_keys instead.
27+
@@clientName(Azure.AI.Projects.CustomCredential.keys,
28+
"credential_keys",
29+
"python"
30+
);
31+
32+
// Make these two internal, since all SDKs hand-write a single public method with boolean "includeCredentials"
33+
// input parameter that calls either on these two.
34+
@@access(Azure.AI.Projects.Connections.get, Access.internal);
35+
@@access(Azure.AI.Projects.Connections.getWithCredentials, Access.internal);
36+
37+
// For some reason for Python the emitter creates an empty ServicePatternsOperations operation
38+
// class. Mark it as internal here. Apply to all languages just in case.
39+
//@@access(Azure.AI.Projects.ServicePatterns, Access.internal); <== this did not work. It makes all methods internal.
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import "@typespec/rest";
2+
import "@typespec/versioning";
3+
import "@azure-tools/typespec-azure-core";
4+
import "@azure-tools/typespec-azure-resource-manager";
5+
6+
namespace Azure.AI.Projects;
7+
8+
alias AssetBase = {
9+
@doc("Asset ID, a unique identifier for the asset")
10+
@visibility(Lifecycle.Read)
11+
id?: string;
12+
13+
@doc("The name of the resource")
14+
@visibility(Lifecycle.Read)
15+
@key
16+
name: string;
17+
18+
@doc("The version of the resource")
19+
@visibility(Lifecycle.Read)
20+
version: string;
21+
22+
@doc("The asset description text.")
23+
@visibility(Lifecycle.Create, Lifecycle.Update)
24+
description?: string;
25+
26+
@doc("Tag dictionary. Tags can be added, removed, and updated.")
27+
@visibility(Lifecycle.Create, Lifecycle.Update)
28+
tags?: Record<string>;
29+
};
30+
31+
#suppress "@azure-tools/typespec-providerhub/no-inline-model" "Need to create responses correctly"
32+
alias ResourceCreatedResponse<T extends TypeSpec.Reflection.Model> = TypeSpec.Http.Response<201> &
33+
T;
34+
35+
#suppress "@azure-tools/typespec-providerhub/no-inline-model" "Need to create responses correctly"
36+
alias OkResponse<T extends TypeSpec.Reflection.Model> = TypeSpec.Http.Response<200> &
37+
T;
38+
39+
// Pending upload spec
40+
41+
// Define a URI alias for clarity.
42+
alias Uri = string;
43+
44+
@doc("The type of pending upload.")
45+
union PendingUploadType {
46+
string,
47+
48+
@doc("No pending upload.")
49+
none: "None",
50+
51+
@doc("Blob Reference is the only supported type.")
52+
BlobReference: "BlobReference",
53+
}
54+
55+
@doc("The type of credential used to access the storage account.")
56+
union PendingUploadCredentialType {
57+
string,
58+
59+
@doc("SAS credential type.")
60+
sas: "SAS",
61+
}
62+
63+
@doc("Represents a request for a pending upload.")
64+
model PendingUploadRequest {
65+
@doc("If PendingUploadId is not provided, a random GUID will be used.")
66+
pendingUploadId?: string;
67+
68+
@doc("Azure Storage Account connection name to use for generating temporary SAS token")
69+
connectionName?: string;
70+
71+
@doc("BlobReference is the only supported type.")
72+
pendingUploadType: PendingUploadType.BlobReference;
73+
}
74+
75+
@doc("Represents the response for a pending upload request")
76+
model PendingUploadResponse {
77+
@doc("Container-level read, write, list SAS.")
78+
blobReference: BlobReference;
79+
80+
@doc("ID for this upload request.")
81+
pendingUploadId: string;
82+
83+
@doc("Version of asset to be created if user did not specify version when initially creating upload")
84+
version?: string;
85+
86+
@doc("BlobReference is the only supported type")
87+
pendingUploadType: PendingUploadType.BlobReference;
88+
}
89+
90+
@doc("SAS Credential definition")
91+
model SasCredential {
92+
@doc("SAS uri")
93+
@visibility(Lifecycle.Read)
94+
sasUri: string;
95+
96+
@visibility(Lifecycle.Read)
97+
@doc("Type of credential")
98+
type: "SAS";
99+
}
100+
101+
@doc("Blob reference details.")
102+
model BlobReference {
103+
@doc("Blob URI path for client to upload data. Example: https://blob.windows.core.net/Container/Path")
104+
blobUri: Uri;
105+
106+
@doc("ARM ID of the storage account to use.")
107+
storageAccountArmId: string;
108+
109+
@doc("Credential info to access the storage account.")
110+
credential: SasCredential;
111+
}
112+
113+
@doc("Represents a reference to a blob for consumption")
114+
model AssetCredentialResponse {
115+
@doc("Credential info to access the storage account.")
116+
blobReference: BlobReference;
117+
}
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
import "@typespec/rest";
2+
import "@azure-tools/typespec-autorest";
3+
import "@typespec/versioning";
4+
import "@azure-tools/typespec-azure-core";
5+
import "@typespec/openapi";
6+
import "@typespec/versioning";
7+
8+
using TypeSpec.Rest;
9+
using TypeSpec.Versioning;
10+
11+
namespace Azure.AI.Projects;
12+
13+
@doc("Response from the list and get connections operations")
14+
@resource("connections")
15+
@added(Versions.v2025_05_01)
16+
model Connection {
17+
@doc("The friendly name of the connection, provided by the user.")
18+
@visibility(Lifecycle.Read)
19+
@key("name")
20+
name: string;
21+
22+
@doc("A unique identifier for the connection, generated by the service")
23+
@visibility(Lifecycle.Read)
24+
id: string;
25+
26+
@doc("Category of the connection")
27+
@visibility(Lifecycle.Read)
28+
type: ConnectionType;
29+
30+
@doc("The connection URL to be used for this service")
31+
@visibility(Lifecycle.Read)
32+
target: string;
33+
34+
@doc("Whether the connection is tagged as the default connection of its type")
35+
@visibility(Lifecycle.Read)
36+
isDefault: boolean;
37+
38+
@doc("The credentials used by the connection")
39+
@visibility(Lifecycle.Read)
40+
credentials: BaseCredentials;
41+
42+
@doc("Metadata of the connection")
43+
@visibility(Lifecycle.Read)
44+
metadata: Record<string>;
45+
}
46+
47+
@doc("A base class for connection credentials")
48+
@discriminator("type")
49+
model BaseCredentials {
50+
@doc("The type of credential used by the connection")
51+
@visibility(Lifecycle.Read)
52+
type: CredentialType;
53+
}
54+
55+
@doc("API Key Credential definition")
56+
model ApiKeyCredentials extends BaseCredentials {
57+
@doc("The credential type")
58+
@visibility(Lifecycle.Read)
59+
type: CredentialType.apiKey;
60+
61+
@doc("API Key")
62+
@visibility(Lifecycle.Read)
63+
@encodedName("application/json", "key")
64+
apiKey?: string;
65+
}
66+
67+
#suppress "@azure-tools/typespec-azure-core/casing-style"
68+
@doc("Entra ID credential definition")
69+
model EntraIDCredentials extends BaseCredentials {
70+
@doc("The credential type")
71+
@visibility(Lifecycle.Read)
72+
type: CredentialType.entraId;
73+
}
74+
75+
@doc("Custom credential definition")
76+
model CustomCredential extends BaseCredentials {
77+
@doc("The credential type")
78+
@visibility(Lifecycle.Read)
79+
type: CredentialType.custom;
80+
81+
@doc("The credential type")
82+
@visibility(Lifecycle.Read)
83+
keys: Record<string>;
84+
}
85+
86+
#suppress "@azure-tools/typespec-azure-core/casing-style"
87+
@doc("Shared Access Signature (SAS) credential definition")
88+
model SASCredentials extends BaseCredentials {
89+
@doc("The credential type")
90+
@visibility(Lifecycle.Read)
91+
type: CredentialType.SAS;
92+
93+
@doc("SAS token")
94+
@visibility(Lifecycle.Read)
95+
@encodedName("application/json", "SAS")
96+
sasToken?: string;
97+
}
98+
99+
@doc("Credentials that do not require authentication")
100+
model NoAuthenticationCredentials extends BaseCredentials {
101+
@doc("The credential type ")
102+
@visibility(Lifecycle.Read)
103+
type: CredentialType.None;
104+
}
105+
106+
// https://learn.microsoft.com/rest/api/azureml/workspace-connections/list-secrets?view=rest-azureml-2024-04-01&tabs=HTTP#ConnectionType
107+
@doc("The Type (or category) of the connection")
108+
union ConnectionType {
109+
string,
110+
111+
@doc("Azure OpenAI Service")
112+
AzureOpenAI: "AzureOpenAI", //TODO: In Python this results in .AZURE_OPEN_AI. How do I make it .AZURE_OPENAI?
113+
114+
@doc("Azure Blob Storage, with specified container")
115+
AzureBlobStorage: "AzureBlob",
116+
117+
@doc("Azure Blob Storage, with container not specified (used by Agents)")
118+
AzureStorageAccount: "AzureStorageAccount",
119+
120+
@doc("Azure AI Search")
121+
AzureAISearch: "CognitiveSearch",
122+
123+
@doc("CosmosDB")
124+
CosmosDB: "CosmosDB",
125+
126+
@doc("Generic connection that uses API Key authentication")
127+
APIKey: "ApiKey",
128+
129+
@doc("Application Configuration")
130+
ApplicationConfiguration: "AppConfig",
131+
132+
@doc("Application Insights")
133+
ApplicationInsights: "AppInsights",
134+
135+
@doc("Custom Keys")
136+
Custom: "CustomKeys",
137+
}
138+
139+
@doc("The credential type used by the connection")
140+
union CredentialType {
141+
string,
142+
143+
@doc("API Key credential")
144+
apiKey: "ApiKey",
145+
146+
@doc("Entra ID credential (formerly known as AAD)")
147+
entraId: "AAD",
148+
149+
@doc("Shared Access Signature (SAS) credential")
150+
SAS: "SAS",
151+
152+
@doc("Custom credential")
153+
custom: "CustomKeys",
154+
155+
@doc("No credential")
156+
None: "None",
157+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import "@typespec/rest";
2+
import "@azure-tools/typespec-autorest";
3+
import "@typespec/versioning";
4+
import "@azure-tools/typespec-azure-core";
5+
import "./models.tsp";
6+
7+
using TypeSpec.Http;
8+
using Azure.Core.Traits;
9+
using TypeSpec.Versioning;
10+
11+
namespace Azure.AI.Projects;
12+
13+
alias ConnectionServiceTraits = SupportsClientRequestId &
14+
NoRepeatableRequests &
15+
NoConditionalRequests;
16+
17+
alias ConnectionOperations = Azure.Core.ResourceOperations<ConnectionServiceTraits>;
18+
19+
@added(Versions.v2025_05_01)
20+
interface Connections {
21+
@doc("Get a connection by name, without populating connection credentials")
22+
get is ConnectionOperations.ResourceRead<Connection>;
23+
24+
@doc("Get a connection by name, with its connection credentials")
25+
@TypeSpec.Http.post
26+
@Rest.actionSeparator("/")
27+
@Rest.action("getConnectionWithCredentials")
28+
getWithCredentials is ConnectionOperations.ResourceAction<
29+
Connection,
30+
{},
31+
Connection
32+
>;
33+
34+
@doc("List all connections in the project, without populating connection credentials")
35+
list is ConnectionOperations.ResourceList<
36+
Connection,
37+
ListQueryParametersTrait<{
38+
@doc("List connections of this specific type")
39+
@query("connectionType")
40+
connectionType?: ConnectionType;
41+
42+
@doc("List connections that are default connections")
43+
@query("defaultConnection")
44+
defaultConnection?: boolean;
45+
}>
46+
>;
47+
}

0 commit comments

Comments
 (0)