Enables publishing of events to an SNS topic.

@param string $key Amazon AWS access key.
@param string $secret Amazon AWS access secret.
@param string $topicArn SNS Topic ARN.

@return PortaText\Command\ICommand
357324
public function publishEventsToSns($key, $secret, $topicArn)
    {
        $this->setArgument("sns_publish_enabled", true);
        $this->setArgument("sns_access_key", $key);
        $this->setArgument("sns_access_secret", $secret);
        return $this->setArgument("sns_topic", $topicArn);
    }
47525
public function subscribeToTopic($topicArn, $protocol, $endpoint)
    {
        // Check against the current Topic Subscriptions
        $subscriptions = $this->getTopicSubscriptions($topicArn);
        foreach ($subscriptions as $subscription) {
            if ($endpoint === $subscription['Endpoint']) {
                return $subscription['SubscriptionArn'];
            }
        }

        $result = $this->sns->subscribe([
            'TopicArn' => $topicArn,
            'Protocol' => $protocol,
            'Endpoint' => $endpoint
        ]);

        $arn = $result->get('SubscriptionArn');

        $context = [
            'Endpoint' => $endpoint,
            'Protocol' => $protocol,
            'SubscriptionArn' => $arn
        ];
        $this->log(200, "Endpoint Subscribed to SNS Topic", $context);

        return $arn;
    }
971791
public static function init($key = null, $secret = null) {
        $patrol = new Patrol;

        if ($key && $secret) {
            $patrol->setApiKey($key);
            $patrol->setApiSecret($secret);
        }

        return $patrol;
    }
221467
public function pong($secret)
    {
        $this->database = $this->database->map(function ($item) use ($secret) {
            if ($item['secret'] == $secret) {
                $item['ponged_at'] = Carbon::now();
            }

            return $item;
        });

        $this->persist();
    }
95068
public function getSharedHeaderParameter(string $key)
    {
        if ($this->hasSharedHeaderParameter($key)) {
            return $this->sharedHeader[$key];
        }

        throw new \InvalidArgumentException(\sprintf('The shared header "%s" does not exist.', $key));
    }
1134958
public function addKey(string $kid, string $secret): void
    {
        $this->keys[$kid] = $secret;
    }
755864
public function getTwitterTokened($token,$secret)
    {
        return new TwitterOAuth($this->consumer_key, $this->consumer_secret, $token,$secret);
    }
537227
private function makePeerAddressTag(string $key, Endpoint $host): BinaryAnnotation
    {
        return new BinaryAnnotation([
            "key" => $key,
            "value" => '0x01',
            "annotation_type" => AnnotationType::BOOL,
            "host" => $host,
        ]);
    }
129102
def create_async_sns_topic(self, lambda_name, lambda_arn):
        
        topic_name = get_topic_name(lambda_name)
        # Create SNS topic
        topic_arn = self.sns_client.create_topic(
            Name=topic_name)['TopicArn']
        # Create subscription
        self.sns_client.subscribe(
            TopicArn=topic_arn,
            Protocol='lambda',
            Endpoint=lambda_arn
        )
        # Add Lambda permission for SNS to invoke function
        self.create_event_permission(
            lambda_name=lambda_name,
            principal='sns.amazonaws.com',
            source_arn=topic_arn
        )
        # Add rule for SNS topic as a event source
        add_event_source(
            event_source={
                "arn": topic_arn,
                "events": ["sns:Publish"]
            },
            lambda_arn=lambda_arn,
            target_function="zappa.asynchronous.route_task",
            boto_session=self.boto_session
        )
        return topic_arn
364820
protected function setCloudApiClient($key, $secret) {
    try {
      $connector = new Connector(array(
        'key' => $key,
        'secret' => $secret,
      ));
      $cloud_api = Client::factory($connector);
      // We must call some method on the client to test authentication.
      $cloud_api->applications();
      $this->cloudApiClient = $cloud_api;
      return $cloud_api;
    }
    catch (\Exception $e) {
      // @todo this is being thrown after first auth. still works? check out.
      $this->logger->error('Failed to authenticate with Acquia Cloud API.');
      $this->logger->error('Exception was thrown: ' . $e->getMessage());
      return NULL;
    }
  }
724469
function subscribe(topicArn) {

        // validate the topic arn
        if (!rxTopicArn.test(topicArn)) throw Error('Cannot subscribe to an invalid AWS Topic Arn: ' + topicArn);

        // if already subscribed then return now
        if (subscriptions[topicArn]) return subscriptions[topicArn].promise;

        // create and store the deferred promise
        const deferred = defer();
        subscriptions[topicArn] = deferred;

        // make the sns subscribe request
        const params = {
            Protocol: /^(https?):/.exec(config.endpoint)[1],
            TopicArn: topicArn,
            Endpoint: config.endpoint
        };
        config.sns.subscribe(params, function(err) {
            debug('Subscription request for ' + topicArn + (err ? ' failed : ' + err.message : ' sent.'));
            if (err) return deferred.reject(err);
        });

        return deferred.promise;
    }
200624
public function sodiumCryptoAuth($message, $key)
    {
        if (in_array($this->libsodiumVersion, ['2', '7'], true)) {
            return sodium_crypto_auth($message, $key);
        }

        throw new CryptoException(self::ERR_NEED_MORE_SALT);
    }
677313
public function trans($key, Array $parameters = array(), $domain = NULL) {
    if (!isset($domain)) $domain = 'project';

    return $this->translationContainer->getTranslator()->trans($key, $parameters, $domain);
  }
895222
public function publish($topic, $message, $qos = 0, $retain = 0, &$msgid = null)
    {
        # set dup 0
        $dup = 0;

        # initial msgid = 0
        $msgid = 0;

        return $this->do_publish($topic, $message, $qos, $retain, $msgid, $dup);
    }
194268
public function sodiumSecretBoxOpen($message, $nonce, $key)
    {
        if (in_array($this->libsodiumVersion, ['2', '7'], true)) {
            return sodium_crypto_secretbox_open($message, $nonce, $key);
        }

        throw new CryptoException(self::ERR_NEED_MORE_SALT);
    }
578926
public static function generate(RequestInterface $request, string $issuer, string $secret): string
    {
        $data = [
            'iss' => $issuer,
            'iat' => \time(),
            'exp' => \strtotime('+1 day'),
            'qsh' => QSHGenerator::generate((string) $request->getUri(), $request->getMethod()),
        ];

        return JWT::encode($data, $secret);
    }
484569
protected function setupKeyPair(EncryptionSecretKey $secret): void
    {
        $this->secretKey = $secret;
        $this->publicKey = $this->secretKey->derivePublicKey();
    }