Cisco.DnaCenter.Api
1.0.0
若要使用 Cisco DNA Center nuget 軟體包:
using Cisco . DnaCenter . Api ;
using System ;
using System . Collections . Generic ;
using System . Threading . Tasks ;
namespace My . Project
{
public static class Program
{
public static async Task Main ( )
{
var dnaCenterClient = new DnaCenterClient ( new DnaCenterClientOptions
{
Uri = new Uri ( " https://mydnac.example.com/ " ) ,
Username = " username " ,
Password = " password "
} ) ;
var sites = await dnaCenterClient
. Sites
. GetAllAsync ( )
. ConfigureAwait ( false ) ;
var firstSite = sites . Response [ 0 ] ;
var devicesResponse = await dnaCenterClient
. Devices
. GetAllAsync ( locationName : new List < string > { firstSite . SiteNameHierarchy } )
. ConfigureAwait ( false ) ;
Console . WriteLine ( " Devices: " ) ;
foreach ( var device in devicesResponse . Response )
{
Console . WriteLine ( $" - { device . SerialNumber } : { device . Hostname } " ) ;
}
}
}
}
DNA 中心意圖 API 文件可在此處找到:
您可以在此處使用 DNA Center Sandbox 進行測試:
登入後,請在頁面左下角找到您的 URL、使用者名稱和密碼。