承接 cis-bv/netbox-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cis-bv/netbox-client

Composer 安装命令:

composer require cis-bv/netbox-client

包简介

NetBox Client with supporting of GraphQl

README 文档

README

This is a simple fluent-based PHP client for the NetBox API.

Installation

composer require cis-bv/netbox-client

Create Client-Instance

The URL (with or without /api) and the NetBox-Token can either be provided directly by passing to the Class Constructor or via (OS-provided) Environment-Variables:

use Cis\NetBox\NetBoxApi;

// direct passing
$netBoxApi = new NetBoxApi('https://demo.netbox.dev', '3d7d31797de934a99a527a620514130980937b4c');

// using the Environment-Variables (OS or set)
putenv(NETBOX_API_URL, 'https://demo.netbox.dev');
putenv(NETBOX_TOKEN, '3d7d31797de934a99a527a620514130980937b4c');
$netBoxApi = new NetBoxApi();

API

All API-calls are made fluently and are based on the URL of the endpoint. For Hypen-based paths you need to convert it to camelCase:

For retrieving data you omit the "Get"-Method. All filters ar passed in an array:

use Cis\NetBox\NetBoxApi;

$netBoxApi = new NetBoxApi();

// Getting all Console-Ports
$consolePorts = $netBoxApi->dcim()->consolePorts();

// Getting all Console-Ports for a specific device
$consolePorts = $netBoxApi->dcim()->consolePorts(['device_id' => 12]);

For all Non-Get-Operations add the necessary Method to the End of the function name:

  • Create for adding Models
  • Put or Patch for updating Models
  • Delete for deleting Models
// Creating a new Console Port
$consolePorts = $netBoxApi->dcim()->consolePortsCreate([
    'device' => 245,
    'name' => 'con'
]);

For Referencing a direct instance of a Model you need to add ById between the path and method and also reference the ID as the first parameter:

use Cis\NetBox\NetBoxApi;
$netBoxApi = new NetBoxApi();

//Get a specific Interface:
$netBoxApi->dcim()->interfacesById(12);

//Delete a specific Console Port:
$netBoxApi->dcim()->consolePortsByIdDelete(234);

GraphQL

To perform a GraphQL query you simply passing an Instance of the Cis\GqlBuilder\Query-Class or a simple string with the query.

use Cis\NetBox\NetBoxApi;
use Cis\GqlBuilder\Query;

$netBoxApi = new NetBoxApi();
$query = Query::create('device_list', selectionSet: ['id', 'name']);

$allDevices = $netBoxApi->graphQl($query);

Return

All Functions return either an NetBoxResult or NetBoxGraphQlResult in case of a GraphQL-Query.

You can iterate over NetBoxResult and use it as Array, even if it is just on instance of a model.

It also holds additional information about the request:

use Cis\NetBox\NetBoxApi;
$netBoxApi = new NetBoxApi();

$consolePorts = $netBoxApi->dcim()->consolePorts();

//Retrieve the status code of the request
$statusCode = $consolePorts->getStatusCode();

//Retrieve the plain Body
$body = $consolePorts->getBody();

//Retrieve the Result(s) always as array:
$results = $consolePorts->getResults();

//Use Result as Array
foreach ($consolePorts as $consolePort) {
    echo $consolePort->id . PHP_EOL;
}

cis-bv/netbox-client 适用场景与选型建议

cis-bv/netbox-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 10 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 cis-bv/netbox-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 cis-bv/netbox-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 cis-bv/netbox-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 9
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-21