Skip to content

Commit 4b4d796

Browse files
author
Matt Humphrey
committed
Added dedicated class for Namespacesand project services
1 parent 820eabe commit 4b4d796

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

lib/Gitlab/Api/ProjectNamespaces.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Gitlab\Api;
4+
5+
class ProjectNamespaces extends AbstractApi
6+
{
7+
public function all($page = 1, $per_page = self::PER_PAGE)
8+
{
9+
return $this->get('namespaces', array(
10+
'page' => $page,
11+
'per_page' => $per_page
12+
));
13+
}
14+
15+
}

lib/Gitlab/Api/Projects.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,14 @@ public function removeForkRelation($project_id)
158158
return $this->delete('projects/'.urlencode($project_id).'/fork');
159159
}
160160

161+
public function setService($project_id, $service_name, array $params = array())
162+
{
163+
return $this->put('projects/'.urlencode($project_id).'/services/'.urlencode($service_name), $params);
164+
}
165+
166+
public function removeService($project_id, $service_name)
167+
{
168+
return $this->delete('projects/'.urlencode($project_id).'/services/'.urlencode($service_name));
169+
}
170+
161171
}

lib/Gitlab/Model/Project.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public static function fromArray(Client $client, array $data)
4242
$data['owner'] = User::fromArray($client, $data['owner']);
4343
}
4444

45+
if (isset($data['namespace']) && is_array($data['namespace'])) {
46+
$data['namespace'] = ProjectNamespace::fromArray($client, $data['namespace']);
47+
}
48+
4549
return $project->hydrate($data);
4650
}
4751

@@ -516,4 +520,14 @@ public function removeForkRelation()
516520
{
517521
return $this->api('projects')->removeForkRelation($this->id);
518522
}
523+
524+
public function setService($service_name, array $params = array())
525+
{
526+
return $this->api('projects')->setService($this->id, $service_name, $params);
527+
}
528+
529+
public function removeService($service_name)
530+
{
531+
return $this->api('projects')->removeService($this->id, $service_name);
532+
}
519533
}

lib/Gitlab/Model/ProjectNamespace.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Gitlab\Model;
4+
5+
use Gitlab\Client;
6+
7+
class ProjectNamespace extends AbstractModel
8+
{
9+
protected static $_properties = array(
10+
'id',
11+
'path',
12+
'kind',
13+
'owner_id',
14+
'created_at',
15+
'updated_at',
16+
'description'
17+
);
18+
19+
public static function fromArray(Client $client, array $data)
20+
{
21+
$project = new ProjectNamespace($data['id']);
22+
$project->setClient($client);
23+
24+
return $project->hydrate($data);
25+
}
26+
27+
public function __construct($id = null, Client $client = null)
28+
{
29+
$this->setClient($client);
30+
$this->id = $id;
31+
}
32+
}

0 commit comments

Comments
 (0)