コード例 #1
0
        public async Task Test_log_stream_crud_sequence()
        {
            // Create a new entity
            var name = "Auth0.net Test Log Stream";

            var request = new LogStreamCreateRequest
            {
                Name = name,
                Type = LogStreamType.Http,
                Sink = new
                {
                    httpEndpoint      = "https://my-stream.com",
                    httpContentType   = "application/json",
                    httpContentFormat = "JSONOBJECT",
                    httpAuthorization = "http-auth"
                }
            };

            var createdLogStream = await _apiClient.LogStreams.CreateAsync(request);

            createdStreams.Add(createdLogStream);

            createdLogStream.Should().NotBeNull();
            createdLogStream.Name.Should().Be(name);

            // Get an entity
            var fetchedLogStream = await _apiClient.LogStreams.GetAsync(createdLogStream.Id);

            fetchedLogStream.Should().NotBeNull();
            fetchedLogStream.Name.Should().Be(name);
            fetchedLogStream.Id.Should().Be(createdLogStream.Id);

            // Update the entity
            var updateRequest = new LogStreamUpdateRequest
            {
                Name   = "Auth0.net Test Updated Stream",
                Status = LogStreamUpdateStatus.Paused,
                Sink   = new
                {
                    httpEndpoint = "https://new-stream.com"
                }
            };

            var updatedLogStream = await _apiClient.LogStreams.UpdateAsync(fetchedLogStream.Id, updateRequest);

            updatedLogStream.Name.Should().Be(updateRequest.Name);
            updatedLogStream.Status.Should().Be(LogStreamStatus.Paused);
            updatedLogStream.Id.Should().Be(fetchedLogStream.Id);

            // show that sink properties are merged
            ((string)updatedLogStream.Sink.httpContentType).Should().Be("application/json");
            ((string)updatedLogStream.Sink.httpEndpoint).Should().Be(updateRequest.Sink.httpEndpoint);

            // Delete the entity
            await _apiClient.LogStreams.DeleteAsync(createdLogStream.Id);

            Func <Task> getFunc = async() => await _apiClient.LogStreams.GetAsync(createdLogStream.Id);

            getFunc.Should().Throw <ErrorApiException>().And.ApiError.Error.Should().Be("Not Found");
        }
コード例 #2
0
        /// <summary>
        /// Updates a log stream
        /// </summary>
        /// <param name="id">The id of the log stream to update</param>
        /// <param name="request">The information required to update the log stream</param>
        /// <returns>The updated <see cref="LogStream"/> object</returns>
        public Task <LogStream> UpdateAsync(string id, LogStreamUpdateRequest request)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(id));
            }

            return(Connection.SendAsync <LogStream>(new HttpMethod("PATCH"), BuildUri($"log-streams/{EncodePath(id)}"), request, DefaultHeaders));
        }