How to correlate Docker image list with tag list both as returned by API? - image

One can do
curl https://index.docker.io/v1/repositories/ubuntu/images
which yields
{ {"checksum": "", "id": "76ca2fd907879906ba5c936738ccce0b577590040ac8d288f07afb3d34ae8b03"}, ... }
One can also do
curl https://index.docker.io/v1/repositories/ubuntu/tags
which yields
{ {"layer": "5ba9dab4", "name": "latest"}, {"layer": "3db9c44f", "name": "10.04"}, ... }
How can you now correlate the image IDs with the tag names? Can you rely on the order of the items? Can you get the image id from the shorthand layer id?

The layer is the first 8 characters of the image id.

Related

How i can get list of popular youtube channels per each country?

How i can get list of popular youtube channels per each country?
this service find solution
https://www.channelcrawler.com/eng/results2/281574
I tried youtube api but i didn't find, anyone know solution?
As mentioned, is not possible to get this information using the YouTube API directly, even in the FAQ of the page you shared says:
The Channel Crawler was made to discover new YouTube channels, based on your search criteria.
and:
The Channel Crawler uses advanced data collection methods in order to collect channel information from YouTube and store it in the database. Basically, it just checks the liked videos and comment sections of channels that are already in the database, in order to add more channels to it. You can also manually add a channel.
Following the highlighted information, I have this idea and you can try it too:
Use the search endpoint for search channels in a specific country and in a specific videoCategory, then, with the channelId returned in the results of the search, use the channel endpoint for get their country1.
1 take into account that some channels doesn't have the country value; in this case, you have to set another criteria(s) for determine whether the channel matches with your requirements.
Example:
Use the search endpoint for search channels in country/region Pakistan and in the videoCategory Sports - test it here:
URL:
https://youtube.googleapis.com/youtube/v3/search?part=id%2Csnippet&order=videoCount&q=Sports&regionCode=PK&key=[YOUR_API_KEY]
The results of this request are as follows:
{
"kind": "youtube#searchListResponse",
"etag": "0C7hSI3oNXJt66PsERuviVQcLCo",
"nextPageToken": "CAUQAA", // Remember the nextPageToken for get the next results.
"regionCode": "PK", // Region queried.
"pageInfo": {
"totalResults": 1000000, // Look the amount of data you have to check, filter and debug.
"resultsPerPage": 5 // Set "maxResults" parameter to "50" for get more results per page.
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "iSwEnBs_yV6lOIBubmRXVwjjujQ",
"id": {
"kind": "youtube#channel", // Make sure that this item is actually an channel.
"channelId": "UCo2TvjBHS1BtyIkeGGTMe6w"
},
"snippet": {
"publishedAt": "2018-07-28T18:34:04Z",
"channelId": "UCo2TvjBHS1BtyIkeGGTMe6w", // Use this value for the "channel" endpoint.
"title": "ONTime Sports",
"description": "قناة اون تايم سبورت واحدة من مجم...",
"thumbnails": { [thumbnails here...] },
"channelTitle": "ONTime Sports",
"liveBroadcastContent": "upcoming",
"publishTime": "2018-07-28T18:34:04Z"
}
},
[other results here...]
]
}
Use channel endpoint for get the channel detailed information - in this case, their country - test it here:
URL - using the channelId UCo2TvjBHS1BtyIkeGGTMe6w - obtained from the previous search results:
https://youtube.googleapis.com/youtube/v3/channels?part=id%2Csnippet&id=UCo2TvjBHS1BtyIkeGGTMe6w&key=[YOUR_API_KEY]
The results of this request are as follows:
{
"kind": "youtube#channelListResponse",
"etag": "8BfUXxlAEBLe7lBmih1JXUwZ394",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "AFk5NCl9393ui58WyRf7WljoatE",
"id": "UCo2TvjBHS1BtyIkeGGTMe6w",
"snippet": {
"title": "ONTime Sports",
"description": "large description here...",
"customUrl": "ontimesportseg",
"publishedAt": "2018-07-28T18:34:04Z",
"thumbnails": {[thumbnails here]},
"localized": {
"title": "ONTime Sports",
"description": "large description here..."
},
"country": "EG" // This is the regionCode of the country this channels has provided.
}
}
]
}
Here, you can see that the value "country" for this channel is "EG" = Egypt2.
Then, repeat these steps with all countries and videoCategory for each country.
Considerations:
As I tested, the type parameter in search is not working as one might expect, in this case (for get channels only), use the order=viewCount combination of parameter=value. Even with this combination, make sure to check that the value of the kind attribute is: youtube#channel. Also, I search the videoCategory using its name, no its id - as it should be -, but, the API is not perfect, that's why I used the name of the videoCategory.
Even specifiyng the region parameter with a valid country, you might get results that are either from another countries or doesn't have the country attribute and value at all = and that's due the channel's popularity in the given country and public channel information. A simple example could be: ESPN, they probably have a YouTube channel for each country, but, their main channel is the most popular in all countries, so, in this case, you'll get the ESPN channel in english and that might differ from your expected results. You have to work with what YouTube provides.
As you notice, there are too many channels/results to debug, so, make sure to provide more filters and set your queries/search criteria and (once you get the desired results), store the valid results in a database or similar.
If you know specific channels that you know are popular in a given country, but, when you query that channel using the YouTube Data API, it doesn't bring the country value, you have to save that channel manually in your database and/or collect more information for automatically set if a channel is from a given country - this point is very related to my point # 2.

Retrive additional tag info in json response

When i use get method on the below bright cove api to retrive video meta data, it generates json response with some fields.
"https://cms.api.brightcove.com/v1/accounts/510000340001/videos?sort=-updated_at&limit=1&offset=0"
How do we get additional tags which are not included, say for example 'category' field in the output json response?
I tried to append below in url and api does not detect.
?custom_field=category
If the video has a value set for that field, it will be present in the custom_fields object as below. If the field is empty, it will not be included for that video.
{
"name": "A video",
...
"custom_fields": {
"category": "something"
}
}

SoftLayer_Virtual_Guest_Block_Device_Template_Group::editObject update datacenters

The createFromExternalSource method does not allow you to specify a list of datacenters to enable the image to be used. I can get the image imported, but then when I then go to edit the image template to augment the datacenters, I always get:
{"error":"Object does not exist to execute method on.
(SoftLayer_Virtual_Guest_Block_Device_Template_Group::editObject)","code":"SoftLayer_Exception"}
Does anyone have a proper example of using editObject for SoftLayer_Virtual_Guest_Block_Device_Template_Group using JSON not XMLRPC like the slcli does?
Preferred if some has a curl example which updates attributes on SoftLayer_Virtual_Guest_Block_Device_Template_Group object would be awesome.
To update the datacenters of an image template you have to use the method “setAvailableLocations” of the service SoftLayer_Virtual_Guest_Block_Device_Template_Group.
The method editObject just edit an image template group's name and note.
You can use this curl example to update the datacenters of an imagen template:
curl -d #post.json -k https://[username]:[apiKey]#api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest_Block_Device_Template_Group/1722867/setAvailableLocations.json | python -mjson.tool
You have to add in this curl example the json file “#post.json”, where is the image template body.
The json file must contain the following data:
{
"parameters": [
[
{
"id": 265592
},
{
"id": 814994
},
{
"id": 138124
},
{
"id": 154820
},
{
"id": 449600
}
]
]
}
To get the datacenters ids you can use this curl command example:
curl -k "https://[username]:[apiKey]#api.softlayer.com/rest/v3/SoftLayer_Location/getDatacenters.json" | python -mjson.tool

Custom unicode sorting order for PouchDB/CouchDB Index (Mango Query)

I am using PouchDB (with a Cloudant remote database) to have a local database in a dictionary web app.
I need to have an index with a custom Pashto alphabet order (using Arabic unicode letters).
The localdb.find queries with $gte (alphabetically searching with partial words) do not work well because of the irregular Unicode characters in the Pashto alphabet.
Is it possible to create a custom sort, based on the Pashto alphabet, for an index?
See Mango Query Language
In this reference it is mentioned that:
The most important feature of a view result is that it is sorted by key.
Assume you have a database consisting of docs with a unicodeString field inside each doc. So a sample doc would look like below:
{
"_id":"2018-01-30-18-04-11",
"_rev":"AE19EBC7654",
"title":"Hello elephant",
"unicodeString":"שלום פיל",
}
Now you can have a CouchDB view with a map function like this:
function(doc) {
emit(doc.unicodeString, doc.title); // doc.unicodeString is key
// doc.title is value
}
The above view sorts all the docs inside the database according to its key which is doc.unicodeString. Therefore, if you use the above view, all of your docs would be sorted based on your Unicode string inside docs.
If you have 3 docs in database, when you query the above view, you receive a response result like this in which rows array is sorted according to key in each row:
{
"total_rows": 3,
"offset": 0,
"rows": [
{
"key": "ארץ",
"id": "2017-09-01-09-05-11",
"value": "Earth"
},
{
"key": "בין",
"id": "2015-01-19-11-30-28",
"value": "between"
},
{
"key": "שלום פיל",
"id": "2018-01-30-18-04-11",
"value": "Hello elephant"
}
]
}

transfer a sibling element in a reponse to a parameter in Ready API / SOAP UI

I have one REST endpoint which returns a response like this
[
{
"id": "dbfff519-e8f6-4db3-9e26-a4e9014dc360",
"code": "123456789012345678901234567890123456789012345678901234567890",
"name": "client-code-with-character-length-sixty",
},
{
"id": "a673fb54-3503-4996-ba9b-a4e9014dc3ea",
"code": "18MTH",
"name": "18 Month",
},
{
"id": "60b781e3-4515-40f5-81ee-a4e9014dc400",
"code": "2periods",
"name": "I Have 2 Periods",
}...
etc.
I would like to be able to retrieve the ID where, for example, the code="2periods" UI can retrieve using either ResponseAsxml (with xpath) or Response with JSONPath. If I use the former I have managed to get the following to nearly retrieve my ID
//Response[1]/e[code='2periods']/id
BUT this looks like this
<id>0bc4aa5f-f8ab-4efe-b788-a4e9014dc45f</id>
And I don't know how to remove the start and end tags, the id has to be just the GUID.
I can't work out how to do something similar in the JSONPath - I've only managed to get something like
$[3].id
to work, but the order of the entities is not guaranteed in the test environment.
For ResponseAsXml using the XPath to get only the id value without <id> tag just add /text() to your actual expression:
//Response[1]/e[code='2periods']/id/text()
If you want to do the same using Response property with JSONPath try with:
$..[?(#.['code']=='2periods')].id[0]
Hope it helps,

Resources