Get list of files name and path in whole google cloud with a particular file extension using NodeJS - node.js

I have a google cloud bucket which is having the files with the extension .jtl, I need to get these file names and paths irrespective of the nesting of folders they are in using NodeJS.
How can we do that!

I think this link might help you
https://cloud.devsite.corp.google.com/storage/docs/json_api/v1/objects/list
You can try this API, and give the preferred parameters present in that,
for example: in your case you can give delimiter as jtl, and then you can copy the curl command or http or node JS as you prefer and execute this in your google cloud platform
The command will look something like this:
curl
'https://storage.googleapis.com/storage/v1/b/xyz12345/o?delimiter=jpg&includeTrailingDelimiter=true&key=[YOUR_API_KEY]'
--header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]'
--header 'Accept: application/json'
--compressed
Provide your API key and Access token to be able to run this in your google cloud platform.

Related

Continuous deployment gitlab

Line of my .gitlab-ci.yml
IID=$(curl --verbose --request GET --header "Content-Type: application/json" --header "PRIVATE-TOKEN: ${CI_PUSH_TOKEN}" ${APP_REPO_URL}/merge_requests?author_id=xxxxxxxx\&search=${CI_COMMIT_SHORT_SHA} | jq '.[0].iid')
output jq: error (at :0): Cannot index object with number
Please refer to the documentation on Merge requests API and How to use the API to construct a properly formed cURL request with GitLab API before piping the result into jq.
There are a few things going on with your query.
First of all, according to the documentation, the /merge_requests endpoint will
Get all merge requests the authenticated user has access to.
This means that APP_REPO_URL needs to be the GitLab instance URL followed by /api/v4 and not the URL of the specific project.
curl "https://gitlab.example.com/api/v4/merge_requests"
If you need all merge requests for a given project, then you can use
curl "https://gitlab.example.com/api/v4/projects/:id/merge_requests"
where :id is the id of your project. See more at List project merge requests
Then, the search attribute is expecting either a title or a description and not a commit SHA:
Search merge requests against their title and description

Limit sharepoint search API results to some geo locations

In a multi geo environment I would like to execute a SharePoint REST API search and limit it to some geo locations only as described in the microsoft multi geo documentation. I have tried the GET as well as POST requests, but all settings in my MultiGeoSearchConfiguration are ignored, I am always getting the full result list from all geo locations.
What am I doing wrong here? Is it maybe the missing sourceId that I have now idea of where to find?
curl --location -g --request GET 'https://<mydev>.sharepoint.com/_api/search/query?querytext=%27test%27&ClientType=%27cb991e32-6ce4-4e98-a91b-4eea9a874962%27&Properties=%27EnableMultiGeoSearch:true,%20MultiGeoSearchConfiguration:[{DataLocation\:%22EUR%22\,Endpoint\:%22https\://<mydev>EUR.sharepoint.com%22}]%27' --header 'Accept: application/json' --header 'Authorization: Bearer ...'
(<mydev> is exchanged for my real sharepoint of course)
In your API request, you have the EnableMultiGeoSearch:true and according to the documentation provided, it mentions that if this parameter is set to true, "the query shall be fanned out to the indexes of other geo locations of the multi-geo tenant", have you tried setting this value to false?

Azure: Parameter 'requestid' value is invalid

I'm trying to use the Microsoft Speech API as documented here: https://www.microsoft.com/cognitive-services/en-us/Speech-api/documentation/GetStarted/GetStarted-cURL
I have a key and I authenticate fine. When I try to use the service I get this error:
Parameter 'requestid' value '1234844532343434' is invalid.
I've tried different types of numbers and strings with no luck. What format is Azure looking for in requestid?
My test script looks like this:
token="..."
requestid="1234844532343434"
curl -v -X POST "https://speech.platform.bing.com/recognize?scenarios=smd&appid=D4D52672-91D7-4C74-8AD8-42B1D98141A5&locale=your_locale&device.os=your_device_os&version=3.0&format=json&instanceid=your_instance_id&requestid=${requestid}" -H "Authorization: Bearer ${token}" -H 'Content-type: audio/wav; codec="audio/pcm"; samplerate=16000' --data-binary #man1_nb.wav
Based on the documentation here, the requestid parameter's value should be a GUID.
Please try using that.

How to show if a camera is online with the nest api

I'm working on a website that contains multiple Nest cameras and I wonder if it is possible to display if a camera is online before a user clicks on the link to view this cam.
I would do it with a XMLRequest in javascript but I cant find how to do it.
You would make a REST call for it, HTTP GET specifically. The request url would look like this:
https://developer-api.nest.com/devices/cameras/<device_id>/is_online?auth=<auth_token>
Using cURL it would look like this:
curl -v -L -H
"Authorization: Bearer <auth_token>"
-X GET "https://developer-api.nest.com/devices/cameras/<device_id>/is_online"
Reference: https://developer.nest.com/documentation/api-reference/overview#cameras

Getting pronunciation of a word using Google Translate API

I am trying to save the pronunciation of a French word into a .wav or .mp3 file.
I was wondering if there was anywhere on the Google Translate API (since it has a pronunciation functionality) that allows me to achieve this objective. Other libraries would work too.
Since this question was asked, it's gotten much harder to "scrape" MP3s from Google Translate, but Google has (finally) set up a TTS API. Interestingly it is billed in input characters, with the first 1 or 4 million input characters per month being free (depending on whether you use WaveNet or old school voices)
Nowadays to do this using gcloud on the command line (versus building this into an app) you would do roughly as follows (I'm paraphrasing the TTS quick start). You need base64, curl, gcloud, and jq for this walkthrough.
Create a project on the GCP console, or run something like gcloud projects create example-throwaway-tts
Enable billing for the project. Do this even if you don't intend to exceed the freebie quota.
Use the GCP console to enable the TTS API for the project you just set up.
Use the console again, this time to make a new service account.
Use any old name
Don't give it a role. You'll get a warning. This is okay.
Select key type JSON if it isn't already selected
Click Create
Hold onto the JSON file that your browser downloads
Set an environment variable to point at that file, e.g. export GOOGLE_APPLICATION_CREDENTIALS="~/Downloads/service-account-file.json"
Get the appropriate access token:
Tell gcloud to use that new project: gcloud config set project example-throwaway-tts
Set a variable TTS_ACCESS_TOKEN=gcloud auth application-default print-access-token
Put together a JSON request. I'll give an example below. For this example we'll call it request.json
Lastly, run the following
curl \
-H "Authorization: Bearer "$TTS_ACCESS_TOKEN \
-H "Content-Type: application/json; charset=utf-8" \
--data-raw #request.json \
"https://texttospeech.googleapis.com/v1/text:synthesize" \
| jq '.audioContent' \
| base64 --decode > very_simple_example.mp3
What this does is to
authenticate using the default access token for the project you set up
set the content type to JSON (so that jq can extract the payload)
use request.json as the data to send using curl's --data-raw flag
extract the value of audioContent from the response
base64 decode that content
save the whole mess as an MP3
Contents of request.json follow. You can see where to insert your desired text, adjust the voice or change output formats via audioConfig:
{
'input':{
'text':'very simple example'
},
'voice':{
'languageCode':'en-gb',
'name':'en-GB-Standard-A',
'ssmlGender':'FEMALE'
},
'audioConfig':{
'audioEncoding':'MP3'
}
}
Original Answer
As Hugolpz alludes, if you know the word or phrase you want (via a previous Translate API call), you can get MP3s from a URL like http://translate.google.com/translate_tts?ie=UTF-8&q=Bonjour&tl=fr
Note that &tl=fr ensures that you get French instead of the default English.
You will need to rate-limit yourself, but if you're looking for a small number of words or phrases you should be fine.
Similar functionality is provided by the Speech Synthesis API (under development). Third-party libraries are already there, such as ResponsiveVoice.JS.

Resources