Class: Nylas::Domains

Inherits:
Resource show all
Includes:
ApiOperations::Delete, ApiOperations::Get, ApiOperations::Post, ApiOperations::Put
Defined in:
lib/nylas/resources/domains.rb

Overview

Nylas Manage Domains API

These endpoints require Nylas Service Account request signing. Pass headers containing X-Nylas-Kid, X-Nylas-Timestamp, X-Nylas-Nonce, and X-Nylas-Signature generated for the exact request being sent.

Constant Summary collapse

REQUIRED_SERVICE_ACCOUNT_HEADERS =
%w[
  X-Nylas-Kid
  X-Nylas-Timestamp
  X-Nylas-Nonce
  X-Nylas-Signature
].freeze

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Nylas::Resource

Instance Method Details

#create(request_body:, headers:) ⇒ Array(Hash, String, Hash)

Create a domain.

Parameters:

  • request_body (Hash)

    The values to create the domain with. Requires name and domain_address.

  • headers (Hash)

    Nylas Service Account request signing headers.

Returns:

  • (Array(Hash, String, Hash))

    The created domain, API Request ID, and response headers.



82
83
84
85
86
87
88
89
90
# File 'lib/nylas/resources/domains.rb', line 82

def create(request_body:, headers:)
  (headers)

  post(
    path: "#{api_uri}/v3/admin/domains",
    request_body: request_body,
    headers: headers
  )
end

#destroy(domain_id:, headers:) ⇒ Array(TrueClass, String)

Delete a domain.

Parameters:

  • domain_id (String)

    The identifier of the domain to delete. Accepts either a UUID or a domain address (FQDN/email format).

  • headers (Hash)

    Nylas Service Account request signing headers.

Returns:

  • (Array(TrueClass, String))

    True and the API Request ID for the delete operation.



116
117
118
119
120
121
122
123
124
125
# File 'lib/nylas/resources/domains.rb', line 116

def destroy(domain_id:, headers:)
  (headers)

  _, request_id = delete(
    path: "#{api_uri}/v3/admin/domains/#{domain_id}",
    headers: headers
  )

  [true, request_id]
end

#find(domain_id:, headers:) ⇒ Array(Hash, String, Hash)

Return a domain.

Parameters:

  • domain_id (String)

    The identifier of the domain to return. Accepts either a UUID or a domain address (FQDN/email format).

  • headers (Hash)

    Nylas Service Account request signing headers.

Returns:

  • (Array(Hash, String, Hash))

    The domain, API request ID, and response headers.



67
68
69
70
71
72
73
74
# File 'lib/nylas/resources/domains.rb', line 67

def find(domain_id:, headers:)
  (headers)

  get(
    path: "#{api_uri}/v3/admin/domains/#{domain_id}",
    headers: headers
  )
end

#info(domain_id:, request_body:, headers:) ⇒ Array(Hash, String, Hash)

Get the DNS record info for a domain verification type.

Parameters:

  • domain_id (String)

    The identifier of the domain. Accepts either a UUID or a domain address (FQDN/email format).

  • request_body (Hash)

    The verification attempt values. Requires type.

  • headers (Hash)

    Nylas Service Account request signing headers.

Returns:

  • (Array(Hash, String, Hash))

    The domain verification result, API Request ID, and response headers.



135
136
137
138
139
140
141
142
143
# File 'lib/nylas/resources/domains.rb', line 135

def info(domain_id:, request_body:, headers:)
  (headers)

  post(
    path: "#{api_uri}/v3/admin/domains/#{domain_id}/info",
    request_body: request_body,
    headers: headers
  )
end

#list(headers:, query_params: nil) ⇒ Array(Array(Hash), String, String, Hash)

Return all domains for the caller's organization.

Parameters:

  • query_params (Hash, nil) (defaults to: nil)

    Query params to pass to the request. Supported keys: domain (filter by exact domain address), region, limit, page_token.

  • headers (Hash)

    Nylas Service Account request signing headers.

Returns:

  • (Array(Array(Hash), String, String, Hash))

    The list of domains, API Request ID, next cursor, and response headers.



51
52
53
54
55
56
57
58
59
# File 'lib/nylas/resources/domains.rb', line 51

def list(headers:, query_params: nil)
  (headers)

  get_list(
    path: "#{api_uri}/v3/admin/domains",
    query_params: query_params,
    headers: headers
  )
end

#update(domain_id:, request_body:, headers:) ⇒ Array(Hash, String)

Update a domain.

Parameters:

  • domain_id (String)

    The identifier of the domain to update. Accepts either a UUID or a domain address (FQDN/email format).

  • request_body (Hash)

    The values to update the domain with. The response echoes only the updated fields, not a full domain object.

  • headers (Hash)

    Nylas Service Account request signing headers.

Returns:

  • (Array(Hash, String))

    The updated domain fields and API Request ID.



100
101
102
103
104
105
106
107
108
# File 'lib/nylas/resources/domains.rb', line 100

def update(domain_id:, request_body:, headers:)
  (headers)

  put(
    path: "#{api_uri}/v3/admin/domains/#{domain_id}",
    request_body: request_body,
    headers: headers
  )
end

#verify(domain_id:, request_body:, headers:) ⇒ Array(Hash, String, Hash)

Trigger a DNS verification check for a domain verification type.

Parameters:

  • domain_id (String)

    The identifier of the domain. Accepts either a UUID or a domain address (FQDN/email format).

  • request_body (Hash)

    The verification attempt values. Requires type.

  • headers (Hash)

    Nylas Service Account request signing headers.

Returns:

  • (Array(Hash, String, Hash))

    The domain verification result, API Request ID, and response headers.



153
154
155
156
157
158
159
160
161
# File 'lib/nylas/resources/domains.rb', line 153

def verify(domain_id:, request_body:, headers:)
  (headers)

  post(
    path: "#{api_uri}/v3/admin/domains/#{domain_id}/verify",
    request_body: request_body,
    headers: headers
  )
end