示例#1
0
        IotCentralAppResource IOperationSource <IotCentralAppResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = IotCentralAppData.DeserializeIotCentralAppData(document.RootElement);

            return(new IotCentralAppResource(_client, data));
        }
        public virtual async Task <ArmOperation <IotCentralAppResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string resourceName, IotCentralAppData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(resourceName, nameof(resourceName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _iotCentralAppAppsClientDiagnostics.CreateScope("IotCentralAppCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _iotCentralAppAppsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, resourceName, data, cancellationToken).ConfigureAwait(false);

                var operation = new IotCentralArmOperation <IotCentralAppResource>(new IotCentralAppOperationSource(Client), _iotCentralAppAppsClientDiagnostics, Pipeline, _iotCentralAppAppsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, resourceName, data).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#3
0
 internal IotCentralAppResource(ArmClient client, IotCentralAppData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }