Pass complex value to templateParameters collection in Devops Pipeline Run API - azure-devops

I'm using the Azure Devops Pipeline Run API documented here. It works fine except that it does not seem to support passing complex objects via the templateParameters in the request body.
E.g.
parameters:
- name: myObject
type: object
default:
- val1
Call the api with this request body:
{
"resources": {
"repositories": {
"self": {
"refName": "refs/heads/main"
}
}
},
"templateParameters": {
"myObject": [
"val2"
]
}
}
The pipeline runs with myObject set to the default val1.

The body should be like this:
{
"resources": {
"repositories": {
"self": {
"refName": "refs/heads/main"
}
}
},
"templateParameters": {
"myObject": "- val2"
}
}
Results of - powershell: Write-Host "${{ parameters.myObject[0] }}":

With pipeline parameter like :
parameters:
- name: myObject
type: object
default:
- val1
- name: myObject2
type: object
default:
- Name: toto
Value: tata
- Name: toto2
Value: tata2
You should use :
$RunPipelineBody = #{
"templateParameters" = #{
"myObject" = "- val1new"
"myObject2" = "- Name: totonew`n Value: tatanew`n- Name: toto2new`n Value: tata2new"
}
}
And
-Body $( $RunPipelineBody | ConvertTo-JSON -Depth 10 -Compress)

Related

Azure Databricks "Failed to prepare subnet"

We are injecting Databricks into a VNet subnet through our Bicep deployment.
Intermittently, we are seeing the error:
{"code":"PrepareSubnetError","message":"Failed to prepare subnet 'DataBricksPrivateSubnet'. Please try again later. Error details: 'Failed to prepare subnet 'DataBricksPrivateSubnet'. Please try again later'"}
Trying again later does usually work, but is not a very satisfactory solution.
Some extracts from our Biep templates:
resource virtualNetwork 'Microsoft.Network/virtualNetworks#2019-11-01' = {
properties: {
subnets: [
{
name: 'DataBricksPublicSubnet'
properties: {
delegations: [
{
name: 'DataBricksPublicSubnetDelegation'
properties: {
serviceName: 'Microsoft.Databricks/workspaces'
}
}
]
}
}
{
name: 'DataBricksPrivateSubnet'
properties: {
delegations: [
{
name: 'DataBricksPrivateSubnetDelegation'
properties: {
serviceName: 'Microsoft.Databricks/workspaces'
}
}
]
}
}
]
}
}
resource ws 'Microsoft.Databricks/workspaces#2018-04-01' = {
properties: {
parameters: {
customPublicSubnetName: {
value: 'DataBricksPublicSubnet'
}
customPrivateSubnetName: {
value: 'DataBricksPrivateSubnet'
}
}
}
}

Filter oData with array of custom attribute ( $expand ) and use $filter for a specific attribute

With this structure of the oData v2 result from a GetEntitySet (JSON Format)
{
d: {
__count: "3215",
result : [
{
City : 'NewYork',
Country : 'USA',
CustomAttributeData : {
results : [
{ Name: "custom1",
Value: "20220707"
},
{ Name: "custom2",
Value: "20220710"
},
{ Name: "custom3",
Value: "20220713"
}
]
}
},
{
City : 'Rome',
Country : 'ITALY',
CustomAttributeData : {
results : [
{ Name: "custom1",
Value: "20220702"
},
{ Name: "custom2",
Value: "20220710"
},
{ Name: "custom3",
Value: "20220710"
}
]
}
},
{
City : 'Tokyo',
Country : 'JAPAN',
CustomAttributeData : {
results : [
{ Name: "custom1",
Value: "20220710"
},
{ Name: "custom2",
Value: "20220711"
},
{ Name: "custom3",
Value: "20220710"
}
]
}
}
],
}
}
....
]
I want to filter all the cities with the CustomAttributeData custom2=20220710 (all but not Tokyo). What is the correct uri ?
https://xxxxxx?$expand=CustomAttributeData$filter=CustomAttributeData/Value eq '20220710'
This one is of course wrong because consider Tokyo too.
Someone can help me?
With OData V2, it's not possible. You'll need to use the any lambda operator* for your filter which is available only in OData V4.
* See also this SAP Developer video section which explains any and all operators for OData V4 filters.
You can filter out Tokyo by using ne operator in $filter query.
$filter=City ne 'Tokyo'
Added to your query
https://xxxxxx?$expand=CustomAttributeData&$filter=City ne 'Tokyo' and CustomAttributeData/Value eq '20220710'

Firestore: Creating Indexes for map values

How to create composite index for map values in a Document?
Data:
{
name: 'rodel',
published:
{
name: 'test'
}
}
Do I need to create it like this?
{
"fieldPath": "published.name",
"mode": "ASCENDING"
}
Try below
{
"fieldPath": "published.`name`",
"mode": "ASCENDING"
}
`

MongoDB get attribute from array inside another array

Series is one document. It has an array of series inside it (in this case it has 'Revenge' and 'Raines').
Each series has a cast array with names. And I need a query to get those names.
Who know how can I get a list of all the names from both cast arrays?
My best approach was this query db.series.find( {}, { _id: 0, cast: 1 } ) where a get a cursor with the two cast json arrays.
{ series:
[
{
name: 'Revenge',
user_rating: 7.9,
duration: 44,
genres: [ ' Drama', ' Mystery', ' Thriller' ],
year_start: '2011',
year_end: '',
cast:
[ { name: 'Madeleine Stowe' },
{ name: 'Emily VanCamp' },
{ name: 'Gabriel Mann' },
{ name: 'Nick Wechsler' },
{ name: 'Henry Czerny' },
{ name: 'Joshua Bowman' },
{ name: 'Christa B. Allen' },
{ name: 'Ashley Madekwe' },
{ name: 'Connor Paolo' },
{ name: 'Barry Sloane' },
{ name: 'Margarita Levieva' } ],
seasons: [ { number: '3' }, { number: '2' }, { number: '1' } ]
},
{
name: 'Raines',
user_rating: 7.4,
duration: 45,
genres: [ ' Crime', ' Drama' ],
year_start: '2007',
year_end: '',
cast:
[ { name: 'Jeff Goldblum' },
{ name: 'Matt Craven' },
{ name: 'Nicole Sullivan' },
{ name: 'Linda Park' },
{ name: 'Dov Davidoff' },
{ name: 'Malik Yoba' },
{ name: 'Madeleine Stowe' } ],
seasons: [ { number: '1' } ]
}
]
}
I need an output like this:
I need this:
{ name: 'Madeleine Stowe' },
{ name: 'Emily VanCamp' },
{ name: 'Gabriel Mann' },
{ name: 'Nick Wechsler' },
{ name: 'Henry Czerny' },
{ name: 'Joshua Bowman' },
{ name: 'Christa B. Allen' },
{ name: 'Ashley Madekwe' },
{ name: 'Connor Paolo' },
{ name: 'Barry Sloane' },
{ name: 'Margarita Levieva' },
{ name: 'Jeff Goldblum' },
{ name: 'Matt Craven' },
{ name: 'Nicole Sullivan' },
{ name: 'Linda Park' },
{ name: 'Dov Davidoff' },
{ name: 'Malik Yoba' },
{ name: 'Madeleine Stowe' }
You can use aggregation framework for this:
db.series.aggregate( { $unwind : "$series" },
{ $unwind : "$series.cast" },
{ $group : { _id : "$_id",
cast : {$push:"$series.cast}
}
}
);
If you want to consolidate multiple actor appearances into one then replace $push with $addToSet.

JSON parsing in ios5 without array name?

Here i m putting code of my json file..can anyone help me "How to parse this json file?".I tried a lot of tutorials.I got some hints.But in my json file i dont have array name.so i couldnt use any key value to access those objects.
[
{
id: 1,
name: "Ice Cube",
properties: [
{
propertyMeta: {
name: "Color",
type: 5
},
value: "Venfield"
},
{
propertyMeta: {
name: "Size",
type: 1
},
value: "38"
}
]
},
{
id: 2,
name: "Lite Shirt",
properties: [
{
propertyMeta: {
name: "Color",
type: 5
},
value: "Otto"
},
{
propertyMeta: {
name: "Size",
type: 1
},
value: "42"
}
]
},
{
id: 3,
name: "Holiday Tops",
properties: [
{
propertyMeta: {
name: "Color",
type: 5
},
value: "Van Heusen"
},
{
propertyMeta: {
name: "Size",
type: 1
},
value: "39"
}
]
}
]
If you're using SBJSON you'd just:
NSArray *myArray = [myJSONString JSONvalue];
And then loop through it as normal