LinkerResource IOperationSource <LinkerResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = LinkerResourceData.DeserializeLinkerResourceData(document.RootElement);

            return(new LinkerResource(_client, data));
        }
Exemplo n.º 2
0
        public virtual ArmOperation <LinkerResource> CreateOrUpdate(WaitUntil waitUntil, string linkerName, LinkerResourceData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(linkerName, nameof(linkerName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _linkerResourceLinkerClientDiagnostics.CreateScope("LinkerResourceCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _linkerResourceLinkerRestClient.CreateOrUpdate(Id, linkerName, data, cancellationToken);
                var operation = new ServiceLinkerArmOperation <LinkerResource>(new LinkerResourceOperationSource(Client), _linkerResourceLinkerClientDiagnostics, Pipeline, _linkerResourceLinkerRestClient.CreateCreateOrUpdateRequest(Id, linkerName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 internal LinkerResource(ArmClient client, LinkerResourceData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }