Пример #1
0
 /**
  * Create a service
  * @link     https://apidocs.serverdensity.com/?python#creating-a-service
  * @param    array  $service with all it's attributes.
  * @return   an array that is the device.
  */
 public function create($service, array $tagNames = array())
 {
     if (!empty($tagNames)) {
         $tagEndpoint = new Tags($this->client);
         $tags = $tagEndpoint->findAll($tagNames);
         if (!empty($tags['notFound'])) {
             foreach ($tags['notFound'] as $name) {
                 $tags['tags'][] = $tagEndpoint->create($name);
             }
         }
         $formattedTags = $tagEndpoint->format($tags['tags'], 'other');
         $service['tags'] = $formattedTags['tags'];
     }
     $service = $this->makeJsonReady($service);
     return $this->post('inventory/services/', $service);
 }
Пример #2
0
 /**
  * Create a user
  * @link     https://apidocs.serverdensity.com/#creating-a-user
  * @param    array $user
  * @return   an array with the user that got created
  */
 public function create(array $user, array $tagNames = array())
 {
     if (!empty($tagNames)) {
         $tagEndpoint = new Tags($this->client);
         $tags = $tagEndpoint->findAll($tagNames);
         if (!empty($tags['notFound'])) {
             foreach ($tags['notFound'] as $name) {
                 $tags['tags'][] = $tagEndpoint->create($name);
             }
         }
         $formattedTags = $tagEndpoint->format($tags['tags'], 'user');
         // don't overwrite permission array if user creates his own.
         if (!empty($user['permissions'])) {
             $user['permissions'] = array_merge($user['permissions'], $formattedTags);
         } else {
             $user['permissions'] = $formattedTags;
         }
     }
     $user = $this->makeJsonReady($user);
     return $this->post('users/users/', $user);
 }
Пример #3
0
require 'lib/Slim/Slim.php';
require_once 'lib/jwt_helper.php';
require_once 'lib/password.php';
require_once 'Helper.php';
require_once 'routes/news.php';
require_once 'routes/tags.php';
require_once 'routes/resource.php';
require_once 'routes/category.php';
require_once 'routes/photo.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->group('/news', function () use($app) {
    News::create($app);
});
$app->group('/tags', function () use($app) {
    Tags::create($app);
});
$app->group('/resources', function () use($app) {
    Resource::create($app);
});
$app->group('/category', function () use($app) {
    Category::create($app);
});
$app->group('/album', function () use($app) {
    Photo::create($app);
});
$app->get('/ninja', function () use($app) {
    chdir('../ninja');
    $ninja = glob('*');
    $res = array();
    foreach ($ninja as $n) {