Container for the parameters to the SetTopicAttributes operation.

The SetTopicAttributes action allows a topic owner to set an attribute of the topic to a new value.

Inheritance: AmazonSimpleNotificationServiceRequest
 protected override void ProcessRecord()
 {
     AmazonSimpleNotificationService client = base.GetClient();
     Amazon.SimpleNotificationService.Model.SetTopicAttributesRequest request = new Amazon.SimpleNotificationService.Model.SetTopicAttributesRequest();
     request.TopicArn = this._TopicArn;
     request.AttributeName = this._AttributeName;
     request.AttributeValue = this._AttributeValue;
     Amazon.SimpleNotificationService.Model.SetTopicAttributesResponse response = client.SetTopicAttributes(request);
 }
Ejemplo n.º 2
0
        public void Save(string sourceArn, IAmazonSimpleNotificationService client)
        {
            ActionIdentifier[] actions = { SNSActionIdentifiers.Subscribe};

            var snsPolicy = new Policy()
                .WithStatements(GetDefaultStatement(sourceArn))
                .WithStatements(new Statement(Statement.StatementEffect.Allow)
                    .WithPrincipals(_accountIds.Select(a => new Principal(a)).ToArray())
                    .WithResources(new Resource(sourceArn))
                    .WithActionIdentifiers(actions));
            var attributeValue = snsPolicy.ToJson();
            var setQueueAttributesRequest = new SetTopicAttributesRequest(sourceArn, "Policy", attributeValue);

            client.SetTopicAttributes(setQueueAttributesRequest);
        }
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.SimpleNotificationService.Model.SetTopicAttributesRequest();

            if (cmdletContext.AttributeName != null)
            {
                request.AttributeName = cmdletContext.AttributeName;
            }
            if (cmdletContext.AttributeValue != null)
            {
                request.AttributeValue = cmdletContext.AttributeValue;
            }
            if (cmdletContext.TopicArn != null)
            {
                request.TopicArn = cmdletContext.TopicArn;
            }

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the SetTopicAttributes operation.
        /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the SetTopicAttributes 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<SetTopicAttributesResponse> SetTopicAttributesAsync(SetTopicAttributesRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new SetTopicAttributesRequestMarshaller();
            var unmarshaller = SetTopicAttributesResponseUnmarshaller.Instance;

            return InvokeAsync<SetTopicAttributesRequest,SetTopicAttributesResponse>(request, marshaller,
                unmarshaller, cancellationToken);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a user account for SNS
        /// </summary>
        /// <param name="userName">The user to create a SNS account for</param>
        /// <param name="number">The user's phone number</param>
        private void CreateSNSAccount(String userName, String number)
        {
            AmazonSimpleNotificationServiceClient client = new AmazonSimpleNotificationServiceClient();

            //Create topic first.
            CreateTopicRequest request = new CreateTopicRequest
            {
                Name = userName
            };

            try
            {
                CreateTopicResponse response = client.CreateTopic(request);
                CreateTopicResult result = response.CreateTopicResult;
                String[] strings = new String[1];
                strings[0] = "Success! Assigned ARN is: " + result.TopicArn + "\n";
                TempData["result"] = strings;
            }
            catch (Exception e)
            {
                TempData["error"] = e.Message;
            }

            String arn = "arn:aws:sns:us-east-1:727060774285:" + userName;

            SetTopicAttributesRequest request2 = new SetTopicAttributesRequest
            {
                AttributeName = "DisplayName",
                AttributeValue = "Cookbook",
                TopicArn = arn
            };

            try
            {
                SetTopicAttributesResponse response = client.SetTopicAttributes(request2);
                ResponseMetadata result = response.ResponseMetadata;
                Console.WriteLine(result.RequestId);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            //Add SMS number to topic.
            SubscribeRequest request3 = new SubscribeRequest
            {
                TopicArn = arn,
                Endpoint = number,
                Protocol = "sms"
            };

            try
            {
                SubscribeResponse response = client.Subscribe(request3);
                SubscribeResult result = response.SubscribeResult;

                string resultSubscribe = "Success! Subscription Arn is: " + result.SubscriptionArn + "\n";
                Console.WriteLine(resultSubscribe);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
 IAsyncResult invokeSetTopicAttributes(SetTopicAttributesRequest setTopicAttributesRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new SetTopicAttributesRequestMarshaller().Marshall(setTopicAttributesRequest);
     var unmarshaller = SetTopicAttributesResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
 /// <summary>
 /// Initiates the asynchronous execution of the SetTopicAttributes operation.
 /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService.SetTopicAttributes"/>
 /// </summary>
 /// 
 /// <param name="setTopicAttributesRequest">Container for the necessary parameters to execute the SetTopicAttributes 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>
 public IAsyncResult BeginSetTopicAttributes(SetTopicAttributesRequest setTopicAttributesRequest, AsyncCallback callback, object state)
 {
     return invokeSetTopicAttributes(setTopicAttributesRequest, callback, state, false);
 }
Ejemplo n.º 8
0
    public static void SNSCreateSubscribePublish()
    {
      #region SNSCreateSubscribePublish
      var snsClient = new AmazonSimpleNotificationServiceClient();

      var topicRequest = new CreateTopicRequest
      {
        Name = "CodingTestResults"
      };

      var topicResponse = snsClient.CreateTopic(topicRequest);

      var topicAttrRequest = new SetTopicAttributesRequest
      {
        TopicArn = topicResponse.TopicArn,
        AttributeName = "DisplayName",
        AttributeValue = "Coding Test Results"
      };

      snsClient.SetTopicAttributes(topicAttrRequest);

      snsClient.Subscribe(new SubscribeRequest
      {
        Endpoint = "*****@*****.**",
        Protocol = "email",
        TopicArn = topicResponse.TopicArn
      });

      // Wait for up to 2 minutes for the user to confirm the subscription.
      DateTime latest = DateTime.Now + TimeSpan.FromMinutes(2);

      while (DateTime.Now < latest)
      {
        var subsRequest = new ListSubscriptionsByTopicRequest
        {
          TopicArn = topicResponse.TopicArn
        };

        var subs = snsClient.ListSubscriptionsByTopic(subsRequest).Subscriptions;

        var sub = subs[0];

        if (!string.Equals(sub.SubscriptionArn,
          "PendingConfirmation", StringComparison.Ordinal))
        {
          break;
        }

        // Wait 15 seconds before trying again.
        System.Threading.Thread.Sleep(TimeSpan.FromSeconds(15));
      }

      snsClient.Publish(new PublishRequest
      {
        Subject = "Coding Test Results for " +
          DateTime.Today.ToShortDateString(),
        Message = "All of today's coding tests passed.",
        TopicArn = topicResponse.TopicArn
      });
      #endregion
    }
        /// <summary>
        /// <para>The <c>SetTopicAttributes</c> action allows a topic owner to set an attribute of the topic to a new value.</para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the SetTopicAttributes service method on
        /// AmazonSimpleNotificationService.</param>
        /// 
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.NotFoundException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.AuthorizationErrorException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.InternalErrorException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.InvalidParameterException" />
		public SetTopicAttributesResponse SetTopicAttributes(SetTopicAttributesRequest request)
        {
            var task = SetTopicAttributesAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
        /// <summary>
        /// Allows a topic owner to set an attribute of the topic to a new value.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the SetTopicAttributes service method.</param>
        /// 
        /// <returns>The response from the SetTopicAttributes 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>
        /// <exception cref="Amazon.SimpleNotificationService.Model.NotFoundException">
        /// Indicates that the requested resource does not exist.
        /// </exception>
        public SetTopicAttributesResponse SetTopicAttributes(SetTopicAttributesRequest request)
        {
            var marshaller = new SetTopicAttributesRequestMarshaller();
            var unmarshaller = SetTopicAttributesResponseUnmarshaller.Instance;

            return Invoke<SetTopicAttributesRequest,SetTopicAttributesResponse>(request, marshaller, unmarshaller);
        }
 /// <summary>
 /// Initiates the asynchronous execution of the SetTopicAttributes operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the SetTopicAttributes 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 SetTopicAttributesAsync(SetTopicAttributesRequest request, AmazonServiceCallback<SetTopicAttributesRequest, SetTopicAttributesResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new SetTopicAttributesRequestMarshaller();
     var unmarshaller = SetTopicAttributesResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<SetTopicAttributesRequest,SetTopicAttributesResponse> responseObject 
                     = new AmazonServiceResult<SetTopicAttributesRequest,SetTopicAttributesResponse>((SetTopicAttributesRequest)req, (SetTopicAttributesResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<SetTopicAttributesRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }
 /// <summary>
 /// Allows a topic owner to set an attribute of the topic to a new value.
 /// </summary>
 /// <param name="topicArn">The ARN of the topic to modify.</param>
 /// <param name="attributeName">The name of the attribute you want to set. Only a subset of the topic's attributes are mutable. Valid values: <code>Policy</code> | <code>DisplayName</code> | <code>DeliveryPolicy</code> </param>
 /// <param name="attributeValue">The new value for the attribute.</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 SetTopicAttributes 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>
 /// <exception cref="Amazon.SimpleNotificationService.Model.NotFoundException">
 /// Indicates that the requested resource does not exist.
 /// </exception>
 public void SetTopicAttributesAsync(string topicArn, string attributeName, string attributeValue,  AmazonServiceCallback<SetTopicAttributesRequest, SetTopicAttributesResponse> callback, AsyncOptions options = null)
 {
     var request = new SetTopicAttributesRequest();
     request.TopicArn = topicArn;
     request.AttributeName = attributeName;
     request.AttributeValue = attributeValue;
     SetTopicAttributesAsync(request, callback, options);
 }
 private Amazon.SimpleNotificationService.Model.SetTopicAttributesResponse CallAWSServiceOperation(IAmazonSimpleNotificationService client, Amazon.SimpleNotificationService.Model.SetTopicAttributesRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Notification Service (SNS)", "SetTopicAttributes");
     try
     {
         #if DESKTOP
         return(client.SetTopicAttributes(request));
         #elif CORECLR
         return(client.SetTopicAttributesAsync(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>
        /// <para>The <c>SetTopicAttributes</c> action allows a topic owner to set an attribute of the topic to a new value.</para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the SetTopicAttributes service method on
        /// AmazonSimpleNotificationService.</param>
        /// 
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.NotFoundException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.AuthorizationErrorException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.InternalErrorException" />
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.InvalidParameterException" />
		public SetTopicAttributesResponse SetTopicAttributes(SetTopicAttributesRequest request)
        {
            var task = SetTopicAttributesAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
 /// <summary>
 /// Allows a topic owner to set an attribute of the topic to a new value.
 /// </summary>
 /// <param name="topicArn">The ARN of the topic to modify.</param>
 /// <param name="attributeName">The name of the attribute you want to set. Only a subset of the topic's attributes are mutable. Valid values: <code>Policy</code> | <code>DisplayName</code> | <code>DeliveryPolicy</code></param>
 /// <param name="attributeValue">The new value for the attribute.</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 SetTopicAttributes 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>
 /// <exception cref="Amazon.SimpleNotificationService.Model.NotFoundException">
 /// Indicates that the requested resource does not exist.
 /// </exception>
 public Task<SetTopicAttributesResponse> SetTopicAttributesAsync(string topicArn, string attributeName, string attributeValue, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new SetTopicAttributesRequest();
     request.TopicArn = topicArn;
     request.AttributeName = attributeName;
     request.AttributeValue = attributeValue;
     return SetTopicAttributesAsync(request, cancellationToken);
 }
 /// <summary>
 /// Allows a topic owner to set an attribute of the topic to a new value.
 /// </summary>
 /// <param name="topicArn">The ARN of the topic to modify.</param>
 /// <param name="attributeName">The name of the attribute you want to set. Only a subset of the topic's attributes are mutable. Valid values: <code>Policy</code> | <code>DisplayName</code> | <code>DeliveryPolicy</code></param>
 /// <param name="attributeValue">The new value for the attribute.</param>
 /// 
 /// <returns>The response from the SetTopicAttributes 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>
 /// <exception cref="Amazon.SimpleNotificationService.Model.NotFoundException">
 /// Indicates that the requested resource does not exist.
 /// </exception>
 public SetTopicAttributesResponse SetTopicAttributes(string topicArn, string attributeName, string attributeValue)
 {
     var request = new SetTopicAttributesRequest();
     request.TopicArn = topicArn;
     request.AttributeName = attributeName;
     request.AttributeValue = attributeValue;
     return SetTopicAttributes(request);
 }
        /// <summary>
        /// <para>The <c>SetTopicAttributes</c> action allows a topic owner to set an attribute of the topic to a new value.</para>
        /// </summary>
        /// 
        /// <param name="setTopicAttributesRequest">Container for the necessary parameters to execute the SetTopicAttributes service method on
        /// AmazonSimpleNotificationService.</param>
        /// 
        /// <exception cref="T:Amazon.SimpleNotificationService.Model.NotFoundException" />
        /// <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<SetTopicAttributesResponse> SetTopicAttributesAsync(SetTopicAttributesRequest setTopicAttributesRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new SetTopicAttributesRequestMarshaller();
            var unmarshaller = SetTopicAttributesResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, SetTopicAttributesRequest, SetTopicAttributesResponse>(setTopicAttributesRequest, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
        /// <summary>
        /// Initiates the asynchronous execution of the SetTopicAttributes operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the SetTopicAttributes 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 EndSetTopicAttributes
        ///         operation.</returns>
        public IAsyncResult BeginSetTopicAttributes(SetTopicAttributesRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new SetTopicAttributesRequestMarshaller();
            var unmarshaller = SetTopicAttributesResponseUnmarshaller.Instance;

            return BeginInvoke<SetTopicAttributesRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
 /// <summary>
 /// <para>The <c>SetTopicAttributes</c> action allows a topic owner to set an attribute of the topic to a new value.</para>
 /// </summary>
 /// 
 /// <param name="setTopicAttributesRequest">Container for the necessary parameters to execute the SetTopicAttributes service method on
 ///          AmazonSimpleNotificationService.</param>
 /// 
 /// <exception cref="NotFoundException"/>
 /// <exception cref="AuthorizationErrorException"/>
 /// <exception cref="InternalErrorException"/>
 /// <exception cref="InvalidParameterException"/>
 public SetTopicAttributesResponse SetTopicAttributes(SetTopicAttributesRequest setTopicAttributesRequest)
 {
     IAsyncResult asyncResult = invokeSetTopicAttributes(setTopicAttributesRequest, null, null, true);
     return EndSetTopicAttributes(asyncResult);
 }
        /// <summary>
        /// Initiates the asynchronous execution of the SetTopicAttributes operation.
        /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService.SetTopicAttributes"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the SetTopicAttributes 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<SetTopicAttributesResponse> SetTopicAttributesAsync(SetTopicAttributesRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new SetTopicAttributesRequestMarshaller();
            var unmarshaller = SetTopicAttributesResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, SetTopicAttributesRequest, SetTopicAttributesResponse>(request, marshaller, unmarshaller, signer, cancellationToken);
        }
        IAsyncResult invokeSetTopicAttributes(SetTopicAttributesRequest request, AsyncCallback callback, object state, bool synchronized)
        {
            var marshaller = new SetTopicAttributesRequestMarshaller();
            var unmarshaller = SetTopicAttributesResponseUnmarshaller.Instance;

            return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer);
        }