예제 #1
0
        public async Task <Response <TagValue> > CreateOrUpdateValueAsync(string tagName, string tagValue, CancellationToken cancellationToken = default)
        {
            if (tagName == null)
            {
                throw new ArgumentNullException(nameof(tagName));
            }
            if (tagValue == null)
            {
                throw new ArgumentNullException(nameof(tagValue));
            }

            using var message = CreateCreateOrUpdateValueRequest(tagName, tagValue);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            case 201:
            {
                TagValue value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                value = TagValue.DeserializeTagValue(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }