Exemple #1
0
        public async Task cannot_post_existing_agent_profile_when_etag_is_invalid()
        {
            // Arrange
            var state = new AgentProfileDocument <string>()
            {
                Content = "foo",
                ETag    = ETAG
            };
            var request = PostAgentProfileRequest.Create(state);

            request.Agent = new Agent()
            {
                Name = AGENT_NAME,
                MBox = new Uri(AGENT_MBOX)
            };
            request.ProfileId = PROFILE_ID;
            this._mockHttp
            .When(HttpMethod.Post, this.GetApiUrl("agents/profile"))
            .WithQueryString("agent", AGENT_QS)
            .WithQueryString("profileId", PROFILE_ID)
            .WithHeaders("If-Match", ETAG)
            .Respond(HttpStatusCode.PreconditionFailed);

            // Act
            bool result = await this._client.AgentProfiles.Post(request);

            // Assert
            result.Should().BeFalse();
        }
Exemple #2
0
        public async Task can_post_new_agent_profile()
        {
            // Arrange
            var state = new AgentProfileDocument <string>()
            {
                Content = "foo"
            };
            var request = PostAgentProfileRequest.Create(state);

            request.Agent = new Agent()
            {
                Name = AGENT_NAME,
                MBox = new Uri(AGENT_MBOX)
            };
            request.ProfileId = PROFILE_ID;
            this._mockHttp
            .When(HttpMethod.Post, this.GetApiUrl("agents/profile"))
            .WithQueryString("agent", AGENT_QS)
            .WithQueryString("profileId", PROFILE_ID)
            .WithHeaders("If-None-Match", "*")
            .Respond(HttpStatusCode.NoContent);

            // Act
            bool result = await this._client.AgentProfiles.Post(request);

            // Assert
            result.Should().BeTrue();
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the PostAgentProfile service method.</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 PostAgentProfile service method, as returned by CodeGuruProfiler.</returns>
        /// <exception cref="Amazon.CodeGuruProfiler.Model.InternalServerException">
        /// The server encountered an internal error and is unable to complete the request.
        /// </exception>
        /// <exception cref="Amazon.CodeGuruProfiler.Model.ResourceNotFoundException">
        /// The resource specified in the request does not exist.
        /// </exception>
        /// <exception cref="Amazon.CodeGuruProfiler.Model.ThrottlingException">
        /// The request was denied due to request throttling.
        /// </exception>
        /// <exception cref="Amazon.CodeGuruProfiler.Model.ValidationException">
        /// The parameter is not valid.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/codeguruprofiler-2019-07-18/PostAgentProfile">REST API Reference for PostAgentProfile Operation</seealso>
        public virtual Task <PostAgentProfileResponse> PostAgentProfileAsync(PostAgentProfileRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = PostAgentProfileRequestMarshaller.Instance;
            options.ResponseUnmarshaller = PostAgentProfileResponseUnmarshaller.Instance;

            return(InvokeAsync <PostAgentProfileResponse>(request, options, cancellationToken));
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the PostAgentProfile service method.</param>
        ///
        /// <returns>The response from the PostAgentProfile service method, as returned by CodeGuruProfiler.</returns>
        /// <exception cref="Amazon.CodeGuruProfiler.Model.InternalServerException">
        /// The server encountered an internal error and is unable to complete the request.
        /// </exception>
        /// <exception cref="Amazon.CodeGuruProfiler.Model.ResourceNotFoundException">
        /// The resource specified in the request does not exist.
        /// </exception>
        /// <exception cref="Amazon.CodeGuruProfiler.Model.ThrottlingException">
        /// The request was denied due to request throttling.
        /// </exception>
        /// <exception cref="Amazon.CodeGuruProfiler.Model.ValidationException">
        /// The parameter is not valid.
        /// </exception>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/codeguruprofiler-2019-07-18/PostAgentProfile">REST API Reference for PostAgentProfile Operation</seealso>
        public virtual PostAgentProfileResponse PostAgentProfile(PostAgentProfileRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = PostAgentProfileRequestMarshaller.Instance;
            options.ResponseUnmarshaller = PostAgentProfileResponseUnmarshaller.Instance;

            return(Invoke <PostAgentProfileResponse>(request, options));
        }
Exemple #5
0
        /// <summary>
        /// Initiates the asynchronous execution of the PostAgentProfile operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the PostAgentProfile operation on AmazonCodeGuruProfilerClient.</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 EndPostAgentProfile
        ///         operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/codeguruprofiler-2019-07-18/PostAgentProfile">REST API Reference for PostAgentProfile Operation</seealso>
        public virtual IAsyncResult BeginPostAgentProfile(PostAgentProfileRequest request, AsyncCallback callback, object state)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = PostAgentProfileRequestMarshaller.Instance;
            options.ResponseUnmarshaller = PostAgentProfileResponseUnmarshaller.Instance;

            return(BeginInvoke(request, options, callback, state));
        }
Exemple #6
0
        async Task <bool> IAgentProfilesApi.Post <T>(PostAgentProfileRequest <T> request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            request.Validate();

            var options = new RequestOptions(ENDPOINT);

            this.CompleteOptions(options, request);

            try
            {
                await this._client.PostJson(options, request.AgentProfile);

                return(true);
            }
            catch (PreConditionFailedException)
            {
                return(false);
            }
        }
Exemple #7
0
 private void CompleteOptions <T>(RequestOptions options, PostAgentProfileRequest <T> request)
 {
     this.CompleteOptionsBase(options, request);
     this.AddETagHeader(options, request.AgentProfile.ETag);
 }