public function Fastly::createService in Fastly 7.2
Same name and namespace in other branches
- 7 fastly.api.inc \Fastly::createService()
Creates a default service for our website once we signed up.
Parameters
array $data: An array of data to create the service with.
Return value
object Data returned from the Fastly request.
File
- ./
fastly.api.inc, line 71 - Contains Faslt class that handles API calls to the Fastly service.
Class
- Fastly
- Fastly API for Drupal.
Code
public function createService($data) {
$service = json_decode($this
->query('service', $data, 'POST')->data);
if (isset($service->id)) {
$data['service'] = $service->id;
$this
->query('service/' . $service->id . '/version/1/domain', array(
'name' => $data['domain'],
), 'POST');
unset($data['domain']);
unset($data['address']);
$this
->query('service/' . $service->id . '/version/1/backend', $data, 'POST');
$this
->query('service/' . $service->id . '/version/1/syslog', $data, 'POST');
$this
->query('service/' . $service->id . '/version/1/activate', array(), 'PUT');
}
return $service;
}