create_mail_server

ManagementApi.create_mail_server(role_id, create_mail_server_request, _request_timeout=None, _request_auth=None, _content_type=None, _headers=None, _host_index=0)

Create a mail server

Creates a mail server. Requires system-settings.fullaccess. If Enabled is true, SMTP is tested first; a failed test still creates the server with Enabled false. Enabling one server disables the others. Service users are rejected (GE-1014).

Parameters:
  • role_id (str) – Amorphic role ID the request is authorized against. Must be a role the user belongs to. Also recorded in audit logs. (required)

  • create_mail_server_request (CreateMailServerRequest) – (required)

  • _request_timeout (int, tuple(int, int), optional) – timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts.

  • _request_auth (dict, optional) – set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request.

  • _content_type (str, Optional) – force content-type for the request.

  • _headers (dict, optional) – set to override the headers for a single request; this effectively ignores the headers in the spec for a single request.

  • _host_index (int, optional) – set to override the host_index for a single request; this effectively ignores the host_index in the spec for a single request.

Return type:

CreateMailServerResponse

Returns:

Returns the result object.

Request and Response Examples

HTTP: POST /mailservers

Request

Request / response example

{
  "ServerName": "corp-smtp",
  "ServerDescription": "Corporate SMTP",
  "Port": 587,
  "Enabled": true,
  "UserName": "smtp-user",
  "Password": "s3cret",
  "AccountEmail": "alerts@example.com"
}

Success (HTTP 200)

Server was stored. server_id is the new id. Message notes a skipped enable when the SMTP test failed.

Created and enabled

{
  "Message": "Successfully created new mail server configuration",
  "server_id": "server-a2f7d3b1-8e5c-4a6f-9d1e-2b3c4d5e6f7a"
}

Created but SMTP test failed

{
  "Message": "Successfully created new mail server configuration but connection test failed, skipped enabling configuration.",
  "server_id": "server-a2f7d3b1-8e5c-4a6f-9d1e-2b3c4d5e6f7a"
}

Errors

Documented error codes: AUTH-1001, AUTH-1003, AUTH-1030, IPV-1002, GE-1014, IPV-1008, IPV-1001, IPV-1010, IPV-1011, IPV-1012, IPV-1013, IPV-1020, IPV-1018, DB-1001, GE-1011, GE-1008.

HTTP 400

Validation or authorization failure. Body is {“Message”: “<CODE> - <text>”}. Codes: AUTH-1001, AUTH-1003, AUTH-1030 (missing system-settings.fullaccess), IPV-1002, GE-1014 (service user), IPV-1008 (missing or extra keys), IPV-1001 (empty value), IPV-1010 (UserName), IPV-1011 (Password, AccountEmail, or ServerName), IPV-1012 (Port), IPV-1013 (Enabled not bool), IPV-1020 (ServerDescription not a string), IPV-1018 (duplicate ServerName).

Caller lacks system-settings.fullaccess

{
  "Message": "AUTH-1030 - User is not authorized to create a new mail server due to the following missing permission(s) - {'System Settings': ['fullaccess']}"
}

Required body key missing

{
  "Message": "IPV-1008 - Invalid request body, missing key(s) - {'Password'}"
}

ServerName already exists

{
  "Message": "IPV-1018 - Invalid parameter - Mail Server Name, parameter value already exists, use different value."
}

Service user is not allowed

{
  "Message": "GE-1014 - MailServer related operations are not supported for service users"
}

HTTP 500

DynamoDB create failure uses DB-1001. SSM credential store failure uses GE-1011. Other uncaught errors use {“Message”: “GE-1008 - Could not complete the request. Please try again.”}.