상속: extends Aws\Common\Client\AbstractClient
예제 #1
0
 public function testErrorsAreParsedCorrectly()
 {
     try {
         $this->logs->deleteLogGroup(array('logGroupName' => 'foo'));
         $this->fail('An exception should have been thrown.');
     } catch (ServiceResponseException $e) {
         $this->assertEquals('ResourceNotFoundException', $e->getExceptionCode(), 'Caught a ' . $e->getExceptionCode() . ' exception instead.');
     }
 }
예제 #2
0
 /**
  * @param string $traceToken
  * @param string $logGroup
  * @return \Guzzle\Service\Resource\Model
  */
 public function getStatementsForTrace($traceToken, $logGroup)
 {
     $logStatements = [];
     try {
         $logStatements = $this->client->filterLogEvents(['logGroupName' => $logGroup, 'filterPattern' => $traceToken]);
     } catch (CloudWatchLogsException $e) {
         /**
          * @TODO fix when i am a real app
          */
         throw $e;
     }
     return $logStatements;
 }
예제 #3
0
 private function initialize()
 {
     // fetch existing groups
     $existingGroups = $this->client->describeLogGroups(['logGroupNamePrefix' => $this->logGroupName])->get('logGroups');
     // extract existing groups names
     $existingGroupsNames = array_map(function ($group) {
         return $group['logGroupName'];
     }, $existingGroups);
     // create group and set retention policy if not created yet
     if (!in_array($this->logGroupName, $existingGroupsNames, true)) {
         $this->client->createLogGroup(['logGroupName' => $this->logGroupName]);
         $this->client->putRetentionPolicy(['logGroupName' => $this->logGroupName, 'retentionInDays' => $this->retentionDays]);
     }
     // fetch existing streams
     $existingStreams = $this->client->describeLogStreams(['logGroupName' => $this->logGroupName, 'logStreamNamePrefix' => $this->logStreamName])->get('logStreams');
     // extract existing streams names
     $existingStreamsNames = array_map(function ($stream) {
         // set sequence token
         if ($stream['logStreamName'] === $this->logStreamName && isset($stream['uploadSequenceToken'])) {
             $this->uploadSequenceToken = $stream['uploadSequenceToken'];
         }
         return $stream['logStreamName'];
     }, $existingStreams);
     // create stream if not created
     if (!in_array($this->logStreamName, $existingStreamsNames, true)) {
         $this->client->createLogStream(['logGroupName' => $this->logGroupName, 'logStreamName' => $this->logStreamName]);
     }
     $this->initialized = true;
 }
 /**
  * @covers Aws\CloudWatchLogs\CloudWatchLogsClient::factory
  */
 public function testFactoryInitializesClient()
 {
     $client = CloudWatchLogsClient::factory(array('key' => 'foo', 'secret' => 'bar', 'region' => 'us-east-1'));
     $this->assertInstanceOf('Aws\\Common\\Signature\\SignatureV4', $client->getSignature());
     $this->assertInstanceOf('Aws\\Common\\Credentials\\Credentials', $client->getCredentials());
     $this->assertEquals('https://logs.us-east-1.amazonaws.com', $client->getBaseUrl());
 }
예제 #5
0
 public function deleteLogGroup($logGroupName)
 {
     $this->cloudWatchLogsClient->deleteLogGroup(['logGroupName' => $logGroupName]);
 }