public static List <AvailabilityStatus> GetResourceGroupHealth(string resourceGroupId, string authToken, TraceWriter log)
        {
            HttpClient hc        = new HttpClient();
            string     healthUrl = "https://management.azure.com" + resourceGroupId + "/providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2015-01-01";
            List <AvailabilityStatus> resourceAvailibility = new List <AvailabilityStatus>();

            while (healthUrl != null)
            {
                hc.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authToken);
                HttpResponseMessage hrm = hc.GetAsync(healthUrl).Result;
                string responseData     = "";
                if (hrm.IsSuccessStatusCode)
                {
                    Stream data = hrm.Content.ReadAsStreamAsync().Result;
                    using (StreamReader reader = new StreamReader(data, Encoding.UTF8))
                    {
                        responseData = reader.ReadToEnd();
                        ResourceHealth parsedResponse = JsonConvert.DeserializeObject <ResourceHealth>(responseData);
                        if (parsedResponse != null && parsedResponse.value.Length > 0)
                        {
                            if (parsedResponse.nextLink != null && !parsedResponse.nextLink.Equals(""))
                            {
                                healthUrl = parsedResponse.nextLink;
                            }
                            else
                            {
                                healthUrl = null;
                            }
                            resourceAvailibility.AddRange(parsedResponse.value);
                        }
                        else
                        {
                            //Empty Resource group
                            healthUrl = null;
                        }
                    }
                }
                else
                {
                    //Did not get a 200 OK. Eventually, you will want to add retry calls.
                    healthUrl = null;
                }
            }

            return(resourceAvailibility);
        }
        private void AssertAreSameValidateResourceHealths(ResourceHealth expected, ResourceHealth found)
        {
            if (expected == null)
            {
                Assert.Null(found);
            }
            else
            {
                Assert.True(InfrastructureInsightsCommon.ResourceAreSame(expected, found));
                if (expected.AlertSummary == null)
                {
                    Assert.Null(found.AlertSummary);
                }
                else
                {
                    Assert.NotNull(found.AlertSummary);
                    Assert.Equal(expected.AlertSummary.CriticalAlertCount, found.AlertSummary.CriticalAlertCount);
                    Assert.Equal(expected.AlertSummary.WarningAlertCount, found.AlertSummary.WarningAlertCount);
                }

                Assert.Equal(found.HealthState, expected.HealthState);
                Assert.Equal(found.NamespaceProperty, expected.NamespaceProperty);
                Assert.Equal(found.RegistrationId, expected.RegistrationId);
                Assert.Equal(found.RoutePrefix, expected.RoutePrefix);

                Assert.Equal(found.ResourceDisplayName, expected.ResourceDisplayName);
                Assert.Equal(found.ResourceLocation, expected.ResourceLocation);
                Assert.Equal(found.ResourceName, expected.ResourceName);
                Assert.Equal(found.ResourceType, expected.ResourceType);
                Assert.Equal(found.ResourceURI, expected.ResourceURI);
                Assert.Equal(found.RpRegistrationId, expected.RpRegistrationId);

                if (found.UsageMetrics == null)
                {
                    Assert.Null(found.UsageMetrics);
                }
                else
                {
                    Assert.NotNull(found.UsageMetrics);
                    Assert.Equal(found.UsageMetrics.Count, expected.UsageMetrics.Count);
                }
            }
        }
        private void ValidateResourceHealth(ResourceHealth resource)
        {
            Assert.NotNull(resource);
            Assert.True(InfrastructureInsightsCommon.ValidateResource(resource));

            Assert.NotNull(resource.AlertSummary);
            Assert.NotNull(resource.HealthState);
            Assert.NotNull(resource.NamespaceProperty);
            Assert.NotNull(resource.RegistrationId);
            Assert.NotNull(resource.RoutePrefix);
            Assert.NotNull(resource.ResourceDisplayName);
            Assert.NotNull(resource.ResourceLocation);
            Assert.NotNull(resource.ResourceName);
            Assert.NotNull(resource.ResourceType);
            Assert.NotNull(resource.ResourceURI);
            Assert.NotNull(resource.RpRegistrationId);
            Assert.NotNull(resource.ResourceName);
            Assert.NotNull(resource.UsageMetrics);
        }
    void FixedUpdate()
    {
        Vector3    rayOrigin = fpsCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0.0f));
        RaycastHit hit;

        if (Physics.Raycast(rayOrigin, fpsCam.transform.forward, out hit, 5f))
        {
            if (hit.collider.gameObject.name == "Bed")
            {
                interractText.text = "Sleep";
                InterractTextTimer = 0;
                if (Input.GetKey(KeyCode.E) && keyDown == false)
                {
                    mainTimer           += sleepTimer;
                    mainTimer           += mainTimer / 600;
                    sleepTimer           = 0;
                    sleepSlider.value    = 0;
                    sleepSlider.maxValue = walkLong;
                    keyDown     = true;
                    coffeeCount = 0;
                    LightControll.currentTimeOfDay += mainTimer / 600;
                }
                else
                {
                    keyDown = false;
                }
            }
            if (hit.collider.tag == "Rock")
            {
                GameObject tempObject = hit.collider.gameObject;
                interractText.text = "Smash";
                InterractTextTimer = 0;
                if (Input.GetKey(KeyCode.E) && keyDown == false)
                {
                    if (rockCount + woodCount < inventoryMax)
                    {
                        rockCount += 1;
                        ResourceHealth tempResourceHealth = tempObject.GetComponentInChildren <ResourceHealth> ();
                        tempResourceHealth.health -= 1;
                        inventorySlider.value     += 1;
                        keyDown            = true;
                        InterractTextTimer = 0;
                    }
                    else
                    {
                        keyDown = false;
                    }
                }
            }
            if (hit.collider.tag == "Wood")
            {
                GameObject tempObject = hit.collider.gameObject;
                interractText.text = "Chop";
                InterractTextTimer = 0;
                if (Input.GetKey(KeyCode.E) && keyDown == false)
                {
                    if (woodCount + rockCount < inventoryMax)
                    {
                        woodCount += 1;
                        ResourceHealth tempResourceHealth = tempObject.GetComponentInChildren <ResourceHealth> ();
                        tempResourceHealth.health -= 1;
                        inventorySlider.value     += 1;
                        keyDown            = true;
                        InterractTextTimer = 0;
                    }
                    else
                    {
                        keyDown = false;
                    }
                }
            }
            if (hit.collider.name == "Coffee" && keyDown == false)
            {
                interractText.text = "Drink";
                InterractTextTimer = 0;
                if (Input.GetKey(KeyCode.E) && keyDown == false)
                {
                    sleepSlider.maxValue += coffeeK;
                    keyDown                = true;
                    coffeeCount           += 1;
                    InterractTextTimer     = 0;
                    badFeelingsImage.color = new Color(1f, 0f, 0f, 0.2f * coffeeCount);
                }
                else
                {
                    keyDown = false;
                }
            }
            if (hit.collider.name == "Stock")
            {
                interractText.text = "Store item";
                InterractTextTimer = 0;
                if (Input.GetKey(KeyCode.E) && keyDown == false)
                {
                    needRock             += rockCount;
                    rockCount             = 0;
                    needWood             += woodCount;
                    woodCount             = 0;
                    inventorySlider.value = 0;
                    keyDown            = true;
                    woodText.text      = needWood.ToString();
                    stoneText.text     = needRock.ToString();
                    InterractTextTimer = 0;
                }
            }
            if (coffeeCount == 0)
            {
                badFeelingsImage.color = Color.clear;
            }
            if (coffeeCount == 5)
            {
                SceneManager.LoadSceneAsync("DieByCoffee");
                SceneManager.UnloadSceneAsync("MainScene");
            }
            if (needRock == FinalNeedRock && needWood == FinalNeedWood)
            {
                SceneManager.LoadScene("WinScreen");
                SceneManager.UnloadSceneAsync("MainScene");
            }
            if (!Input.GetKey(KeyCode.E))
            {
                keyDown = false;
            }
        }
        else
        {
            keyDown = false;
        }
    }