Published
Edited
Aug 28, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
baseUrl = "https://api.edelweissdata.com" // Points to the specific Edelweiss API url

Insert cell
uiUrl = "https://edelweissdata.com" // The URL of the user interface - only used for direct linking
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
createDatasetFn = function() {
const data = { name: 'my-dataset' };

let fetchOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `bearer ${token}`
},
body: JSON.stringify(data)
};

return fetch(`${baseUrl}/datasets/create`, fetchOptions)
.then(response => response.json())
.catch(error => {
console.error('Error:', error);
});
}
Insert cell
Insert cell
Insert cell
datasetid = createResponse.id
Insert cell
Insert cell
content = FileAttachment("test.csv").blob()
Insert cell
uploadDataFn = function() {
// upload data
let formData = new FormData();

formData.append("data", content);

let fetchOptions = {
method: 'POST',
headers: {
Authorization: `bearer ${token}`
},
body: formData
};

return fetch(
`${baseUrl}/datasets/${datasetid}/in-progress/data/upload`,
fetchOptions
).then(response => response.json());
}
Insert cell
Insert cell
Insert cell
Insert cell
inferSchemaFn = function() {
// upload data
let fetchOptions = {
method: 'POST',
headers: {
Authorization: `bearer ${token}`
}
};

return fetch(
`${baseUrl}/datasets/${datasetid}/in-progress/schema/infer`,
fetchOptions
).then(response => response.json());
}
Insert cell
Insert cell
Insert cell
Insert cell
uploadSchemaFn = function() {
// upload data
let data = {
schema: {
columns: [
{
name: "FirstName",
dataType: "xsd:string",
description: "First Name"
},
{
name: "LastName",
dataType: "xsd:string",
description: "Last Name"
}
]
}
};

let fetchOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `bearer ${token}`
},
body: JSON.stringify(data)
};

return fetch(
`${baseUrl}/datasets/${datasetid}/in-progress`,
fetchOptions
).then(response => response.json());
}
Insert cell
Insert cell
Insert cell
Insert cell
uploadMetadataDescriptionFn = function() {
let description = `
# My Dataset
**by Jane Doe**

Description of the Dataset in Markdown. This can contain [links](https://en.wikipedia.org/wiki/Hyperlink) and **formatting**.
`;

let metadata = {
author: "Jane Doe",
location: "Basel, Switzerland"
};

let datasetInfo = {
name: "My dataset",
description: description,
metadata: metadata
};

let fetchOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `bearer ${token}`
},
body: JSON.stringify(datasetInfo)
};

return fetch(
`${baseUrl}/datasets/${datasetid}/in-progress`,
fetchOptions
).then(response => response.json());
}
Insert cell
Insert cell
Insert cell
Insert cell
toggleVisibilityFn = function() {
const data = ({
isPublic: false
})
// upload data
let fetchOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `bearer ${token}`
},
body: JSON.stringify(data)
};

return fetch(
`${baseUrl}/datasets/${datasetid}/permissions/visibility`,
fetchOptions
).then(response => response.ok);
}
Insert cell
Insert cell
Insert cell
Insert cell
publishDatasetFn = function() {
const data = { changelog: 'Initial Version' };

let fetchOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `bearer ${token}`
},
body: JSON.stringify(data),
}

return fetch(`${baseUrl}/datasets/${datasetid}/in-progress/publish`, fetchOptions)
.then(response => response.json())
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {secret} from "@tmcw/secret"

Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more