Exemplo n.º 1
0
 /// <inheritdoc/>
 public DeleteTopicResponse DeleteTopic(DeleteTopicRequest request)
 {
     return(AggregateExceptionExtract.Extract(() =>
     {
         return DeleteTopicAsync(request).Result;
     }));
 }
Exemplo n.º 2
0
 public bool DeleteTopic(string ID, string CreateUser, ref string msg)
 {
     try
     {
         DeleteTopicRequest paraBody = new DeleteTopicRequest();
         paraBody.CreatedUser = CreateUser;
         paraBody.ID          = ID;
         //====================
         var result = (NSApiResponse)ApiResponse.Post <NSApiResponse>(Commons.TopicAPIDelete, null, paraBody);
         if (result != null)
         {
             if (result.Success)
             {
                 return(true);
             }
             else
             {
                 msg = result.Message;
                 NSLog.Logger.Info("TopicDelete", result.Message);
                 return(false);
             }
         }
         else
         {
             NSLog.Logger.Info("TopicDelete", result);
             return(false);
         }
     }
     catch (Exception e)
     {
         msg = e.ToString();
         NSLog.Logger.Error("TopicDelete_Fail", e);
         return(false);
     }
 }
Exemplo n.º 3
0
        public async Task <DeleteTopicResponse> DeleteTopicAsync(DeleteTopicRequest request)
        {
            var marshaller   = new DeleteTopicRequestMarshaller();
            var unmarshaller = DeleteTopicResponseUnmarshaller.Instance;

            return(await InvokeAsync <DeleteTopicRequest, DeleteTopicResponse>(request, marshaller, unmarshaller).ConfigureAwait(false));
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DeleteTopic operation.
        /// <seealso cref="Amazon.SimpleNotificationService.IAmazonSimpleNotificationService"/>
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the DeleteTopic 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 <DeleteTopicResponse> DeleteTopicAsync(DeleteTopicRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new DeleteTopicRequestMarshaller();
            var unmarshaller = DeleteTopicResponseUnmarshaller.Instance;

            return(Invoke <IRequest, DeleteTopicRequest, DeleteTopicResponse>(request, marshaller, unmarshaller, signer, cancellationToken));
        }
Exemplo n.º 5
0
        public void FindTopic()
        {
            // create new topic
            var name = "dotnetsdk" + DateTime.Now.Ticks;
            var createTopicRequest = new CreateTopicRequest
            {
                Name = name
            };
            var createTopicResult = Client.CreateTopic(createTopicRequest);
            var topicArn          = createTopicResult.TopicArn;

            try
            {
                // find the topic by name
                var foundTopic = Client.FindTopic(name);

                // verify that the topic was fund
                Assert.IsNotNull(foundTopic);
            }
            finally
            {
                // delete the topic
                var deleteTopicRequest = new DeleteTopicRequest
                {
                    TopicArn = topicArn
                };
                Client.DeleteTopic(deleteTopicRequest);
            }
        }
Exemplo n.º 6
0
        /// <inheritdoc/>
        public DeleteTopicResponse DeleteTopic(DeleteTopicRequest request)
        {
            var marshaller   = new DeleteTopicRequestMarshaller();
            var unmarshaller = DeleteTopicResponseUnmarshaller.Instance;

            return(Invoke <DeleteTopicRequest, DeleteTopicResponse>(request, marshaller, unmarshaller));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Deletes the specified topic.
        /// &lt;br/&gt;
        /// Transactions Per Minute (TPM) per-tenancy limit for this operation: 60.
        ///
        /// </summary>
        /// <param name="request">The request object containing the details to send. Required.</param>
        /// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param>
        /// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param>
        /// <returns>A response object containing details about the completed operation</returns>
        /// <example>Click <a href="https://docs.cloud.oracle.com/en-us/iaas/tools/dot-net-examples/latest/ons/DeleteTopic.cs.html">here</a> to see an example of how to use DeleteTopic API.</example>
        public async Task <DeleteTopicResponse> DeleteTopic(DeleteTopicRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called deleteTopic");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/topics/{topicId}".Trim('/')));
            HttpMethod         method         = new HttpMethod("DELETE");
            HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request);

            requestMessage.Headers.Add("Accept", "application/json");
            GenericRetrier      retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration);
            HttpResponseMessage responseMessage;

            try
            {
                if (retryingClient != null)
                {
                    responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken).ConfigureAwait(false);
                }
                else
                {
                    responseMessage = await this.restClient.HttpSend(requestMessage).ConfigureAwait(false);
                }
                this.restClient.CheckHttpResponseMessage(requestMessage, responseMessage);

                return(Converter.FromHttpResponseMessage <DeleteTopicResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"DeleteTopic failed with error: {e.Message}");
                throw;
            }
        }
Exemplo n.º 8
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            if (!ConfirmDelete("OCIOnsTopic", "Remove"))
            {
                return;
            }

            DeleteTopicRequest request;

            try
            {
                request = new DeleteTopicRequest
                {
                    TopicId      = TopicId,
                    OpcRequestId = OpcRequestId,
                    IfMatch      = IfMatch
                };

                response = client.DeleteTopic(request).GetAwaiter().GetResult();
                WriteOutput(response);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Delete a SNS Topic
        /// </summary>
        /// <param name="topicArn"></param>
        public void DeleteTopic(string topicArn)
        {
            var request = new DeleteTopicRequest {
                TopicArn = topicArn
            };

            Client.DeleteTopic(request);
        }
Exemplo n.º 10
0
        public async Task <DeleteTopicResponse> DeleteTopicAsync(string topicName)
        {
            var request = new DeleteTopicRequest {
                TopicName = topicName
            };

            return(await DeleteTopicAsync(request).ConfigureAwait(false));
        }
Exemplo n.º 11
0
        /// <inheritdoc/>
        public DeleteTopicResponse DeleteTopic(string topicName)
        {
            var request = new DeleteTopicRequest {
                TopicName = topicName
            };

            return(DeleteTopic(request));
        }
Exemplo n.º 12
0
        /// <inheritdoc/>
        public IAsyncResult BeginDeleteTopic(DeleteTopicRequest request, AsyncCallback callback, object state)
        {
            var marshaller   = new DeleteTopicRequestMarshaller();
            var unmarshaller = DeleteTopicResponseUnmarshaller.Instance;

            return(BeginInvoke <DeleteTopicRequest>(request, marshaller, unmarshaller,
                                                    callback, state));
        }
Exemplo n.º 13
0
        public override async Task <DeleteTopicResponse> Delete(DeleteTopicRequest request, ServerCallContext context)
        {
            var id = await _topicService.RemoveAsync(request.Id);

            return(new DeleteTopicResponse
            {
                DeletedId = id ?? -1
            });
        }
Exemplo n.º 14
0
        public async Task <bool> DeleteMessage(string topicArn)
        {
            //delete an SNS topic
            DeleteTopicRequest  deleteTopicRequest  = new DeleteTopicRequest(topicArn);
            DeleteTopicResponse deleteTopicResponse = await _sns.DeleteTopicAsync(deleteTopicRequest);

            Console.WriteLine("DeleteTopic RequestId: {0}", deleteTopicResponse.ResponseMetadata.RequestId);
            return(true);
        }
Exemplo n.º 15
0
        public virtual void DeleteTopic(AmazonSimpleNotificationServiceClient snsClient, string topicArn)
        {
            // Create the request
            var deleteTopicRequest = new DeleteTopicRequest
            {
                TopicArn = topicArn
            };

            snsClient.DeleteTopic(deleteTopicRequest);
        }
Exemplo n.º 16
0
        /**
         * Convert DeleteTopicRequest to name value pairs
         */
        private static IDictionary<string, string> ConvertDeleteTopic(DeleteTopicRequest request)
        {
            IDictionary<string, string> parameters = new Dictionary<string, string>();
            parameters["Action"] = "DeleteTopic";
            if (request.IsSetTopicArn())
            {
                parameters["TopicArn"] = request.TopicArn;
            }

            return parameters;
        }
Exemplo n.º 17
0
        private static IDictionary <string, string> ConvertDeleteTopic(DeleteTopicRequest request)
        {
            IDictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary["Action"] = "DeleteTopic";
            if (request.IsSetTopicArn())
            {
                dictionary["TopicArn"] = request.TopicArn;
            }
            return(dictionary);
        }
Exemplo n.º 18
0
        public void CRUDTopics()
        {
            // list all topics
            var allTopics         = GetAllTopics();
            var currentTopicCount = allTopics.Count;

            // create new topic
            var name = "dotnetsdk" + DateTime.Now.Ticks;
            var createTopicRequest = new CreateTopicRequest
            {
                Name = name
            };
            var createTopicResult = Client.CreateTopic(createTopicRequest);
            var topicArn          = createTopicResult.TopicArn;

            try
            {
                // verify there is a new topic
                allTopics = GetAllTopics();
                Assert.AreNotEqual(currentTopicCount, allTopics.Count);

                // set topic attribute
                var setTopicAttributesRequest = new SetTopicAttributesRequest
                {
                    TopicArn       = topicArn,
                    AttributeName  = "DisplayName",
                    AttributeValue = "Test topic"
                };
                Client.SetTopicAttributes(setTopicAttributesRequest);

                // verify topic attributes
                var getTopicAttributesRequest = new GetTopicAttributesRequest
                {
                    TopicArn = topicArn
                };
                var topicAttributes =
                    Client.GetTopicAttributes(getTopicAttributesRequest).Attributes;
                Assert.AreEqual(setTopicAttributesRequest.AttributeValue,
                                topicAttributes[setTopicAttributesRequest.AttributeName]);
            }
            finally
            {
                // delete new topic
                var deleteTopicRequest = new DeleteTopicRequest
                {
                    TopicArn = topicArn
                };
                Client.DeleteTopic(deleteTopicRequest);

                // verify the topic was deleted
                allTopics = GetAllTopics();
                Assert.AreEqual(currentTopicCount, allTopics.Count);
            }
        }
        public async System.Threading.Tasks.Task <DeleteTopicResponse> DeleteTopic(string topicArn)
        {
            DeleteTopicResponse deleteTopicResponse = new DeleteTopicResponse();

            using (AmazonSimpleNotificationServiceClient snsClient = new AmazonSimpleNotificationServiceClient(credentials, Amazon.RegionEndpoint.USEast2))
            {
                DeleteTopicRequest deleteRequest = new DeleteTopicRequest(topicArn);
                deleteTopicResponse = await snsClient.DeleteTopicAsync(deleteRequest);
            }

            return(deleteTopicResponse);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Deletes the topic with the given name. Generates `NOT_FOUND` if the topic
        /// does not exist. After a topic is deleted, a new topic may be created with
        /// the same name; this is an entirely new topic with none of the old
        /// configuration or subscriptions. Existing subscriptions to this topic are
        /// not deleted, but their `topic` field is set to `_deleted-topic_`.
        /// </summary>
        /// <param name="topic">Name of the topic to delete.</param>
        /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
        /// <returns>The RPC response.</returns>
        public override void DeleteTopic(
            string topic,
            CallSettings callSettings = null)
        {
            DeleteTopicRequest request = new DeleteTopicRequest
            {
                Topic = topic,
            };

            GrpcClient.DeleteTopic(
                request,
                _clientHelper.BuildCallOptions(null, callSettings));
        }
Exemplo n.º 21
0
        public static void SNSDeleteTopic()
        {
            #region SNSDeleteTopic
            var snsClient = new AmazonSimpleNotificationServiceClient();

            var request = new DeleteTopicRequest
            {
                TopicArn = "arn:aws:sns:us-east-1:80398EXAMPLE:CodingTestResults"
            };

            snsClient.DeleteTopic(request);
            #endregion
        }
Exemplo n.º 22
0
        public async System.Threading.Tasks.Task RemoveTopicAsync()
        {
            AmazonSimpleNotificationServiceClient snsClient = new AmazonSimpleNotificationServiceClient(RegionEndpoint.APSoutheast1);

            string topicArn = "";

            // Delete an Amazon SNS topic.
            DeleteTopicRequest  deleteTopicRequest  = new DeleteTopicRequest(topicArn);
            DeleteTopicResponse deleteTopicResponse = await snsClient.DeleteTopicAsync(deleteTopicRequest);

            // Print the request ID for the DeleteTopicRequest action.
            Console.WriteLine("DeleteTopicRequest: " + deleteTopicResponse.ResponseMetadata.RequestId);
        }
        internal DeleteTopicResponse DeleteTopic(DeleteTopicRequest request)
        {
            var task = DeleteTopicAsync(request);

            try
            {
                return(task.Result);
            }
            catch (AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return(null);
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// 删除ckafka主题
        /// </summary>
        /// <param name="req"><see cref="DeleteTopicRequest"/></param>
        /// <returns><see cref="DeleteTopicResponse"/></returns>
        public DeleteTopicResponse DeleteTopicSync(DeleteTopicRequest req)
        {
            JsonResponseModel <DeleteTopicResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "DeleteTopic");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <DeleteTopicResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
Exemplo n.º 25
0
        public void DeleteTopic()
        {
            ListTopics();
            Console.WriteLine("======Previuos Topics=======");
            DeleteTopicRequest request = new DeleteTopicRequest {
                TopicArn = TopicARN
            };
            var response = client.DeleteTopic(request);

            if (response.HttpStatusCode.IsSuccess())
            {
                Console.WriteLine("Topic has been deleted successfully");
                ListTopics();
            }
        }
        public void DeletedTopic()
        {
            DeleteTopicRequest request = new DeleteTopicRequest
            {
                TopicArn = "arn:aws:sns:us-west-1:491483104165:TopicApp"
            };

            var response = client.DeleteTopic(request);

            if (response.HttpStatusCode.IsSuccess())
            {
                Console.WriteLine($"Topic has ben deleted successfullt!");
                ListTopics();
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// Deletes the topic with the given name. Generates `NOT_FOUND` if the topic
        /// does not exist. After a topic is deleted, a new topic may be created with
        /// the same name; this is an entirely new topic with none of the old
        /// configuration or subscriptions. Existing subscriptions to this topic are
        /// not deleted, but their `topic` field is set to `_deleted-topic_`.
        /// </summary>
        /// <param name="topic">Name of the topic to delete.</param>
        /// <param name="cancellationToken">If not null, a <see cref="CancellationToken"/> to use for this RPC.</param>
        /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
        /// <returns>A Task containing the RPC response.</returns>
        public override Task DeleteTopicAsync(
            string topic,
            CancellationToken?cancellationToken = null,
            CallSettings callSettings           = null)
        {
            DeleteTopicRequest request = new DeleteTopicRequest
            {
                Topic = topic,
            };

            return(GrpcClient.DeleteTopicAsync(
                       request,
                       _clientHelper.BuildCallOptions(cancellationToken, callSettings)
                       ).ResponseAsync);
        }
        public void DeleteTopic_RequestObject()
        {
            // Snippet: DeleteTopic(DeleteTopicRequest,CallSettings)
            // Create client
            PublisherClient publisherClient = PublisherClient.Create();
            // Initialize request argument(s)
            DeleteTopicRequest request = new DeleteTopicRequest
            {
                TopicAsTopicName = new TopicName("[PROJECT]", "[TOPIC]"),
            };

            // Make the request
            publisherClient.DeleteTopic(request);
            // End snippet
        }
        public void DeleteTopicResourceNames()
        {
            moq::Mock <Publisher.PublisherClient> mockGrpcClient = new moq::Mock <Publisher.PublisherClient>(moq::MockBehavior.Strict);
            DeleteTopicRequest request = new DeleteTopicRequest
            {
                TopicAsTopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.DeleteTopic(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null);

            client.DeleteTopic(request.TopicAsTopicName);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for DeleteTopicAsync</summary>
        public async Task DeleteTopicAsync_RequestObject()
        {
            // Snippet: DeleteTopicAsync(DeleteTopicRequest,CallSettings)
            // Create client
            PublisherServiceApiClient publisherServiceApiClient = await PublisherServiceApiClient.CreateAsync();

            // Initialize request argument(s)
            DeleteTopicRequest request = new DeleteTopicRequest
            {
                TopicAsTopicName = new TopicName("[PROJECT]", "[TOPIC]"),
            };
            // Make the request
            await publisherServiceApiClient.DeleteTopicAsync(request);

            // End snippet
        }