def check_if_workspace_available_on_first_day()

in source/ecs/workspaces_helper.py [0:0]


    def check_if_workspace_available_on_first_day(self, workspace_id):
        """
        This methods checks if the workspace was available on the first day of the month
        :param workspace_id: Workspace ID for the workspace
        """

        workspace_available = False
        log.debug("Checking if the workspace {} was available between first day {} and "
                  "second day {} ".format(workspace_id, first_day, second_day))
        try:
            metrics = self.cloudwatch_client.get_metric_statistics(
                Dimensions=[{
                    'Name': 'WorkspaceId',
                    'Value': workspace_id
                }],
                Namespace='AWS/WorkSpaces',
                MetricName='Available',
                StartTime=first_day,
                EndTime=second_day,
                Period=300,
                Statistics=['Maximum']
            )
            if metrics.get('Datapoints', None):
                workspace_available = True
        except Exception as error:
            log.error(error)
        log.debug("Returning the value {} for workspace available.".format(workspace_available))
        return workspace_available