import { loadRestJsonErrorCode, parseJsonBody as parseBody, parseJsonErrorBody as parseErrorBody } from "@aws-sdk/core";
import { HttpRequest as __HttpRequest } from "@smithy/protocol-http";
import { _json, collectBody, decorateServiceException as __decorateServiceException, expectBoolean as __expectBoolean, expectInt32 as __expectInt32, expectNonNull as __expectNonNull, expectNumber as __expectNumber, expectString as __expectString, parseEpochTimestamp as __parseEpochTimestamp, take, withBaseException, } from "@smithy/smithy-client";
import { v4 as generateIdempotencyToken } from "uuid";
import { CodePipelineServiceException as __BaseException } from "../models/CodePipelineServiceException";
import { ActionNotFoundException, ActionTypeNotFoundException, ApprovalAlreadyCompletedException, ConcurrentModificationException, ConcurrentPipelineExecutionsLimitExceededException, ConditionNotOverridableException, ConflictException, DuplicatedStopRequestException, InvalidActionDeclarationException, InvalidApprovalTokenException, InvalidArnException, InvalidBlockerDeclarationException, InvalidClientTokenException, InvalidJobException, InvalidJobStateException, InvalidNextTokenException, InvalidNonceException, InvalidStageDeclarationException, InvalidStructureException, InvalidTagsException, InvalidWebhookAuthenticationParametersException, InvalidWebhookFilterPatternException, JobNotFoundException, LimitExceededException, NotLatestPipelineExecutionException, OutputVariablesSizeExceededException, PipelineExecutionNotFoundException, PipelineExecutionNotStoppableException, PipelineExecutionOutdatedException, PipelineNameInUseException, PipelineNotFoundException, PipelineVersionNotFoundException, RequestFailedException, ResourceNotFoundException, StageNotFoundException, StageNotRetryableException, TooManyTagsException, UnableToRollbackStageException, ValidationException, WebhookNotFoundException, } from "../models/models_0";
export const se_AcknowledgeJobCommand = async (input, context) => {
    const headers = sharedHeaders("AcknowledgeJob");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_AcknowledgeThirdPartyJobCommand = async (input, context) => {
    const headers = sharedHeaders("AcknowledgeThirdPartyJob");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_CreateCustomActionTypeCommand = async (input, context) => {
    const headers = sharedHeaders("CreateCustomActionType");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_CreatePipelineCommand = async (input, context) => {
    const headers = sharedHeaders("CreatePipeline");
    let body;
    body = JSON.stringify(se_CreatePipelineInput(input, context));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_DeleteCustomActionTypeCommand = async (input, context) => {
    const headers = sharedHeaders("DeleteCustomActionType");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_DeletePipelineCommand = async (input, context) => {
    const headers = sharedHeaders("DeletePipeline");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_DeleteWebhookCommand = async (input, context) => {
    const headers = sharedHeaders("DeleteWebhook");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_DeregisterWebhookWithThirdPartyCommand = async (input, context) => {
    const headers = sharedHeaders("DeregisterWebhookWithThirdParty");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_DisableStageTransitionCommand = async (input, context) => {
    const headers = sharedHeaders("DisableStageTransition");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_EnableStageTransitionCommand = async (input, context) => {
    const headers = sharedHeaders("EnableStageTransition");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_GetActionTypeCommand = async (input, context) => {
    const headers = sharedHeaders("GetActionType");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_GetJobDetailsCommand = async (input, context) => {
    const headers = sharedHeaders("GetJobDetails");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_GetPipelineCommand = async (input, context) => {
    const headers = sharedHeaders("GetPipeline");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_GetPipelineExecutionCommand = async (input, context) => {
    const headers = sharedHeaders("GetPipelineExecution");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_GetPipelineStateCommand = async (input, context) => {
    const headers = sharedHeaders("GetPipelineState");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_GetThirdPartyJobDetailsCommand = async (input, context) => {
    const headers = sharedHeaders("GetThirdPartyJobDetails");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_ListActionExecutionsCommand = async (input, context) => {
    const headers = sharedHeaders("ListActionExecutions");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_ListActionTypesCommand = async (input, context) => {
    const headers = sharedHeaders("ListActionTypes");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_ListPipelineExecutionsCommand = async (input, context) => {
    const headers = sharedHeaders("ListPipelineExecutions");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_ListPipelinesCommand = async (input, context) => {
    const headers = sharedHeaders("ListPipelines");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_ListRuleExecutionsCommand = async (input, context) => {
    const headers = sharedHeaders("ListRuleExecutions");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_ListRuleTypesCommand = async (input, context) => {
    const headers = sharedHeaders("ListRuleTypes");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_ListTagsForResourceCommand = async (input, context) => {
    const headers = sharedHeaders("ListTagsForResource");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_ListWebhooksCommand = async (input, context) => {
    const headers = sharedHeaders("ListWebhooks");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_OverrideStageConditionCommand = async (input, context) => {
    const headers = sharedHeaders("OverrideStageCondition");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_PollForJobsCommand = async (input, context) => {
    const headers = sharedHeaders("PollForJobs");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_PollForThirdPartyJobsCommand = async (input, context) => {
    const headers = sharedHeaders("PollForThirdPartyJobs");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_PutActionRevisionCommand = async (input, context) => {
    const headers = sharedHeaders("PutActionRevision");
    let body;
    body = JSON.stringify(se_PutActionRevisionInput(input, context));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_PutApprovalResultCommand = async (input, context) => {
    const headers = sharedHeaders("PutApprovalResult");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_PutJobFailureResultCommand = async (input, context) => {
    const headers = sharedHeaders("PutJobFailureResult");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_PutJobSuccessResultCommand = async (input, context) => {
    const headers = sharedHeaders("PutJobSuccessResult");
    let body;
    body = JSON.stringify(se_PutJobSuccessResultInput(input, context));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_PutThirdPartyJobFailureResultCommand = async (input, context) => {
    const headers = sharedHeaders("PutThirdPartyJobFailureResult");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_PutThirdPartyJobSuccessResultCommand = async (input, context) => {
    const headers = sharedHeaders("PutThirdPartyJobSuccessResult");
    let body;
    body = JSON.stringify(se_PutThirdPartyJobSuccessResultInput(input, context));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_PutWebhookCommand = async (input, context) => {
    const headers = sharedHeaders("PutWebhook");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_RegisterWebhookWithThirdPartyCommand = async (input, context) => {
    const headers = sharedHeaders("RegisterWebhookWithThirdParty");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_RetryStageExecutionCommand = async (input, context) => {
    const headers = sharedHeaders("RetryStageExecution");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_RollbackStageCommand = async (input, context) => {
    const headers = sharedHeaders("RollbackStage");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_StartPipelineExecutionCommand = async (input, context) => {
    const headers = sharedHeaders("StartPipelineExecution");
    let body;
    body = JSON.stringify(se_StartPipelineExecutionInput(input, context));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_StopPipelineExecutionCommand = async (input, context) => {
    const headers = sharedHeaders("StopPipelineExecution");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_TagResourceCommand = async (input, context) => {
    const headers = sharedHeaders("TagResource");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_UntagResourceCommand = async (input, context) => {
    const headers = sharedHeaders("UntagResource");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_UpdateActionTypeCommand = async (input, context) => {
    const headers = sharedHeaders("UpdateActionType");
    let body;
    body = JSON.stringify(_json(input));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const se_UpdatePipelineCommand = async (input, context) => {
    const headers = sharedHeaders("UpdatePipeline");
    let body;
    body = JSON.stringify(se_UpdatePipelineInput(input, context));
    return buildHttpRpcRequest(context, headers, "/", undefined, body);
};
export const de_AcknowledgeJobCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_AcknowledgeThirdPartyJobCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_CreateCustomActionTypeCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_CreatePipelineCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = de_CreatePipelineOutput(data, context);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_DeleteCustomActionTypeCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    await collectBody(output.body, context);
    const response = {
        $metadata: deserializeMetadata(output),
    };
    return response;
};
export const de_DeletePipelineCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    await collectBody(output.body, context);
    const response = {
        $metadata: deserializeMetadata(output),
    };
    return response;
};
export const de_DeleteWebhookCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_DeregisterWebhookWithThirdPartyCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_DisableStageTransitionCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    await collectBody(output.body, context);
    const response = {
        $metadata: deserializeMetadata(output),
    };
    return response;
};
export const de_EnableStageTransitionCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    await collectBody(output.body, context);
    const response = {
        $metadata: deserializeMetadata(output),
    };
    return response;
};
export const de_GetActionTypeCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_GetJobDetailsCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_GetPipelineCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = de_GetPipelineOutput(data, context);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_GetPipelineExecutionCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = de_GetPipelineExecutionOutput(data, context);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_GetPipelineStateCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = de_GetPipelineStateOutput(data, context);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_GetThirdPartyJobDetailsCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_ListActionExecutionsCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = de_ListActionExecutionsOutput(data, context);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_ListActionTypesCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_ListPipelineExecutionsCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = de_ListPipelineExecutionsOutput(data, context);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_ListPipelinesCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = de_ListPipelinesOutput(data, context);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_ListRuleExecutionsCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = de_ListRuleExecutionsOutput(data, context);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_ListRuleTypesCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_ListTagsForResourceCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_ListWebhooksCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = de_ListWebhooksOutput(data, context);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_OverrideStageConditionCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    await collectBody(output.body, context);
    const response = {
        $metadata: deserializeMetadata(output),
    };
    return response;
};
export const de_PollForJobsCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_PollForThirdPartyJobsCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_PutActionRevisionCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_PutApprovalResultCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = de_PutApprovalResultOutput(data, context);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_PutJobFailureResultCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    await collectBody(output.body, context);
    const response = {
        $metadata: deserializeMetadata(output),
    };
    return response;
};
export const de_PutJobSuccessResultCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    await collectBody(output.body, context);
    const response = {
        $metadata: deserializeMetadata(output),
    };
    return response;
};
export const de_PutThirdPartyJobFailureResultCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    await collectBody(output.body, context);
    const response = {
        $metadata: deserializeMetadata(output),
    };
    return response;
};
export const de_PutThirdPartyJobSuccessResultCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    await collectBody(output.body, context);
    const response = {
        $metadata: deserializeMetadata(output),
    };
    return response;
};
export const de_PutWebhookCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = de_PutWebhookOutput(data, context);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_RegisterWebhookWithThirdPartyCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_RetryStageExecutionCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_RollbackStageCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_StartPipelineExecutionCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_StopPipelineExecutionCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_TagResourceCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_UntagResourceCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = _json(data);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
export const de_UpdateActionTypeCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    await collectBody(output.body, context);
    const response = {
        $metadata: deserializeMetadata(output),
    };
    return response;
};
export const de_UpdatePipelineCommand = async (output, context) => {
    if (output.statusCode >= 300) {
        return de_CommandError(output, context);
    }
    const data = await parseBody(output.body, context);
    let contents = {};
    contents = de_UpdatePipelineOutput(data, context);
    const response = {
        $metadata: deserializeMetadata(output),
        ...contents,
    };
    return response;
};
const de_CommandError = async (output, context) => {
    const parsedOutput = {
        ...output,
        body: await parseErrorBody(output.body, context),
    };
    const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
    switch (errorCode) {
        case "InvalidNonceException":
        case "com.amazonaws.codepipeline#InvalidNonceException":
            throw await de_InvalidNonceExceptionRes(parsedOutput, context);
        case "JobNotFoundException":
        case "com.amazonaws.codepipeline#JobNotFoundException":
            throw await de_JobNotFoundExceptionRes(parsedOutput, context);
        case "ValidationException":
        case "com.amazonaws.codepipeline#ValidationException":
            throw await de_ValidationExceptionRes(parsedOutput, context);
        case "InvalidClientTokenException":
        case "com.amazonaws.codepipeline#InvalidClientTokenException":
            throw await de_InvalidClientTokenExceptionRes(parsedOutput, context);
        case "ConcurrentModificationException":
        case "com.amazonaws.codepipeline#ConcurrentModificationException":
            throw await de_ConcurrentModificationExceptionRes(parsedOutput, context);
        case "InvalidTagsException":
        case "com.amazonaws.codepipeline#InvalidTagsException":
            throw await de_InvalidTagsExceptionRes(parsedOutput, context);
        case "LimitExceededException":
        case "com.amazonaws.codepipeline#LimitExceededException":
            throw await de_LimitExceededExceptionRes(parsedOutput, context);
        case "TooManyTagsException":
        case "com.amazonaws.codepipeline#TooManyTagsException":
            throw await de_TooManyTagsExceptionRes(parsedOutput, context);
        case "InvalidActionDeclarationException":
        case "com.amazonaws.codepipeline#InvalidActionDeclarationException":
            throw await de_InvalidActionDeclarationExceptionRes(parsedOutput, context);
        case "InvalidBlockerDeclarationException":
        case "com.amazonaws.codepipeline#InvalidBlockerDeclarationException":
            throw await de_InvalidBlockerDeclarationExceptionRes(parsedOutput, context);
        case "InvalidStageDeclarationException":
        case "com.amazonaws.codepipeline#InvalidStageDeclarationException":
            throw await de_InvalidStageDeclarationExceptionRes(parsedOutput, context);
        case "InvalidStructureException":
        case "com.amazonaws.codepipeline#InvalidStructureException":
            throw await de_InvalidStructureExceptionRes(parsedOutput, context);
        case "PipelineNameInUseException":
        case "com.amazonaws.codepipeline#PipelineNameInUseException":
            throw await de_PipelineNameInUseExceptionRes(parsedOutput, context);
        case "WebhookNotFoundException":
        case "com.amazonaws.codepipeline#WebhookNotFoundException":
            throw await de_WebhookNotFoundExceptionRes(parsedOutput, context);
        case "PipelineNotFoundException":
        case "com.amazonaws.codepipeline#PipelineNotFoundException":
            throw await de_PipelineNotFoundExceptionRes(parsedOutput, context);
        case "StageNotFoundException":
        case "com.amazonaws.codepipeline#StageNotFoundException":
            throw await de_StageNotFoundExceptionRes(parsedOutput, context);
        case "ActionTypeNotFoundException":
        case "com.amazonaws.codepipeline#ActionTypeNotFoundException":
            throw await de_ActionTypeNotFoundExceptionRes(parsedOutput, context);
        case "PipelineVersionNotFoundException":
        case "com.amazonaws.codepipeline#PipelineVersionNotFoundException":
            throw await de_PipelineVersionNotFoundExceptionRes(parsedOutput, context);
        case "PipelineExecutionNotFoundException":
        case "com.amazonaws.codepipeline#PipelineExecutionNotFoundException":
            throw await de_PipelineExecutionNotFoundExceptionRes(parsedOutput, context);
        case "InvalidJobException":
        case "com.amazonaws.codepipeline#InvalidJobException":
            throw await de_InvalidJobExceptionRes(parsedOutput, context);
        case "InvalidNextTokenException":
        case "com.amazonaws.codepipeline#InvalidNextTokenException":
            throw await de_InvalidNextTokenExceptionRes(parsedOutput, context);
        case "InvalidArnException":
        case "com.amazonaws.codepipeline#InvalidArnException":
            throw await de_InvalidArnExceptionRes(parsedOutput, context);
        case "ResourceNotFoundException":
        case "com.amazonaws.codepipeline#ResourceNotFoundException":
            throw await de_ResourceNotFoundExceptionRes(parsedOutput, context);
        case "ConcurrentPipelineExecutionsLimitExceededException":
        case "com.amazonaws.codepipeline#ConcurrentPipelineExecutionsLimitExceededException":
            throw await de_ConcurrentPipelineExecutionsLimitExceededExceptionRes(parsedOutput, context);
        case "ConditionNotOverridableException":
        case "com.amazonaws.codepipeline#ConditionNotOverridableException":
            throw await de_ConditionNotOverridableExceptionRes(parsedOutput, context);
        case "ConflictException":
        case "com.amazonaws.codepipeline#ConflictException":
            throw await de_ConflictExceptionRes(parsedOutput, context);
        case "NotLatestPipelineExecutionException":
        case "com.amazonaws.codepipeline#NotLatestPipelineExecutionException":
            throw await de_NotLatestPipelineExecutionExceptionRes(parsedOutput, context);
        case "ActionNotFoundException":
        case "com.amazonaws.codepipeline#ActionNotFoundException":
            throw await de_ActionNotFoundExceptionRes(parsedOutput, context);
        case "ApprovalAlreadyCompletedException":
        case "com.amazonaws.codepipeline#ApprovalAlreadyCompletedException":
            throw await de_ApprovalAlreadyCompletedExceptionRes(parsedOutput, context);
        case "InvalidApprovalTokenException":
        case "com.amazonaws.codepipeline#InvalidApprovalTokenException":
            throw await de_InvalidApprovalTokenExceptionRes(parsedOutput, context);
        case "InvalidJobStateException":
        case "com.amazonaws.codepipeline#InvalidJobStateException":
            throw await de_InvalidJobStateExceptionRes(parsedOutput, context);
        case "OutputVariablesSizeExceededException":
        case "com.amazonaws.codepipeline#OutputVariablesSizeExceededException":
            throw await de_OutputVariablesSizeExceededExceptionRes(parsedOutput, context);
        case "InvalidWebhookAuthenticationParametersException":
        case "com.amazonaws.codepipeline#InvalidWebhookAuthenticationParametersException":
            throw await de_InvalidWebhookAuthenticationParametersExceptionRes(parsedOutput, context);
        case "InvalidWebhookFilterPatternException":
        case "com.amazonaws.codepipeline#InvalidWebhookFilterPatternException":
            throw await de_InvalidWebhookFilterPatternExceptionRes(parsedOutput, context);
        case "StageNotRetryableException":
        case "com.amazonaws.codepipeline#StageNotRetryableException":
            throw await de_StageNotRetryableExceptionRes(parsedOutput, context);
        case "PipelineExecutionOutdatedException":
        case "com.amazonaws.codepipeline#PipelineExecutionOutdatedException":
            throw await de_PipelineExecutionOutdatedExceptionRes(parsedOutput, context);
        case "UnableToRollbackStageException":
        case "com.amazonaws.codepipeline#UnableToRollbackStageException":
            throw await de_UnableToRollbackStageExceptionRes(parsedOutput, context);
        case "DuplicatedStopRequestException":
        case "com.amazonaws.codepipeline#DuplicatedStopRequestException":
            throw await de_DuplicatedStopRequestExceptionRes(parsedOutput, context);
        case "PipelineExecutionNotStoppableException":
        case "com.amazonaws.codepipeline#PipelineExecutionNotStoppableException":
            throw await de_PipelineExecutionNotStoppableExceptionRes(parsedOutput, context);
        case "RequestFailedException":
        case "com.amazonaws.codepipeline#RequestFailedException":
            throw await de_RequestFailedExceptionRes(parsedOutput, context);
        default:
            const parsedBody = parsedOutput.body;
            return throwDefaultError({
                output,
                parsedBody,
                errorCode,
            });
    }
};
const de_ActionNotFoundExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new ActionNotFoundException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_ActionTypeNotFoundExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new ActionTypeNotFoundException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_ApprovalAlreadyCompletedExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new ApprovalAlreadyCompletedException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_ConcurrentModificationExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new ConcurrentModificationException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_ConcurrentPipelineExecutionsLimitExceededExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new ConcurrentPipelineExecutionsLimitExceededException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_ConditionNotOverridableExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new ConditionNotOverridableException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_ConflictExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new ConflictException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_DuplicatedStopRequestExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new DuplicatedStopRequestException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_InvalidActionDeclarationExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new InvalidActionDeclarationException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_InvalidApprovalTokenExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new InvalidApprovalTokenException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_InvalidArnExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new InvalidArnException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_InvalidBlockerDeclarationExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new InvalidBlockerDeclarationException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_InvalidClientTokenExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new InvalidClientTokenException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_InvalidJobExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new InvalidJobException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_InvalidJobStateExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new InvalidJobStateException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_InvalidNextTokenExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new InvalidNextTokenException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_InvalidNonceExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new InvalidNonceException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_InvalidStageDeclarationExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new InvalidStageDeclarationException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_InvalidStructureExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new InvalidStructureException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_InvalidTagsExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new InvalidTagsException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_InvalidWebhookAuthenticationParametersExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new InvalidWebhookAuthenticationParametersException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_InvalidWebhookFilterPatternExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new InvalidWebhookFilterPatternException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_JobNotFoundExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new JobNotFoundException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_LimitExceededExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new LimitExceededException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_NotLatestPipelineExecutionExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new NotLatestPipelineExecutionException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_OutputVariablesSizeExceededExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new OutputVariablesSizeExceededException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_PipelineExecutionNotFoundExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new PipelineExecutionNotFoundException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_PipelineExecutionNotStoppableExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new PipelineExecutionNotStoppableException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_PipelineExecutionOutdatedExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new PipelineExecutionOutdatedException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_PipelineNameInUseExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new PipelineNameInUseException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_PipelineNotFoundExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new PipelineNotFoundException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_PipelineVersionNotFoundExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new PipelineVersionNotFoundException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_RequestFailedExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new RequestFailedException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_ResourceNotFoundExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new ResourceNotFoundException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_StageNotFoundExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new StageNotFoundException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_StageNotRetryableExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new StageNotRetryableException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_TooManyTagsExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new TooManyTagsException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_UnableToRollbackStageExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new UnableToRollbackStageException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_ValidationExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new ValidationException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const de_WebhookNotFoundExceptionRes = async (parsedOutput, context) => {
    const body = parsedOutput.body;
    const deserialized = _json(body);
    const exception = new WebhookNotFoundException({
        $metadata: deserializeMetadata(parsedOutput),
        ...deserialized,
    });
    return __decorateServiceException(exception, body);
};
const se_ActionRevision = (input, context) => {
    return take(input, {
        created: (_) => _.getTime() / 1000,
        revisionChangeId: [],
        revisionId: [],
    });
};
const se_CreatePipelineInput = (input, context) => {
    return take(input, {
        pipeline: _json,
        tags: _json,
    });
};
const se_CurrentRevision = (input, context) => {
    return take(input, {
        changeIdentifier: [],
        created: (_) => _.getTime() / 1000,
        revision: [],
        revisionSummary: [],
    });
};
const se_PutActionRevisionInput = (input, context) => {
    return take(input, {
        actionName: [],
        actionRevision: (_) => se_ActionRevision(_, context),
        pipelineName: [],
        stageName: [],
    });
};
const se_PutJobSuccessResultInput = (input, context) => {
    return take(input, {
        continuationToken: [],
        currentRevision: (_) => se_CurrentRevision(_, context),
        executionDetails: _json,
        jobId: [],
        outputVariables: _json,
    });
};
const se_PutThirdPartyJobSuccessResultInput = (input, context) => {
    return take(input, {
        clientToken: [],
        continuationToken: [],
        currentRevision: (_) => se_CurrentRevision(_, context),
        executionDetails: _json,
        jobId: [],
    });
};
const se_StartPipelineExecutionInput = (input, context) => {
    return take(input, {
        clientRequestToken: [true, (_) => _ ?? generateIdempotencyToken()],
        name: [],
        sourceRevisions: _json,
        variables: _json,
    });
};
const se_UpdatePipelineInput = (input, context) => {
    return take(input, {
        pipeline: _json,
    });
};
const de_ActionExecution = (output, context) => {
    return take(output, {
        actionExecutionId: __expectString,
        errorDetails: _json,
        externalExecutionId: __expectString,
        externalExecutionUrl: __expectString,
        lastStatusChange: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        lastUpdatedBy: __expectString,
        logStreamARN: __expectString,
        percentComplete: __expectInt32,
        status: __expectString,
        summary: __expectString,
        token: __expectString,
    });
};
const de_ActionExecutionDetail = (output, context) => {
    return take(output, {
        actionExecutionId: __expectString,
        actionName: __expectString,
        input: _json,
        lastUpdateTime: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        output: _json,
        pipelineExecutionId: __expectString,
        pipelineVersion: __expectInt32,
        stageName: __expectString,
        startTime: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        status: __expectString,
        updatedBy: __expectString,
    });
};
const de_ActionExecutionDetailList = (output, context) => {
    const retVal = (output || [])
        .filter((e) => e != null)
        .map((entry) => {
        return de_ActionExecutionDetail(entry, context);
    });
    return retVal;
};
const de_ActionRevision = (output, context) => {
    return take(output, {
        created: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        revisionChangeId: __expectString,
        revisionId: __expectString,
    });
};
const de_ActionState = (output, context) => {
    return take(output, {
        actionName: __expectString,
        currentRevision: (_) => de_ActionRevision(_, context),
        entityUrl: __expectString,
        latestExecution: (_) => de_ActionExecution(_, context),
        revisionUrl: __expectString,
    });
};
const de_ActionStateList = (output, context) => {
    const retVal = (output || [])
        .filter((e) => e != null)
        .map((entry) => {
        return de_ActionState(entry, context);
    });
    return retVal;
};
const de_ArtifactRevision = (output, context) => {
    return take(output, {
        created: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        name: __expectString,
        revisionChangeIdentifier: __expectString,
        revisionId: __expectString,
        revisionSummary: __expectString,
        revisionUrl: __expectString,
    });
};
const de_ArtifactRevisionList = (output, context) => {
    const retVal = (output || [])
        .filter((e) => e != null)
        .map((entry) => {
        return de_ArtifactRevision(entry, context);
    });
    return retVal;
};
const de_ConditionExecution = (output, context) => {
    return take(output, {
        lastStatusChange: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        status: __expectString,
        summary: __expectString,
    });
};
const de_ConditionState = (output, context) => {
    return take(output, {
        latestExecution: (_) => de_ConditionExecution(_, context),
        ruleStates: (_) => de_RuleStateList(_, context),
    });
};
const de_ConditionStateList = (output, context) => {
    const retVal = (output || [])
        .filter((e) => e != null)
        .map((entry) => {
        return de_ConditionState(entry, context);
    });
    return retVal;
};
const de_CreatePipelineOutput = (output, context) => {
    return take(output, {
        pipeline: _json,
        tags: _json,
    });
};
const de_GetPipelineExecutionOutput = (output, context) => {
    return take(output, {
        pipelineExecution: (_) => de_PipelineExecution(_, context),
    });
};
const de_GetPipelineOutput = (output, context) => {
    return take(output, {
        metadata: (_) => de_PipelineMetadata(_, context),
        pipeline: _json,
    });
};
const de_GetPipelineStateOutput = (output, context) => {
    return take(output, {
        created: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        pipelineName: __expectString,
        pipelineVersion: __expectInt32,
        stageStates: (_) => de_StageStateList(_, context),
        updated: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
    });
};
const de_ListActionExecutionsOutput = (output, context) => {
    return take(output, {
        actionExecutionDetails: (_) => de_ActionExecutionDetailList(_, context),
        nextToken: __expectString,
    });
};
const de_ListPipelineExecutionsOutput = (output, context) => {
    return take(output, {
        nextToken: __expectString,
        pipelineExecutionSummaries: (_) => de_PipelineExecutionSummaryList(_, context),
    });
};
const de_ListPipelinesOutput = (output, context) => {
    return take(output, {
        nextToken: __expectString,
        pipelines: (_) => de_PipelineList(_, context),
    });
};
const de_ListRuleExecutionsOutput = (output, context) => {
    return take(output, {
        nextToken: __expectString,
        ruleExecutionDetails: (_) => de_RuleExecutionDetailList(_, context),
    });
};
const de_ListWebhookItem = (output, context) => {
    return take(output, {
        arn: __expectString,
        definition: _json,
        errorCode: __expectString,
        errorMessage: __expectString,
        lastTriggered: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        tags: _json,
        url: __expectString,
    });
};
const de_ListWebhooksOutput = (output, context) => {
    return take(output, {
        NextToken: __expectString,
        webhooks: (_) => de_WebhookList(_, context),
    });
};
const de_PipelineExecution = (output, context) => {
    return take(output, {
        artifactRevisions: (_) => de_ArtifactRevisionList(_, context),
        executionMode: __expectString,
        executionType: __expectString,
        pipelineExecutionId: __expectString,
        pipelineName: __expectString,
        pipelineVersion: __expectInt32,
        rollbackMetadata: _json,
        status: __expectString,
        statusSummary: __expectString,
        trigger: _json,
        variables: _json,
    });
};
const de_PipelineExecutionSummary = (output, context) => {
    return take(output, {
        executionMode: __expectString,
        executionType: __expectString,
        lastUpdateTime: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        pipelineExecutionId: __expectString,
        rollbackMetadata: _json,
        sourceRevisions: _json,
        startTime: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        status: __expectString,
        statusSummary: __expectString,
        stopTrigger: _json,
        trigger: _json,
    });
};
const de_PipelineExecutionSummaryList = (output, context) => {
    const retVal = (output || [])
        .filter((e) => e != null)
        .map((entry) => {
        return de_PipelineExecutionSummary(entry, context);
    });
    return retVal;
};
const de_PipelineList = (output, context) => {
    const retVal = (output || [])
        .filter((e) => e != null)
        .map((entry) => {
        return de_PipelineSummary(entry, context);
    });
    return retVal;
};
const de_PipelineMetadata = (output, context) => {
    return take(output, {
        created: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        pipelineArn: __expectString,
        pollingDisabledAt: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        updated: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
    });
};
const de_PipelineSummary = (output, context) => {
    return take(output, {
        created: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        executionMode: __expectString,
        name: __expectString,
        pipelineType: __expectString,
        updated: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        version: __expectInt32,
    });
};
const de_PutApprovalResultOutput = (output, context) => {
    return take(output, {
        approvedAt: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
    });
};
const de_PutWebhookOutput = (output, context) => {
    return take(output, {
        webhook: (_) => de_ListWebhookItem(_, context),
    });
};
const de_RuleExecution = (output, context) => {
    return take(output, {
        errorDetails: _json,
        externalExecutionId: __expectString,
        externalExecutionUrl: __expectString,
        lastStatusChange: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        lastUpdatedBy: __expectString,
        ruleExecutionId: __expectString,
        status: __expectString,
        summary: __expectString,
        token: __expectString,
    });
};
const de_RuleExecutionDetail = (output, context) => {
    return take(output, {
        input: _json,
        lastUpdateTime: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        output: _json,
        pipelineExecutionId: __expectString,
        pipelineVersion: __expectInt32,
        ruleExecutionId: __expectString,
        ruleName: __expectString,
        stageName: __expectString,
        startTime: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        status: __expectString,
        updatedBy: __expectString,
    });
};
const de_RuleExecutionDetailList = (output, context) => {
    const retVal = (output || [])
        .filter((e) => e != null)
        .map((entry) => {
        return de_RuleExecutionDetail(entry, context);
    });
    return retVal;
};
const de_RuleRevision = (output, context) => {
    return take(output, {
        created: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        revisionChangeId: __expectString,
        revisionId: __expectString,
    });
};
const de_RuleState = (output, context) => {
    return take(output, {
        currentRevision: (_) => de_RuleRevision(_, context),
        entityUrl: __expectString,
        latestExecution: (_) => de_RuleExecution(_, context),
        revisionUrl: __expectString,
        ruleName: __expectString,
    });
};
const de_RuleStateList = (output, context) => {
    const retVal = (output || [])
        .filter((e) => e != null)
        .map((entry) => {
        return de_RuleState(entry, context);
    });
    return retVal;
};
const de_StageConditionState = (output, context) => {
    return take(output, {
        conditionStates: (_) => de_ConditionStateList(_, context),
        latestExecution: _json,
    });
};
const de_StageState = (output, context) => {
    return take(output, {
        actionStates: (_) => de_ActionStateList(_, context),
        beforeEntryConditionState: (_) => de_StageConditionState(_, context),
        inboundExecution: _json,
        inboundExecutions: _json,
        inboundTransitionState: (_) => de_TransitionState(_, context),
        latestExecution: _json,
        onFailureConditionState: (_) => de_StageConditionState(_, context),
        onSuccessConditionState: (_) => de_StageConditionState(_, context),
        retryStageMetadata: _json,
        stageName: __expectString,
    });
};
const de_StageStateList = (output, context) => {
    const retVal = (output || [])
        .filter((e) => e != null)
        .map((entry) => {
        return de_StageState(entry, context);
    });
    return retVal;
};
const de_TransitionState = (output, context) => {
    return take(output, {
        disabledReason: __expectString,
        enabled: __expectBoolean,
        lastChangedAt: (_) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
        lastChangedBy: __expectString,
    });
};
const de_UpdatePipelineOutput = (output, context) => {
    return take(output, {
        pipeline: _json,
    });
};
const de_WebhookList = (output, context) => {
    const retVal = (output || [])
        .filter((e) => e != null)
        .map((entry) => {
        return de_ListWebhookItem(entry, context);
    });
    return retVal;
};
const deserializeMetadata = (output) => ({
    httpStatusCode: output.statusCode,
    requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"] ?? output.headers["x-amz-request-id"],
    extendedRequestId: output.headers["x-amz-id-2"],
    cfId: output.headers["x-amz-cf-id"],
});
const collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
const throwDefaultError = withBaseException(__BaseException);
const buildHttpRpcRequest = async (context, headers, path, resolvedHostname, body) => {
    const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
    const contents = {
        protocol,
        hostname,
        port,
        method: "POST",
        path: basePath.endsWith("/") ? basePath.slice(0, -1) + path : basePath + path,
        headers,
    };
    if (resolvedHostname !== undefined) {
        contents.hostname = resolvedHostname;
    }
    if (body !== undefined) {
        contents.body = body;
    }
    return new __HttpRequest(contents);
};
function sharedHeaders(operation) {
    return {
        "content-type": "application/x-amz-json-1.1",
        "x-amz-target": `CodePipeline_20150709.${operation}`,
    };
}
