Skip to content

Commit

Permalink
Support Typespec file for Easm api version 2023-03-01-preview (#24937)
Browse files Browse the repository at this point in the history
* Add typespec file for easm

* Change service version doc

* Update file structure and add config file

* Move examples under a version

* Add a openapi.json file

* Remove openapi.json file

* Change operation names and empty object

* Update tspconfig

* Change config file to add .net and js emitter

* Add service dir to config file

* Update csharp config

* Add projected name for csharp

* Use original op

* Update disco group list example

* Remove observations endpoint

* Remove observation models

* Add java options

* Use Azure.Core standard operation and use resource models

* Reformat folder structure

* Suppress warnings

* Change metadata to record<unknown>

* Add suppression for Record<unknown>

* Update examples

* Remove unused examples

* Change apiversion to apiVersion

* Reformat with prettier

* Use foundations for list operation

* Update examples and list operations

* Remove unused minimum set

* Update all uuid

* Update Assets example

* Run prettier on Assets_List

* update oauth2 definition

* remove implicitflow model

* Update specification/riskiq/Easm/tspconfig.yaml

Co-authored-by: Mike Harder <[email protected]>

* Update models.tsp

* Update routes.tsp

* Remove typespec-apiview emitter

* update examples, add client.tsp

* run prettier

* Run prettier on Easm examples

* Update examples, main.tsp. Remove client.tsp

* Add operation id to examples under typespec project

* Add titles to examples

* Reformat typespec files

* Update DataConnection validate example

* Update data connection validation example

* Update the easm.json file based on tsv tool

* Update swagger file and its examples

* Update Easm typespec examples

* Update uris in examples

* Update cvss3 name

* Update cvss3 model with tsp

* Add totalElements to DiscoGroups, DiscoTemplates, and SavedFilters List traits

* Run validation for the previous commit

* Suppress linting rule of typespec generated swagger

* Update namespace for dotnet and javascript to the approved namespace

* Update package directory for java sdk from azure-defender-easm to azure-analytics-defender-easm

* use AlexaDetails instead of AlexaInfo in java sdk

* Fix git diff issue in Typespec Validation by running npx tsp

* Remove unused paged result models, add @pagedResult, @nextlink, and @Items decorators to paged result models and their properties.
Remove custom NoContentResult model and use Typespec.Http.NoContentResponse model instead

* Add decorators to indicate the resource is createOrUpdate or just update

---------

Co-authored-by: shadahmed-microsoft <[email protected]>
Co-authored-by: Mike Harder <[email protected]>
Co-authored-by: Shad <[email protected]>
  • Loading branch information
4 people authored and zman-ms committed Jan 9, 2024
1 parent 1d9a731 commit 8055387
Show file tree
Hide file tree
Showing 62 changed files with 12,881 additions and 4,018 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "Assets_GetAssetResource",
"title": "Assets_GetAssetResource",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "Assets_ListAssetResource",
"title": "Assets_ListAssetResource",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand All @@ -13,7 +15,7 @@
"body": {
"totalElements": 50000,
"mark": null,
"nextLink": "https://<api-endpoint>/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/workspaces/ThisisaWorkspace/assets?filter=state+%3D+%22confirmed%22&skip=1&maxpagesize=25&api-version=2023-03-01-preview",
"nextLink": "https://eastus.easm.defender.microsoft.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/workspaces/ThisisaWorkspace/assets?filter=state+%3D+%22confirmed%22&skip=1&maxpagesize=25&api-version=2023-03-01-preview",
"value": [
{
"id": "host$$contoso.net",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "Assets_UpdateAssets",
"title": "Assets_UpdateAssets",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "DataConnections_CreateOrReplaceDataConnection",
"title": "DataConnections_CreateOrReplaceDataConnection",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "DataConnections_DeleteDataConnection",
"title": "DataConnections_DeleteDataConnection",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "DataConnections_GetDataConnection",
"title": "DataConnections_GetDataConnection",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "DataConnections_ListDataConnection",
"title": "DataConnections_ListDataConnection",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand All @@ -9,7 +11,7 @@
"200": {
"body": {
"totalElements": 2,
"nextLink": "https://<api-endpoint>/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/workspaces/ThisisaWorkspace/dataConnections?maxpagesize=25&api-version=2023-03-01-preview",
"nextLink": "https://eastus.easm.defender.microsoft.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/workspaces/ThisisaWorkspace/dataConnections?maxpagesize=25&api-version=2023-03-01-preview",
"value": [
{
"id": "ThisisaDataConnection",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "DataConnections_ValidateDataConnection",
"title": "DataConnections_ValidateDataConnection",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "DiscoveryGroups_CreateOrReplaceDiscoGroup",
"title": "DiscoveryGroups_CreateOrReplaceDiscoGroup",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "DiscoveryGroups_GetDiscoGroup",
"title": "DiscoveryGroups_GetDiscoGroup",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "DiscoveryGroups_ListDiscoGroup",
"title": "DiscoveryGroups_ListDiscoGroup",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "DiscoveryGroups_ListRuns",
"title": "DiscoveryGroups_ListRuns",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand All @@ -10,7 +12,7 @@
"200": {
"body": {
"totalElements": 45,
"nextLink": "https://<api-endpoint>/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/workspaces/ThisisaWorkspace/discoGroups/ThisisaDiscoGroup/runs?skip=1&maxpagesize=2&api-version=2023-03-01-preview",
"nextLink": "https://eastus.easm.defender.microsoft.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/workspaces/ThisisaWorkspace/discoGroups/ThisisaDiscoGroup/runs?skip=1&maxpagesize=2&api-version=2023-03-01-preview",
"value": [
{
"submittedDate": "2022-03-29T23:10:01.000+00:00",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "DiscoveryGroups_RunDiscoGroup",
"title": "DiscoveryGroups_RunDiscoGroup",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "DiscoveryGroups_ValidateDiscoGroup",
"title": "DiscoveryGroups_ValidateDiscoGroup",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "DiscoveryTemplates_GetDiscoTemplate",
"title": "DiscoveryTemplates_GetDiscoTemplate",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "DiscoveryTemplates_ListDiscoTemplate",
"title": "DiscoveryTemplates_ListDiscoTemplate",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "Reports_GetBillable",
"title": "Reports_GetBillable",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "Reports_GetSnapshot",
"title": "Reports_GetSnapshot",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "Reports_GetSummary",
"title": "Reports_GetSummary",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "SavedFilters_CreateOrReplaceSavedFilter",
"title": "SavedFilters_CreateOrReplaceSavedFilter",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "SavedFilters_DeleteSavedFilter",
"title": "SavedFilters_DeleteSavedFilter",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "SavedFilters_GetSavedFilter",
"title": "SavedFilters_GetSavedFilter",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "SavedFilters_ListSavedFilter",
"title": "SavedFilters_ListSavedFilter",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"operationId": "Tasks_CancelTask",
"title": "Tasks_CancelTask",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"resourceGroupName": "dummyrg",
"workspaceName": "ThisisaWorkspace",
"taskId": "ThisisaTaskId"
},
"responses": {
"200": {
"body": {
"id": "ThisisaTaskId",
"startedAt": "2022-05-02T19:30:14.432+00:00",
"completedAt": "2022-05-02T19:30:54.432+00:00",
"lastPolledAt": "2022-05-02T19:30:19.432+00:00",
"state": "complete",
"phase": "complete",
"reason": "This is a Task id"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "Tasks_GetTask",
"title": "Tasks_GetTask",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"operationId": "Tasks_ListTask",
"title": "Tasks_ListTask",
"parameters": {
"api-version": "2023-03-01-preview",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
Expand Down
55 changes: 55 additions & 0 deletions specification/riskiq/Easm/main.tsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import "@typespec/http";
import "@typespec/rest";
import "@azure-tools/typespec-azure-core";
import "@typespec/versioning";
import "./routes.tsp";
import "./models.tsp";

using TypeSpec.Http;
using TypeSpec.Rest;
using Azure.Core;
using TypeSpec.Versioning;

@useAuth(
OAuth2Auth<[
{
@doc("implicit flow")
type: OAuth2FlowType.implicit,

@doc("the authorization URL")
authorizationUrl: "https://login.microsoftonline.com/common/oauth2/authorize",

@doc("list of scopes for the credential")
scopes: ["https://easm.defender.microsoft.com/.default"],
}
]>
)
@versioned(Easm.Versions)
@service({
title: "Defender EASM",
})
@server(
"{endpoint}/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/workspaces/{workspaceName}",
"",
{
@doc("The endpoint hosting the requested resource. For example, https://{region}.easm.defender.microsoft.com")
endpoint: string,

@doc("The ID of the target subscription.")
subscriptionId: string,

@doc("The name of the Resource Group.")
resourceGroupName: string,

@doc("The name of the Workspace.")
workspaceName: string,
}
)
@doc("Defender EASM discovers and maps your digital attack surface to provide an \"outside-in\" perspective using probes to discover assets. The assets are provided with detailed metadata associated, including vulnerabilities, configurations and web components, allowing customers to view and prioritize external risk. The EASM REST API enables you to develop clients that integrate with your application.")
namespace Easm;
@doc("The EASM Defender service version.")
enum Versions {
@doc("Version 2023-03-01-preview")
@useDependency(Azure.Core.Versions.v1_0_Preview_2)
v2023_03_01_preview: "2023-03-01-preview",
}
Loading

0 comments on commit 8055387

Please sign in to comment.