Skip to content

Commit 94e943d

Browse files
authored
Merge pull request #489 from ecloud-jay2/master
Adds AffinityRuleMemberClient to the sdk
2 parents 9af21c9 + f5a974d commit 94e943d

File tree

3 files changed

+34
-26
lines changed

3 files changed

+34
-26
lines changed

src/eCloud/AffinityRuleClient.php

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,4 @@ public function getMembers($id, $filters = [])
3636
return new AffinityRuleMember($this->apiToFriendly($data, AffinityRuleMember::$entityMap));
3737
}, $filters);
3838
}
39-
40-
/**
41-
* Assigns an instance to a rule
42-
* @param $id
43-
* @param $instanceId
44-
* @return bool
45-
*/
46-
public function assignMember($id, $instanceId)
47-
{
48-
$response = $this->post(
49-
$this->collectionPath . '/' . $id . '/members',
50-
json_encode([ 'instance_id' => $instanceId ])
51-
);
52-
return $response->getStatusCode() == 202;
53-
}
54-
/**
55-
* Detaches an instance from a rule
56-
* @param $id
57-
* @param $memberId
58-
* @return bool
59-
*/
60-
public function detachMember($id, $memberId)
61-
{
62-
$response = $this->delete($this->collectionPath . '/' . $id . '/members/' . $memberId);
63-
return $response->getStatusCode() == 202;
64-
}
6539
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace UKFast\SDK\eCloud;
4+
5+
use UKFast\SDK\eCloud\Entities\AffinityRuleMember;
6+
use UKFast\SDK\Entities\ClientEntityInterface;
7+
use UKFast\SDK\Traits\PageItems;
8+
9+
class AffinityRuleMemberClient extends Client implements ClientEntityInterface
10+
{
11+
use PageItems;
12+
13+
protected $collectionPath = 'v2/affinity-rule-members';
14+
15+
public function getEntityMap()
16+
{
17+
return AffinityRuleMember::$entityMap;
18+
}
19+
20+
public function loadEntity($data)
21+
{
22+
return new AffinityRuleMember(
23+
$this->apiToFriendly($data, $this->getEntityMap())
24+
);
25+
}
26+
}

src/eCloud/Client.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,4 +359,12 @@ public function affinityRules()
359359
{
360360
return (new AffinityRuleClient($this->httpClient))->auth($this->token);
361361
}
362+
363+
/**
364+
* @return BaseClient
365+
*/
366+
public function affinityRuleMembers()
367+
{
368+
return (new AffinityRuleMemberClient($this->httpClient))->auth($this->token);
369+
}
362370
}

0 commit comments

Comments
 (0)