CreateObject Network Components - json

have been referring to the createObject API and as part of my request to order a virtual machine, I would like to configure the machine with both a public and a private interface. Here are the relevant parts of the JSON which works -
{
"parameters":[{
"hostname": "hostname-test",
"domain": "domain-test",
"startCpus": 8,
"maxMemory": 16384,
"hourlyBillingFlag": true,
"operatingSystemReferenceCode": "ubuntu_14_64",
"localDiskFlag": true,
"privateNetworkOnlyFlag": false,
"networkComponents": [
{
"maxSpeed": 1000
}
]
}]
}
However I would like to also set a limited public bandwidth, similar to the options presented on the web interface. Reading the network component structure as well as the above referenced create object call, am unable to decipher the fields for choosing a specific bandwidth.
I also find no mention of the bandwidth options in getCreateObjectOptions. Any help would be great.

all the available options for the createObject method are displayed using this method:
https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getCreateObjectOptions
In regards with the network configuration the method above will return values like this:
"networkComponents": [
{
"itemPrice": {
"hourlyRecurringFee": "0",
"recurringFee": "0",
"item": {
"description": "10 Mbps Public & Private Network Uplinks"
}
},
"template": {
"id": null,
"networkComponents": [
{
"maxSpeed": 10
}
],
"privateNetworkOnlyFlag": false
}
}
In the JSON above you can see the item "10 Mbps Public & Private Network Uplinks" if you want to configure that item in your order you need to follow the "template" configuration in this case it says that you need to add the follow configuration:
"networkComponents": [
{
"maxSpeed": 10
}
],
"privateNetworkOnlyFlag": false
That's it, however the createObject method has a drawback you only can configure the options displayed by the method getCreateObjectOptions, but the portal offers many other options which are not available using the createObject method. In case you need advanced options at the moment to order you need to use the placeOrder method this article could help you to undertand the placeOrder method:
https://sldn.softlayer.com/blog/bpotter/going-further-softlayer-api-python-client-part-3
Regards

Adding this here for posterity.
Here is a JSON template which can be used as a basis to build other configurations :
{
"parameters": [{
"imageTemplateId": null,
"location": "449500",
"packageId": 46,
"prices": [{
"hourlyRecurringFee": ".131",
"id": 30823,
"recurringFee": "87",
"item": {
"description": "8 x 2.0 GHz Cores"
}
}, {
"hourlyRecurringFee": ".153",
"id": 29663,
"recurringFee": "101.5",
"item": {
"description": "16 GB "
}
}, {
"hourlyRecurringFee": "0",
"id": 37204,
"recurringFee": "0",
"item": {
"description": "Ubuntu Linux 14.04 LTS Trusty Tahr - Minimal Install (64 bit)"
}
}, {
"hourlyRecurringFee": ".004",
"id": 26466,
"recurringFee": "2.9",
"item": {
"description": "100 GB (LOCAL)"
}
}, {
"hourlyRecurringFee": "0",
"id": 23070,
"recurringFee": "0",
"item": {
"description": "Reboot / Remote Console"
}
}, {
"hourlyRecurringFee": ".014",
"id": 23777,
"recurringFee": "5",
"item": {
"description": "1 Gbps Private Network Uplink"
}
}, {
"hourlyRecurringFee": "0",
"id": 34183,
"item": {
"description": "0 GB Bandwidth"
}
}, {
"hourlyRecurringFee": "0",
"id": 34807,
"recurringFee": "0",
"item": {
"description": "1 IP Address"
}
}, {
"hourlyRecurringFee": "0",
"id": 27023,
"recurringFee": "0",
"item": {
"description": "Host Ping"
}
}, {
"hourlyRecurringFee": "0",
"id": 32500,
"recurringFee": "0",
"item": {
"description": "Email and Ticket"
}
}, {
"hourlyRecurringFee": "0",
"id": 32627,
"recurringFee": "0",
"item": {
"description": "Automated Notification"
}
}, {
"hourlyRecurringFee": "0",
"id": 33483,
"recurringFee": "0",
"item": {
"description": "Unlimited SSL VPN Users & 1 PPTP VPN User per account"
}
}, {
"hourlyRecurringFee": "0",
"id": 35310,
"recurringFee": "0",
"item": {
"description": "Nessus Vulnerability Assessment & Reporting"
}
}],
"quantity": 1,
"sourceVirtualGuestId": null,
"sshKeys": [{
"sshKeyIds": [
12345
]
}],
"useHourlyPricing": true,
"virtualGuests": [{
"domain": "domain.test",
"hostname": "hostname.test"
}],
"complexType": "SoftLayer_Container_Product_Order_Virtual_Guest"
}]
}
Required ID's:
package id - obtained from SoftLayer_Product_Package->getAllObjects - it is the field "id"
price id - obtained from SoftLayer_Product_Package->getItemPrices - once again it is the field id (note there are several places where the same field name is used). This lists all the possible configurations that can go into a virtual machine. The above JSON selects a few of the options.
Finally with the JSON template, the order can be verified and placed.
(PS: Have tested this only with a virtual machine order. The SSH Key ID is an example and should be replaced with a valid ID.)

Related

Set Location in BIM360 Quality issue via API? (Rather than Location Details)

I am able to add Quality Issues through the BIM360 API (or associated APIs, link below) and I am able to set the Location Details. However, my customer uses the Location field, not Location Details. Is there any way to set the Location, specifically?
Here is the page for posting an item:
https://forge.autodesk.com/en/docs/bim360/v1/reference/http/field-issues-POST/
I don't see a location attribute or a location permitted attribute, just location details.
See image: https://i.stack.imgur.com/3OmZd.png
We can get the location id under the path attributes.lbs_location
{
"id": "038edfcf-t56y-4e04-a358-42c95f20c945",
"type": "quality_issues",
//...
"attributes": {
//...
"lbs_location": "d14ce3a6-e61b-4ab0-a9be-5acf7b5366df",
//...
},
// ...
}
To get corresponding location data, we need to call GET v2/containers/{containerId}/trees/{treeId}/nodes
{
"pagination": {
"limit": 2,
"offset": 0,
"totalResults": 2,
"nextUrl": null
},
"results": [
{
"id": "5add4375-f223-4201-88b9-8049e68416aa",
"parentId": null,
"type": "Root",
"name": "Project",
"description": "Project description",
"barcode": null,
"order": 0,
"documentCount": 0,
"areaDefined": false
},
{
"id": "d14ce3a6-e61b-4ab0-a9be-5acf7b5366df",
"parentId": "5add4375-f223-4201-88b9-8049e68416aa",
"type": "Area",
"name": "Area 1",
"description": "An Area 1 node",
"barcode": "ABC123",
"order": 0,
"documentCount": 2,
"areaDefined": true
}
]
}
To modify the location id for a quality issue, we can call PATCH issues/:id with the below payload:
{
"data": {
"type": "quality_issues",
"id": "038edfcf-t56y-4e04-a358-42c95f20c945",
"attributes": {
"lbs_location": "d14ce3a6-e61b-4ab0-a9be-5acf7b5366df"
}
}
}

error occurred while deploying a module to iot edge device (ErrorCode:Argumentinvalid)

I'm trying to deploy a Modbus module from iot hub to iot edge device but i'm having some difficulties.
Docker Image I used:
mcr.microsoft.com/azureiotedge/modbus:1.0
Container Create Option:
(I have used this beacuse i'm using this module to read data from a modbus rtu device)
{
"HostConfig": {
"Devices": [
{
"PathOnHost": "/dev/ttyS0",
"PathInContainer": "/dev/ttyS0",
"CgroupPermissions": "rwm"
}
]
}
}
Module Twine Setings:
{
"properties.desired":{
"PublishInterval": "5000",
"SlaveConfigs": {
"Slave01": {
"SlaveConnection": "<IPV4 address>",
"TcpPort": "502",
"RetryCount": "10",
"RetryInterval": "100",
"HwId": "PowerMeter-0a:01:01:01:01:01",
"Operations": {
"Op01": {
"PollingInterval": "2000",
"UnitId": "1",
"StartAddress": "400001",
"Count": "2",
"CorrelationId": "MessageType1",
"DisplayName": "Voltage"
},
"Op02": {
"PollingInterval": "2000",
"UnitId": "1",
"StartAddress": "400002",
"Count": "2",
"CorrelationId": "MessageType2",
"DisplayName": "Current"
}
}
},
"Slave02": {
"SlaveConnection": "/dev/ttyS0",
"RetryCount": "10",
"RetryInterval": "50",
"HwId": "mfm",
"BaudRate": "9600",
"DataBits": "8",
"StopBits": "1",
"Parity": "NONE",
"FlowControl": "NONE",
"Operations": {
"Op01": {
"PollingInterval": "2000",
"UnitId": "1",
"StartAddress": "40001",
"Count": "2",
"DisplayName": "Voltage"
},
"Op02": {
"PollingInterval": "2000",
"UnitId": "1",
"StartAddress": "40002",
"Count": "2",
"DisplayName": "Current"
}
}
}
}
}
}
Error:
Set Modules
An error occurred while submitting. The request contained incorrectly formatted information.
Details: ErrorCode:Argumentinvalid; Property or Tag name has invalid characters. Error in Property/Tag properties.desired. Must not contain Control Characters,
'.', '$', '#', or ''.
GitHub link with tutorial
It appears that you should make "desired" a separate node in your JSON. e.g.:

Compare 2 cucumber JSON reports with ruby

The problem is: I have 2 cucumber test reports in JSON format
I need to remove redundant key-value pairs from those reports and compare them, but I can't understand how to remove the unnecessary data from those 2 jsons because of their structure after JSON.parse (array or hash with many nested arrays/hashes). Please advice if there are some gems or known solutions to do this
JSON structure is e.g. :
[
{
"uri": "features/home_screen.feature",
"id": "as-a-user-i-want-to-explore-home-screen",
"keyword": "Feature",
"name": "As a user I want to explore home screen",
"description": "",
"line": 2,
"tags": [
{
"name": "#home_screen",
"line": 1
}
],
"elements": [
{
"keyword": "Background",
"name": "",
"description": "",
"line": 3,
"type": "background",
"before": [
{
"match": {
"location": "features/step_definitions/support/hooks.rb:1"
},
"result": {
"status": "passed",
"duration": 505329000
}
}
],
"steps": [
{
"keyword": "Given ",
"name": "I click OK button in popup",
"line": 4,
"match": {
"location": "features/step_definitions/registration_steps.rb:91"
},
"result": {
"status": "passed",
"duration": 2329140000
}
},
{
"keyword": "And ",
"name": "I click Allow button in popup",
"line": 5,
"match": {
"location": "features/step_definitions/registration_steps.rb:96"
},
"result": {
"status": "passed",
"duration": 1861776000
}
}
]
},
Since you are asking for a gem, you might try iteraptor I have created exactly for this kind of tasks.
It allows iterating, mapping and reducing the deeply nested structures. For instance, to filter out all the keys called "name" on all levels, you might do:
input.iteraptor.reject(/name/)
The more detailed description might be found on the github page linked above.

Getting an API generated in-person signing envelope tracked through Salesforce Connect

I'm using the rest API to create an in person signing session from salesforce. My envelope creation json is like this:
{
"documents": [{
"documentBase64": "'+base64EncodedDocToSign+'",
"documentId": "1",
"fileExtension": "pdf",
"name": "contract.pdf"
}
],
"emailSubject": "Please Sign",
"recipients": {
"inPersonSigners": [{
"email": "some#gsome.com",
"name": "Luis",
"hostEmail": "some#gsome.com",
"hostName": "Luis",
"signerEmail": "other#gother.com",
"signerName": "Charles",
"recipientId": "1",
"tabs": {
"signHereTabs": [{
"anchorString": "s1",
"anchorXOffset": "0",
"anchorYOffset": "0",
"anchorIgnoreIfNotPresent": "false",
"anchorUnits": "inches"
}
]
},
"routingOrder": "1",
"clientUserId": "1000",
"embeddedRecipientStartURL": "SIGN_AT_DOCUSIGN",
}
]
},
"status": "sent"
}
The next step would be for the object to be tracked using Connect. Connect is properly configured for the object and works if I "Sign with Docusign" or use a custom button.
I understand I must change the json to include the DSFSSourceObjectId custom field, with value equal to the Id of the object that is originating the request, but if I try to get a customField in there the json is not properly formatted anymore.
I tried adding the customField like:
...
}
]
},
"customFields": [
{
"Name": "DSFSSourceObjectId",
"Value": "' + objectId + '"
}
],
"status": "sent"
}
Is this viable?
I got this working adding the following to the JSON:
"customFields": {
"textCustomFields": [{
"value": "salesforceId",
"required": "false",
"show": "false",
"name": "DSFSSourceObjectId"
}
]
},

How do I make a QBO v3 API Create, Update, and Delete Request with a JSON body

I'm constructing my own HTTP requests for use with the QuickBooks Online v3 REST API, 'rolling my own' in the words of Keith Palmer - Consolibyt's response to this post.
I particular, I want to create, update, and delete transactions and names using JSON-formatted request bodies. The documentation is very sparse with JSON examples, so this is all I could find:
{
...
"domain":"QBO"
"sparse":{"true","false"}
...
}
The API gives XML examples for creating, updating, and deleting transactions, and I have been able to use those in the API explorer successfully. (For other reasons, though, I don't want to work with XML. I want to work in JSON.)
In trying to figure out how to do the same thing with JSON, I did a read of an existing JournalEntry (in the API Explorer), getting this response and planning to build the request body starting from here:
{
"JournalEntry": {
"Adjustment": false,
"domain": "QBO",
"sparse": false,
"Id": "1056",
"SyncToken": "2",
"MetaData": {
"CreateTime": "2014-02-07T13:21:51-08:00",
"LastUpdatedTime": "2014-02-07T13:29:53-08:00"
},
"DocNumber": "4",
"TxnDate": "2014-02-08",
"CurrencyRef": {
"value": "USD",
"name": "United States Dollar"
},
"Line": [
{
"Id": "0",
"Description": "test entry",
"Amount": 102.0,
"DetailType": "JournalEntryLineDetail",
"JournalEntryLineDetail": {
"PostingType": "Credit",
"AccountRef": {
"value": "57",
"name": "Miscellaneous Income"
}
}
},
{
"Id": "1",
"Description": "test entry (UPDATED!)",
"Amount": 252.0,
"DetailType": "JournalEntryLineDetail",
"JournalEntryLineDetail": {
"PostingType": "Debit",
"AccountRef": {
"value": "29",
"name": "6240 Miscellaneous"
}
}
},
{
"Id": "2",
"Description": "test entry",
"Amount": 150.0,
"DetailType": "JournalEntryLineDetail",
"JournalEntryLineDetail": {
"PostingType": "Credit",
"AccountRef": {
"value": "82",
"name": "12100 Inventory Asset"
}
}
}
]
},
"time": "2014-02-07T14:21:16.181-08:00"
}
Here's the request body I'm using for an Update operation (on the same JournalEntry page of the API Explorer) -- note that I'm only changing the DocNumber (from 4 to 12345):
{
"Adjustment": false,
"domain": "QBO",
"sparse": false,
"Id": "1056",
"SyncToken": "2",
"MetaData": {
"CreateTime": "2014-02-07T13:21:51-08:00",
"LastUpdatedTime": "2014-02-07T13:29:53-08:00"
},
"DocNumber": "12345",
"TxnDate": "2014-02-08",
"CurrencyRef": {
"value": "USD",
"name": "United States Dollar"
},
"Line": [
{
"Id": "0",
"Description": "test entry",
"Amount": 102.0,
"DetailType": "JournalEntryLineDetail",
"JournalEntryLineDetail": {
"PostingType": "Credit",
"AccountRef": {
"value": "57",
"name": "Miscellaneous Income"
}
}
},
{
"Id": "1",
"Description": "test entry (UPDATED!)",
"Amount": 252.0,
"DetailType": "JournalEntryLineDetail",
"JournalEntryLineDetail": {
"PostingType": "Debit",
"AccountRef": {
"value": "29",
"name": "6240 Miscellaneous"
}
}
},
{
"Id": "2",
"Description": "test entry",
"Amount": 150.0,
"DetailType": "JournalEntryLineDetail",
"JournalEntryLineDetail": {
"PostingType": "Credit",
"AccountRef": {
"value": "82",
"name": "12100 Inventory Asset"
}
}
}
]
}
Here's the Response Body I get back:
{"Fault":{"Error":[{"Message":"An application error has occurred while processing your request","Detail":"System Failure Error: null","code":"10000"}],"type":"SystemFault"},"time":"2014-02-07T14:36:18.888-08:00"}
I'm also trying a sparse update, as per these instructions, just to keep things simple. The request body:
{
"sparse": "true",
"Id": "1056",
"SyncToken": "2",
"DocNumber": "12345"
}
The response body I get back (in bright red):
{"Fault":{"Error":[{"Message":"An application error has occurred while processing your request","Detail":"System Failure Error: null","code":"10000"}],"type":"SystemFault"},"time":"2014-02-07T14:05:05.197-08:00"}
I have a feeling the problem here is something small. Can you point out what it is? Alternatively, if you have a working example of a JSON request body (for create, update, and delete operations of a transaction, ideally), that would be very helpful too (as hopefully I could use it as a template).
You need to add Accept : application/json to your header.