From 45c5b979e0ca373e75dbed9992d321931147d4e0 Mon Sep 17 00:00:00 2001 From: Raul Marin Date: Fri, 1 Feb 2019 11:17:00 +0100 Subject: [PATCH 1/2] https --- doc/batch_queries.md | 32 ++++++++++++++++---------------- docs/guides/03-batch-queries.md | 32 ++++++++++++++++---------------- docs/guides/09-copy-queries.md | 10 +++++----- docs/reference/swagger.yaml | 4 ++-- 4 files changed, 39 insertions(+), 39 deletions(-) diff --git a/doc/batch_queries.md b/doc/batch_queries.md index d115edfa..caf98acb 100644 --- a/doc/batch_queries.md +++ b/doc/batch_queries.md @@ -25,7 +25,7 @@ Using cURL tool: ```bash curl -X POST -H "Content-Type: application/json" -d '{ "query": "{query}" -}' "http://{username}.carto.com/api/v2/sql/job?api_key={api_key}" +}' "https://{username}.carto.com/api/v2/sql/job?api_key={api_key}" ``` Using Node.js request client: @@ -35,7 +35,7 @@ var request = require("request"); var options = { method: "POST", - url: "http://{username}.carto.com/api/v2/sql/job", + url: "https://{username}.carto.com/api/v2/sql/job", qs: { "api_key": "{api_key}" }, @@ -124,7 +124,7 @@ If you are using the Batch Query create operation for a cURL POST request, use t ```bash curl -X POST -H "Content-Type: application/json" -d '{ "query": "CREATE TABLE world_airports AS SELECT a.cartodb_id, a.the_geom, a.the_geom_webmercator, a.name airport, b.name country FROM world_borders b JOIN airports a ON ST_Contains(b.the_geom, a.the_geom)" -}' "http://{username}.carto.com/api/v2/sql/job" +}' "https://{username}.carto.com/api/v2/sql/job" ``` If you are using the Batch Query create operation for a Node.js client POST request, use the following code: @@ -134,7 +134,7 @@ var request = require("request"); var options = { method: "POST", - url: "http://{username}.carto.com/api/v2/sql/job", + url: "https://{username}.carto.com/api/v2/sql/job", headers: { "content-type": "application/json" }, body: { query: "CREATE TABLE world_airports AS SELECT a.cartodb_id, a.the_geom, a.the_geom_webmercator, a.name airport, b.name country FROM world_borders b JOIN airports a ON ST_Contains(b.the_geom, a.the_geom)" @@ -177,7 +177,7 @@ BODY: { If you are using the Batch Query read operation for a cURL GET request, use the following code: ```bash -curl -X GET "http://{username}.carto.com/api/v2/sql/job/{job_id}" +curl -X GET "https://{username}.carto.com/api/v2/sql/job/{job_id}" ``` If you are a Batch Query read operation for a Node.js client GET request, use the following code: @@ -187,7 +187,7 @@ var request = require("request"); var options = { method: "GET", - url: "http://{username}.carto.com/api/v2/sql/job/{job_id}" + url: "https://{username}.carto.com/api/v2/sql/job/{job_id}" }; request(options, function (error, response, body) { @@ -238,7 +238,7 @@ errors: [ If you are using the Batch Query cancel operation for cURL DELETE request, use the following code: ```bash -curl -X DELETE "http://{username}.carto.com/api/v2/sql/job/{job_id}" +curl -X DELETE "https://{username}.carto.com/api/v2/sql/job/{job_id}" ``` If you are using the Batch Query cancel operation for a Node.js client DELETE request, use the following code: @@ -248,7 +248,7 @@ var request = require("request"); var options = { method: "DELETE", - url: "http://{username}.carto.com/api/v2/sql/job/{job_id}", + url: "https://{username}.carto.com/api/v2/sql/job/{job_id}", }; request(options, function (error, response, body) { @@ -317,7 +317,7 @@ curl -X POST -H "Content-Type: application/json" -d '{ "DROP TABLE airports", "ALTER TABLE world_airports RENAME TO airport" ] -}' "http://{username}.carto.com/api/v2/sql/job" +}' "https://{username}.carto.com/api/v2/sql/job" ``` If you are using the Chained Batch Query operation for a Node.js client POST request, use the following code: @@ -327,7 +327,7 @@ var request = require("request"); var options = { method: "POST", - url: "http://{username}.carto.com/api/v2/sql/job", + url: "https://{username}.carto.com/api/v2/sql/job", headers: { "content-type": "application/json" }, body: { "query": [ @@ -358,7 +358,7 @@ curl -X PUT -H "Content-Type: application/json" -d '{ "ALTER TABLE world_airports RENAME TO airport", "UPDATE airports SET airport = upper(airport)" ] -}' "http://{username}.carto.com/api/v2/sql/job/{job_id}" +}' "https://{username}.carto.com/api/v2/sql/job/{job_id}" ``` If you are using the Chained Batch Query operation for a Node.js client PUT request, use the following code: @@ -368,7 +368,7 @@ var request = require("request"); var options = { method: "PUT", - url: "http://{username}.carto.com/api/v2/sql/job/{job_id}", + url: "https://{username}.carto.com/api/v2/sql/job/{job_id}", headers: { "content-type": "application/json" }, body: { query: [ @@ -405,7 +405,7 @@ curl -X POST -H "Content-Type: application/json" -d '{ "onerror": "UPDATE market_status SET status = 'outdated' WHERE table_name = 'nasdaq'" }] } -}' "http://{username}.carto.com/api/v2/sql/job" +}' "https://{username}.carto.com/api/v2/sql/job" ``` If query finishes successfully, then onsuccess fallback will be fired. Otherwise, onerror will be fired. You can define fallbacks per query: @@ -423,7 +423,7 @@ curl -X POST -H "Content-Type: application/json" -d '{ "onerror": "UPDATE market_status SET status = 'outdated' WHERE table_name = 'down_jones'" }] } -}' "http://{username}.carto.com/api/v2/sql/job" +}' "https://{username}.carto.com/api/v2/sql/job" ``` ...at the job level.. @@ -439,7 +439,7 @@ curl -X POST -H "Content-Type: application/json" -d '{ "onsuccess": "UPDATE market_status SET status = 'updated', updated_at = NOW()", "onerror": "UPDATE market_status SET status = 'outdated'" } -}' "http://{username}.carto.com/api/v2/sql/job" +}' "https://{username}.carto.com/api/v2/sql/job" ``` If a query of a job fails (and onerror fallbacks for that query and job are defined), then Batch Queries runs the first fallback for that query. The job fallback runs next and sets the job as failed. Remaining queries will not be executed. Furthermore, Batch Queries will run the onsuccess fallback at the job level, if (and only if), every query has finished successfully. @@ -461,7 +461,7 @@ curl -X POST -H "Content-Type: application/json" -d '{ }], "onerror": "INSERT INTO errors_log (job_id, error_message, date) VALUES ('<%= job_id %>', '<%= error_message %>', NOW())" } -}' "http://{username}.carto.com/api/v2/sql/job" +}' "https://{username}.carto.com/api/v2/sql/job" ``` More templates are coming soon. diff --git a/docs/guides/03-batch-queries.md b/docs/guides/03-batch-queries.md index c82575f0..5d408117 100644 --- a/docs/guides/03-batch-queries.md +++ b/docs/guides/03-batch-queries.md @@ -25,7 +25,7 @@ Using cURL tool: ```bash curl -X POST -H "Content-Type: application/json" -d '{ "query": "{query}" -}' "http://{username}.carto.com/api/v2/sql/job?api_key={api_key}" +}' "https://{username}.carto.com/api/v2/sql/job?api_key={api_key}" ``` Using Node.js request client: @@ -35,7 +35,7 @@ var request = require("request"); var options = { method: "POST", - url: "http://{username}.carto.com/api/v2/sql/job", + url: "https://{username}.carto.com/api/v2/sql/job", qs: { "api_key": "{api_key}" }, @@ -124,7 +124,7 @@ If you are using the Batch Query create operation for a cURL POST request, use t ```bash curl -X POST -H "Content-Type: application/json" -d '{ "query": "CREATE TABLE world_airports AS SELECT a.cartodb_id, a.the_geom, a.the_geom_webmercator, a.name airport, b.name country FROM world_borders b JOIN airports a ON ST_Contains(b.the_geom, a.the_geom)" -}' "http://{username}.carto.com/api/v2/sql/job" +}' "https://{username}.carto.com/api/v2/sql/job" ``` If you are using the Batch Query create operation for a Node.js client POST request, use the following code: @@ -134,7 +134,7 @@ var request = require("request"); var options = { method: "POST", - url: "http://{username}.carto.com/api/v2/sql/job", + url: "https://{username}.carto.com/api/v2/sql/job", headers: { "content-type": "application/json" }, body: { query: "CREATE TABLE world_airports AS SELECT a.cartodb_id, a.the_geom, a.the_geom_webmercator, a.name airport, b.name country FROM world_borders b JOIN airports a ON ST_Contains(b.the_geom, a.the_geom)" @@ -180,7 +180,7 @@ BODY: { If you are using the Batch Query read operation for a cURL GET request, use the following code: ```bash -curl -X GET "http://{username}.carto.com/api/v2/sql/job/{job_id}" +curl -X GET "https://{username}.carto.com/api/v2/sql/job/{job_id}" ``` If you are a Batch Query read operation for a Node.js client GET request, use the following code: @@ -190,7 +190,7 @@ var request = require("request"); var options = { method: "GET", - url: "http://{username}.carto.com/api/v2/sql/job/{job_id}" + url: "https://{username}.carto.com/api/v2/sql/job/{job_id}" }; request(options, function (error, response, body) { @@ -241,7 +241,7 @@ errors: [ If you are using the Batch Query cancel operation for cURL DELETE request, use the following code: ```bash -curl -X DELETE "http://{username}.carto.com/api/v2/sql/job/{job_id}" +curl -X DELETE "https://{username}.carto.com/api/v2/sql/job/{job_id}" ``` If you are using the Batch Query cancel operation for a Node.js client DELETE request, use the following code: @@ -251,7 +251,7 @@ var request = require("request"); var options = { method: "DELETE", - url: "http://{username}.carto.com/api/v2/sql/job/{job_id}", + url: "https://{username}.carto.com/api/v2/sql/job/{job_id}", }; request(options, function (error, response, body) { @@ -320,7 +320,7 @@ curl -X POST -H "Content-Type: application/json" -d '{ "DROP TABLE airports", "ALTER TABLE world_airports RENAME TO airport" ] -}' "http://{username}.carto.com/api/v2/sql/job" +}' "https://{username}.carto.com/api/v2/sql/job" ``` If you are using the Chained Batch Query operation for a Node.js client POST request, use the following code: @@ -330,7 +330,7 @@ var request = require("request"); var options = { method: "POST", - url: "http://{username}.carto.com/api/v2/sql/job", + url: "https://{username}.carto.com/api/v2/sql/job", headers: { "content-type": "application/json" }, body: { "query": [ @@ -361,7 +361,7 @@ curl -X PUT -H "Content-Type: application/json" -d '{ "ALTER TABLE world_airports RENAME TO airport", "UPDATE airports SET airport = upper(airport)" ] -}' "http://{username}.carto.com/api/v2/sql/job/{job_id}" +}' "https://{username}.carto.com/api/v2/sql/job/{job_id}" ``` If you are using the Chained Batch Query operation for a Node.js client PUT request, use the following code: @@ -371,7 +371,7 @@ var request = require("request"); var options = { method: "PUT", - url: "http://{username}.carto.com/api/v2/sql/job/{job_id}", + url: "https://{username}.carto.com/api/v2/sql/job/{job_id}", headers: { "content-type": "application/json" }, body: { query: [ @@ -408,7 +408,7 @@ curl -X POST -H "Content-Type: application/json" -d '{ "onerror": "UPDATE market_status SET status = 'outdated' WHERE table_name = 'nasdaq'" }] } -}' "http://{username}.carto.com/api/v2/sql/job" +}' "https://{username}.carto.com/api/v2/sql/job" ``` If query finishes successfully, then onsuccess fallback will be fired. Otherwise, onerror will be fired. You can define fallbacks per query: @@ -426,7 +426,7 @@ curl -X POST -H "Content-Type: application/json" -d '{ "onerror": "UPDATE market_status SET status = 'outdated' WHERE table_name = 'down_jones'" }] } -}' "http://{username}.carto.com/api/v2/sql/job" +}' "https://{username}.carto.com/api/v2/sql/job" ``` ...at the job level.. @@ -442,7 +442,7 @@ curl -X POST -H "Content-Type: application/json" -d '{ "onsuccess": "UPDATE market_status SET status = 'updated', updated_at = NOW()", "onerror": "UPDATE market_status SET status = 'outdated'" } -}' "http://{username}.carto.com/api/v2/sql/job" +}' "https://{username}.carto.com/api/v2/sql/job" ``` If a query of a job fails (and onerror fallbacks for that query and job are defined), then Batch Queries runs the first fallback for that query. The job fallback runs next and sets the job as failed. Remaining queries will not be executed. Furthermore, Batch Queries will run the onsuccess fallback at the job level, if (and only if), every query has finished successfully. @@ -464,7 +464,7 @@ curl -X POST -H "Content-Type: application/json" -d '{ }], "onerror": "INSERT INTO errors_log (job_id, error_message, date) VALUES ('<%= job_id %>', '<%= error_message %>', NOW())" } -}' "http://{username}.carto.com/api/v2/sql/job" +}' "https://{username}.carto.com/api/v2/sql/job" ``` More templates are coming soon. diff --git a/docs/guides/09-copy-queries.md b/docs/guides/09-copy-queries.md index 05850f77..01adc663 100644 --- a/docs/guides/09-copy-queries.md +++ b/docs/guides/09-copy-queries.md @@ -4,8 +4,8 @@ Copy queries allow you to use the [PostgreSQL copy command](https://www.postgres The support for copy is split across two API end points: -* `http://{username}.carto.com/api/v2/sql/copyfrom` for uploading data to CARTO -* `http://{username}.carto.com/api/v2/sql/copyto` for exporting data out of CARTO +* `https://{username}.carto.com/api/v2/sql/copyfrom` for uploading data to CARTO +* `https://{username}.carto.com/api/v2/sql/copyto` for exporting data out of CARTO ### Copy From @@ -78,7 +78,7 @@ Assuming that you have already created the table, and that the CSV file is named -H "Transfer-Encoding: chunked" \ -H "Content-Type: application/octet-stream" \ --data-binary @upload_example.csv \ - "http://{username}.carto.com/api/v2/sql/copyfrom?api_key={api_key}&q=COPY+upload_example+(the_geom,+name,+age)+FROM+STDIN+WITH+(FORMAT+csv,+HEADER+true)" + "https://{username}.carto.com/api/v2/sql/copyfrom?api_key={api_key}&q=COPY+upload_example+(the_geom,+name,+age)+FROM+STDIN+WITH+(FORMAT+csv,+HEADER+true)" To upload a larger file, using compression for a faster transfer, first compress the file, and then upload it with the content encoding set: @@ -87,7 +87,7 @@ To upload a larger file, using compression for a faster transfer, first compress -H "Transfer-Encoding: chunked" \ -H "Content-Type: application/octet-stream" \ --data-binary @upload_example.csv.gz \ - "http://{username}.carto.com/api/v2/sql/copyfrom?api_key={api_key}&q=COPY+upload_example+(the_geom,+name,+age)+FROM+STDIN+WITH+(FORMAT+csv,+HEADER+true)" + "https://{username}.carto.com/api/v2/sql/copyfrom?api_key={api_key}&q=COPY+upload_example+(the_geom,+name,+age)+FROM+STDIN+WITH+(FORMAT+csv,+HEADER+true)" #### Python Example @@ -196,7 +196,7 @@ The SQL needs to be URL-encoded before being embedded in the CURL command, so th curl \ --output upload_example_dl.csv \ --compressed \ - "http://{username}.carto.com/api/v2/sql/copyto?q=COPY+upload_example+(the_geom,name,age)+TO+stdout+WITH(FORMAT+csv,HEADER+true)&api_key={api_key}" + "https://{username}.carto.com/api/v2/sql/copyto?q=COPY+upload_example+(the_geom,name,age)+TO+stdout+WITH(FORMAT+csv,HEADER+true)&api_key={api_key}" #### Python Example diff --git a/docs/reference/swagger.yaml b/docs/reference/swagger.yaml index 3627bf1b..2f1d6f40 100644 --- a/docs/reference/swagger.yaml +++ b/docs/reference/swagger.yaml @@ -229,7 +229,7 @@ paths: x-code-samples: - lang: Curl source: | - curl -X POST -H 'Content-Encoding: gzip' -H 'Transfer-Encoding: chunked' -H 'Content-Type: application/octet-stream' --data-binary @upload_example.csv.gz 'http://{username}.carto.com/api/v2/sql/copyfrom?q=COPY upload_example (the_geom,name,age) FROM stdin WITH (FORMAT csv,HEADER true)&api_key={api_key}' + curl -X POST -H 'Content-Encoding: gzip' -H 'Transfer-Encoding: chunked' -H 'Content-Type: application/octet-stream' --data-binary @upload_example.csv.gz 'https://{username}.carto.com/api/v2/sql/copyfrom?q=COPY upload_example (the_geom,name,age) FROM stdin WITH (FORMAT csv,HEADER true)&api_key={api_key}' /sql/copyto: get: @@ -272,7 +272,7 @@ paths: x-code-samples: - lang: Curl source: | - curl --output upload_example_dl.csv --compressed "http://{username}.carto.com/api/v2/sql/copyto?q=COPY upload_example (the_geom,name,age) TO stdout WITH(FORMAT csv,HEADER true)&api_key={api_key}" + curl --output upload_example_dl.csv --compressed "https://{username}.carto.com/api/v2/sql/copyto?q=COPY upload_example (the_geom,name,age) TO stdout WITH(FORMAT csv,HEADER true)&api_key={api_key}" /sql/job: post: From 1e0b8a9a4c623692ddb82dc55173dcc09a86b573 Mon Sep 17 00:00:00 2001 From: Raul Marin Date: Fri, 1 Feb 2019 11:21:29 +0100 Subject: [PATCH 2/2] Tonino linter --- docs/guides/09-copy-queries.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guides/09-copy-queries.md b/docs/guides/09-copy-queries.md index 01adc663..2334f401 100644 --- a/docs/guides/09-copy-queries.md +++ b/docs/guides/09-copy-queries.md @@ -102,7 +102,7 @@ username = {api_key} upload_file = 'upload_example.csv' q = "COPY upload_example (the_geom, name, age) FROM STDIN WITH (FORMAT csv, HEADER true)" -url = "http://%s.carto.com/api/v2/sql/copyfrom" % username +url = "https://%s.carto.com/api/v2/sql/copyfrom" % username with open(upload_file, 'rb') as f: r = requests.post(url, params={'api_key': api_key, 'q': q}, data=f, stream=True) @@ -211,7 +211,7 @@ download_filename = 'download_example.csv' q = "COPY upload_example (the_geom, name, age) TO stdout WITH (FORMAT csv, HEADER true)" # request the download -url = "http://%s.carto.com/api/v2/sql/copyto" % username +url = "https://%s.carto.com/api/v2/sql/copyto" % username r = requests.get(url, params={'api_key': api_key, 'q': q}, stream=True) r.raise_for_status()