Java源码示例:com.amazonaws.services.sns.model.GetTopicAttributesResult
示例1
private void addPermissions() {
if (permissions != null && permissions.isEmpty() == false) {
GetTopicAttributesResult result = client
.getTopicAttributes(topicArn);
AwsUtil.addPermissions(result.getAttributes(), permissions,
new AwsUtil.AddPermissionHandler() {
@Override
public void execute(Permission p) {
client.addPermission(new AddPermissionRequest()
.withTopicArn(topicArn)
.withLabel(p.getLabel())
.withAWSAccountIds(p.getAwsAccountIds())
.withActionNames(p.getActions()));
}
});
}
}
示例2
@SuppressWarnings({"checkstyle:illegalCatch"})
private static boolean topicExists(AmazonSNS client, String topicName) {
try {
GetTopicAttributesResult topicAttributesResult = client.getTopicAttributes(topicName);
return topicAttributesResult != null
&& topicAttributesResult.getSdkHttpMetadata().getHttpStatusCode() == 200;
} catch (Exception e) {
LOG.warn("Error checking whether topic {} exists.", topicName, e);
throw e;
}
}
示例3
private static void configureAmazonSnsMock(AmazonSNS amazonSNS) {
final GetTopicAttributesResult result = Mockito.mock(GetTopicAttributesResult.class);
final SdkHttpMetadata metadata = Mockito.mock(SdkHttpMetadata.class);
Mockito.when(metadata.getHttpHeaders()).thenReturn(new HashMap<>());
Mockito.when(metadata.getHttpStatusCode()).thenReturn(200);
Mockito.when(result.getSdkHttpMetadata()).thenReturn(metadata);
Mockito.when(amazonSNS.getTopicAttributes(Mockito.anyString())).thenReturn(result);
}
示例4
@Override
public boolean load(GetTopicAttributesRequest request,
ResultCapture<GetTopicAttributesResult> extractor) {
return resource.load(request, extractor);
}
示例5
/**
* Makes a call to the service to load this resource's attributes if they
* are not loaded yet, and use a ResultCapture to retrieve the low-level
* client response
* 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>
*
* @return Returns {@code true} if the resource is not yet loaded when this
* method was invoked, which indicates that a service call has been
* made to retrieve the attributes.
* @see GetTopicAttributesRequest
*/
boolean load(GetTopicAttributesRequest request,
ResultCapture<GetTopicAttributesResult> extractor);