|
| 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 "./models.tsp"; |
| 6 | + |
| 7 | +using TypeSpec.Rest; |
| 8 | +using Azure.ResourceManager; |
| 9 | +using TypeSpec.Http; |
| 10 | +using TypeSpec.OpenAPI; |
| 11 | + |
| 12 | +namespace Microsoft.Solutions; |
| 13 | +/** |
| 14 | + * Information about managed application. |
| 15 | + */ |
| 16 | +#suppress "@azure-tools/typespec-azure-core/no-private-usage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" |
| 17 | +#suppress "@azure-tools/typespec-azure-core/composition-over-inheritance" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" |
| 18 | +#suppress "@azure-tools/typespec-azure-resource-manager/arm-custom-resource-usage-discourage" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" |
| 19 | +@Http.Private.includeInapplicableMetadataInPayload(false) |
| 20 | +model Application extends GenericResource { |
| 21 | + @visibility(Lifecycle.Read) |
| 22 | + @path |
| 23 | + @key("applicationName") |
| 24 | + @minLength(3) |
| 25 | + @maxLength(64) |
| 26 | + @segment("applications") |
| 27 | + name: string; |
| 28 | + |
| 29 | + /** |
| 30 | + * The managed application properties. |
| 31 | + */ |
| 32 | + properties: ApplicationProperties; |
| 33 | + |
| 34 | + /** |
| 35 | + * The plan information. |
| 36 | + */ |
| 37 | + #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" |
| 38 | + plan?: Plan; |
| 39 | + |
| 40 | + /** |
| 41 | + * The kind of the managed application. Allowed values are MarketPlace and ServiceCatalog. |
| 42 | + */ |
| 43 | + #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" |
| 44 | + @pattern("^[-\\w\\._,\\(\\)]+$") |
| 45 | + kind: string; |
| 46 | + |
| 47 | + /** |
| 48 | + * The identity of the resource. |
| 49 | + */ |
| 50 | + #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-invalid-envelope-property" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" |
| 51 | + identity?: Identity; |
| 52 | +} |
| 53 | + |
| 54 | +@armResourceOperations |
| 55 | +interface Applications { |
| 56 | + /** |
| 57 | + * Gets the managed application. |
| 58 | + */ |
| 59 | + get is ArmResourceRead< |
| 60 | + Application, |
| 61 | + Response = ArmResponse<Application> | NotFoundResponse |
| 62 | + >; |
| 63 | + |
| 64 | + /** |
| 65 | + * Creates or updates a managed application. |
| 66 | + */ |
| 67 | + createOrUpdate is ArmResourceCreateOrReplaceAsync<Application>; |
| 68 | + |
| 69 | + /** |
| 70 | + * Updates an existing managed application. |
| 71 | + */ |
| 72 | + #suppress "@azure-tools/typespec-azure-resource-manager/arm-resource-patch" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" |
| 73 | + #suppress "@azure-tools/typespec-azure-resource-manager/lro-location-header" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" |
| 74 | + #suppress "@azure-tools/typespec-azure-resource-manager/no-response-body" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" |
| 75 | + @patch(#{ implicitOptionality: false }) |
| 76 | + update is Azure.ResourceManager.Legacy.CustomPatchAsync< |
| 77 | + Application, |
| 78 | + PatchModel = ApplicationPatchable, |
| 79 | + Response = |
| 80 | + | ArmResponse<Application> |
| 81 | + | (ArmAcceptedLroResponse<LroHeaders = ArmAsyncOperationHeader<FinalResult = Application> & |
| 82 | + Azure.Core.Foundations.RetryAfterHeader> & { |
| 83 | + @bodyRoot |
| 84 | + _: Application; |
| 85 | + }), |
| 86 | + OptionalRequestBody = true |
| 87 | + >; |
| 88 | + |
| 89 | + /** |
| 90 | + * Deletes the managed application. |
| 91 | + */ |
| 92 | + #suppress "@azure-tools/typespec-azure-resource-manager/lro-location-header" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" |
| 93 | + #suppress "@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" |
| 94 | + delete is ArmResourceDeleteWithoutOkAsync< |
| 95 | + Application, |
| 96 | + Response = |
| 97 | + | ArmDeletedResponse |
| 98 | + | ArmDeleteAcceptedLroResponse<ArmAsyncOperationHeader & |
| 99 | + Azure.Core.Foundations.RetryAfterHeader> |
| 100 | + | ArmDeletedNoContentResponse |
| 101 | + >; |
| 102 | + |
| 103 | + /** |
| 104 | + * Lists all the applications within a resource group. |
| 105 | + */ |
| 106 | + listByResourceGroup is ArmResourceListByParent<Application>; |
| 107 | + |
| 108 | + /** |
| 109 | + * Lists all the applications within a subscription. |
| 110 | + */ |
| 111 | + listBySubscription is ArmListBySubscription<Application>; |
| 112 | + |
| 113 | + /** |
| 114 | + * Refresh Permissions for application. |
| 115 | + */ |
| 116 | + refreshPermissions is ArmResourceActionAsyncBase< |
| 117 | + Application, |
| 118 | + void, |
| 119 | + OkResponse | ArmAcceptedLroResponse<LroHeaders = ArmLroLocationHeader>, |
| 120 | + Azure.ResourceManager.Foundations.BaseParameters<Application> |
| 121 | + >; |
| 122 | + |
| 123 | + /** |
| 124 | + * List allowed upgrade plans for application. |
| 125 | + */ |
| 126 | + listAllowedUpgradePlans is ArmResourceActionSync< |
| 127 | + Application, |
| 128 | + void, |
| 129 | + ArmResponse<AllowedUpgradePlansResult> |
| 130 | + >; |
| 131 | + |
| 132 | + /** |
| 133 | + * Update access for application. |
| 134 | + */ |
| 135 | + #suppress "@azure-tools/typespec-azure-resource-manager/no-response-body" "FIXME: Update justification, follow aka.ms/tsp/conversion-fix for details" |
| 136 | + updateAccess is ArmResourceActionAsyncBase< |
| 137 | + Application, |
| 138 | + UpdateAccessDefinition, |
| 139 | + |
| 140 | + | OkResponse |
| 141 | + | (ArmAcceptedLroResponse< |
| 142 | + "Resource operation accepted.", |
| 143 | + ArmLroLocationHeader<FinalResult = UpdateAccessDefinition> & |
| 144 | + Azure.Core.Foundations.RetryAfterHeader |
| 145 | + > & |
| 146 | + Body<UpdateAccessDefinition>), |
| 147 | + BaseParameters = Azure.ResourceManager.Foundations.BaseParameters<Application> |
| 148 | + >; |
| 149 | + |
| 150 | + /** |
| 151 | + * List tokens for application. |
| 152 | + */ |
| 153 | + listTokens is ArmResourceActionSync< |
| 154 | + Application, |
| 155 | + ListTokenRequest, |
| 156 | + ArmResponse<ManagedIdentityTokenResult> |
| 157 | + >; |
| 158 | +} |
| 159 | + |
| 160 | +@@maxLength(Application.name, 64); |
| 161 | +@@minLength(Application.name, 3); |
| 162 | +@@doc(Application.name, "The name of the managed application."); |
| 163 | +@@doc(Application.properties, "The managed application properties."); |
| 164 | +@@doc( |
| 165 | + Applications.createOrUpdate::parameters.resource, |
| 166 | + "Parameters supplied to the create or update a managed application." |
| 167 | +); |
| 168 | +@@doc( |
| 169 | + Applications.update::parameters.properties, |
| 170 | + "Parameters supplied to update an existing managed application." |
| 171 | +); |
| 172 | +@@doc( |
| 173 | + Applications.updateAccess::parameters.body, |
| 174 | + "Request body parameters to update access." |
| 175 | +); |
| 176 | +@@doc( |
| 177 | + Applications.listTokens::parameters.body, |
| 178 | + "Request body parameters to list tokens." |
| 179 | +); |
0 commit comments