Example #1
0
        internal static AccountList DeserializeAccountList(JsonElement element)
        {
            Optional <string> nextLink = default;
            Optional <IReadOnlyList <DeviceUpdateAccountData> > value = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("value"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <DeviceUpdateAccountData> array = new List <DeviceUpdateAccountData>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(DeviceUpdateAccountData.DeserializeDeviceUpdateAccountData(item));
                    }
                    value = array;
                    continue;
                }
            }
            return(new AccountList(nextLink.Value, Optional.ToList(value)));
        }
Example #2
0
        protected async Task <DeviceUpdateAccount> CreateAccount(ResourceGroup rg, string accountName)
        {
            DeviceUpdateAccountData input = ResourceDataHelper.CreateAccountData();
            var lro = await rg.GetDeviceUpdateAccounts().CreateOrUpdateAsync(WaitUntil.Completed, accountName, input);

            return(lro.Value);
        }
Example #3
0
        DeviceUpdateAccount IOperationSource <DeviceUpdateAccount> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = DeviceUpdateAccountData.DeserializeDeviceUpdateAccountData(document.RootElement);

            return(new DeviceUpdateAccount(_armClient, data));
        }
Example #4
0
        public static DeviceUpdateAccountData CreateAccountData()
        {
            var account = new DeviceUpdateAccountData(AzureLocation.WestUS2)
            {
                Sku = DeviceUpdateSku.Standard
            };

            return(account);
        }
        public async Task CreateAccounts()
        {
            #region Snippet:Managing_Accounts_CreateAnAccount
            // Get the account collection from the specific resource group and create an account
            string accountName = "myAccount";
            DeviceUpdateAccountData            input = new DeviceUpdateAccountData(AzureLocation.WestUS2);
            ArmOperation <DeviceUpdateAccount> lro   = await resourceGroup.GetDeviceUpdateAccounts().CreateOrUpdateAsync(true, accountName, input);

            DeviceUpdateAccount account = lro.Value;
            #endregion Snippet:Managing_Accounts_CreateAnAccount
        }
        public async Task CreateInstances()
        {
            #region Snippet:Managing_Instances_CreateAnInstance
            // Create a new account
            string accountName             = "myAccount";
            DeviceUpdateAccountData input1 = new DeviceUpdateAccountData(AzureLocation.WestUS2);
            DeviceUpdateAccountCreateOrUpdateOperation lro1 = await resourceGroup.GetDeviceUpdateAccounts().CreateOrUpdateAsync(true, accountName, input1);

            DeviceUpdateAccount account = lro1.Value;
            // Get the instance collection from the specific account and create an instance
            string instanceName             = "myInstance";
            DeviceUpdateInstanceData input2 = new DeviceUpdateInstanceData(AzureLocation.WestUS2);
            input2.IotHubs.Add(new IotHubSettings("/subscriptions/.../resourceGroups/.../providers/Microsoft.Devices/IotHubs/..."));
            DeviceUpdateInstanceCreateOrUpdateOperation lro2 = await account.GetDeviceUpdateInstances().CreateOrUpdateAsync(true, instanceName, input2);

            DeviceUpdateInstance instance = lro2.Value;
            #endregion Snippet:Managing_Instances_CreateAnInstance
        }