Add Support for PATCH method
For now implementation is done in Prefixes only, more to come.
This commit is contained in:
parent
025a7edacb
commit
9a5bb016bc
3 changed files with 41 additions and 0 deletions
|
|
@ -52,6 +52,17 @@ abstract class AbstractApi implements ApiInterface
|
|||
return $this->client->getHttpClient()->put($path, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $path
|
||||
* @param array $parameters
|
||||
* @return array
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
protected function patch($path, array $parameters): array
|
||||
{
|
||||
return $this->client->getHttpClient()->patch($path, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $path
|
||||
* @param array $parameters
|
||||
|
|
|
|||
|
|
@ -39,6 +39,17 @@ class Prefixes extends AbstractApi
|
|||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
|
|
|
|||
|
|
@ -107,6 +107,25 @@ class HttpClient implements HttpClientInterface
|
|||
return json_decode($response->getBody()->getContents(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param array $body
|
||||
* @return array
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function patch(string $path = "", array $body = []): array
|
||||
{
|
||||
$response = $this->getClient()->request(
|
||||
'PATCH',
|
||||
getenv('NETBOX_API') . $path,
|
||||
[
|
||||
'json' => $body
|
||||
]
|
||||
);
|
||||
|
||||
return json_decode($response->getBody()->getContents(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
* @param array $body
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue