Update swagger.yaml

https://github.com/CartoDB/developers/pull/338
This commit is contained in:
cillas 2018-07-06 11:01:25 +02:00 committed by GitHub
parent 5676e00a7d
commit bee6c84961
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -149,6 +149,105 @@ paths:
"query": "SELECT count(*) FROM cities", \ "query": "SELECT count(*) FROM cities", \
"filename": "number_of_cities.json" \ "filename": "number_of_cities.json" \
}' "https://username.carto.com/api/v2/sql" }' "https://username.carto.com/api/v2/sql"
/sql/copyfrom:
post:
summary: Runs a copy command to ingest data
description: |
Runs a single COPY command:
- COPY mytable (col1, col2) FROM stdin WITH (FORMAT CSV)
tags:
- Single COPY command
operationId: postCopyFromStatement
parameters:
- in: query
name: q
description: COPY statement
schema:
$ref: '#/components/schemas/SQLStatementString'
required: true
example: COPY upload_example (the_geom,name,age) FROM stdin WITH (FORMAT csv,HEADER true)
- in: header
name: Transfer-Encoding
schema:
type: string
enum:
- chunked
required: true
- in: header
name: Content-Encoding
schema:
type: string
enum:
- gzip
required: false
requestBody:
required: true
content:
application/octet-stream:
schema:
type: string
responses:
'200':
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/CopyFromStatement'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
security:
- ApiKeyHTTPBasicAuth: []
- ApiKeyQueryParam: []
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}'
/sql/copyto:
get:
summary: Runs a copy command to extract data
description: |
Runs a single COPY command:
- COPY mytable TO stdout WITH (FORMAT CSV)
tags:
- Single COPY command
operationId: getCopyToStatement
parameters:
- in: query
name: q
description: COPY statement
schema:
$ref: '#/components/schemas/SQLStatementString'
required: true
- in: query
name: filename
description: Sets the content-disposition file name header
schema:
type: string
required: false
responses:
'200':
description: Text file formatted as described by the COPY statement
content:
application/octet-stream:
schema:
type: string
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
security:
- ApiKeyHTTPBasicAuth: []
- ApiKeyQueryParam: []
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}"
/sql/job: /sql/job:
post: post:
summary: Create a Job summary: Create a Job
@ -320,6 +419,20 @@ paths:
https://username.carto.com/api/v2/sql/job/de305d54-75b4-431b-adb2-eb6b9e546014 https://username.carto.com/api/v2/sql/job/de305d54-75b4-431b-adb2-eb6b9e546014
components: components:
schemas: schemas:
CopyFromStatement:
type: object
properties:
time:
type: number
format: float
description: time in seconds it has taken to run the statement
total_rows:
type: number
format: integer
description: number of rows copied into the database
example:
time: 2.3
total_rows: 142012
StatementResult: StatementResult:
type: object type: object
properties: properties: