public async stt::Task UpdateTopicRequestObjectAsync()
        {
            moq::Mock <Publisher.PublisherClient> mockGrpcClient = new moq::Mock <Publisher.PublisherClient>(moq::MockBehavior.Strict);
            UpdateTopicRequest request = new UpdateTopicRequest
            {
                Topic      = new Topic(),
                UpdateMask = new wkt::FieldMask(),
            };
            Topic expectedResponse = new Topic
            {
                TopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
                Labels    =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                MessageStoragePolicy     = new MessageStoragePolicy(),
                KmsKeyName               = "kms_key_name06bd122b",
                SchemaSettings           = new SchemaSettings(),
                SatisfiesPzs             = false,
                MessageRetentionDuration = new wkt::Duration(),
            };

            mockGrpcClient.Setup(x => x.UpdateTopicAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Topic>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null);
            Topic responseCallSettings       = await client.UpdateTopicAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Topic responseCancellationToken = await client.UpdateTopicAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Beispiel #2
0
        public async Task UpdateTopicAsync()
        {
            Mock <Publisher.PublisherClient> mockGrpcClient = new Mock <Publisher.PublisherClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateIAMPolicyClient())
            .Returns(new Mock <IAMPolicy.IAMPolicyClient>().Object);
            UpdateTopicRequest request = new UpdateTopicRequest
            {
                Topic      = new Topic(),
                UpdateMask = new FieldMask(),
            };
            Topic expectedResponse = new Topic
            {
                TopicName  = new TopicName("[PROJECT]", "[TOPIC]"),
                KmsKeyName = "kmsKeyName2094986649",
            };

            mockGrpcClient.Setup(x => x.UpdateTopicAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Topic>(Task.FromResult(expectedResponse), null, null, null, null));
            PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null);
            Topic response = await client.UpdateTopicAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void UpdateTopicRequestObject()
        {
            moq::Mock <Publisher.PublisherClient> mockGrpcClient = new moq::Mock <Publisher.PublisherClient>(moq::MockBehavior.Strict);
            UpdateTopicRequest request = new UpdateTopicRequest
            {
                Topic      = new Topic(),
                UpdateMask = new wkt::FieldMask(),
            };
            Topic expectedResponse = new Topic
            {
                TopicName = TopicName.FromProjectTopic("[PROJECT]", "[TOPIC]"),
                Labels    =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                MessageStoragePolicy = new MessageStoragePolicy(),
                KmsKeyName           = "kms_key_name06bd122b",
                SchemaSettings       = new SchemaSettings(),
                SatisfiesPzs         = false,
            };

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

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #4
0
        /// <summary>
        /// Updates the specified topic&#39;s configuration.
        /// &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/UpdateTopic.cs.html">here</a> to see an example of how to use UpdateTopic API.</example>
        public async Task <UpdateTopicResponse> UpdateTopic(UpdateTopicRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called updateTopic");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/topics/{topicId}".Trim('/')));
            HttpMethod         method         = new HttpMethod("PUT");
            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 <UpdateTopicResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"UpdateTopic failed with error: {e.Message}");
                throw;
            }
        }
 /// <summary>Snippet for UpdateTopic</summary>
 public void UpdateTopic_RequestObject()
 {
     // Snippet: UpdateTopic(UpdateTopicRequest,CallSettings)
     // Create client
     PublisherServiceApiClient publisherServiceApiClient = PublisherServiceApiClient.Create();
     // Initialize request argument(s)
     UpdateTopicRequest request = new UpdateTopicRequest
     {
         Topic      = new Topic(),
         UpdateMask = new FieldMask(),
     };
     // Make the request
     Topic response = publisherServiceApiClient.UpdateTopic(request);
     // End snippet
 }
Beispiel #6
0
        public override Task <UpdateTopicResponse> Update(UpdateTopicRequest request, ServerCallContext context)
        {
            var oldTopic = new Topic(request.Id);
            var newTopic = new Topic(request.Id)
            {
                Description = request.NewDescription,
                Name        = request.NewName
            };

            var updated = _topicService.Update(oldTopic, newTopic);

            return(Task.FromResult(new UpdateTopicResponse
            {
                Id = updated ? oldTopic.Id : -1
            }));
        }
Beispiel #7
0
        /// <summary>Snippet for UpdateTopicAsync</summary>
        public async Task UpdateTopicAsync_RequestObject()
        {
            // Snippet: UpdateTopicAsync(UpdateTopicRequest,CallSettings)
            // Create client
            PublisherClient publisherClient = await PublisherClient.CreateAsync();

            // Initialize request argument(s)
            UpdateTopicRequest request = new UpdateTopicRequest
            {
                Topic      = new Topic(),
                UpdateMask = new FieldMask(),
            };
            // Make the request
            Topic response = await publisherClient.UpdateTopicAsync(request);

            // End snippet
        }
Beispiel #8
0
        /// <summary>
        /// 更新topic
        /// </summary>
        public void UpdateTopic()
        {
            // 设置请求对象
            UpdateTopicRequest request = new UpdateTopicRequest
            {
                DisplayName = "哈哈哈",
                TopicUrn    = "urn:smn:cn-north-1:cffe4fc4c9a54219b60dbaf7b586e132:create_by_zhangyx_test_csharp"
            };

            try
            {
                // 发送请求并返回响应
                UpdateTopicResponse response = smnClient.SendRequest(request);
                string result = response.RequestId;
                Console.WriteLine("{0}", result);
                Console.ReadLine();
            }
            catch (Exception e)
            {
                // 处理异常
                Console.WriteLine("{0}", e.Message);
            }
        }
Beispiel #9
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            UpdateTopicRequest request;

            try
            {
                request = new UpdateTopicRequest
                {
                    TopicId = TopicId,
                    TopicAttributesDetails = TopicAttributesDetails,
                    OpcRequestId           = OpcRequestId,
                    IfMatch = IfMatch
                };

                response = client.UpdateTopic(request).GetAwaiter().GetResult();
                WriteOutput(response, response.NotificationTopic);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
        /// <summary>
        /// Updates the specified topic's configuration.
        /// Transactions Per Minute (TPM) per-tenancy limit for this operation: 60.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <UpdateTopicResponse> UpdateTopic(UpdateTopicRequest request)
        {
            var uri = new Uri($"{GetEndPoint(NotificationServices.Topics, this.Region)}/{request.TopicId}");

            var httpRequestHeaderParam = new HttpRequestHeaderParam()
            {
                OpcRequestId = request.OpcRequestId,
                IfMatch      = request.IfMatch
            };
            var webResponse = await this.RestClientAsync.Put(uri, request.TopicAttributesDetails, httpRequestHeaderParam);

            using (var stream = webResponse.GetResponseStream())
                using (var reader = new StreamReader(stream))
                {
                    var response = reader.ReadToEnd();

                    return(new UpdateTopicResponse()
                    {
                        OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                        ETag = webResponse.Headers.Get("etag"),
                        NotificationTopic = this.JsonSerializer.Deserialize <NotificationTopicDetails>(response)
                    });
                }
        }
Beispiel #11
0
        public void UpdateTopic()
        {
            Mock <Publisher.PublisherClient> mockGrpcClient = new Mock <Publisher.PublisherClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateIAMPolicyClient())
            .Returns(new Mock <IAMPolicy.IAMPolicyClient>().Object);
            UpdateTopicRequest request = new UpdateTopicRequest
            {
                Topic      = new Topic(),
                UpdateMask = new FieldMask(),
            };
            Topic expectedResponse = new Topic
            {
                TopicName = new TopicName("[PROJECT]", "[TOPIC]"),
            };

            mockGrpcClient.Setup(x => x.UpdateTopic(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            PublisherServiceApiClient client = new PublisherServiceApiClientImpl(mockGrpcClient.Object, null);
            Topic response = client.UpdateTopic(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #12
0
 /// <summary>
 ///  此接口可以用来更新主题,创建归档,修改归档,删除归档,传入不同的参数可以实现不同的功能。修改归档只需要修改相应归档的参数,删除归档只需要把归档参数置为空即可
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public async Task <UpdateTopicResponse> UpdateTopic(UpdateTopicRequest request)
 {
     return(await new UpdateTopicExecutor().Client(this).Execute <UpdateTopicResponse, UpdateTopicResult, UpdateTopicRequest>(request).ConfigureAwait(false));
 }
Beispiel #13
0
 /// <summary>
 ///  此接口可以用来更新主题,创建归档,修改归档,删除归档,传入不同的参数可以实现不同的功能。修改归档只需要修改相应归档的参数,删除归档只需要把归档参数置为空即可
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public UpdateTopicResponse UpdateTopic(UpdateTopicRequest request)
 {
     return(new UpdateTopicExecutor().Client(this).Execute <UpdateTopicResponse, UpdateTopicResult, UpdateTopicRequest>(request));
 }