Пример #1
0
        public async ValueTask <Response <Skillset> > CreateOrUpdateAsync(string skillsetName, Guid?xMsClientRequestId, string ifMatch, string ifNoneMatch, Skillset skillset, CancellationToken cancellationToken = default)
        {
            if (skillsetName == null)
            {
                throw new ArgumentNullException(nameof(skillsetName));
            }
            if (skillset == null)
            {
                throw new ArgumentNullException(nameof(skillset));
            }

            using var scope = clientDiagnostics.CreateScope("SkillsetsClient.CreateOrUpdate");
            scope.Start();
            try
            {
                using var message = CreateCreateOrUpdateRequest(skillsetName, xMsClientRequestId, ifMatch, ifNoneMatch, skillset);
                await pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

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

                    var value = Skillset.DeserializeSkillset(document.RootElement);
                    return(Response.FromValue(value, message.Response));
                }
        public async Task <Response <Skillset> > CreateOrUpdateAsync(string skillsetName, Skillset skillset, RequestOptions requestOptions = null, AccessCondition accessCondition = null, CancellationToken cancellationToken = default)
        {
            if (skillsetName == null)
            {
                throw new ArgumentNullException(nameof(skillsetName));
            }
            if (skillset == null)
            {
                throw new ArgumentNullException(nameof(skillset));
            }

            using var message = CreateCreateOrUpdateRequest(skillsetName, skillset, requestOptions, accessCondition);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

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

                if (document.RootElement.ValueKind == JsonValueKind.Null)
                {
                    value = null;
                }
                else
                {
                    value = Skillset.DeserializeSkillset(document.RootElement);
                }
                return(Response.FromValue(value, message.Response));
            }