diff --git a/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/GraphQueryAdd.json b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/GraphQueryAdd.json new file mode 100644 index 000000000000..2f61c242e3ae --- /dev/null +++ b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/GraphQueryAdd.json @@ -0,0 +1,34 @@ +{ + "title": "Create a saved query", + "description": "Create new saved query resource.", + "parameters": { + "subscriptionId": "024e2271-06fa-46b6-9079-f1ed3c7b070e", + "resourceGroupName": "my-resource-group", + "resourceName": "MyDockerVMs", + "api-version": "2018-09-01-preview", + "properties": { + "tags": {}, + "properties": { + "description": "Docker VMs in PROD", + "query": "where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'docker'" + } + } + }, + "responses": { + "200": { + "body": { + "id": " /subscriptions/024e2271-06fa-46b6-9079-f1ed3c7b070e/resources/my-resource-group/providers/Microsoft.ResourceGraph/queries/MyDockerVMs", + "name": "MyDockerVMs", + "type": "Microsoft.ResourceGraph/queries", + "eTag": "5d64408e-4ca3-41f7-b725-6914f3012afa", + "tags": {}, + "properties": { + "description": "Docker VMs in PROD", + "query": "where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'docker'", + "resultKind": "basic", + "timeModified": "2019-03-12T13:51:13-07:00" + } + } + } + } +} \ No newline at end of file diff --git a/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/GraphQueryDelete.json b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/GraphQueryDelete.json new file mode 100644 index 000000000000..1288229841cf --- /dev/null +++ b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/GraphQueryDelete.json @@ -0,0 +1,14 @@ +{ + "title": "Delete a saved query", + "description": "Delete a saved query resource by subid, resource group, and resource name.", + "parameters": { + "subscriptionId": "024e2271-06fa-46b6-9079-f1ed3c7b070e", + "resourceGroupName": "my-resource-group", + "resourceName": "MyDockerVM", + "api-version": "2018-09-01-preview" + }, + "responses": { + "200": {}, + "204": {} + } +} \ No newline at end of file diff --git a/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/GraphQueryGet.json b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/GraphQueryGet.json new file mode 100644 index 000000000000..c9fc0f4bb736 --- /dev/null +++ b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/GraphQueryGet.json @@ -0,0 +1,27 @@ +{ + "title": "Get a saved query", + "description": "Get a saved query resource by subid, resource group, and resource name.", + "parameters": { + "subscriptionId": "024e2271-06fa-46b6-9079-f1ed3c7b070e", + "resourceGroupName": "my-resource-group", + "resourceName": "MyDockerVMs", + "api-version": "2018-09-01-preview" + }, + "responses": { + "200": { + "body": { + "id": " /subscriptions/024e2271-06fa-46b6-9079-f1ed3c7b070e/resources/my-resource-group/providers/Microsoft.ResourceGraph/queries/MyDockerVMs", + "name": "MyDockerVMs", + "type": "Microsoft.ResourceGraph/queries", + "eTag": "5d64408e-4ca3-41f7-b725-6914f3012afa", + "tags": null, + "properties": { + "description": "Docker VMs in PROD", + "query": "where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'docker'", + "resultKind": "basic", + "timeModified": "2019-03-12T13:51:13-07:00" + } + } + } + } +} \ No newline at end of file diff --git a/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/GraphQueryList.json b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/GraphQueryList.json new file mode 100644 index 000000000000..7e5316caa4c8 --- /dev/null +++ b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/GraphQueryList.json @@ -0,0 +1,44 @@ +{ + "title": "Get a list of saved queries", + "description": "Get a list of saved queries within subscription id and resource group.", + "parameters": { + "subscriptionId": "024e2271-06fa-46b6-9079-f1ed3c7b070e", + "resourceGroupName": "my-resource-group", + "api-version": "2018-09-01-preview" + }, + "responses": { + "200": { + "body": { + "nextLink": "https://management.azure.com/subscriptions/subscriptionId/providers/Microsoft.ResourceGraph/queries?api-version=2019-09-01-preview&$top=10&$skiptoken=skiptoken", + "value": [ + { + "id": "/subscriptions/87f4f8b0-83c1-4aa9-b318-5237aeb15264/resources/rid1/providers/Microsoft.ResourceGraph/queries/MyDockerVMs", + "name": "MyDockerVMs", + "type": "Microsoft.ResourceGraph/queries", + "tags": {}, + "eTag": "5d64408e-4ca3-41f7-b725-6914f3012afa", + "properties": { + "description": "Docker VMs in PROD", + "query": "where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'docker'", + "resultKind": "basic", + "timeModified": "2019-03-12T13:51:13-07:00" + } + }, + { + "id": "/subscriptions/6abb2f31-3e6a-4134-9968-219a596012a0/resources/rid2/providers/Microsoft.ResourceGraph/queries/MyTestVMs", + "name": "MyTestVMs", + "type": "Microsoft.ResourceGraph/queries", + "tags": {}, + "eTag": "b0809832-ca62-4133-8f13-0c46580f9db1", + "properties": { + "description": "Test VMs in PROD", + "query": "where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'test'", + "resultKind": "basic", + "timeModified": "2019-03-13T13:51:13-07:00" + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/GraphQueryUpdate.json b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/GraphQueryUpdate.json new file mode 100644 index 000000000000..c7a0b88d640f --- /dev/null +++ b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/GraphQueryUpdate.json @@ -0,0 +1,35 @@ +{ + "title": "Update a saved query", + "description": "Update the existing saved query resource.", + "parameters": { + "subscriptionId": "024e2271-06fa-46b6-9079-f1ed3c7b070e", + "resourceGroupName": "my-resource-group", + "resourceName": "MyDockerVMs", + "api-version": "2018-09-01-preview", + "body": { + "tags": null, + "eTag": "b0809832-ca62-4133-8f13-0c46580f9db1", + "properties": { + "description": "Modified description", + "query": "where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'docker'" + } + } + }, + "responses": { + "200": { + "body": { + "id": " /subscriptions/024e2271-06fa-46b6-9079-f1ed3c7b070e/resources/my-resource-group/providers/Microsoft.ResourceGraph/queries/MyDockerVMs", + "name": "MyDockerVMs", + "type": "Microsoft.ResourceGraph/queries", + "eTag": "73811091-6188-4523-97b7-b5e7134e7fd9", + "tags": null, + "properties": { + "description": "Modified description", + "query": "where isnotnull(tags['Prod']) and properties.extensions[0].Name == 'docker'", + "resultKind": "basic", + "timeModified": "2019-03-14T13:51:13-07:00" + } + } + } + } +} \ No newline at end of file diff --git a/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/OperationsList.json b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/OperationsList.json index 8e2165b092e8..21cf8b809c60 100644 --- a/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/OperationsList.json +++ b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/examples/OperationsList.json @@ -5,6 +5,7 @@ "responses": { "200": { "body": { + "nextLink": "https://management.azure.com/subscriptions/subscriptionId/providers/Microsoft.ResourceGraph/?api-version=2019-09-01-preview&$top=10&$skiptoken=skiptoken", "value": [ { "name": "Microsoft.ResourceGraph/resources/action", @@ -14,6 +15,15 @@ "operation": "Query resources", "description": "Submits a query on resources within specified subscriptions" } + }, + { + "name": "Microsoft.ResourceGraph/queries/action", + "display": { + "provider": "Microsoft Resource Graph", + "resource": "Queries", + "operation": "CRUD operations of graph queries", + "description": "Create/Update/Retrieve a query within specified subscription and resource group." + } } ] } diff --git a/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/graphquery.json b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/graphquery.json new file mode 100644 index 000000000000..bc26c8e4b273 --- /dev/null +++ b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/graphquery.json @@ -0,0 +1,493 @@ +{ + "swagger": "2.0", + "info": { + "title": "Azure Resource Graph Query", + "description": "Azure Resource Graph Query API Reference", + "version": "2018-09-01-preview" + }, + "host": "management.azure.com", + "schemes": [ + "https" + ], + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "security": [ + { + "azure_auth": [ + "user_impersonation" + ] + } + ], + "securityDefinitions": { + "azure_auth": { + "type": "oauth2", + "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", + "flow": "implicit", + "description": "Azure Active Directory OAuth2 Flow.", + "scopes": { + "user_impersonation": "impersonate your user account" + } + } + }, + "paths": { + "/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/Microsoft.ResourceGraph/queries": { + "get": { + "description": "Get all graph queries defined within a specified subscription and resource group.", + "operationId": "GraphQuery_List", + "parameters": [ + { + "$ref": "#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "#/parameters/ResourceGroupNameParameter" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "A list containing 0 or more graph queries.", + "schema": { + "$ref": "#/definitions/GraphQueryListResult" + } + }, + "default": { + "description": "Error response describing why the operation failed.", + "schema": { + "$ref": "#/definitions/GraphQueryError" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + }, + "x-ms-examples": { + "Get a list of Graph Queries": { + "$ref": "./examples/GraphQueryList.json" + } + } + } + }, + "/subscriptions/{subscriptionId}/resourceGroup/{resourceGroupName}/providers/Microsoft.ResourceGraph/queries/{resourceName}": { + "get": { + "description": "Get a single graph query by its resourceName.", + "operationId": "GraphQuery_Get", + "parameters": [ + { + "$ref": "#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "#/parameters/ResourceGroupNameParameter" + }, + { + "$ref": "#/parameters/GraphQueryResourceNameParameter" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "A graph query definition.", + "schema": { + "$ref": "#/definitions/GraphQueryResource" + } + }, + "default": { + "description": "Error response describing why the operation failed.", + "schema": { + "$ref": "#/definitions/GraphQueryError" + } + } + }, + "x-ms-examples": { + "Get Graph Query": { + "$ref": "./examples/GraphQueryGet.json" + } + } + }, + "delete": { + "description": "Delete a graph query.", + "operationId": "GraphQuery_Delete", + "parameters": [ + { + "$ref": "#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "#/parameters/ResourceGroupNameParameter" + }, + { + "$ref": "#/parameters/GraphQueryResourceNameParameter" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "The graph query has been successfully deleted." + }, + "204": { + "description": "The resource doesn't exist." + }, + "default": { + "description": "Error response describing why the operation failed.", + "schema": { + "$ref": "#/definitions/GraphQueryError" + } + } + }, + "x-ms-examples": { + "Delete Graph Query": { + "$ref": "./examples/GraphQueryDelete.json" + } + } + }, + "put": { + "description": "Create a new graph query.", + "operationId": "GraphQuery_CreateOrUpdate", + "parameters": [ + { + "$ref": "#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "#/parameters/ResourceGroupNameParameter" + }, + { + "$ref": "#/parameters/GraphQueryResourceNameParameter" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "name": "properties", + "description": "Properties that need to be specified to create a new graph query.", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/GraphQueryResource" + } + } + ], + "responses": { + "200": { + "description": "The newly created graph query.", + "schema": { + "$ref": "#/definitions/GraphQueryResource" + } + }, + "default": { + "description": "Error response describing why the operation failed.", + "schema": { + "$ref": "#/definitions/GraphQueryError" + } + } + }, + "x-ms-examples": { + "Create Graph Query": { + "$ref": "./examples/GraphQueryAdd.json" + } + } + }, + "patch": { + "description": "Updates a graph query that has already been added.", + "operationId": "GraphQuery_Update", + "parameters": [ + { + "$ref": "#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "#/parameters/ResourceGroupNameParameter" + }, + { + "$ref": "#/parameters/GraphQueryResourceNameParameter" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "name": "body", + "description": "Properties that need to be specified to create a new graph query.", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/GraphQueryUpdateParameters" + } + } + ], + "responses": { + "200": { + "description": "The graph query definition updated.", + "schema": { + "$ref": "#/definitions/GraphQueryResource" + } + }, + "default": { + "description": "Error response describing why the operation failed.", + "schema": { + "$ref": "#/definitions/GraphQueryError" + } + } + }, + "x-ms-examples": { + "Update Graph Query": { + "$ref": "./examples/GraphQueryUpdate.json" + } + } + } + }, + "/providers/Microsoft.ResourceGraph/operations": { + "get": { + "tags": [ + "Operations" + ], + "description": "Lists all of the available REST API operations.", + "operationId": "Operations_List", + "x-ms-examples": { + "OperationsList": { + "$ref": "./examples/OperationsList.json" + } + }, + "parameters": [ + { + "$ref": "#/parameters/ApiVersionParameter" + } + ], + "responses": { + "200": { + "description": "OK. The request has succeeded.", + "schema": { + "$ref": "resourcegraph.json#/definitions/OperationListResult" + } + } + }, + "x-ms-pageable": { + "nextLinkName": "nextLink" + } + } + } + }, + "definitions": { + "Resource": { + "properties": { + "id": { + "type": "string", + "readOnly": true, + "description": "Azure resource Id" + }, + "name": { + "type": "string", + "readOnly": true, + "description": "Azure resource name. This is GUID value. The display name should be assigned within properties field." + }, + "type": { + "type": "string", + "readOnly": true, + "description": "Azure resource type" + }, + "eTag": { + "type": "string", + "readOnly": true, + "description": "This will be used to handle Optimistic Concurrency. If not present, it will always overwrite the existing resource without checking conflict." + }, + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags" + } + }, + "x-ms-azure-resource": true, + "description": "An azure resource object" + }, + "GraphQueryListResult": { + "properties": { + "nextLink": { + "description": "URL to fetch the next set of queries.", + "type": "string" + }, + "value": { + "type": "array", + "readOnly": true, + "items": { + "$ref": "#/definitions/GraphQueryResource" + }, + "description": "An array of graph queries." + } + }, + "description": "Graph query list result." + }, + "GraphQueryResource": { + "description": "Graph Query entity definition.", + "allOf": [ + { + "$ref": "#/definitions/Resource" + } + ], + "properties": { + "properties": { + "x-ms-client-flatten": true, + "description": "Metadata describing a graph query for an Azure resource.", + "$ref": "#/definitions/GraphQueryProperties" + } + } + }, + "GraphQueryProperties": { + "description": "Properties that contain a graph query.", + "required": [ + "query" + ], + "properties": { + "timeModified": { + "type": "string", + "description": "Date and time in UTC of the last modification that was made to this graph query definition.", + "format": "date-time", + "readOnly": true + }, + "description": { + "type": "string", + "description": "The description of a graph query." + }, + "query": { + "type": "string", + "description": "KQL query that will be graph." + }, + "resultKind": { + "description": "Enum indicating a type of graph query.", + "readOnly": true, + "default": "basic", + "type": "string", + "enum": [ + "basic" + ], + "x-ms-enum": { + "name": "ResultKind", + "modelAsString": true + } + } + } + }, + "GraphQueryUpdateParameters": { + "properties": { + "tags": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Resource tags" + }, + "eTag": { + "type": "string", + "readOnly": true, + "description": "This will be used to handle Optimistic Concurrency. If not present, it will always overwrite the existing resource without checking conflict." + }, + "properties": { + "x-ms-client-flatten": true, + "description": "Metadata describing a graph query for an Azure resource.", + "$ref": "#/definitions/GraphQueryPropertiesUpdateParameters" + } + }, + "description": "The parameters that can be provided when updating workbook properties properties." + }, + "GraphQueryPropertiesUpdateParameters": { + "description": "Properties that contain a workbook for PATCH operation.", + "properties": { + "description": { + "type": "string", + "description": "The description of a graph query." + }, + "query": { + "type": "string", + "description": "KQL query that will be graph." + }, + "resultKind": { + "description": "Enum indicating a type of graph query.", + "default": "basic", + "type": "string", + "enum": [ + "basic" + ], + "x-ms-enum": { + "name": "ResultKind", + "modelAsString": true + } + } + } + }, + "ErrorFieldContract": { + "properties": { + "code": { + "type": "string", + "description": "Property level error code." + }, + "message": { + "type": "string", + "description": "Human-readable representation of property-level error." + }, + "target": { + "type": "string", + "description": "Property name." + } + }, + "description": "Error Field contract." + }, + "GraphQueryError": { + "properties": { + "code": { + "type": "string", + "description": "Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response." + }, + "message": { + "type": "string", + "description": "Human-readable representation of the error." + }, + "details": { + "type": "array", + "items": { + "$ref": "#/definitions/ErrorFieldContract" + }, + "description": "The list of invalid fields send in request, in case of validation error." + } + }, + "description": "Error message body that will indicate why the operation failed." + } + }, + "parameters": { + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "The Azure subscription Id." + }, + "ApiVersionParameter": { + "name": "api-version", + "in": "query", + "required": true, + "type": "string", + "description": "Client Api Version." + }, + "ResourceGroupNameParameter": { + "name": "resourceGroupName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the resource group.", + "x-ms-parameter-location": "method" + }, + "GraphQueryResourceNameParameter": { + "name": "resourceName", + "in": "path", + "required": true, + "type": "string", + "description": "The name of the Graph Query resource.", + "x-ms-parameter-location": "method" + } + } +} \ No newline at end of file diff --git a/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/resourcegraph.json b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/resourcegraph.json index fb66706f7ce3..50600b2a8cd8 100644 --- a/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/resourcegraph.json +++ b/specification/resourcegraph/resource-manager/Microsoft.ResourceGraph/preview/2018-09-01-preview/resourcegraph.json @@ -27,7 +27,7 @@ "type": "oauth2", "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", "flow": "implicit", - "description": "Azure Active Directory OAuth2 Flow", + "description": "Azure Active Directory OAuth2 Flow.", "scopes": { "user_impersonation": "impersonate your user account" } @@ -196,7 +196,7 @@ } }, "x-ms-pageable": { - "nextLinkName": null + "nextLinkName": "nextLink" } } } @@ -701,6 +701,10 @@ "$ref": "#/definitions/Operation" }, "description": "List of Resource Graph operations supported by the Resource Graph resource provider." + }, + "nextLink": { + "description": "The link used to get the next page of results.", + "type": "string" } } }, @@ -745,7 +749,7 @@ "in": "query", "required": true, "type": "string", - "description": "API version." + "description": "Client Api Version." } } -} +} \ No newline at end of file diff --git a/specification/resourcegraph/resource-manager/readme.go.md b/specification/resourcegraph/resource-manager/readme.go.md index 484e2e980fe7..9c93699bc8af 100644 --- a/specification/resourcegraph/resource-manager/readme.go.md +++ b/specification/resourcegraph/resource-manager/readme.go.md @@ -14,6 +14,7 @@ go: ``` yaml $(go) && $(multiapi) batch: - tag: package-2019-04 + - tag: package-2018-09-preview ``` ### Tag: package-2019-04 and go @@ -24,3 +25,12 @@ Please also specify `--go-sdk-folder=`. + +``` yaml $(tag) == 'package-2018-09-preview' && $(go) +output-folder: $(go-sdk-folder)/services/preview/$(namespace)/mgmt/2018-09-01/$(namespace) +``` diff --git a/specification/resourcegraph/resource-manager/readme.md b/specification/resourcegraph/resource-manager/readme.md index ccd79c65170c..d86fc8b81f55 100644 --- a/specification/resourcegraph/resource-manager/readme.md +++ b/specification/resourcegraph/resource-manager/readme.md @@ -56,7 +56,8 @@ These settings apply only when `--tag=package-2018-09-preview` is specified on t ``` yaml $(tag) == 'package-2018-09-preview' input-file: -- Microsoft.ResourceGraph/preview/2018-09-01-preview/resourcegraph.json + - Microsoft.ResourceGraph/preview/2018-09-01-preview/resourcegraph.json + - Microsoft.ResourceGraph/preview/2018-09-01-preview/graphquery.json ``` # Code Generation