APIEnvironment::index PHP Method

index() public method

public index ( SS_HTTPRequest $request ) : SS_HTTPResponse
$request SS_HTTPRequest
return SS_HTTPResponse
    public function index(\SS_HTTPRequest $request)
    {
        if (!$this->record->canView($this->getMember())) {
            return $this->message('You are not authorized to view this environment', 403);
        }
        switch ($request->httpMethod()) {
            case 'GET':
                $href = Director::absoluteURL($this->record->Project()->APILink($this->record->Name));
                return $this->getAPIResponse(array("name" => $this->record->Name, "project" => $this->record->Project()->Name, "href" => $href, "created" => $this->record->Created, "last-edited" => $this->record->LastEdited, "actions" => array(array("name" => "deploy", "method" => "POST", "href" => "{$href}/deploy", "type" => "application/json", "fields" => array(array("name" => "release", "type" => "text"))))));
            default:
                return $this->message('API not found', 404);
        }
    }