Skip to content

Commit a799ce9

Browse files
Theodore Changmikeharderookoka
committed
New resource type - Gallery Scripts (Azure#35887)
* added models and main.tsp reference * update * add added decorators * fix unintentional change * add examples * update galleryScript name pattern * fix parameter name with back-compatibles * fix CI failures * update responses codes * fix enum descriptions * add validationStatus * update * set readOnly properties as readOnly * remove schema from 202 returns * fix typo * tsp compiler updated * Included Azure-AsyncOperation headers to address ARM Comments * Added ArmAsyncOperationHeader for ARM Comments and fixed Tsp compile issues * Attempt to fix CI TypeSpec Validation * Attempt to fix CI TypeSpec Validation through npx commands * Attempted fix * Cleanup GalleryScriptVersion.tsp file * Attempted to use Azure decorators --------- Co-authored-by: Mike Harder <[email protected]> Co-authored-by: Ojo Okoka <[email protected]>
1 parent 7f6f59a commit a799ce9

31 files changed

+3728
-87
lines changed

specification/compute/Gallery.Management/Gallery.tsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ model Gallery is Azure.ResourceManager.TrackedResource<GalleryProperties> {
1818
Resource = Gallery,
1919
KeyName = "galleryName",
2020
SegmentName = "galleries",
21-
NamePattern = ""
21+
NamePattern = "^[a-zA-Z0-9][a-zA-Z0-9._-]*[a-zA-Z0-9]$|^[a-zA-Z0-9]$"
2222
>;
2323

2424
/**
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import "@azure-tools/typespec-azure-core";
2+
import "@azure-tools/typespec-azure-resource-manager";
3+
import "@typespec/openapi";
4+
import "@typespec/rest";
5+
import "@typespec/versioning";
6+
import "./models.tsp";
7+
import "./Gallery.tsp";
8+
import "../Common.Management/operations.tsp";
9+
10+
using TypeSpec.Rest;
11+
using Versioning;
12+
using Azure.ResourceManager;
13+
using TypeSpec.Http;
14+
15+
namespace Microsoft.Compute;
16+
17+
/**
18+
* Gallery script name with pattern validation
19+
*/
20+
@pattern("^[a-zA-Z0-9]+([_]?[a-zA-Z0-9]+)*$")
21+
@doc("The name of the gallery Script Definition in which the Script Version is to be created.")
22+
scalar GalleryScriptName extends string;
23+
24+
/**
25+
* Specifies information about the gallery Script Definition that you want to create or update.
26+
*/
27+
@added(Versions.v2025_03_03)
28+
@parentResource(Gallery)
29+
model GalleryScript
30+
is Azure.ResourceManager.TrackedResource<GalleryScriptProperties> {
31+
@key("galleryScriptName")
32+
@segment("scripts")
33+
@path
34+
name: GalleryScriptName;
35+
}
36+
37+
@armResourceOperations
38+
interface GalleryScripts {
39+
/**
40+
* Retrieves information about a gallery script definition.
41+
*/
42+
@added(Versions.v2025_03_03)
43+
get is ComputeResourceRead<GalleryScript>;
44+
45+
/**
46+
* Create or update a Gallery Script Definition. Gallery scripts allow the storage, sharing and reuse of common scripts
47+
*/
48+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes" "For backward compatibility"
49+
#suppress "@azure-tools/typespec-azure-resource-manager/no-response-body" "For backward compatibility"
50+
@added(Versions.v2025_03_03)
51+
createOrUpdate is ComputeResourceCreateOrReplaceAsync<
52+
GalleryScript,
53+
Response = ArmResourceUpdatedResponse<GalleryScript> | ArmResourceCreatedResponse<
54+
GalleryScript,
55+
ArmLroLocationHeader & Azure.Core.Foundations.RetryAfterHeader
56+
>
57+
>;
58+
59+
/**
60+
* Update a gallery Script Definition.
61+
*/
62+
@patch(#{ implicitOptionality: false })
63+
@added(Versions.v2025_03_03)
64+
update is ComputeCustomPatchAsync<
65+
GalleryScript,
66+
PatchModel = GalleryScriptUpdate,
67+
Response = ArmResponse<GalleryScript> | ArmAcceptedLroResponse
68+
>;
69+
70+
/**
71+
* Delete a gallery Script Definition.
72+
*/
73+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "For backward compatibility"
74+
@added(Versions.v2025_03_03)
75+
delete is ComputeResourceDeleteAsync<
76+
GalleryScript,
77+
Response = ArmDeleteAcceptedLroResponse | ArmDeletedNoContentResponse
78+
>;
79+
80+
/**
81+
* List gallery Script Definitions in a gallery.
82+
*/
83+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-duplicate-property" "For backward compatibility"
84+
@added(Versions.v2025_03_03)
85+
listByGallery is ComputeResourceListByParent<
86+
GalleryScript,
87+
Response = ArmResponse<GalleryScriptList>
88+
>;
89+
}
90+
91+
@@doc(GalleryScript.name,
92+
"The name of the gallery Script Definition to be retrieved."
93+
);
94+
@@doc(GalleryScript.properties,
95+
"Describes the properties of a gallery Script Definition."
96+
);
97+
@@doc(GalleryScripts.createOrUpdate::parameters.resource,
98+
"Parameters supplied to the create or update gallery Script operation."
99+
);
100+
@@doc(GalleryScripts.update::parameters.properties,
101+
"Parameters supplied to the update gallery Script operation."
102+
);
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import "@azure-tools/typespec-azure-core";
2+
import "@azure-tools/typespec-azure-resource-manager";
3+
import "@typespec/rest";
4+
import "@typespec/versioning";
5+
import "./models.tsp";
6+
import "./GalleryScript.tsp";
7+
import "../Common.Management/operations.tsp";
8+
9+
using TypeSpec.Rest;
10+
using Versioning;
11+
using Azure.ResourceManager;
12+
using TypeSpec.Http;
13+
using Azure.Core; // Needed for @useFinalStateVia decorator
14+
15+
namespace Microsoft.Compute {
16+
@pattern("^[0-9]+\\.[0-9]+\\.[0-9]+$")
17+
@doc("The name of the gallery Script Version to be created. Needs to follow semantic version name pattern: The allowed characters are digit and period. Digits must be within the range of a 32-bit integer. Format: <MajorVersion>.<MinorVersion>.<Patch>")
18+
scalar GalleryScriptVersionName extends string;
19+
20+
@added(Versions.v2025_03_03)
21+
model GalleryScriptVersionList is Azure.Core.Page<GalleryScriptVersion>;
22+
23+
@added(Versions.v2025_03_03)
24+
@parentResource(GalleryScript)
25+
model GalleryScriptVersion
26+
is Azure.ResourceManager.TrackedResource<GalleryScriptVersionProperties> {
27+
@key("galleryScriptVersionName")
28+
@segment("versions")
29+
@path
30+
name: GalleryScriptVersionName;
31+
}
32+
33+
/**
34+
* Common LRO headers (Azure-AsyncOperation required Jan 2025). Keep Location + Retry-After for backward compatibility.
35+
*/
36+
alias GalleryScriptVersionLroHeaders = ArmAsyncOperationHeader<FinalResult = GalleryScriptVersion> &
37+
ArmLroLocationHeader &
38+
Azure.Core.Foundations.RetryAfterHeader;
39+
40+
@armResourceOperations
41+
interface GalleryScriptVersions {
42+
@added(Versions.v2025_03_03)
43+
get is ComputeResourceRead<GalleryScriptVersion>;
44+
45+
/**
46+
* Create or update a gallery Script Version.
47+
*/
48+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes" "For backward compatibility"
49+
#suppress "@azure-tools/typespec-azure-resource-manager/no-response-body" "For backward compatibility"
50+
@useFinalStateVia("azure-async-operation")
51+
@added(Versions.v2025_03_03)
52+
createOrUpdate is ComputeResourceCreateOrReplaceAsync<
53+
GalleryScriptVersion,
54+
Azure.ResourceManager.Foundations.DefaultBaseParameters<GalleryScriptVersion>,
55+
GalleryScriptVersionLroHeaders,
56+
{},
57+
ArmResourceUpdatedResponse<GalleryScriptVersion> | ArmResourceCreatedResponse<
58+
GalleryScriptVersion,
59+
GalleryScriptVersionLroHeaders
60+
>
61+
>;
62+
63+
/**
64+
* Update a gallery Script Version.
65+
*/
66+
@useFinalStateVia("azure-async-operation")
67+
@added(Versions.v2025_03_03)
68+
@patch(#{ implicitOptionality: false })
69+
update is ComputeCustomPatchAsync<
70+
GalleryScriptVersion,
71+
GalleryScriptVersionUpdate,
72+
Azure.ResourceManager.Foundations.DefaultBaseParameters<GalleryScriptVersion>,
73+
GalleryScriptVersionLroHeaders,
74+
{},
75+
ArmResponse<GalleryScriptVersion> | ArmAcceptedLroResponse<
76+
"Resource update request accepted.",
77+
GalleryScriptVersionLroHeaders
78+
>
79+
>;
80+
81+
/**
82+
* Delete a gallery Script Version.
83+
*/
84+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "For backward compatibility"
85+
@useFinalStateVia("azure-async-operation")
86+
@added(Versions.v2025_03_03)
87+
delete is ComputeResourceDeleteAsync<
88+
GalleryScriptVersion,
89+
Azure.ResourceManager.Foundations.DefaultBaseParameters<GalleryScriptVersion>,
90+
GalleryScriptVersionLroHeaders,
91+
{},
92+
ArmDeleteAcceptedLroResponse<GalleryScriptVersionLroHeaders> | ArmDeletedNoContentResponse
93+
>;
94+
95+
/**
96+
* List gallery Script Versions in a gallery Script Definition.
97+
*/
98+
#suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-duplicate-property" "For backward compatibility"
99+
@added(Versions.v2025_03_03)
100+
listByGalleryScript is ComputeResourceListByParent<
101+
GalleryScriptVersion,
102+
Response = ArmResponse<GalleryScriptVersionList>
103+
>;
104+
}
105+
106+
@@doc(GalleryScriptVersion.name,
107+
"The name of the gallery Script Version to be retrieved."
108+
);
109+
@@doc(GalleryScriptVersion.properties,
110+
"Describes the properties of a gallery Script Version."
111+
);
112+
@@doc(GalleryScriptVersions.createOrUpdate::parameters.resource,
113+
"Parameters supplied to the create or update gallery Script Version operation."
114+
);
115+
@@doc(GalleryScriptVersions.update::parameters.properties,
116+
"Parameters supplied to the update gallery Script Version operation."
117+
);
118+
}

specification/compute/Gallery.Management/back-compatible.tsp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ using Microsoft.Compute;
6868
@@clientName(GalleryApplications.update::parameters.properties,
6969
"galleryApplication"
7070
);
71+
72+
@@clientName(GalleryScripts.createOrUpdate::parameters.resource,
73+
"galleryScript"
74+
);
75+
@@clientName(GalleryScripts.update::parameters.properties, "galleryScript");
76+
77+
@@clientName(GalleryScriptVersions.createOrUpdate::parameters.resource,
78+
"galleryScriptVersion"
79+
);
80+
@@clientName(GalleryScriptVersions.update::parameters.properties,
81+
"galleryScriptVersion"
82+
);
83+
84+
#suppress "deprecated" "@flattenProperty decorator is not recommended to use."
85+
@@flattenProperty(GalleryApplication.properties);
7186
#suppress "@azure-tools/typespec-azure-core/no-legacy-usage" "@flattenProperty decorator is not recommended to use."
7287
@@Azure.ClientGenerator.Core.Legacy.flattenProperty(GalleryApplication.properties
7388
);

0 commit comments

Comments
 (0)