Skip to content
This repository has been archived by the owner on Nov 2, 2022. It is now read-only.

Commit

Permalink
Added Organisation railguns support. Version bumped
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesryanbell committed Jun 5, 2016
1 parent 5c01c48 commit 912e49f
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "jamesryanbell/cloudflare",
"description": "Cloudflare API V4 PHP wrapper",
"license": "MIT",
"version": "1.1.0",
"keywords": ["cloudflare", "api"],
"authors": [
{
Expand Down
104 changes: 104 additions & 0 deletions src/CloudFlare/Organizations/Railguns.php
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);
}

}

0 comments on commit 912e49f

Please sign in to comment.