Skip to content

Commit

Permalink
ARG Query Generation API in 2023-09-01-preview (#25699)
Browse files Browse the repository at this point in the history
* Adds base for updating Microsoft.ResourceGraph from version stable/2022-10-01 to version 2023-09-01-preview

* Updates readme

* Updates API version in new specs and examples

* Updated ARG Swagger Specs by Adding Copilot Swagger.

* Updated ARG Copilot Swagger Spec with Linter Fix.

* Updated ARG Swagger Spec ReadMe with Avocado Fix.

* Updated ARG Swagger Specs to Handle Linter Issue.
  • Loading branch information
visingla-ms authored Sep 18, 2023
1 parent 79e0974 commit 35c7876
Show file tree
Hide file tree
Showing 18 changed files with 1,631 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"parameters": {
"api-version": "2023-09-01-preview"
},
"responses": {
"200": {
"body": {
"value": [
{
"name": "Microsoft.ResourceGraph/operations/read",
"display": {
"provider": "Microsoft Resource Graph",
"resource": "Operation",
"operation": "Get Operations",
"description": "Gets the list of supported operations"
}
},
{
"name": "Microsoft.ResourceGraph/resources/read",
"display": {
"provider": "Microsoft Resource Graph",
"resource": "Resources",
"operation": "Query resources",
"description": "Submits a query on resources within specified subscriptions, the specified management groups, or against all access granted in the tenant."
}
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"title": "Basic Query",
"description": "A simple resources query.",
"parameters": {
"api-version": "2023-09-01-preview",
"query": {
"subscriptions": [
"cfbbd179-59d2-4052-aa06-9270a38aa9d6"
],
"query": "Resources | project id, name, type, location, tags | limit 3"
}
},
"responses": {
"200": {
"body": {
"totalRecords": 3,
"count": 3,
"resultTruncated": "false",
"facets": [],
"data": [
{
"id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG1/providers/Microsoft.Network/networkInterfaces/myNetworkInterface",
"name": "myNetworkInterface",
"type": "microsoft.network/networkinterfaces",
"location": "centralus",
"tags": {
"tag1": "Value1"
}
},
{
"id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Network/virtualNetworks/myVnet",
"name": "myVnet",
"type": "microsoft.network/virtualnetworks",
"location": "westus",
"tags": {}
},
{
"id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Network/publicIPAddresses/myPublicIp",
"name": "myPublicIp",
"type": "microsoft.network/publicipaddresses",
"location": "westus",
"tags": {}
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"title": "Complex Query",
"description": "A complex query on resources featuring multiple operations.",
"parameters": {
"api-version": "2023-09-01-preview",
"query": {
"subscriptions": [
"cfbbd179-59d2-4052-aa06-9270a38aa9d6"
],
"query": "Resources | project id, name, type, location | where type =~ 'Microsoft.Compute/virtualMachines' | summarize count() by location | top 3 by count_"
}
},
"responses": {
"200": {
"body": {
"totalRecords": 3,
"count": 3,
"resultTruncated": "false",
"facets": [],
"data": [
{
"location": "centralus",
"count_": 11
},
{
"location": "eastus",
"count_": 11
},
{
"location": "southcentralus",
"count_": 3
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
{
"title": "Facet Query",
"description": "A query on resources requesting extra facets.",
"parameters": {
"api-version": "2023-09-01-preview",
"query": {
"subscriptions": [
"cfbbd179-59d2-4052-aa06-9270a38aa9d6"
],
"query": "Resources | where type =~ 'Microsoft.Compute/virtualMachines' | project id, name, location, resourceGroup, properties.storageProfile.osDisk.osType | limit 5",
"facets": [
{
"expression": "location",
"options": {
"sortOrder": "desc",
"$top": 3
}
},
{
"expression": "properties.storageProfile.osDisk.osType",
"options": {
"sortOrder": "desc",
"$top": 3
}
},
{
"expression": "nonExistingColumn",
"options": {
"sortOrder": "desc",
"$top": 3
}
},
{
"expression": "resourceGroup",
"options": {
"sortBy": "tolower(resourceGroup)",
"sortOrder": "asc",
"$top": 3
}
},
{
"expression": "resourceGroup",
"options": {
"filter": "resourceGroup contains 'test'",
"$top": 3
}
}
]
}
},
"responses": {
"200": {
"body": {
"totalRecords": 5,
"count": 5,
"resultTruncated": "false",
"data": [
{
"id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/B-TEST-RG/providers/Microsoft.Compute/virtualMachines/myTestVm",
"name": "myTestVm",
"location": "eastus",
"resourceGroup": "B-TEST-RG",
"properties_storageProfile_osDisk_osType": "Windows"
},
{
"id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/c-rg/providers/Microsoft.Compute/virtualMachines/myTestAccountVm",
"name": "myTestAccountVm",
"location": "westcentralus",
"resourceGroup": "c-rg",
"properties_storageProfile_osDisk_osType": "Windows"
},
{
"id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/I-RG/providers/Microsoft.Compute/virtualMachines/yetanothertest",
"name": "yetanothertest",
"location": "eastus",
"resourceGroup": "I-RG",
"properties_storageProfile_osDisk_osType": "Linux"
},
{
"id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/x-test-rg/providers/Microsoft.Compute/virtualMachines/drafttest1bux4cv7a7q3aw",
"name": "drafttest1bux4cv7a7q3aw",
"location": "southcentralus",
"resourceGroup": "x-test-rg",
"properties_storageProfile_osDisk_osType": "Linux"
},
{
"id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/y-rg/providers/Microsoft.Compute/virtualMachines/testvmntp25370",
"name": "testvmntp25370",
"location": "eastus",
"resourceGroup": "y-rg",
"properties_storageProfile_osDisk_osType": "Windows"
}
],
"facets": [
{
"expression": "location",
"resultType": "FacetResult",
"totalRecords": 3,
"count": 3,
"data": [
{
"location": "eastus",
"count": 3
},
{
"location": "southcentralus",
"count": 1
},
{
"location": "westcentralus",
"count": 1
}
]
},
{
"expression": "properties.storageProfile.osDisk.osType",
"resultType": "FacetResult",
"totalRecords": 2,
"count": 2,
"data": [
{
"properties_storageProfile_osDisk_osType": "Linux",
"count": 2
},
{
"properties_storageProfile_osDisk_osType": "Windows",
"count": 3
}
]
},
{
"expression": "nonExistingColumn",
"resultType": "FacetError",
"errors": [
{
"code": "NoValidColumns",
"message": "No valid columns in facet expression."
},
{
"code": "InvalidColumnNames",
"message": "Invalid column names: [nonExistingColumn]."
}
]
},
{
"expression": "resourceGroup",
"resultType": "FacetResult",
"totalRecords": 5,
"count": 3,
"data": [
{
"resourceGroup": "B-TEST-RG",
"count": 1
},
{
"resourceGroup": "c-rg",
"count": 1
},
{
"resourceGroup": "I-RG",
"count": 1
}
]
},
{
"expression": "resourceGroup",
"resultType": "FacetResult",
"totalRecords": 2,
"count": 2,
"data": [
{
"resourceGroup": "B-TEST-RG",
"count": 1
},
{
"resourceGroup": "x-test-rg",
"count": 1
}
]
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"title": "Filter query",
"description": "A filtering query on resources.",
"parameters": {
"api-version": "2023-09-01-preview",
"query": {
"subscriptions": [
"cfbbd179-59d2-4052-aa06-9270a38aa9d6"
],
"query": "Resources | project id, name, type, location | where type =~ 'Microsoft.Compute/virtualMachines' | limit 3"
}
},
"responses": {
"200": {
"body": {
"totalRecords": 3,
"count": 3,
"resultTruncated": "false",
"facets": [],
"data": [
{
"id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG1/providers/Microsoft.Compute/virtualMachines/myVm1",
"name": "myVm1",
"type": "microsoft.compute/virtualmachines",
"location": "centralus"
},
{
"id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Compute/virtualMachines/myVirtualMachine",
"name": "myVirtualMachine",
"type": "microsoft.compute/virtualmachines",
"location": "eastus"
},
{
"id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG3/providers/Microsoft.Compute/virtualMachines/testVm",
"name": "testVm",
"type": "microsoft.compute/virtualmachines",
"location": "eastus"
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"title": "First page query",
"description": "A query requesting a first page with of results. Please note id field is required in the response to return the pages in stable sorted fashion.",
"parameters": {
"api-version": "2023-09-01-preview",
"query": {
"subscriptions": [
"cfbbd179-59d2-4052-aa06-9270a38aa9d6"
],
"query": "Resources | where name contains 'test' | project id, name, type, location",
"options": {
"$top": 3,
"$skip": 0
}
}
},
"responses": {
"200": {
"body": {
"totalRecords": 386,
"count": 3,
"resultTruncated": "false",
"facets": [],
"$skipToken": "eyAibm8iOiAibHVjayIsICJidXQiOiAibmljZSIsICJ0cnkiOiAiISIgfQ==",
"data": [
{
"id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG1/providers/Microsoft.Compute/disks/yetanothertest_OsDisk_1_f396cbcb625a457bb69fe2abf5975820",
"name": "yetanothertest_OsDisk_1_f396cbcb625a457bb69fe2abf5975820",
"type": "microsoft.compute/disks",
"location": "eastus"
},
{
"id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Automation/automationAccounts/TestAA",
"name": "TestAA",
"type": "microsoft.automation/automationaccounts",
"location": "westcentralus"
},
{
"id": "/subscriptions/cfbbd179-59d2-4052-aa06-9270a38aa9d6/resourceGroups/RG2/providers/Microsoft.Automation/automationAccounts/TestAA/runbooks/TestRB",
"name": "TestRB",
"type": "microsoft.automation/automationaccounts/runbooks",
"location": "westcentralus"
}
]
}
}
}
}
Loading

0 comments on commit 35c7876

Please sign in to comment.