How to filter the resources count in GET Request in AzureRM ?
For an example in List Virtual Machines in an subscription . We get all the Vm's running in an account .
But I need to get 10 VM's alone in ascending or any sorting order . Is there any filter available like that ?
If the sorting order does not matter for you, you can filter the resource count for the top 10 VMs in the GET request below:
I've tried the requests below and tweak resource count for filtering and they all worked as expected.
https://management.azure.com/subscriptions/{subscriptionId}/resources?$filter=resourceType eq 'Microsoft.Compute/virtualmachines'&$top=10&api-version={apiVersion}
Sample response is like below:
{
"value": [
{
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vm}",
"name": "{vm}",
"type": "Microsoft.Compute/virtualMachines",
"location": "{location}"
},
{
"id": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vm}",
"name": "{vm}",
"type": "Microsoft.Compute/virtualMachines",
"location": "{location}"
}
]
}
Hope this helps.
You could use the following API.
https://management.azure.com/subscriptions/**********/providers/Microsoft.Compute/virtualmachines?api-version=2017-12-01&top=10
Using $top=10 to filter the top 10 result. See this example.
Related
if /wallet returns a list a wallets and each wallet has a list of transactions. What is the standard OpenAPI/REST standard?
For example,
http://localhost:8000/api/wallets/ gives me
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"user": 1,
"address": "3E8ociqZa9mZUSwGdSmAEMAoAxBK3FNDcd",
"balance": "2627199.00000000"
}
]
}
http://localhost:8000/api/wallets/3E8ociqZa9mZUSwGdSmAEMAoAxBK3FNDcd/ gives me
{
"user": 1,
"address": "3E8ociqZa9mZUSwGdSmAEMAoAxBK3FNDcd",
"balance": "2627199.00000000"
}
If I wanted to add a transactions list, what is the standard way to form this?
http://localhost:8000/api/wallets/3E8ociqZa9mZUSwGdSmAEMAoAxBK3FNDcd/transactions ?
http://localhost:8000/api/wallets/3E8ociqZa9mZUSwGdSmAEMAoAxBK3FNDcd/transactions?offset=100 for pagination
REST doesn't care what spelling conventions you use for your resources. What it would instead expect is that you have representations of links between resources, along with meta data describing the nature of the link.
So this schema is fine.
/api/wallets/3E8ociqZa9mZUSwGdSmAEMAoAxBK3FNDcd
/api/wallets/3E8ociqZa9mZUSwGdSmAEMAoAxBK3FNDcd/transactions
And this schema is also fine.
/api/wallets/3E8ociqZa9mZUSwGdSmAEMAoAxBK3FNDcd
/api/transactions/3E8ociqZa9mZUSwGdSmAEMAoAxBK3FNDcd
As far as I can tell, OpenAPI also gives you the freedom to design your resource model the way that works best for you (it just tells you one possible way to document the resource model you have selected).
I am using a Kafka-connect, and I want to filter out some messages.
This is how a single message in Kafka looks like.
{
"code": 2001,
"time": 11111111,
"requestId": "123456789",
"info": [
{
"name": "dan",
"value": 21
}
]
}
And this is how my transformer looks like
transforms:
transforms: FilterByCode
transforms.FilterByCode.type: io.confluent.connect.transforms.Filter$Value
transforms.FilterByCode.filter.condition: $[?(#.code == 2000)]
transforms.FilterByCode.filter.type: include
I want to filter out the messages that their code value is not 2000.
I tried to few different syntax for the condition, but could not find any that works.
All the messages are transformed, and no one is filtered.
Any ideas on how I should use the syntax for the filtering condition?
If you want to filter out all non 2000 codes, try [?(#.code != 2000)]
You may test it here - http://jsonpath.herokuapp.com/
I am trying to create an OData Query to return Bugs from Azure DevOps for a PowerBI report, but I am not getting the results I am looking for, as one of the Related Entities that I am trying to expand returns multiple results.
My base Query looks like this (simplified & removing custom fields)
https://analytics.dev.azure.com/[organization]/[project]/_odata/v3.0-preview/WorkItems?$select=WorkItemId,WorkItemType,Title,State,LeadTimeDays&$filter=WorkItemType eq 'bug'&$expand=Teams($select=TeamName,AnalyticsUpdatedDate)
Some records return multiple Team Names in the JSON Response
"value": [
{
"WorkItemId": 16547,
"LeadTimeDays": 173.0639004,
"Title": "test",
"WorkItemType": "Bug",
"State": "Closed",
"Severity": "3 - Medium",
"Teams": [
{
"TeamName": "Team1",
"AnalyticsUpdatedDate": "2019-09-17T01:48:46.5433333Z"
},
{
"TeamName": "Team2",
"AnalyticsUpdatedDate": "2019-12-03T16:52:39.9466667Z"
}
]
}
]
I can't tell why these records have multiple values for this Entity, but I only need the most recent (Team 2 in the example above). Is it possible to return only the most recent record for the Related Teams Entity? I've tried using orderby and top on the expand clause and other places in the query to no effect. If I can't do it in the OData query, then I can accomplish it in Power BI after expanding the Table.
I found how to solve this. I needed semicolons between the clauses within the Expand clause.
https://analytics.dev.azure.com/[organization]/[projet]_odata/v3.0-preview/WorkItems?$select=WorkItemId,WorkItemType,Title,State,LeadTimeDays&$filter=WorkItemType eq 'bug'&$expand=Teams($select=TeamName,AnalyticsUpdatedDate;$orderby=AnalyticsUpdatedDate desc;$top=1)
Steps I followed:
First create corpus, then send create a document in it.
Check if the processing of the document is ready (done processing)
https://gateway.watsonplatform.net/concept-insights/api/v2/corpora/{account-id}/{corpus-name}/documents/{document-name}/processing_state
If it is ready then i retrieve the related_concepts in the document
https://gateway.watsonplatform.net/concept-insights/api/v2/corpora/{account-id}/{corpus-name}/documents/{document-name}/related_concepts
All the above steps are working (I get a 200/201 reply from Bluemix server).
The problem is in the reply of step 2. I keep getting the following response
{ "status": "processing", "last_modified": "2015-11-10T15:27:12.473Z" }
But when I do step 3, I am getting the desired response (the related concepts in the document)
{
"concepts" : [
{
"score" : ...,
"concept" : {
"id": "........",
"label": ".....
}
}, .....
]
}
UPDATE
The processing_state API problem has been fixed. Gives the desired response
The processing_state API problem has been fixed. Gives the desired response now.
As I create entities in an Orion server, I can search by ID, as flat or using regular expressions:
http://<localhost>:1026/v1/queryContext
Content:
{
"entities": [
{
"type": "Sensor",
"isPattern": "true",
"id": "sensor_1.*"
}
],
"attributes": ["temperature","humidity"]
}
In the above example I'd get all objects of type "Sensor" whose ID starts with "sensor_1", and their attributes "temperature" and "humidity". I wonder if there is any way that would allow me to search by specific attribute value, for example to get those sensors whose humidity is over "60.2", or this selection must be done over the retrieved data queried by ID.
Not in the current Orion version (0.19.0) but it will be possible in the future. Have a look to the attribute::<name> filter with the = operator in this document.