netbox-php/src/Api/IPAM/Prefixes.php

117 lines
2.7 KiB
PHP
Raw Normal View History

<?php
2022-05-31 12:56:36 +02:00
namespace port389\NetBox\Api\IPAM;
2022-05-31 12:56:36 +02:00
use GuzzleHttp\Exception\GuzzleException;
use port389\NetBox\Api\AbstractApi;
class Prefixes extends AbstractApi
{
/**
2022-05-31 12:56:36 +02:00
* @param array $params
* @return array
* @throws GuzzleException
*/
2022-05-31 12:56:36 +02:00
public function add(array $params = []): array
{
return $this->post("/ipam/prefixes/", $params);
}
/**
2022-05-31 12:56:36 +02:00
* @param int $id
* @param array $params
* @return bool
* @throws GuzzleException
*/
2022-05-31 12:56:36 +02:00
public function remove(int $id, array $params = []): bool
{
2022-05-31 12:56:36 +02:00
return $this->delete("/ipam/prefixes/" . $id . "/", $params);
}
/**
2022-05-31 12:56:36 +02:00
* @param int $id
* @param array $params
* @return array
* @throws GuzzleException
*/
2022-05-31 12:56:36 +02:00
public function edit(int $id, array $params = []): array
{
2022-05-31 12:56:36 +02:00
return $this->put("/ipam/prefixes/" . $id . "/", $params);
}
/**
* @param int $id
* @param array $params
* @return array
* @throws GuzzleException
*/
public function update(int $id, array $params = []): array
{
return $this->patch("/ipam/prefixes/" . $id . "/", $params);
}
/**
2022-05-31 12:56:36 +02:00
* @param array $params
* @return mixed
2022-05-31 12:56:36 +02:00
* @throws GuzzleException
*/
2022-05-31 12:56:36 +02:00
public function list(array $params = [])
{
return $this->get("/ipam/prefixes/", $params);
}
/**
2022-05-31 12:56:36 +02:00
* @param int $id
* @param array $params
* @return mixed
2022-05-31 12:56:36 +02:00
* @throws GuzzleException
*/
2022-05-31 12:56:36 +02:00
public function show(int $id, array $params = [])
{
2022-05-31 12:56:36 +02:00
return $this->get("/ipam/prefixes/" . $id . "/", $params);
}
/**
2022-05-31 12:56:36 +02:00
* @param int $id
* @param array $params
* @return mixed
2022-05-31 12:56:36 +02:00
* @throws GuzzleException
*/
2022-05-31 12:56:36 +02:00
public function showAvailableIps(int $id, array $params = [])
{
2022-05-31 12:56:36 +02:00
return $this->get("/ipam/prefixes/" . $id . "/available-ips/", $params);
}
/**
2022-05-31 12:56:36 +02:00
* @param int $id
* @param array $params
* @return array
* @throws GuzzleException
*/
2022-05-31 12:56:36 +02:00
public function addAvailableIps(int $id, array $params = []): array
{
2022-05-31 12:56:36 +02:00
return $this->post("/ipam/prefixes/" . $id . "/available-ips/", $params);
}
/**
2022-05-31 12:56:36 +02:00
* @param int $id
* @param array $params
* @return mixed
2022-05-31 12:56:36 +02:00
* @throws GuzzleException
*/
2022-05-31 12:56:36 +02:00
public function showAvailable(int $id, array $params = [])
{
2022-05-31 12:56:36 +02:00
return $this->get("/ipam/prefixes/" . $id . "/available-prefixes/", $params);
}
/**
2022-05-31 12:56:36 +02:00
* @param int $id
* @param array $params
* @return array
* @throws GuzzleException
*/
2022-05-31 12:56:36 +02:00
public function addAvailable(int $id, array $params = []): array
{
2022-05-31 12:56:36 +02:00
return $this->post("/ipam/prefixes/" . $id . "/available-prefixes/", $params);
}
}