public async Task <bool> DeleteDeviceGroupAsync(AzureSphereTenant tenant, AzureSphereDeviceGroup deviceGroup, CancellationToken cancellationToken)
        {
            Console.WriteLine("DeleteDeviceGroupAsync()");

            var jsonString = await MethodAsync($"v2/tenants/{tenant.Id}/devicegroups/{deviceGroup.Id}", Method.DELETE, null, null, cancellationToken);

            Console.WriteLine(jsonString);
            var operation = new AzureSphereOperation(JObject.Parse(jsonString));

            return(await GetAsyncOperation(tenant, operation.OperationId, cancellationToken));
        }
        public async Task <bool> PostDeployAsync(AzureSphereTenant tenant, AzureSphereDeviceGroup deviceGroup, HttpContent jsonContent,
                                                 CancellationToken cancellationToken)
        {
            Console.WriteLine("PostDeployAsync()");

            var jsonString = await MethodAsync($"v2/tenants/{tenant.Id}/devicegroups/{deviceGroup.Id}/deployments",
                                               Method.POST,
                                               jsonContent,
                                               null,
                                               cancellationToken);

            Console.WriteLine(jsonString);
            var operation = new AzureSphereOperation(JObject.Parse(jsonString));

            return(await GetAsyncOperation(tenant, operation.OperationId, cancellationToken));
        }
        public async Task <List <AzureSphereDeployment> > GetDeploymentsAsync(AzureSphereTenant tenant, AzureSphereDeviceGroup deviceGroup, CancellationToken cancellationToken)
        {
            var jsonString = await GetAsync($"v2/tenants/{tenant.Id}/devicegroups/{deviceGroup.Id}/deployments", cancellationToken);

            Console.WriteLine("GetDeploymentsAsync()");
            Console.WriteLine(jsonString);
            var json            = JToken.Parse(jsonString);
            var jsonDeployments = json.Value <JArray>("Items");

            var deployments = new List <AzureSphereDeployment>();

            foreach (var jsonDeployment in jsonDeployments)
            {
                deployments.Add(new AzureSphereDeployment(jsonDeployment));
            }

            return(deployments);
        }
 public async Task DeleteDeviceGroupAsync(AzureSphereTenant tenant, AzureSphereDeviceGroup deviceGroup, CancellationToken cancellationToken)
 {
     await DeleteAsync($"v2/tenants/{tenant.Id}/devicegroups/{deviceGroup.Id}", cancellationToken);
 }
        public async Task <List <AzureSphereDeployment> > GetDeploymentsAsync(AzureSphereTenant tenant, AzureSphereDeviceGroup deviceGroup, CancellationToken cancellationToken)
        {
            Console.WriteLine("GetDeploymentsAsync()");
            var deployments = new List <AzureSphereDeployment>();

            string continuationToken = null;

            while (true)
            {
                var jsonString = await MethodAsync($"v2/tenants/{tenant.Id}/devicegroups/{deviceGroup.Id}/deployments",
                                                   Method.GET, null, null, cancellationToken);

                Console.WriteLine(jsonString);
                var json            = JToken.Parse(jsonString);
                var jsonDeployments = json.Value <JArray>("Items");

                foreach (var jsonDeployment in jsonDeployments)
                {
                    deployments.Add(new AzureSphereDeployment(jsonDeployment));
                }

                if (json["ContinuationToken"] == null || json["ContinuationToken"].Type == JTokenType.Null)
                {
                    break;
                }
                continuationToken = json.Value <string>("ContinuationToken");
            }

            return(deployments);
        }