# Copyright The Cloud Custodian Authors.
# SPDX-License-Identifier: Apache-2.0
from .common import BaseTest, functional

# datapipeline is not available in us-east-2 where we run our functional tests
# so we do a forced override here.
REGION = "us-west-2"


class DataPipelineTest(BaseTest):

    def test_reporting(self):
        factory = self.replay_flight_data("test_datapipeline_reporting")

        session = factory()
        client = session.client("datapipeline")
        pipeline = client.create_pipeline(name="PipelinesFTW", uniqueId="PipelinesFTW")
        pipe_id = pipeline["pipelineId"]
        client.put_pipeline_definition(
            pipelineId=pipe_id,
            pipelineObjects=[
                {
                    "id": "Default",
                    "name": "Default",
                    "fields": [{"key": "workerGroup", "stringValue": "workerGroup"}],
                },
                {
                    "id": "Schedule",
                    "name": "Schedule",
                    "fields": [
                        {"key": "startDateTime", "stringValue": "2012-12-12T00:00:00"},
                        {"key": "type", "stringValue": "Schedule"},
                        {"key": "period", "stringValue": "1 hour"},
                        {"key": "endDateTime", "stringValue": "2012-12-21T18:00:00"},
                    ],
                },
                {
                    "id": "SayHello",
                    "name": "SayHello",
                    "fields": [
                        {"key": "type", "stringValue": "ShellCommandActivity"},
                        {"key": "command", "stringValue": "echo hello"},
                        {"key": "parent", "refValue": "Default"},