Updated readme, install and other documentation, changed panel() to site() since it makes more sense that way with netbox. started fixing authentication, hostfact had a login method, but netbox does not, but the user model provides a password that we can authenticate against.

This commit is contained in:
Tony Roy 2021-03-13 14:34:15 -04:00
commit 0df9b15379
7 changed files with 120 additions and 92 deletions

View file

@ -4,6 +4,17 @@ namespace wickedsoft\NetBox\Api\Users;
class Users extends AbstractApi
{
/**
* @param $params
* @return mixed
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function checkLogin($params)
{
return $this->get("/users/users/".$id."/", $params);
//return $this->post(array_merge(['controller' => 'debtor', 'action' => 'checkLogin'], $params));
}
/**
* @param $params
* @return mixed

View file

@ -64,7 +64,7 @@ class Client
'tags' => 'Extras\Tags',
//ipam
'aggregates' => 'IPAM\Aggregates'
'aggregates' => 'IPAM\Aggregates',
'ipAddresses' => 'IPAM\IpAddresses',
'prefixes' => 'IPAM\Prefixes',
'rirs' => 'IPAM\Rirs',
@ -131,9 +131,7 @@ class Client
if (!isset($this->classes[$name])) {
throw new \InvalidArgumentException(sprintf('Undefined method called:"%s"', $name));
}
$class = '\\wickedsoft\\NetBox\\Api\\' . $this->classes[$name];
return new $class($this);
}
@ -145,9 +143,7 @@ class Client
if (!isset($this->httpClient)) {
$this->httpClient = new HttpClient();
}
$this->httpClient->setOptions($this->getOptions());
return $this->httpClient;
}

View file

@ -11,7 +11,7 @@ class NetBox
protected $client;
/** @var array */
protected $panels = [];
protected $sites = [];
/**
* NetBox constructor.
@ -36,17 +36,17 @@ class NetBox
* @param null|string $name
* @return \wickedsoft\NetBox\Client
*/
public function panel($name = null)
public function site($name = null)
{
$name = $name ?: $this->getDefaultPanel();
$name = $name ?: $this->getDefaultSite();
return $this->panels[$name] = $this->get($name);
return $this->sites[$name] = $this->get($name);
}
/**
* @return string
*/
public function getDefaultPanel()
public function getDefaultSite()
{
return $this->app['config']['netbox.default'];
}
@ -57,7 +57,7 @@ class NetBox
*/
protected function get($name)
{
return $this->panels[$name] ?? $this->resolve($name);
return $this->sites[$name] ?? $this->resolve($name);
}
/**
@ -83,6 +83,6 @@ class NetBox
*/
protected function getConfig($name)
{
return $this->app['config']["netbox.panels.{$name}"];
return $this->app['config']["netbox.sites.{$name}"];
}
}

View file

@ -14,7 +14,6 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider
$this->publishes([
__DIR__ . '/../config/netbox.php' => config_path('netbox.php')
], 'config');
\Auth::provider('netbox', function ($app, array $config) {
return new \wickedsoft\NetBox\Providers\NetBoxProvider();
});
@ -39,11 +38,10 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider
{
$this->app->singleton('wickedsoft\NetBox\NetBox', function ($app) {
$netBox = new NetBox($app);
$netBox->panel($netBox->getDefaultPanel());
$netBox->site($netBox->getDefaultSite());
return $netBox;
});
$this->app->alias('wickedsoft\NetBox\NetBox', 'NetBox');
}
}