You are here

public function NewRelicApiClient::createDeployment in New Relic 8

Same name and namespace in other branches
  1. 2.x src/Client/NewRelicApiClient.php \Drupal\new_relic_rpm\Client\NewRelicApiClient::createDeployment()
  2. 2.0.x src/Client/NewRelicApiClient.php \Drupal\new_relic_rpm\Client\NewRelicApiClient::createDeployment()

Create a deployment marker in newrelic.

Parameters

string $revision: The revision to deploy.

string $description: A description for the deployment.

string $user: The user to deploy as.

string $changelog: The changelog information.

Return value

bool Whether the deployment marker was successful or not.

File

src/Client/NewRelicApiClient.php, line 187

Class

NewRelicApiClient
Controls the interaction between us and newrelic rest API v2.

Namespace

Drupal\new_relic_rpm\Client

Code

public function createDeployment($revision, $description = NULL, $user = NULL, $changelog = NULL) {
  $app_id = $this
    ->getAppId();
  if (empty($app_id)) {
    return FALSE;
  }
  $post_vars = [
    'deployment' => [
      'revision' => $revision,
    ],
  ];
  if (isset($description)) {
    $post_vars['deployment']['description'] = $description;
  }
  if (isset($user)) {
    $post_vars['deployment']['user'] = $user;
  }
  if (isset($changelog)) {
    $post_vars['deployment']['changelog'] = $changelog;
  }
  $uri = '/applications/' . $app_id . '/deployments';
  try {
    $this
      ->request($uri, [
      'form_params' => $post_vars,
    ], 'POST');
    return TRUE;
  } catch (GuzzleException $e) {
    return FALSE;
  }
}