protected override void ProcessRecord() { AmazonSimpleNotificationService client = base.GetClient(); Amazon.SimpleNotificationService.Model.ListTopicsRequest request = new Amazon.SimpleNotificationService.Model.ListTopicsRequest(); request.NextToken = this._NextToken; Amazon.SimpleNotificationService.Model.ListTopicsResponse response = client.ListTopics(request); base.WriteObject(response.ListTopicsResult, true); }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; var useParameterSelect = this.Select.StartsWith("^"); // create request and set iteration invariants var request = new Amazon.SimpleNotificationService.Model.ListTopicsRequest(); // Initialize loop variant and commence piping var _nextToken = cmdletContext.NextToken; var _userControllingPaging = this.NoAutoIteration.IsPresent || ParameterWasBound(nameof(this.NextToken)); var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint); do { request.NextToken = _nextToken; CmdletOutput output; try { var response = CallAWSServiceOperation(client, request); object pipelineOutput = null; if (!useParameterSelect) { pipelineOutput = cmdletContext.Select(response, this); } output = new CmdletOutput { PipelineOutput = pipelineOutput, ServiceResponse = response }; _nextToken = response.NextToken; } catch (Exception e) { output = new CmdletOutput { ErrorResponse = e }; } ProcessOutput(output); } while (!_userControllingPaging && AutoIterationHelpers.HasValue(_nextToken)); if (useParameterSelect) { WriteObject(cmdletContext.Select(null, this)); } return(null); }
public void publish_a_message() { GetUserNameAndPassword(); var snsClient = Amazon.AWSClientFactory.CreateAmazonSNSClient(_key, _secret); var listTopicsRequest = new ListTopicsRequest(); var listTopicsResponse = snsClient.ListTopics(listTopicsRequest); var topicArn = string.Empty; foreach (var result in listTopicsResponse.ListTopicsResult.Topics) { if (result.TopicArn.EndsWith("Elliott-has-an-awesome-blog")) { topicArn = result.TopicArn; break; } } var publishMessageRequest = new PublishRequest() .WithMessage(DateTime.Now.ToString() + " YOOOOOOOO!") .WithSubject("Elliott has an amazing blog") .WithTopicArn(topicArn); snsClient.Publish(publishMessageRequest); }
public static void SNSListTopics() { #region SNSListTopics var snsClient = new AmazonSimpleNotificationServiceClient(); var request = new ListTopicsRequest(); var response = new ListTopicsResponse(); do { response = snsClient.ListTopics(request); foreach (var topic in response.Topics) { Console.WriteLine("Topic: {0}", topic.TopicArn); var attrs = snsClient.GetTopicAttributes( new GetTopicAttributesRequest { TopicArn = topic.TopicArn }).Attributes; if (attrs.Count > 0) { foreach (var attr in attrs) { Console.WriteLine(" -{0} : {1}", attr.Key, attr.Value); } } Console.WriteLine(); } request.NextToken = response.NextToken; } while (!string.IsNullOrEmpty(response.NextToken)); #endregion Console.ReadLine(); }
private Amazon.SimpleNotificationService.Model.ListTopicsResponse CallAWSServiceOperation(IAmazonSimpleNotificationService client, Amazon.SimpleNotificationService.Model.ListTopicsRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Notification Service (SNS)", "ListTopics"); try { #if DESKTOP return(client.ListTopics(request)); #elif CORECLR return(client.ListTopicsAsync(request).GetAwaiter().GetResult()); #else #error "Unknown build edition" #endif } catch (AmazonServiceException exc) { var webException = exc.InnerException as System.Net.WebException; if (webException != null) { throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException); } throw; } }
/// <summary> /// List the SNS Topics. /// </summary> /// <param name="nextToken"></param> /// <returns></returns> public string[] ListTopics(string nextToken) { ListTopicsRequest request = new ListTopicsRequest(); request.NextToken = nextToken; ListTopicsResponse response = Client.ListTopics(request); var topics = new List<string>(); foreach (Topic topic in response.ListTopicsResult.Topics) { Debug.WriteLine(topic.TopicArn, "TopicArn"); topics.Add(topic.TopicArn); } Debug.WriteLine(response.ListTopicsResult.NextToken, "NextToken"); return topics.ToArray(); }
IAsyncResult invokeListTopics(ListTopicsRequest listTopicsRequest, AsyncCallback callback, object state, bool synchronized) { IRequest irequest = new ListTopicsRequestMarshaller().Marshall(listTopicsRequest); var unmarshaller = ListTopicsResponseUnmarshaller.GetInstance(); AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller); Invoke(result); return result; }
/// <summary> /// Initiates the asynchronous execution of the ListTopics operation. /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService.ListTopics"/> /// </summary> /// /// <param name="listTopicsRequest">Container for the necessary parameters to execute the ListTopics operation on /// AmazonSimpleNotificationService.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndListTopics /// operation.</returns> public IAsyncResult BeginListTopics(ListTopicsRequest listTopicsRequest, AsyncCallback callback, object state) { return invokeListTopics(listTopicsRequest, callback, state, false); }
IAsyncResult invokeListTopics(ListTopicsRequest request, AsyncCallback callback, object state, bool synchronized) { var marshaller = new ListTopicsRequestMarshaller(); var unmarshaller = ListTopicsResponseUnmarshaller.Instance; return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer); }
/// <summary> /// <para>The <c>ListTopics</c> action returns a list of the requester's topics. Each call returns a limited list of topics, up to 100. If there /// are more topics, a <c>NextToken</c> is also returned. Use the <c>NextToken</c> parameter in a new <c>ListTopics</c> call to get further /// results.</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListTopics service method on /// AmazonSimpleNotificationService.</param> /// /// <returns>The response from the ListTopics service method, as returned by AmazonSimpleNotificationService.</returns> /// /// <exception cref="T:Amazon.SimpleNotificationService.Model.AuthorizationErrorException" /> /// <exception cref="T:Amazon.SimpleNotificationService.Model.InternalErrorException" /> /// <exception cref="T:Amazon.SimpleNotificationService.Model.InvalidParameterException" /> public ListTopicsResponse ListTopics(ListTopicsRequest request) { var task = ListTopicsAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
/// <summary> /// Initiates the asynchronous execution of the ListTopics operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListTopics operation on AmazonSimpleNotificationServiceClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndListTopics /// operation.</returns> public IAsyncResult BeginListTopics(ListTopicsRequest request, AsyncCallback callback, object state) { var marshaller = new ListTopicsRequestMarshaller(); var unmarshaller = ListTopicsResponseUnmarshaller.Instance; return BeginInvoke<ListTopicsRequest>(request, marshaller, unmarshaller, callback, state); }
/// <summary> /// Returns a list of the requester's topics. Each call returns a limited list of topics, /// up to 100. If there are more topics, a <code>NextToken</code> is also returned. /// Use the <code>NextToken</code> parameter in a new <code>ListTopics</code> call to /// get further results. /// </summary> /// <param name="nextToken">Token returned by the previous <code>ListTopics</code> request.</param> /// /// <returns>The response from the ListTopics service method, as returned by SimpleNotificationService.</returns> /// <exception cref="Amazon.SimpleNotificationService.Model.AuthorizationErrorException"> /// Indicates that the user has been denied access to the requested resource. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InternalErrorException"> /// Indicates an internal service error. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InvalidParameterException"> /// Indicates that a request parameter does not comply with the associated constraints. /// </exception> public ListTopicsResponse ListTopics(string nextToken) { var request = new ListTopicsRequest(); request.NextToken = nextToken; return ListTopics(request); }
/// <summary> /// Initiates the asynchronous execution of the ListTopics operation. /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListTopics operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<ListTopicsResponse> ListTopicsAsync(ListTopicsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ListTopicsRequestMarshaller(); var unmarshaller = ListTopicsResponseUnmarshaller.Instance; return InvokeAsync<ListTopicsRequest,ListTopicsResponse>(request, marshaller, unmarshaller, cancellationToken); }
/// <summary> /// Paginator for ListTopics operation ///</summary> public IListTopicsPaginator ListTopics(ListTopicsRequest request) { return(new ListTopicsPaginator(this.client, request)); }
internal ListTopicsPaginator(IAmazonSimpleNotificationService client, ListTopicsRequest request) { this._client = client; this._request = request; }
/// <summary> /// Initiates the asynchronous execution of the ListTopics operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListTopics operation on AmazonSimpleNotificationServiceClient.</param> /// <param name="callback">An Action delegate that is invoked when the operation completes.</param> /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> public void ListTopicsAsync(ListTopicsRequest request, AmazonServiceCallback<ListTopicsRequest, ListTopicsResponse> callback, AsyncOptions options = null) { options = options == null?new AsyncOptions():options; var marshaller = new ListTopicsRequestMarshaller(); var unmarshaller = ListTopicsResponseUnmarshaller.Instance; Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null; if(callback !=null ) callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { AmazonServiceResult<ListTopicsRequest,ListTopicsResponse> responseObject = new AmazonServiceResult<ListTopicsRequest,ListTopicsResponse>((ListTopicsRequest)req, (ListTopicsResponse)res, ex , ao.State); callback(responseObject); }; BeginInvoke<ListTopicsRequest>(request, marshaller, unmarshaller, options, callbackHelper); }
/// <summary> /// Returns a list of the requester's topics. Each call returns a limited list of topics, /// up to 100. If there are more topics, a <code>NextToken</code> is also returned. Use /// the <code>NextToken</code> parameter in a new <code>ListTopics</code> call to get /// further results. /// </summary> /// <param name="nextToken">Token returned by the previous <code>ListTopics</code> request.</param> /// <param name="callback">An Action delegate that is invoked when the operation completes.</param> /// <param name="options"> /// A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property. /// </param> /// /// <returns>The response from the ListTopics service method, as returned by SimpleNotificationService.</returns> /// <exception cref="Amazon.SimpleNotificationService.Model.AuthorizationErrorException"> /// Indicates that the user has been denied access to the requested resource. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InternalErrorException"> /// Indicates an internal service error. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InvalidParameterException"> /// Indicates that a request parameter does not comply with the associated constraints. /// </exception> public void ListTopicsAsync(string nextToken, AmazonServiceCallback<ListTopicsRequest, ListTopicsResponse> callback, AsyncOptions options = null) { var request = new ListTopicsRequest(); request.NextToken = nextToken; ListTopicsAsync(request, callback, options); }
/// <summary> /// Notification configuration window load event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NcWindow_Loaded(object sender, RoutedEventArgs e) { try { AmazonAutoScalingConfig config = new AmazonAutoScalingConfig(); config.ServiceURL = ((ViewModel)this.DataContext).Region.Url; AmazonAutoScalingClient client = new AmazonAutoScalingClient(config); DescribeAutoScalingNotificationTypesRequest dasntreq = new DescribeAutoScalingNotificationTypesRequest(); DescribeAutoScalingNotificationTypesResponse dasntresp = client.DescribeAutoScalingNotificationTypes(dasntreq); foreach (string asnt in dasntresp.DescribeAutoScalingNotificationTypesResult.AutoScalingNotificationTypes) { this.notificationTypes.Add(asnt); } AmazonSimpleNotificationServiceConfig snsconfig = new AmazonSimpleNotificationServiceConfig(); config.ServiceURL = ((ViewModel)this.DataContext).Region.Url; AmazonSimpleNotificationServiceClient snsclient = new AmazonSimpleNotificationServiceClient(snsconfig); ListTopicsRequest ltrequest = new ListTopicsRequest(); ListTopicsResponse ltresp = snsclient.ListTopics(ltrequest); foreach (Topic topic in ltresp.ListTopicsResult.Topics) { this.snstopics.Add(topic.TopicArn); } rlbNcTypes.ItemsSource = this.notificationTypes; cboTopics.ItemsSource = this.snstopics; } catch { MessageBox.Show(Window.GetWindow(this), "Error occured while loading the notification configuration options.", "Error", MessageBoxButton.OK); this.Close(); } }
/// <summary> /// <para>The <c>ListTopics</c> action returns a list of the requester's topics. Each call returns a limited list of topics, up to 100. If there /// are more topics, a <c>NextToken</c> is also returned. Use the <c>NextToken</c> parameter in a new <c>ListTopics</c> call to get further /// results.</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListTopics service method on /// AmazonSimpleNotificationService.</param> /// /// <returns>The response from the ListTopics service method, as returned by AmazonSimpleNotificationService.</returns> /// /// <exception cref="T:Amazon.SimpleNotificationService.Model.AuthorizationErrorException" /> /// <exception cref="T:Amazon.SimpleNotificationService.Model.InternalErrorException" /> /// <exception cref="T:Amazon.SimpleNotificationService.Model.InvalidParameterException" /> public ListTopicsResponse ListTopics(ListTopicsRequest request) { var task = ListTopicsAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
/// <summary> /// Returns a list of the requester's topics. Each call returns a limited list of topics, /// up to 100. If there are more topics, a <code>NextToken</code> is also returned. /// Use the <code>NextToken</code> parameter in a new <code>ListTopics</code> call to /// get further results. /// </summary> /// <param name="nextToken">Token returned by the previous <code>ListTopics</code> request.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// /// <returns>The response from the ListTopics service method, as returned by SimpleNotificationService.</returns> /// <exception cref="Amazon.SimpleNotificationService.Model.AuthorizationErrorException"> /// Indicates that the user has been denied access to the requested resource. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InternalErrorException"> /// Indicates an internal service error. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InvalidParameterException"> /// Indicates that a request parameter does not comply with the associated constraints. /// </exception> public Task<ListTopicsResponse> ListTopicsAsync(string nextToken, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var request = new ListTopicsRequest(); request.NextToken = nextToken; return ListTopicsAsync(request, cancellationToken); }
/// <summary> /// Returns a list of the requester's topics. Each call returns a limited list of topics, /// up to 100. If there are more topics, a <code>NextToken</code> is also returned. /// Use the <code>NextToken</code> parameter in a new <code>ListTopics</code> call to /// get further results. /// </summary> /// <param name="request">Container for the necessary parameters to execute the ListTopics service method.</param> /// /// <returns>The response from the ListTopics service method, as returned by SimpleNotificationService.</returns> /// <exception cref="Amazon.SimpleNotificationService.Model.AuthorizationErrorException"> /// Indicates that the user has been denied access to the requested resource. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InternalErrorException"> /// Indicates an internal service error. /// </exception> /// <exception cref="Amazon.SimpleNotificationService.Model.InvalidParameterException"> /// Indicates that a request parameter does not comply with the associated constraints. /// </exception> public ListTopicsResponse ListTopics(ListTopicsRequest request) { var marshaller = new ListTopicsRequestMarshaller(); var unmarshaller = ListTopicsResponseUnmarshaller.Instance; return Invoke<ListTopicsRequest,ListTopicsResponse>(request, marshaller, unmarshaller); }
/// <summary> /// <para>The <c>ListTopics</c> action returns a list of the requester's topics. Each call returns a limited list of topics, up to 100. If there /// are more topics, a <c>NextToken</c> is also returned. Use the <c>NextToken</c> parameter in a new <c>ListTopics</c> call to get further /// results.</para> /// </summary> /// /// <param name="listTopicsRequest">Container for the necessary parameters to execute the ListTopics service method on /// AmazonSimpleNotificationService.</param> /// /// <returns>The response from the ListTopics service method, as returned by AmazonSimpleNotificationService.</returns> /// /// <exception cref="T:Amazon.SimpleNotificationService.Model.AuthorizationErrorException" /> /// <exception cref="T:Amazon.SimpleNotificationService.Model.InternalErrorException" /> /// <exception cref="T:Amazon.SimpleNotificationService.Model.InvalidParameterException" /> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> public async Task<ListTopicsResponse> ListTopicsAsync(ListTopicsRequest listTopicsRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ListTopicsRequestMarshaller(); var unmarshaller = ListTopicsResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, ListTopicsRequest, ListTopicsResponse>(listTopicsRequest, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }
/// <summary> /// Initiates the asynchronous execution of the ListTopics operation. /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService.ListTopics"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the ListTopics operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task<ListTopicsResponse> ListTopicsAsync(ListTopicsRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new ListTopicsRequestMarshaller(); var unmarshaller = ListTopicsResponseUnmarshaller.GetInstance(); return Invoke<IRequest, ListTopicsRequest, ListTopicsResponse>(request, marshaller, unmarshaller, signer, cancellationToken); }
/// <summary> /// <para>The <c>ListTopics</c> action returns a list of the requester's topics. Each call returns a limited list of topics, up to 100. If there /// are more topics, a <c>NextToken</c> is also returned. Use the <c>NextToken</c> parameter in a new <c>ListTopics</c> call to get further /// results.</para> /// </summary> /// /// <param name="listTopicsRequest">Container for the necessary parameters to execute the ListTopics service method on /// AmazonSimpleNotificationService.</param> /// /// <returns>The response from the ListTopics service method, as returned by AmazonSimpleNotificationService.</returns> /// /// <exception cref="AuthorizationErrorException"/> /// <exception cref="InternalErrorException"/> /// <exception cref="InvalidParameterException"/> public ListTopicsResponse ListTopics(ListTopicsRequest listTopicsRequest) { IAsyncResult asyncResult = invokeListTopics(listTopicsRequest, null, null, true); return EndListTopics(asyncResult); }
/// <summary>Determine if the specified SNS topic exists</summary> /// <returns>True if the topic exists</returns> private bool DoesTopicExist() { Project.Log(Level.Info, "Checking if SNS topic '{0}' exists.", Topic); using (Client) { try { var request = new ListTopicsRequest(); var response = Client.ListTopics(request); foreach (var topic in response.ListTopicsResult.Topics) { Project.Log(Level.Info, "Found SNS topic ARN: {0}", topic.TopicArn); if (topic.TopicArn.Contains(Topic)) { Project.Log(Level.Info, "SNS topic '{0}' already exists!", Topic); return true; } } } catch (AmazonS3Exception ex) { ShowError(ex); } } Project.Log(Level.Info, "SNS topic '{0}' does not exist!", Topic); return false; }
public static bool List_All_Topics(out List<Topic> topics) { ListTopicsRequest lt_request = new ListTopicsRequest(); ListTopicsResponse lt_response = sns_client.ListTopics(lt_request); topics = lt_response.ListTopicsResult.Topics; return true; }