You are here

function fastly_new_service_form_submit in Fastly 7

Same name and namespace in other branches
  1. 7.2 fastly.admin.inc \fastly_new_service_form_submit()

Implements hook_form_submit().

File

./fastly.admin.inc, line 350
Administrative forms for Fastly module.

Code

function fastly_new_service_form_submit($form, &$form_state) {
  $data = array(
    'name' => $form_state['values']['name'],
    'domain' => $form_state['values']['domain_name'],
    'port' => $form_state['values']['port'],
    'address' => $form_state['values']['domain_name'],
    'ipv4' => $form_state['values']['origin_ip'],
    'version' => 1,
    'id' => 'syslog',
  );
  $api = fastly_get_api();
  $service = $api
    ->createService($data);
  if (isset($service->msg)) {
    drupal_set_message($service->msg, 'error');
  }
  else {
    variable_set('fastly_service_id', $service->id);
    drupal_set_message(t('A new service successfuly created and set to default.'));
    drupal_goto('admin/config/services/fastly');
  }
}