Published
Edited
Sep 29, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof url = Inputs.text({label: "DNAC Url", value: "https://sandboxdnac.cisco.com"})
Insert cell
viewof userpass = Inputs.text({label: "Username:Password", value: "devnetuser:Cisco123!"})
Insert cell
Insert cell
authvar = "Basic " +window.btoa(unescape(encodeURIComponent(userpass)))
Insert cell
Insert cell
url+ "/dna/system/api/v1/auth/token"
Insert cell
Insert cell
Insert cell
data = await fetchp(url+ "/dna/system/api/v1/auth/token",
{
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': authvar
},
mode : "cors"
}).then((response) => {
return response.json()
})
Insert cell
Insert cell
Insert cell
realToken = data.Token
Insert cell
Insert cell
Insert cell
devices = await fetchp(url+ "/dna/intent/api/v1/network-device",
{
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'x-auth-token': realToken
},
mode : "cors"
}).then((response) => {
return response.json()
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
newRole2 = {
let databody = {
id: selectedDevices.id,
role: "ACCESS",
roleSource: "AUTO"
};
return databody;
}
Insert cell
newRole = {
let dase = [];
let x = 0;
for (let i = 0; i < 1; i++) {
let databody = {
id: "aa0a5258-3e6f-422f-9c4e-9c196db115ae",
role: "ACCESS",
roleSource: "AUTO"
};
const resp = await fetchp(url + "/dna/intent/api/v1/network-device/brief", {
method: "PUT",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
"x-auth-token": realToken
},
mode: "cors",
body: JSON.stringify(databody)
}).then((response) => {
return response.json();
});
dase[i] = resp.response;
}
return dase;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
selectedInterface
Insert cell
Insert cell
advInterface = {
let dase = [];
let x = 0;
for (let i = 0; i < selectedInterface.length; i++) {
const resp = await fetchp(url+ "/dna/intent/api/v1/interface/"+ selectedInterface[i].id,
{
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'x-auth-token': realToken
},
mode : "cors"
}).then((response) => {
return response.json()
})
dase[i] = resp.response;
}
return dase;
}
Insert cell
Insert cell
advInterface1 = {
let dase = [];
let x = 0;
for (let i = 0; i < selectedInterface.length; i++) {
let databody = {
entity: {
_id: "aa0a5258-3e6f-422f-9c4e-9c196db115ae"
},
dimensions: [
{
name: "o_interfaceName",
value: "GigabitEthernet1/0/2"
}
],
name: "derivedInterfaceAvailability",
timeRange: {
start: "2022-09-28T12:46:40.528Z",
end: "2022-09-29T12:46:40.528Z"
}
};
const resp = await fetchp(
url +
"/api/assurance/v1/network-device/assurance-metric?page=1&pageSize=4000&order=ASC",
{
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
"x-auth-token": realToken
},
mode: "cors",
body: JSON.stringify(databody)
}
).then((response) => {
return response.json();
});
dase[i] = resp.response;
}
return dase;
}
Insert cell
Insert cell
Insert cell
issues = await fetchp(url+ "/dna/intent/api/v1/issues",
{
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'x-auth-token': realToken
},
mode : "cors"
}).then((response) => {
return response.json()
})
Insert cell
Insert cell
// Create a view of the summary statistics
viewof summary_data = SummaryTable(devices.response, {label: "Inventory Data"})
Insert cell
// Create a view of the summary statistics
viewof summary_data_if = SummaryTable(deviceinterfaces.response, {label: "Interface Data"})
Insert cell
Insert cell
Insert cell
ALLOW_DOMAINS = ["sandboxdnac.cisco.com"]
Insert cell
import { fetchp } with { ALLOW_DOMAINS } from "@tomlarkworthy/fetchp"
Insert cell
import { SummaryTable } from "@observablehq/summary-table"
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