def execute(self, parameter_pool):
        eb_client = ElasticBeanstalkClient(
            parameter_pool.get_value(ParameterName.AwsAccessKeyId),
            parameter_pool.get_value(ParameterName.AwsSecretAccessKey),
            parameter_pool.get_value(ParameterName.ServiceEndpoint),
        )

        app_name = parameter_pool.get_value(ParameterName.ApplicationName)
        env_name = parameter_pool.get_value(ParameterName.EnvironmentName)
        prompt.action(DescribeEnvironmentOpMessage.Start.format(env_name))

        response = eb_client.describe_environments(app_name, env_name, include_deleted=u"false")
        log.info(u"Received response for DescribeEnvironemnts call.")
        self._log_api_result(self.__class__.__name__, u"DescribeEnvironments", response.result)

        if len(response.result) > 0:  # If have result
            env_info = response.result[0]
            message = DescribeEnvironmentOpMessage.Result.format(env_info.cname, env_info.status, env_info.health)
            prompt.result(message)
            prompt.info(
                DescribeEnvironmentOpMessage.Detail.format(
                    env_info.environment_name,
                    env_info.environment_id,
                    env_info.solution_stack_name,
                    env_info.version_label,
                    env_info.date_created,
                    env_info.date_updated,
                    env_info.description,
                )
            )

            # If not Green, pull the most recent warning and error events
            if env_info.health in [EnvironmentHealth.Red, EnvironmentHealth.Yellow]:
                events = eb_client.describe_events(
                    app_name,
                    env_name,
                    max_records=ServiceDefault.STATUS_EVENT_MAX_NUM,
                    severity=ServiceDefault.STATUS_EVENT_LEVEL,
                )
                if len(events.result) > 0:
                    # Having one error event
                    for event in events.result:
                        msg = u"{0}\t{1}\t{2}".format(event.event_date, event.severity, event.message)
                        log.info(u"Found last error event: {0}".format(msg))
                        prompt.plain(msg)

            # Display RDS instance host info
            try:
                logical_id, rds_property = rds_utils.retrieve_rds_instance_property(parameter_pool, env_name)
                if rds_property is not None:
                    prompt.result(
                        DescribeEnvironmentOpMessage.RdsInfo.format(
                            logical_id, rds_property.endpoint.address, rds_property.endpoint.port
                        )
                    )
                    prompt.info(
                        DescribeEnvironmentOpMessage.RdsDetail.format(
                            rds_property.engine + u" " + rds_property.engine_version,
                            rds_property.allocated_storage,
                            rds_property.db_instance_class,
                            rds_property.multi_az,
                            rds_property.master_username,
                            rds_property.instance_create_time,
                            rds_property.db_instance_status,
                        )
                    )

            except BaseException as ex:
                log.error(u"Encountered error when retrieve environment resources: {0}.".format(ex))
                raise

        else:
            # No result. Environment not exist.
            message = DescribeEnvironmentOpMessage.NoEnvironment.format(env_name)
            prompt.result(message)

        ret_result = OperationResult(self, response.request_id, message, response.result)
        return ret_result
    def execute(self, parameter_pool):
        eb_client = ElasticBeanstalkClient(
            parameter_pool.get_value(ParameterName.AwsAccessKeyId),
            parameter_pool.get_value(ParameterName.AwsSecretAccessKey),
            parameter_pool.get_value(ParameterName.ServiceEndpoint))

        app_name = parameter_pool.get_value(ParameterName.ApplicationName)
        env_name = parameter_pool.get_value(ParameterName.EnvironmentName)
        prompt.action(DescribeEnvironmentOpMessage.Start.format(env_name))

        response = eb_client.describe_environments(app_name,
                                                   env_name,
                                                   include_deleted='false')
        log.info('Received response for DescribeEnvironemnts call.')
        self._log_api_result(self.__class__.__name__, 'DescribeEnvironments',
                             response.result)

        if len(response.result) > 0:  # If have result
            env_info = response.result[0]
            message = DescribeEnvironmentOpMessage.Result.format(
                env_info.cname, env_info.status, env_info.health)
            prompt.result(message)
            prompt.info(
                DescribeEnvironmentOpMessage.Detail.format(
                    env_info.environment_name, env_info.environment_id,
                    env_info.solution_stack_name, env_info.version_label,
                    env_info.date_created, env_info.date_updated,
                    env_info.description))

            # If not Green, pull the most recent warning and error events
            if env_info.health in [EnvironmentHealth.Red, EnvironmentHealth.Yellow] \
                or (env_info.status == EnvironmentStatus.Ready \
                    and env_info.health == EnvironmentHealth.Grey):
                events = eb_client.describe_events(
                    app_name,
                    env_name,
                    max_records=ServiceDefault.STATUS_EVENT_MAX_NUM,
                    severity=ServiceDefault.STATUS_EVENT_LEVEL)
                if len(events.result) > 0:
                    # Having one error event
                    for event in events.result:
                        msg = '{0}\t{1}\t{2}'.format(event.event_date,
                                                     event.severity,
                                                     event.message)
                        log.info('Found last error event: {0}'.format(msg))
                        prompt.plain(msg)

            # Display RDS instance host info
            try:
                logical_id, rds_property = rds_utils.retrieve_rds_instance_property\
                                                        (parameter_pool, env_name)
                if rds_property is not None:
                    prompt.result(DescribeEnvironmentOpMessage.RdsInfo.format\
                                  (logical_id,
                                   rds_property.endpoint.address,
                                   rds_property.endpoint.port))
                    prompt.info(DescribeEnvironmentOpMessage.RdsDetail.format\
                                  (rds_property.engine + ' ' + rds_property.engine_version,
                                   rds_property.allocated_storage,
                                   rds_property.db_instance_class,
                                   rds_property.multi_az,
                                   rds_property.master_username,
                                   rds_property.instance_create_time,
                                   rds_property.db_instance_status))

            except BaseException as ex:
                log.error(
                    'Encountered error when retrieve environment resources: {0}.'
                    .format(ex))
                raise

        else:
            # No result. Environment not exist.
            message = DescribeEnvironmentOpMessage.NoEnvironment.format(
                env_name)
            prompt.result(message)

        ret_result = OperationResult(self, response.request_id, message,
                                     response.result)
        return ret_result