What is the proper SCIM syntax for adding a custom property - scim

I am trying to extend the user model and add a new string property. If I understand, I can simply add it and return the value.
My question is how do I document this in the resource type endpoint. Currently we have just the basic scim implementation so we return
"Resources": [
{
"name": "User",
"description": "User Accounts",
"endpoint": "/Users",
"schema": "urn:ietf:params:scim:schemas:core:2.0:User",
"schemas": [
"urn:ietf:params:scim:schemas:core:2.0:ResourceType"
],
"id": "User",
"meta": {
"resourceType": "ResourceType",
"location": "https://apidsw017086.docusignhq.com/v201411/scim/resourcetypes/user"
}
}
Should I just add the attribute section and add the new attribute, or do I need to list all the default attributes as well?

As described in RFC 7643 Section 3.3, you need to define a new schema and specify that schema in the ResourceType "schemaExtensions". You can look at the enterprise user schema extension throughout the spec for an example of how to do this.
Example Resource Type Representation:
[
{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:ResourceType"],
"id": "User",
"name": "User",
"endpoint": "/Users",
"description": "User Account",
"schema": "urn:ietf:params:scim:schemas:core:2.0:User",
"schemaExtensions": [
{
"schema": "urn:your:user:extension:schema",
"required": false
}
],
"meta": {
"location": "https://example.com/v2/ResourceTypes/User",
"resourceType": "ResourceType"
}
}
]
Example Resource Schema Representation:
[
{
"id": "urn:ietf:params:scim:schemas:core:2.0:User",
"schemas": [ "urn:ietf:params:scim:schemas:core:2.0:Schema" ],
"name": "User",
"description": "User Account",
"attributes": [ {...} ]
},
{
"id": "urn:your:user:extension:schema",
"schemas": [ "urn:ietf:params:scim:schemas:core:2.0:Schema" ],
"name": "Your Custom User Extension Name",
"description": "Your Custom User Extension Description",
"attributes": [ {...} ]
}
]

Related

json-schema : Get a list of additionalProperties?

Is it possible to get a list of all additionalProperties found by json-schema ?
For example, if my schema looks like this :
{
"type": "object",
"properties": {
"firstName": {
"type": "string",
},
"lastName": {
"type": "string",
},
"age": {
"type": "integer"
}
}
}
And data loooks like this :
{
"firstName": "John",
"lastName": "Doe",
"age": 21,
"extraField": "some new data I was not expecting",
"anotherExtraField": "another unexpected data point"
}
In this case, instead of an exception from json-schema because of additionalProperties: false, I want a list in return, like : [extraField, anotherExtraField]
If you're using an implementation that supports 2019-09 or 2020-12 with annotations, you're in luck! additionalProperties should produce an annotation result of the properties it validates (spec).
If you add additionalProperties: true, then all extra properties pass and are validated by the keyword, which means those extra properties should be listed in the annotation result.
{
"type": "object",
"properties": {
"firstName": {
"type": "string"
},
"lastName": {
"type": "string"
},
"age": {
"type": "integer"
}
},
"additionalProperties": true
}
This yields (in the Detailed output format)
{
"valid": true,
"keywordLocation": "#",
"instanceLocation": "#",
"annotations": [
{
"valid": true,
"keywordLocation": "#/properties",
"instanceLocation": "#",
"annotation": [
"firstName",
"lastName",
"age"
]
},
{
"valid": true,
"keywordLocation": "#/additionalProperties",
"instanceLocation": "#",
"annotation": [
"extraField",
"anotherExtraField"
]
}
]
}
You can try it on https://json-everything.net, which is powered by my validator, JsonSchema.Net.
If you're not using .Net, you can browse the implementations page for other libraries. Some of them may also support annotations, but I'm not sure which do.

Retrieve FQDN of Azure SQL from a linkted template

I'm looking for a valid property to retrieve FQDN of a managed Azure SQL server from a deployment of linked template. The one below seems not to be valid
[reference(variables('sqlDeployment')).outputs.fullyQualifiedDomainName.value]"
and where can I find all supported parameters? It seems to be challenging to find enough info from Microsoft Docs.
Looks like your linked template did not have an output property named as 'fullyQualifiedDomainName'.
To get an output value from a linked template, retrieve the property value with syntax like "[reference('deploymentName').outputs.propertyName.value]" as explained here -> https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-linked-templates#get-values-from-linked-template
Please find below sample parent and linked templates to accomplish your requirement of retrieving FQDN of a managed Azure SQL server.
Parent template named as "parenttemplate.json":
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {
"sqlserverName": "gttestsqlserver",
"sqlAdministratorLogin": "gttestuser",
"sqlAdministratorLoginPassword": "gttestpassword2#",
"sqlDeployment": "linkedTemplate"
},
"resources": [
{
"apiVersion": "2017-05-10",
"name": "[variables('sqlDeployment')]",
"type": "Microsoft.Resources/deployments",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[uri(deployment().properties.templateLink.uri, 'linkedtemplate.json')]",
"contentVersion": "1.0.0.0"
}
}
}
],
"outputs": {
"messageFromLinkedTemplate": {
"type": "string",
"value": "[reference(variables('sqlDeployment')).outputs.MessageOne.value]"
}
}
}
Linked template named as "linkedtemplate.json":
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {
"sqlserverName": "gttestsqlserver",
"sqlAdministratorLogin": "gttestuser",
"sqlAdministratorLoginPassword": "gttestpassword2#"
},
"resources": [
{
"name": "[variables('sqlserverName')]",
"type": "Microsoft.Sql/servers",
"location": "[parameters('location')]",
"tags": {
"displayName": "gttestsqlserver"
},
"apiVersion": "2014-04-01",
"properties": {
"administratorLogin": "[variables('sqlAdministratorLogin')]",
"administratorLoginPassword": "[variables('sqlAdministratorLoginPassword')]",
"version": "12.0"
}
}
],
"outputs": {
"MessageOne": {
"type" : "string",
"value": "[reference(variables('sqlserverName')).fullyQualifiedDomainName]"
}
}
}
Both the above mentioned templates are placed in Storage blob container.
Deployment:
Illustration of retrieval of FQDN from the deployment:
In the above example and illustration, the output property name in linked template is named as "MessageOne" and as we need FQDN of managed Azure SQL server so the value of that "MessageOne" output property is referenced to "fullyQualifiedDomainName".
And regarding finding all the supported parameters, one of the easiest ways is to get all the properties of any resource by using 'Get-Member' as shown in below example.
Hope this helps!! Cheers!!

eBay API issues - cannot publish an offer

All of the following is being performed in eBay's API sandbox.
I am attempting to list an item by using the inventory API. Specifically, I have created an inventory item and a relevant offer for that item. When I make a POST request to the publish offer endpoint, I get the following error:
{
"errors": [
{
"errorId": 25016,
"domain": "API_INVENTORY",
"subdomain": "Selling",
"category": "REQUEST",
"message": "The title value is invalid. Seller Provided Title Value is missing."
},
{
"errorId": 25002,
"domain": "API_INVENTORY",
"subdomain": "Selling",
"category": "REQUEST",
"message": "A user error has occurred. The duration \"GTC\" day(s) is not available for this listing type, or invalid for category \"49996\".",
"parameters": [
{
"name": "0",
"value": "GTC"
},
{
"name": "1",
"value": "49996"
}
]
}
]
}
I can't see any reference in any of the API documentation to a "Seller Provided Title". The duration error is also confusing as the API says it only supports "GTC" listings. The product has a title so it must be in reference to something else.
My inventory item is as follows:
{
"sku": "13725",
"product": {
"title": "Harley Davidson bike",
"aspects": {
"Year": [
"2016"
],
"Model": [
"Road Glide Special"
],
"Manufacurer": [
"Harley-Davidson®"
],
"Type": [
"Touring"
],
"For Sale By": [
"Dealer"
],
"Vehicle Title": [
"Clear"
],
"Mileage": [
"13393"
],
"VIN (Vehicle Identification Number)": [
"1HD1KTM10GB627264"
],
"Color": [
"Black Quartz"
]
},
"description": "Item description goes here",
"imageUrls": [
"https://dw4i9za0jmiyk.cloudfront.net/2018/01/12/pre_ic60e5df584b870c3d2a55c86800eede_70618b24eb08.jpg"
]
},
"condition": "USED_EXCELLENT",
"availability": {
"pickupAtLocationAvailability": [
{
"quantity": 1,
"merchantLocationKey": "425",
"availabilityType": "IN_STOCK",
"fulfillmentTime": {
"value": 1,
"unit": "DAY"
}
}
]
}
}
And my offer object is as follows:
{
"offerId": "5852159010",
"sku": "13725",
"marketplaceId": "EBAY_MOTORS",
"format": "FIXED_PRICE",
"availableQuantity": 0,
"pricingSummary": {
"price": {
"value": "18294.0",
"currency": "USD"
}
},
"listingPolicies": {
"paymentPolicyId": "5807565000",
"fulfillmentPolicyId": "5806186000"
},
"categoryId": "49996",
"merchantLocationKey": "425",
"tax": {
"applyTax": false
},
"status": "UNPUBLISHED",
"eBayPlusEligible": false
}
I had similar issues on sandbox, and came to the conculsion it was broken.
They also have some limits on only certain categories working.
Have you tried it agains the live API, I have found this to be far more reliable, ignoring the fact doing development work live is dangerous!
For your info here is my working code offer:
inventory_template = {
"availability": {
"shipToLocationAvailability": {
"quantity": product.quantity_available
}
},
"condition": "NEW",
"product": {
"aspects": {spec.name: [spec.value] for spec in product.specifics},
"brand": product.product_brand,
"description": product.product_description,
"imageUrls": [
"https://ebay.mydomain.co.uk/{}".format(img.image_link) for img in product.images],
"mpn": product.product_mpn,
"title": product.product_title,
"upc": [
product.product_upc,
],
"ean": [
product.product_ean,
],
# "epid": "string"
},
"sku": sku,
}
offer_body = {
"availableQuantity": offer.available_quantity,
"categoryId": offer.category_id,
"listingDescription": html,
"listingPolicies": {
"paymentPolicyId": offer.payment_policy_id,
"returnPolicyId": offer.return_policy_id,
"fulfillmentPolicyId": offer.fulfillment_policy_id,
},
"merchantLocationKey": offer.merchant_location_key,
"pricingSummary": {
"price": {
"value": offer.summary_price_value,
"currency": offer.summary_price_currency
}
},
"sku": offer.sku,
"marketplaceId": offer.marketplace_id,
"format": offer.format
}
the offer.available_quantity etc are items from my database, its the structure I'm showing.

How to update existing Knowledgebase using QnA Maker API v4.0?

I've successfully created my Knowledgebase using API.
But I forgot to add some alternative questions and metadata for one of the pairs.
I've noticed PATH method in the API to update the Knowledebase, so updating kb is supported.
I've created a payload which looked like this:
{
"add": {
},
"delete": {
},
"update": {
"qnaList": [
{
"id": 1,
"answer": "Answer",
"source": "link_to_source",
"questions": [
"Question 1?",
"Question 2?"
],
"metadata": [
{
"name": "oldMetadata",
"value": "oldMetadata"
},
{
"name": "newlyAddedMetaData",
"value": "newlyAddedMetaData"
}
]
}]}
}
I get back the following response HTTP 202 Accepted:
{
"operationState": "NotStarted",
"createdTimestamp": "2018-05-21T07:46:52Z",
"lastActionTimestamp": "2018-05-21T07:46:52Z",
"userId": "user_uuid",
"operationId": "operation_uuid"
}
So, looks like it worked. But in reality, this request doesn't take any affect.
When I check operation details, it returns me the following:
{
"operationState": "Succeeded",
"createdTimestamp": "2018-05-21T07:46:52Z",
"lastActionTimestamp": "2018-05-21T07:46:54Z",
"resourceLocation": "/knowledgebases/kb_uuid",
"userId": "user_uuid",
"operationId": "operation_uuid"
}
What am I doing wrong? And how should I update my kb via API properly?
Please help
I had the same problem, I discovered that it was necessary to have all the data of the json even if they were not used.
In your case you need "name" and "urls" in the "update" section and "Delete" in "update/qnaList/questions" section:
{
"add": {},
"delete": {},
"update": {
"name": "nameofKbBase", //this
"qnaList": [
{
"id": 2370,
"answer": "DemoAnswerEdit",
"source": "CustomSource",
"questions": {
"add": [
"DemoQuestionEdit"
],
"delete": [] //this
},
"metadata": { }
}
],
"urls": [] //this
}
}

OpenIDM - How to assign default groups when creating a user

I want to assign default roles (using AD groups) at the user creation in OpenIDM.
I already created and setted role assignments using the OpenIDM REST API but I want to add the user to AD groups without adding him a specific role.
Here is on of my role mapping :
{
"properties": {
"description": "Data Provider Role"
},
"assignments": {
"ad": {
"attributes": [
{
"name": "ldapGroups",
"assignmentOperation": "mergeWithTarget",
"unassignmentOperation": "removeFromTarget",
"value": [
"CN=GRP_SHARE_USERS,CN=Users,DC=acme,DC=com"
]
}
]
},
"alfresco": {
"attributes": [
{
"name": "groups",
"value": "ACMEUSER"
}
],
"onAssignment": {
"file": "roles/onAssignment_alfresco.groovy",
"type": "groovy"
},
"onUnassignment": {
"file": "roles/onUnassignment_alfresco.groovy",
"type": "groovy"
}
}
}
}
How to proceed ? Can I modify the ldapGroups property on the "onCreate" script ?