Skip to content

create_agreement

create_agreement(
    server_id: ServerId,
    local_profile_id: ProfileId,
    partner_profile_id: ProfileId,
    access_role: Role,
    *,
    config_overrides: Optional[TransferClientConfig] = None,
    description: Optional[Description] = None,
    base_directory: Optional[HomeDirectory] = None,
    status: Optional[AgreementStatusType] = None,
    tags: Optional[Tags] = None,
    preserve_filename: Optional[PreserveFilenameType] = None,
    enforce_message_signing: Optional[EnforceMessageSigningType] = None,
    custom_directories: Optional[CustomDirectoriesType] = None,
) -> CreateAgreementResponse

Creates an agreement. An agreement is a bilateral trading partner agreement, or partnership, between an Transfer Family server and an AS2 process. The agreement defines the file and message transfer relationship between the server and the AS2 process. To define an agreement, Transfer Family combines a server, local profile, partner profile, certificate, and other attributes.

The partner is identified with the PartnerProfileId, and the AS2 process is identified with the LocalProfileId.

Specify either BaseDirectory or CustomDirectories, but not both. Specifying both causes the command to fail.

Parameters:

  • description (Optional[Description], default: None ) –

    A name or short description to identify the agreement.

  • server_id (ServerId) –

    A system-assigned unique identifier for a server instance. This is the specific server that the agreement uses.

  • local_profile_id (ProfileId) –

    A unique identifier for the AS2 local profile.

  • partner_profile_id (ProfileId) –

    A unique identifier for the partner profile used in the agreement.

  • base_directory (Optional[HomeDirectory], default: None ) –

    The landing directory (folder) for files transferred by using the AS2 protocol.

    A BaseDirectory example is /amzn-s3-demo-bucket/home/mydirectory.

  • access_role (Role) –

    Connectors are used to send files using either the AS2 or SFTP protocol. For the access role, provide the Amazon Resource Name (ARN) of the Identity and Access Management role to use.

    For AS2 connectors

    With AS2, you can send files by calling StartFileTransfer and specifying the file paths in the request parameter, SendFilePaths. We use the file’s parent directory (for example, for --send-file-paths /bucket/dir/file.txt, parent directory is /bucket/dir/) to temporarily store a processed AS2 message file, store the MDN when we receive them from the partner, and write a final JSON file containing relevant metadata of the transmission. So, the AccessRole needs to provide read and write access to the parent directory of the file location used in the StartFileTransfer request. Additionally, you need to provide read and write access to the parent directory of the files that you intend to send with StartFileTransfer.

    If you are using Basic authentication for your AS2 connector, the access role requires the secretsmanager:GetSecretValue permission for the secret. If the secret is encrypted using a customer-managed key instead of the Amazon Web Services managed key in Secrets Manager, then the role also needs the kms:Decrypt permission for that key.

    For SFTP connectors

    Make sure that the access role provides read and write access to the parent directory of the file location that's used in the StartFileTransfer request. Additionally, make sure that the role provides secretsmanager:GetSecretValue permission to Secrets Manager.

  • status (Optional[AgreementStatusType], default: None ) –

    The status of the agreement. The agreement can be either ACTIVE or INACTIVE.

  • tags (Optional[Tags], default: None ) –

    Key-value pairs that can be used to group and search for agreements.

  • preserve_filename (Optional[PreserveFilenameType], default: None ) –

    Determines whether or not Transfer Family appends a unique string of characters to the end of the AS2 message payload filename when saving it.

    • ENABLED: the filename provided by your trading parter is preserved when the file is saved.

    • DISABLED (default value): when Transfer Family saves the file, the filename is adjusted, as described in File names and locations.

  • enforce_message_signing (Optional[EnforceMessageSigningType], default: None ) –

    Determines whether or not unsigned messages from your trading partners will be accepted.

    • ENABLED: Transfer Family rejects unsigned messages from your trading partner.

    • DISABLED (default value): Transfer Family accepts unsigned messages from your trading partner.

  • custom_directories (Optional[CustomDirectoriesType], default: None ) –

    A CustomDirectoriesType structure. This structure specifies custom directories for storing various AS2 message files. You can specify directories for the following types of files.

    • Failed files

    • MDN files

    • Payload files

    • Status files

    • Temporary files

Raises:

Source code in docs_src/capo_transfer/_services/transfer.py
def create_agreement(
    self,
    server_id: "capo_transfer.types.server_id.ServerId",
    local_profile_id: "capo_transfer.types.profile_id.ProfileId",
    partner_profile_id: "capo_transfer.types.profile_id.ProfileId",
    access_role: "capo_transfer.types.role.Role",
    *,
    config_overrides: Optional[TransferClientConfig] = None,
    description: Optional["capo_transfer.types.description.Description"] = None,
    base_directory: Optional[
        "capo_transfer.types.home_directory.HomeDirectory"
    ] = None,
    status: Optional[
        "capo_transfer.types.agreement_status_type.AgreementStatusType"
    ] = None,
    tags: Optional["capo_transfer.types.tags.Tags"] = None,
    preserve_filename: Optional[
        "capo_transfer.types.preserve_filename_type.PreserveFilenameType"
    ] = None,
    enforce_message_signing: Optional[
        "capo_transfer.types.enforce_message_signing_type.EnforceMessageSigningType"
    ] = None,
    custom_directories: Optional[
        "capo_transfer.types.custom_directories_type.CustomDirectoriesType"
    ] = None,
) -> "capo_transfer.types.create_agreement_response.CreateAgreementResponse":
    """<p>Creates an agreement. An agreement is a bilateral trading partner agreement, or partnership, between an Transfer Family server and an AS2 process. The agreement defines the file and message transfer relationship between the server and the AS2 process. To define an agreement, Transfer Family combines a server, local profile, partner profile, certificate, and other attributes.</p> <p>The partner is identified with the <code>PartnerProfileId</code>, and the AS2 process is identified with the <code>LocalProfileId</code>.</p> <note> <p>Specify <i>either</i> <code>BaseDirectory</code> or <code>CustomDirectories</code>, but not both. Specifying both causes the command to fail.</p> </note>

    Args:
        description: <p>A name or short description to identify the agreement. </p>
        server_id: <p>A system-assigned unique identifier for a server instance. This is the specific server that the agreement uses.</p>
        local_profile_id: <p>A unique identifier for the AS2 local profile.</p>
        partner_profile_id: <p>A unique identifier for the partner profile used in the agreement.</p>
        base_directory: <p>The landing directory (folder) for files transferred by using the AS2 protocol.</p> <p>A <code>BaseDirectory</code> example is <code>/<i>amzn-s3-demo-bucket</i>/home/mydirectory</code>.</p>
        access_role: <p>Connectors are used to send files using either the AS2 or SFTP protocol. For the access role, provide the Amazon Resource Name (ARN) of the Identity and Access Management role to use.</p> <p> <b>For AS2 connectors</b> </p> <p>With AS2, you can send files by calling <code>StartFileTransfer</code> and specifying the file paths in the request parameter, <code>SendFilePaths</code>. We use the file’s parent directory (for example, for <code>--send-file-paths /bucket/dir/file.txt</code>, parent directory is <code>/bucket/dir/</code>) to temporarily store a processed AS2 message file, store the MDN when we receive them from the partner, and write a final JSON file containing relevant metadata of the transmission. So, the <code>AccessRole</code> needs to provide read and write access to the parent directory of the file location used in the <code>StartFileTransfer</code> request. Additionally, you need to provide read and write access to the parent directory of the files that you intend to send with <code>StartFileTransfer</code>.</p> <p>If you are using Basic authentication for your AS2 connector, the access role requires the <code>secretsmanager:GetSecretValue</code> permission for the secret. If the secret is encrypted using a customer-managed key instead of the Amazon Web Services managed key in Secrets Manager, then the role also needs the <code>kms:Decrypt</code> permission for that key.</p> <p> <b>For SFTP connectors</b> </p> <p>Make sure that the access role provides read and write access to the parent directory of the file location that's used in the <code>StartFileTransfer</code> request. Additionally, make sure that the role provides <code>secretsmanager:GetSecretValue</code> permission to Secrets Manager.</p>
        status: <p>The status of the agreement. The agreement can be either <code>ACTIVE</code> or <code>INACTIVE</code>.</p>
        tags: <p>Key-value pairs that can be used to group and search for agreements.</p>
        preserve_filename: <p> Determines whether or not Transfer Family appends a unique string of characters to the end of the AS2 message payload filename when saving it. </p> <ul> <li> <p> <code>ENABLED</code>: the filename provided by your trading parter is preserved when the file is saved.</p> </li> <li> <p> <code>DISABLED</code> (default value): when Transfer Family saves the file, the filename is adjusted, as described in <a href="https://docs.aws.amazon.com/transfer/latest/userguide/send-as2-messages.html#file-names-as2">File names and locations</a>.</p> </li> </ul>
        enforce_message_signing: <p> Determines whether or not unsigned messages from your trading partners will be accepted. </p> <ul> <li> <p> <code>ENABLED</code>: Transfer Family rejects unsigned messages from your trading partner.</p> </li> <li> <p> <code>DISABLED</code> (default value): Transfer Family accepts unsigned messages from your trading partner.</p> </li> </ul>
        custom_directories: <p>A <code>CustomDirectoriesType</code> structure. This structure specifies custom directories for storing various AS2 message files. You can specify directories for the following types of files.</p> <ul> <li> <p>Failed files</p> </li> <li> <p>MDN files</p> </li> <li> <p>Payload files</p> </li> <li> <p>Status files</p> </li> <li> <p>Temporary files</p> </li> </ul>

    Raises:
        capo_transfer.errors.internal_service_error.InternalServiceError: <p>This exception is thrown when an error occurs in the Transfer Family service.</p>
        capo_transfer.errors.invalid_request_exception.InvalidRequestException: <p>This exception is thrown when the client submits a malformed request.</p>
        capo_transfer.errors.resource_exists_exception.ResourceExistsException: <p>The requested resource does not exist, or exists in a region other than the one specified for the command.</p>
        capo_transfer.errors.resource_not_found_exception.ResourceNotFoundException: <p>This exception is thrown when a resource is not found by the Amazon Web ServicesTransfer Family service.</p>
        capo_transfer.errors.service_unavailable_exception.ServiceUnavailableException: <p>The request has failed because the Amazon Web ServicesTransfer Family service is not available.</p>
        capo_transfer.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_transfer.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_transfer.types.create_agreement_request.CreateAgreementRequest]",
    ) -> OperationResponse[
        "capo_transfer.types.create_agreement_response.CreateAgreementResponse"
    ]:
        import capo_transfer._operations.transfer_service.create_agreement

        output, http_response = (
            capo_transfer._operations.transfer_service.create_agreement.create_agreement(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateAgreement")
    )
    input_: capo_transfer.types.create_agreement_request.CreateAgreementRequest = {
        "server_id": server_id,
        "local_profile_id": local_profile_id,
        "partner_profile_id": partner_profile_id,
        "access_role": access_role,
    }
    if description is not None:
        input_["description"] = description
    if base_directory is not None:
        input_["base_directory"] = base_directory
    if status is not None:
        input_["status"] = status
    if tags is not None:
        input_["tags"] = tags
    if preserve_filename is not None:
        input_["preserve_filename"] = preserve_filename
    if enforce_message_signing is not None:
        input_["enforce_message_signing"] = enforce_message_signing
    if custom_directories is not None:
        input_["custom_directories"] = custom_directories

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output