com.amazonaws.services.sns.model.SetTopicAttributesRequest Java Examples
The following examples show how to use
com.amazonaws.services.sns.model.SetTopicAttributesRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SnsTopicResourceTest.java From Cheddar with Apache License 2.0 | 6 votes |
@Test public void shouldSetPolicy_withPolicy() { // Given final Policy mockPolicy = mock(Policy.class); final String mockPolicyJson = randomString(); when(mockPolicy.toJson()).thenReturn(mockPolicyJson); // When snsTopicResource.setPolicy(mockPolicy); // Then final ArgumentCaptor<SetTopicAttributesRequest> captor = ArgumentCaptor .forClass(SetTopicAttributesRequest.class); verify(mockAmazonSnsClient).setTopicAttributes(captor.capture()); final SetTopicAttributesRequest setTopicAttributesRequest = captor.getValue(); assertEquals(topicArn, setTopicAttributesRequest.getTopicArn()); assertEquals("Policy", setTopicAttributesRequest.getAttributeName()); assertEquals(mockPolicyJson, setTopicAttributesRequest.getAttributeValue()); }
Example #2
Source File: SnsTopicResourceTest.java From Cheddar with Apache License 2.0 | 6 votes |
@Test public void shouldThrowException_onAmazonClientExceptionFromSetPolicy() { // Given final Policy mockPolicy = mock(Policy.class); final String mockPolicyJson = randomString(); when(mockPolicy.toJson()).thenReturn(mockPolicyJson); doThrow(AmazonClientException.class).when(mockAmazonSnsClient) .setTopicAttributes(any(SetTopicAttributesRequest.class)); // When AmazonClientException thrownException = null; try { snsTopicResource.setPolicy(mockPolicy); } catch (final AmazonClientException e) { thrownException = e; } // Then assertNotNull(thrownException); }
Example #3
Source File: PubSubUtils.java From kork with Apache License 2.0 | 5 votes |
/** * Ensure that the topic exists and has a policy granting the specified accounts permission to * publish messages to it */ public static String ensureTopicExists( AmazonSNS amazonSNS, ARN topicARN, AmazonPubsubSubscription subscription) { String createdTopicARN = retrySupport.retry( () -> amazonSNS.createTopic(topicARN.getName()).getTopicArn(), MAX_RETRIES, RETRY_BACKOFF, EXPONENTIAL); log.debug( (createdTopicARN.equals(topicARN.getArn())) ? "Reusing existing topic {}" : "Created topic {}", createdTopicARN); if (!subscription.getAccountIds().isEmpty()) { amazonSNS.setTopicAttributes( new SetTopicAttributesRequest() .withTopicArn(createdTopicARN) .withAttributeName("Policy") .withAttributeValue( buildSNSPolicy(new ARN(createdTopicARN), subscription.getAccountIds()).toJson())); } return createdTopicARN; }
Example #4
Source File: TopicImpl.java From aws-sdk-java-resources with Apache License 2.0 | 5 votes |
@Override public void setAttributes(String attributeName, String attributeValue, ResultCapture<Void> extractor) { SetTopicAttributesRequest request = new SetTopicAttributesRequest() .withAttributeName(attributeName) .withAttributeValue(attributeValue); setAttributes(request, extractor); }
Example #5
Source File: TopicImpl.java From aws-sdk-java-resources with Apache License 2.0 | 4 votes |
@Override public void setAttributes(SetTopicAttributesRequest request) { setAttributes(request, null); }
Example #6
Source File: TopicImpl.java From aws-sdk-java-resources with Apache License 2.0 | 4 votes |
@Override public void setAttributes(SetTopicAttributesRequest request, ResultCapture<Void> extractor) { resource.performAction("SetAttributes", request, extractor); }
Example #7
Source File: SnsTopicResource.java From Cheddar with Apache License 2.0 | 2 votes |
/** * Sets the {@link Policy} of the AWS SNS topic * @param policy {@link Policy} to set * @throws AmazonClientException */ public void setPolicy(final Policy policy) throws AmazonClientException { amazonSnsClient .setTopicAttributes(new SetTopicAttributesRequest(topicArn, TOPIC_POLICY_ATTRIBUTE, policy.toJson())); }
Example #8
Source File: Topic.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * Performs the <code>SetAttributes</code> action. * * <p> * The following request parameters will be populated from the data of this * <code>Topic</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>TopicArn</code></b> * - mapped from the <code>Arn</code> identifier. * </li> * </ul> * * <p> * * @see SetTopicAttributesRequest */ void setAttributes(SetTopicAttributesRequest request);
Example #9
Source File: Topic.java From aws-sdk-java-resources with Apache License 2.0 | 2 votes |
/** * Performs the <code>SetAttributes</code> action and use a ResultCapture to * retrieve the low-level client response. * * <p> * The following request parameters will be populated from the data of this * <code>Topic</code> resource, and any conflicting parameter value set in * the request will be overridden: * <ul> * <li> * <b><code>TopicArn</code></b> * - mapped from the <code>Arn</code> identifier. * </li> * </ul> * * <p> * * @see SetTopicAttributesRequest */ void setAttributes(SetTopicAttributesRequest request, ResultCapture<Void> extractor);