software.amazon.awssdk.services.sns.model.GetTopicAttributesResponse Java Examples

The following examples show how to use software.amazon.awssdk.services.sns.model.GetTopicAttributesResponse. 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: GetTopicAttributes.java    From aws-doc-sdk-examples with Apache License 2.0 6 votes vote down vote up
public static void getSNSTopicAttributes(SnsClient snsClient, String topicArn ) {

        try {
            GetTopicAttributesRequest request = GetTopicAttributesRequest.builder()
                .topicArn(topicArn)
                .build();

            GetTopicAttributesResponse result = snsClient.getTopicAttributes(request);
            System.out.println("\n\nStatus was " + result.sdkHttpResponse().statusCode() + "\n\nAttributes: \n\n" + result.attributes());

        } catch (SnsException e) {
            System.err.println(e.awsErrorDetails().errorMessage());
            System.exit(1);
        }
        //snippet-end:[sns.java2.GetTopicAttributes.main]
    }
 
Example #2
Source File: SnsIO.java    From beam with Apache License 2.0 5 votes vote down vote up
private static boolean isTopicExists(SnsClient client, String topicArn) {
  try {
    GetTopicAttributesRequest getTopicAttributesRequest =
        GetTopicAttributesRequest.builder().topicArn(topicArn).build();
    GetTopicAttributesResponse topicAttributesResponse =
        client.getTopicAttributes(getTopicAttributesRequest);
    return topicAttributesResponse != null
        && topicAttributesResponse.sdkHttpResponse().statusCode() == 200;
  } catch (Exception e) {
    throw e;
  }
}
 
Example #3
Source File: SnsClientMockErrors.java    From beam with Apache License 2.0 5 votes vote down vote up
@Override
public GetTopicAttributesResponse getTopicAttributes(
    GetTopicAttributesRequest topicAttributesRequest) {
  GetTopicAttributesResponse response = Mockito.mock(GetTopicAttributesResponse.class);
  SdkHttpResponse metadata = Mockito.mock(SdkHttpResponse.class);

  Mockito.when(metadata.statusCode()).thenReturn(200);
  Mockito.when(response.sdkHttpResponse()).thenReturn(metadata);

  return response;
}
 
Example #4
Source File: SnsClientMockSuccess.java    From beam with Apache License 2.0 5 votes vote down vote up
@Override
public GetTopicAttributesResponse getTopicAttributes(
    GetTopicAttributesRequest topicAttributesRequest) {
  GetTopicAttributesResponse response = Mockito.mock(GetTopicAttributesResponse.class);
  SdkHttpResponse metadata = Mockito.mock(SdkHttpResponse.class);

  Mockito.when(metadata.statusCode()).thenReturn(200);
  Mockito.when(response.sdkHttpResponse()).thenReturn(metadata);

  return response;
}