This repository has been archived by the owner on Nov 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Organisation railguns support. Version bumped
- Loading branch information
1 parent
5c01c48
commit 912e49f
Showing
2 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
|
||
namespace Cloudflare\Organizations; | ||
|
||
use Cloudflare\Api; | ||
use Cloudflare\Organizations; | ||
|
||
/** | ||
* CloudFlare API wrapper | ||
* | ||
* Organization Railgun | ||
* CloudFlare Railgun for Organizations | ||
* | ||
* @author James Bell <[email protected]> | ||
* @version 1 | ||
*/ | ||
|
||
class Railguns extends Api | ||
{ | ||
/** | ||
* Default permissions level | ||
* @var array | ||
*/ | ||
protected $permission_level = array('read' => '#organization:read', 'edit' => '#organization:edit'); | ||
|
||
/** | ||
* Create Railgun (permission needed: #organization:edit) | ||
* @param string $organization_identifier Organization identifier tag | ||
* @param string $name Readable identifier of the railgun | ||
*/ | ||
public function create($organization_identifier, $name) | ||
{ | ||
$data = array( | ||
'name' => $name | ||
); | ||
return $this->post('/organizations/' . $organization_identifier . '/railguns', $data); | ||
} | ||
|
||
/** | ||
* List Railguns (permission needed: #organization:read) | ||
* List, search, sort and filter your Railguns | ||
* @param string $organization_identifier Organization identifier tag | ||
* @param int|null $page Page number of paginated results | ||
* @param int|null $per_page Number of items per page | ||
* @param string|null $direction Direction to order Railguns (asc, desc) | ||
*/ | ||
public function railguns($organization_identifier, $page = null, $per_page = null, $direction = null) | ||
{ | ||
$data = array( | ||
'page' => $page, | ||
'per_page' => $per_page, | ||
'direction' => $direction | ||
); | ||
return $this->get('/organizations/' . $organization_identifier . '/railguns', $data); | ||
} | ||
|
||
/** | ||
* Railgun details (permission needed: #organization:read) | ||
* @param string $organization_identifier Organization identifier tag | ||
* @param string $identifier API item identifier tag | ||
*/ | ||
public function details($organization_identifier, $identifier) | ||
{ | ||
return $this->get('/organizations/' . $organization_identifier . '/railguns/' . $identifier); | ||
} | ||
|
||
/** | ||
* Get zones connected to a Railgun (permission needed: #organization:read) | ||
* The zones that are currently using this Railgun | ||
* @param string $organization_identifier Organization identifier tag | ||
* @param string $identifier API item identifier tag | ||
*/ | ||
public function zones($organization_identifier, $identifier) | ||
{ | ||
return $this->get('/organizations/' . $organization_identifier . '/railguns/'. $identifier . '/zones'); | ||
} | ||
|
||
/** | ||
* Enable or disable a Railgun (permission needed: #organization:edit) | ||
* Enable or disable a Railgun for all zones connected to it | ||
* @param string $organization_identifier Organization identifier tag | ||
* @param string $zone_identifier API item identifier tag | ||
* @param bool|null $enabled Flag to determine if the Railgun is accepting connections | ||
*/ | ||
public function enabled($organization_identifier, $zone_identifier, $enabled = null) | ||
{ | ||
$data = array( | ||
'enabled' => $enabled | ||
); | ||
return $this->patch('/organizations/' . $organization_identifier . '/railguns/'. $identifier, $data); | ||
} | ||
|
||
/** | ||
* Delete Railgun (permission needed: #organization:edit) | ||
* Disable and delete a Railgun. This will immediately disable the Railgun for any connected zones | ||
* @param string $organization_identifier Organization identifier tag | ||
* @param string $identifier API item identifier tag | ||
*/ | ||
public function delete_railgun($organization_identifier, $identifier) | ||
{ | ||
return $this->delete('/organizations/' . $organization_identifier . '/railguns/'. $identifier); | ||
} | ||
|
||
} |