atlasapi package¶
atlasapi.atlas module¶
Atlas module
Core module which provides access to MongoDB Atlas Cloud Provider APIs
-
class
atlasapi.atlas.
AlertsGetAll
(atlas, status, pageNum, itemsPerPage)¶ Bases:
atlasapi.atlas.AtlasPagination
Pagination for Alerts : Get All
-
fetch
(pageNum, itemsPerPage)¶ Intermediate fetching
Parameters: - pageNum (int) – Page number
- itemsPerPage (int) – Number of Users per Page
Returns: Response payload
Return type: dict
-
-
class
atlasapi.atlas.
Atlas
(user: str, password: str, group: str = None, auth_method: Union[requests.auth.HTTPBasicAuth, requests.auth.HTTPDigestAuth] = <class 'requests.auth.HTTPDigestAuth'>)¶ Bases:
object
Atlas constructor
Parameters: - user (str) – Atlas user
- password (str) – Atlas password
- group (str) – Atlas group
- auth_method (Union[HTTPBasicAuth,HTTPDigestAuth]) – Authentication method to use, defaults to digest, but you
- override to Basic if needed for use with a Proxy. (can) –
-
class
atlasapi.atlas.
AtlasPagination
(atlas, fetch, pageNum: int, itemsPerPage: int)¶ Bases:
object
Atlas Pagination Generic Implementation
Constructor
Parameters: - atlas (Atlas) – Atlas instance
- fetch (function) – The function “get_all” to call
- pageNum (int) – Page number
- itemsPerPage (int) – Number of Users per Page
-
class
atlasapi.atlas.
CloudBackupSnapshotsGetAll
(atlas, pageNum, itemsPerPage)¶ Bases:
atlasapi.atlas.AtlasPagination
Pagination for Database User : Get All
-
class
atlasapi.atlas.
ClustersGetAll
(atlas, pageNum, itemsPerPage)¶ Bases:
atlasapi.atlas.AtlasPagination
Pagination for Clusters : Get All
-
class
atlasapi.atlas.
DatabaseUsersGetAll
(atlas, pageNum, itemsPerPage)¶ Bases:
atlasapi.atlas.AtlasPagination
Pagination for Database User : Get All
-
class
atlasapi.atlas.
EventsGetForProject
(atlas: atlasapi.atlas.Atlas, since_datetime: datetime.datetime, pageNum: int, itemsPerPage: int)¶ Bases:
atlasapi.atlas.AtlasPagination
-
fetch
(pageNum, itemsPerPage)¶ Intermediate fetching
Parameters: - pageNum (int) – Page number
- itemsPerPage (int) – Number of Events per Page
Returns: Response payload
Return type: dict
-
-
class
atlasapi.atlas.
HostsGetAll
(atlas: atlasapi.atlas.Atlas, pageNum: int, itemsPerPage: int)¶ Bases:
atlasapi.atlas.AtlasPagination
Pagination for Processes : Get All
-
class
atlasapi.atlas.
WhitelistGetAll
(atlas, pageNum, itemsPerPage)¶ Bases:
atlasapi.atlas.AtlasPagination
Pagination for Database User : Get All
atlasapi.atlas_types module¶
atlasapi.clusters module¶
Classes related to Atlas clusters.
Supports the creation and configuration of Atlas clusters of various types.
Enums are used in order to minimize invalid configuration values.
-
class
atlasapi.clusters.
AdvancedOptions
(failIndexKeyTooLong: Optional[bool] = None, javascriptEnabled: Optional[bool] = None, minimumEnabledTlsProtocol: Optional[atlasapi.clusters.TLSProtocols] = None, noTableScan: Optional[bool] = None, oplogSizeMB: Optional[int] = None, sampleSizeBIConnector: Optional[int] = None, sampleRefreshIntervalBIConnector: Optional[int] = None)¶ Bases:
object
Container for Atlas Cluster Advanced options
Parameters: - failIndexKeyTooLong – When true, documents can only be updated or inserted if, for all indexed fields on the target collection, the corresponding index entries do not exceed 1024 bytes.When false, mongod writes documents that breach the limit but does not index them.
- javascriptEnabled – When true, the cluster allows execution of operations that perform server-side executions of JavaScript. When false, the cluster disables execution of those operations.
- minimumEnabledTlsProtocol – The minimum Transport Layer Security (TLS) version the cluster accepts for incoming connections.
- noTableScan – When true, the cluster disables the execution of any query that requires a collection scan to return results. When false, the cluster allows the execution of those operations.
- oplogSizeMB – The custom oplog size of the cluster. A value of null indicates that the cluster uses the default oplog size calculated by Atlas.
- sampleSizeBIConnector – Number of documents per database to sample when gathering schema information.
- sampleRefreshIntervalBIConnector – Interval in seconds at which the mongosqld process re-samples data to create its relational schema.
-
as_dict
¶ Returns a json-able dict of only non-null properties.
Returns:
-
classmethod
fill_from_dict
(data_dict: dict)¶ Fills the advanced options object from an Atlas Dict
Parameters: data_dict ( dict
) – A dict as returned from AtlasReturns:
-
class
atlasapi.clusters.
AtlasBasicReplicaSet
(name: str, size: atlasapi.clusters.InstanceSizeName = <InstanceSizeName.M10: 'M10'>, disk_size: int = 10, provider: atlasapi.lib.ProviderName = <ProviderName.AWS: 'Amazon Web Services'>, region: str = 'US_WEST_2', version: atlasapi.lib.MongoDBMajorVersion = <MongoDBMajorVersion.v4_0: '4.0'>)¶ Bases:
object
Helper object for the creation of a basic replica set with default options.
Only the cluster name is required.
Other parameters will default to An M10 cluster on AWS US_WEST_2 running 4.0 with a 10 GB disk.
- Args:
- name: The name given to the cluster/replica set. size: The InstanceSizeName of the cluster/replica set disk_size: Size of disks on all members provider: The Cloud provider region: The region in the cloud provider version: The MongoDB major version
-
as_dict
()¶
-
class
atlasapi.clusters.
ClusterConfig
(backup_enabled: bool = False, cluster_type: atlasapi.lib.ClusterType = <ClusterType.REPLICASET: 'Replica Set'>, disk_size_gb: int = 32, name: str = None, mongodb_major_version: atlasapi.lib.MongoDBMajorVersion = <MongoDBMajorVersion.v4_0: '4.0'>, mongodb_version: Optional[str] = None, num_shards: int = 1, mongo_uri: Optional[str] = None, mongo_uri_updated: Optional[str] = None, mongo_uri_with_options: Optional[str] = None, paused: bool = False, pit_enabled: bool = False, replication_factor: Optional[int] = None, state_name: Optional[atlasapi.clusters.ClusterStates] = None, autoscaling: dict = None, replication_specs: atlasapi.clusters.ReplicationSpecs = None, srv_address: Optional[str] = None, providerSettings: Optional[atlasapi.clusters.ProviderSettings] = None, links: list = None, id: Optional[str] = None)¶ Bases:
object
Stores the Atlas Cluster Config, is sent back to the API for any reconfiguations.
https://docs.atlas.mongodb.com/reference/api/clusters-get-one/#http-response-elements
- Args:
- backup_enabled: cluster_type: disk_size_gb: name: mongodb_major_version: mongodb_version: num_shards: mongo_uri: mongo_uri_updated: mongo_uri_with_options: paused: pit_enabled: replication_factor: state_name: autoscaling: replication_specs: srv_address: providerSettings: links:
-
as_create_dict
() → dict¶ Returns the config object in a format acceptable for the POST (create) endpoint.
Removes properties which are read-only.
TODO: Refactor to identify which properties are RO in the spec, and automatically loop through and remove.
Returns: dict: A dict containing a valid create object for the POST endpoint.
-
as_dict
() → dict¶
-
as_modify_dict
() → dict¶ Returns the config object in a format acceptable for the PATCH (modify) endpoint.
Removes properties which are read-only.
TODO: Refactor to identify which properties are RO in the spec, and automatically loop through and remove.
Returns: dict: A dict containing a valid create object for the POST endpoint.
-
classmethod
fill_from_dict
(data_dict: dict)¶
-
class
atlasapi.clusters.
ClusterStates
¶ Bases:
enum.Enum
The states of Atlas clusters. RO attribute.
-
CREATING
= 'Creating'¶
-
DELETED
= 'Deleted'¶
-
DELETING
= 'Deleting'¶
-
IDLE
= 'Idle'¶
-
REPAIRING
= 'Repairing'¶
-
UNKNOWN
= 'Unknown'¶
-
UPDATING
= 'Updating'¶
-
-
class
atlasapi.clusters.
InstanceSizeName
¶ Bases:
enum.Enum
The Atlas instance sizes, which are equivalent across all providers.
NVME suggixed types provide loval NVME disk.
-
M0
= 'M0'¶
-
M10
= 'M10'¶
-
M100
= 'M100'¶
-
M140
= 'M140'¶
-
M2
= 'M2'¶
-
M20
= 'M20'¶
-
M200
= 'M200'¶
-
M200_NVME
= 'M200_NVME'¶
-
M30
= 'M30'¶
-
M300
= 'M300'¶
-
M40
= 'M40'¶
-
M400
= 'M400'¶
-
M400_NVME
= 'M400_NVME'¶
-
M40_NVME
= 'M40 NVME'¶
-
M5
= 'M5'¶
-
M50
= 'M50'¶
-
M50_NVME
= 'M50 NVME'¶
-
M60
= 'M60'¶
-
M60_NVME
= 'M60 NVME'¶
-
M80
= 'M80'¶
-
M80_NVME
= 'M80 NVME'¶
-
R200
= 'R200'¶
-
R300
= 'R300'¶
-
R40
= 'R40'¶
-
R400
= 'R400'¶
-
R50
= 'R50'¶
-
R60
= 'R60'¶
-
R700
= 'R700'¶
-
R80
= 'R80'¶
-
-
class
atlasapi.clusters.
ProviderSettings
(size: atlasapi.clusters.InstanceSizeName = <InstanceSizeName.M10: 'M10'>, provider: atlasapi.lib.ProviderName = <ProviderName.AWS: 'Amazon Web Services'>, region: str = 'US_WEST_1', autoScaling: Optional[dict] = None, diskIOPS: int = None, encryptEBSVolume: bool = True, volumeType: atlasapi.clusters.VolumeTypes = <VolumeTypes.STANDARD: 'Standard'>)¶ Bases:
object
-
as_dict
() → dict¶
-
classmethod
from_dict
(data_dict: dict)¶
-
-
class
atlasapi.clusters.
RegionConfig
(electable_node_count: int = 3, priority: int = 7, read_only_node_count: int = 0, analytics_node_count: int = 0)¶ Bases:
object
Configuration object for each region.
Allows for the configuration of each region independently. Includes sane defaults.
Parameters: - electable_node_count (int) – Number of electable nodes.
- priority – Priority of the region in the replica set.
- read_only_node_count – Count of read_only nodes.
- analytics_node_count – Count of analytics nodes.
-
class
atlasapi.clusters.
ReplicationSpecs
(id: Optional[str] = 'df860421-e1ea-466a-ae90-800c437eea7e', num_shards: Optional[int] = 1, zone_name: Optional[str] = None, regions_config: Optional[dict] = None)¶ Bases:
object
-
as_create_dict
()¶
-
as_dict
()¶
-
classmethod
from_dict
(data_dict: dict)¶
-
-
class
atlasapi.clusters.
ShardedClusterConfig
(backup_enabled: bool = False, cluster_type: atlasapi.lib.ClusterType = <ClusterType.REPLICASET: 'Replica Set'>, disk_size_gb: int = 32, name: str = None, mongodb_major_version: atlasapi.lib.MongoDBMajorVersion = <MongoDBMajorVersion.v4_0: '4.0'>, mongodb_version: Optional[str] = None, num_shards: int = 1, mongo_uri: Optional[str] = None, mongo_uri_updated: Optional[str] = None, mongo_uri_with_options: Optional[str] = None, paused: bool = False, pit_enabled: bool = False, replication_factor: Optional[int] = None, state_name: Optional[atlasapi.clusters.ClusterStates] = None, autoscaling: dict = {}, replication_specs: list = [], srv_address: Optional[str] = None, providerSettings: Optional[atlasapi.clusters.ProviderSettings] = None, links: list = None, id: Optional[str] = None)¶ Bases:
atlasapi.clusters.ClusterConfig
-
as_dict
() → dict¶
-
atlasapi.events module¶
-
class
atlasapi.events.
AtlasCPSEvent
(value_dict: dict)¶ Bases:
atlasapi.events._AtlasBaseEvent
-
class
atlasapi.events.
AtlasClusterEvent
(value_dict: dict)¶ Bases:
atlasapi.events._AtlasBaseEvent
-
class
atlasapi.events.
AtlasDataExplorerEvent
(value_dict: dict)¶ Bases:
atlasapi.events._AtlasUserBaseEvent
-
class
atlasapi.events.
AtlasEvent
(value_dict: dict)¶ Bases:
atlasapi.events._AtlasBaseEvent
-
class
atlasapi.events.
AtlasFeatureEvent
(value_dict: dict)¶ Bases:
atlasapi.events._AtlasUserBaseEvent
-
class
atlasapi.events.
AtlasHostEvent
(value_dict: dict)¶ Bases:
atlasapi.events._AtlasBaseEvent
-
atlasapi.events.
atlas_event_factory
(value_dict: dict) → Union[atlasapi.events.AtlasEvent, atlasapi.events.AtlasDataExplorerEvent, atlasapi.events.AtlasClusterEvent, atlasapi.events.AtlasHostEvent, atlasapi.events.AtlasFeatureEvent, atlasapi.events.AtlasCPSEvent]¶
atlasapi.measurements module¶
atlasapi.whitelist module¶
-
class
atlasapi.whitelist.
WhitelistEntry
(cidrBlock: str = None, comment: str = None, ipAddress: str = None, links: list = None, last_used: str = None, count: int = None, last_used_address: str = None)¶ Bases:
object
-
as_dict
() → dict¶ Dumps obj as a json valid dict. :return:
-
classmethod
fill_from_dict
(data_dict: dict)¶ Fills the object from the standard Atlas API dictionary. :type data_dict:
dict
:param data_dict: :return:
-
atlasapi.errors module¶
Errors module
Provides all specific Exceptions
-
exception
atlasapi.errors.
ErrAtlasBackupError
(c, details)¶ Bases:
atlasapi.errors.ErrAtlasGeneric
Atlas : Atlas Backup
Constructor
Parameters: - c (int) – HTTP code
- details (dict) – Response payload
-
exception
atlasapi.errors.
ErrAtlasBadRequest
(c, details)¶ Bases:
atlasapi.errors.ErrAtlasGeneric
Atlas : Bad Request
Constructor
Parameters: - c (int) – HTTP code
- details (dict) – Response payload
-
exception
atlasapi.errors.
ErrAtlasConflict
(c, details)¶ Bases:
atlasapi.errors.ErrAtlasGeneric
Atlas : Conflict
Constructor
Parameters: - c (int) – HTTP code
- details (dict) – Response payload
-
exception
atlasapi.errors.
ErrAtlasDuplicateClusterName
(c, details)¶ Bases:
atlasapi.errors.ErrAtlasGeneric
Atlas : Duplicate Clustername
Constructor
Parameters: - c (int) – HTTP code
- details (dict) – Response payload
-
exception
atlasapi.errors.
ErrAtlasForbidden
(c, details)¶ Bases:
atlasapi.errors.ErrAtlasGeneric
Atlas : Forbidden
Constructor
Parameters: - c (int) – HTTP code
- details (dict) – Response payload
-
exception
atlasapi.errors.
ErrAtlasForbiddenWL
(c, details)¶ Bases:
atlasapi.errors.ErrAtlasGeneric
Atlas : Forbidden by WhiteList
Constructor
Parameters: - c (int) – HTTP code
- details (dict) – Response payload
-
exception
atlasapi.errors.
ErrAtlasGeneric
(msg, c, details)¶ Bases:
Exception
Atlas Generic Exception
Constructor
Parameters: - msg (str) – Short description of the error
- c (int) – HTTP code
- details (dict) – Response payload
-
getAtlasResponse
()¶ Get details about the Atlas response
Returns: HTTP code, Response payload Return type: int, str
-
exception
atlasapi.errors.
ErrAtlasJobError
(c, details)¶ Bases:
atlasapi.errors.ErrAtlasGeneric
Atlas : Job error Clustername
Constructor
Parameters: - c (int) – HTTP code
- details (dict) – Response payload
-
exception
atlasapi.errors.
ErrAtlasMethodNotAllowed
(c, details)¶ Bases:
atlasapi.errors.ErrAtlasGeneric
Atlas : Method Not Allowed
Constructor
Parameters: - c (int) – HTTP code
- details (dict) – Response payload
-
exception
atlasapi.errors.
ErrAtlasNotFound
(c, details)¶ Bases:
atlasapi.errors.ErrAtlasGeneric
Atlas : Not Found
Constructor
Parameters: - c (int) – HTTP code
- details (dict) – Response payload
-
exception
atlasapi.errors.
ErrAtlasRestoreConflictError
(c, details)¶ Bases:
atlasapi.errors.ErrAtlasGeneric
Atlas : RestoreConflictError
Constructor
Parameters: - c (int) – HTTP code
- details (dict) – Response payload
-
exception
atlasapi.errors.
ErrAtlasServerErrors
(c, details)¶ Bases:
atlasapi.errors.ErrAtlasGeneric
Atlas : Server Errors
Constructor
Parameters: - c (int) – HTTP code
- details (dict) – Response payload
Bases:
atlasapi.errors.ErrAtlasGeneric
Atlas : Unauthorized
Constructor
Parameters: - c (int) – HTTP code
- details (dict) – Response payload
-
exception
atlasapi.errors.
ErrConfirmationRequested
(msg)¶ Bases:
Exception
No Confirmation provided
Constructor
Parameters: msg (str) – Short description of the error
-
exception
atlasapi.errors.
ErrPagination
¶ Bases:
Exception
An issue occurs during a “Get All” function
-
exception
atlasapi.errors.
ErrPaginationLimits
(error_code)¶ Bases:
Exception
Out of limit on ‘pageNum’ or ‘itemsPerPage’ parameters
Constructor
Parameters: error_code (int) – ERR_PAGE_NUM or ERR_ITEMS_PER_PAGE -
ERR_ITEMS_PER_PAGE
= 1¶
-
ERR_PAGE_NUM
= 0¶
-
checkAndRaise
(itemsPerPage)¶ Check and Raise an Exception if needed
Parameters: - pageNum (int) – Page number
- itemsPerPage (int) – Number of items per Page
Raises: ErrPaginationLimits
– If we are out of limits
-
-
exception
atlasapi.errors.
ErrRole
¶ Bases:
Exception
A role is not compatible with Atlas
atlasapi.network module¶
Network module
Module which handles the basic network operations with the Atlas API>
-
class
atlasapi.network.
Network
(user, password, AuthMethod: Union[requests.auth.HTTPDigestAuth, requests.auth.HTTPBasicAuth] = <class 'requests.auth.HTTPDigestAuth'>)¶ Bases:
object
Network constructor
Parameters: - user (str) – user
- password (str) – password
-
answer
(c, details: Union[dict, _io.BytesIO])¶ Answer will provide all necessary feedback for the caller
Parameters: - c (int) – HTTP Code
- details (dict) – Response payload
Returns: Response payload
Return type: dict
Raises: ErrAtlasBadRequest
ErrAtlasUnauthorized
ErrAtlasForbidden
ErrAtlasNotFound
ErrAtlasMethodNotAllowed
ErrAtlasConflict
ErrAtlasServerErrors
-
delete
(uri)¶ Delete request
Parameters: uri (str) – URI Returns: API response Return type: Json Raises: Exception
– Network issue
-
get
(uri)¶ Get request
Parameters: uri (str) – URI Returns: API response Return type: Json Raises: Exception
– Network issue
-
get_file
(uri)¶ Get request which returns a binary file
Parameters: uri (str) – URI Returns: API response as file Return type: Binary File Raises: Exception
– Network issue
-
patch
(uri, payload)¶ Patch request
Parameters: - uri (str) – URI
- payload (dict) – Content to patch
Returns: API response
Return type: Json
Raises: Exception
– Network issue
-
post
(uri, payload)¶ Post request
Parameters: - uri (str) – URI
- payload (dict) – Content to post
Returns: API response
Return type: Json
Raises: Exception
– Network issue
atlasapi.settings module¶
Settings module
Provides few constants, APIs endpoints.
-
class
atlasapi.settings.
Settings
¶ Bases:
object
-
ACCEPTED
= 202¶
-
BAD_REQUEST
= 400¶
-
BASE_URL
= 'https://cloud.mongodb.com'¶
-
CONFLICT
= 409¶
-
CREATED
= 201¶
-
FORBIDDEN
= 403¶
-
METHOD_NOT_ALLOWED
= 405¶
-
NOTFOUND
= 404¶
-
NO_CONTENT
= 204¶
-
SERVER_ERRORS
= 500¶
-
SUCCESS
= 200¶
-
UNAUTHORIZED
= 401¶
-
URI_STUB
= '/api/atlas/v1.0'¶
-
api_resources
= {'Alerts': {'Acknowledge an Alert': '/api/atlas/v1.0/groups/%s/alerts/%s', 'Get All Alerts': '/api/atlas/v1.0/groups/%s/alerts?pageNum=%d&itemsPerPage=%d', 'Get All Alerts with status': '/api/atlas/v1.0/groups/%s/alerts?status=%s&pageNum=%d&itemsPerPage=%d', 'Get an Alert': '/api/atlas/v1.0/groups/%s/alerts/%s'}, 'Cloud Backup': {'Delete snapshot by SNAPSHOT-ID': '/api/atlas/v1.0/groups/{GROUP_ID}/clusters/{CLUSTER_NAME}/backup/snapshots/{SNAPSHOT_ID}', 'Get all Cloud Backups for cluster': '/api/atlas/v1.0/groups/{GROUP_ID}/clusters/{CLUSTER_NAME}/backup/snapshots', 'Get snapshot by SNAPSHOT-ID': '/api/atlas/v1.0/groups/{GROUP_ID}/clusters/{CLUSTER_NAME}/backup/snapshots/{SNAPSHOT_ID}', 'Take an on-demand snapshot': '/api/atlas/v1.0/groups/{GROUP_ID}/clusters/{CLUSTER_NAME}/backup/snapshots'}, 'Cloud Backup Restore Jobs': {'Cancel manual download restore job by job_id': '/api/atlas/v1.0/groups/{GROUP_ID}/clusters/{CLUSTER_NAME}/backup/restoreJobs/{JOB_ID}', 'Get Cloud Backup restore job by cluster': '/api/atlas/v1.0/groups/{GROUP_ID}/clusters/{CLUSTER_NAME}/backup/restoreJobs/{JOB_ID}', 'Get all Cloud Backup restore jobs by cluster': '/api/atlas/v1.0/groups/{GROUP_ID}/clusters/{CLUSTER_NAME}/backup/restoreJobs', 'Restore snapshot by cluster': '/api/atlas/v1.0/groups/{GROUP_ID}/clusters/{CLUSTER_NAME}/backup/restoreJobs'}, 'Clusters': {'Advanced Configuration Options': '/api/atlas/v1.0/groups/{GROUP_ID}/clusters/{CLUSTER_NAME}/processArgs', 'Create a Cluster': '/api/atlas/v1.0/groups/{GROUP_ID}/clusters/', 'Delete a Cluster': '/api/atlas/v1.0/groups/%s/clusters/%s', 'Get All Clusters': '/api/atlas/v1.0/groups/%s/clusters?pageNum=%d&itemsPerPage=%d', 'Get a Single Cluster': '/api/atlas/v1.0/groups/%s/clusters/%s', 'Modify a Cluster': '/api/atlas/v1.0/groups/{GROUP_ID}/clusters/{CLUSTER_NAME}', 'Test Failover': '/api/atlas/v1.0/groups/{GROUP_ID}/clusters/{CLUSTER_NAME}/restartPrimaries'}, 'Database Users': {'Create a Database User': '/api/atlas/v1.0/groups/%s/databaseUsers', 'Delete a Database User': '/api/atlas/v1.0/groups/%s/databaseUsers/admin/%s', 'Get All Database Users': '/api/atlas/v1.0/groups/%s/databaseUsers?pageNum=%d&itemsPerPage=%d', 'Get a Single Database User': '/api/atlas/v1.0/groups/%s/databaseUsers/admin/%s', 'Update a Database User': '/api/atlas/v1.0/groups/%s/databaseUsers/admin/%s'}, 'Events': {'Get All Project Events': '/api/atlas/v1.0/groups/{group_id}/events??includeRaw=true&pageNum={page_num}&itemsPerPage={items_per_page}', 'Get Project Events Since Date': '/api/atlas/v1.0/groups/{group_id}/events?includeRaw=true&pageNum={page_num}&itemsPerPage={items_per_page}&minDate={min_date}'}, 'Maintenance Windows': {'Defer Maintenance Window': '/api/atlas/v1.0/groups/{GROUP_ID}/maintenanceWindow/defer', 'Delete Maintenance Window': '/api/atlas/v1.0/groups/{GROUP_ID}/maintenanceWindow', 'Get Maintenance Window': '/api/atlas/v1.0/groups/{GROUP_ID}/maintenanceWindow', 'Update Maintenance Window': '/api/atlas/v1.0/groups/{GROUP_ID}/maintenanceWindow'}, 'Monitoring and Logs': {'Get all processes for group': '/api/atlas/v1.0/groups/{group_id}/processes?pageNum={page_num}&itemsPerPage={items_per_page}', 'Get information for process in group': '/api/atlas/v1.0/groups/%s/processes/%s:&s?pageNum=%d&itemsPerPage=%d', 'Get list of databases for host': '/api/atlas/v1.0/groups/{GROUP-ID}/processes/{HOST}:{PORT}/databases', 'Get list of disks or partitions for host.': '/api/atlas/v1.0/groups/{GROUP-ID}/processes/{HOST}:{PORT}/disks', 'Get measurement for host': '/api/atlas/v1.0/groups/{group_id}/processes/{host}:{port}/measurements?granularity={granularity}&period={period}&m={measurement}', 'Get measurements of database for host.': '/api/atlas/v1.0/groups/{GROUP-ID}/processes/{HOST}:{PORT}/databases/{DATABASE-NAME}/measurements', 'Get measurements of for host': '/api/atlas/v1.0/groups/{GROUP-ID}/processes/{HOST}:{PORT}/disks/{DISK-NAME}/measurements', 'Get the log file for a host in the cluster': '/api/atlas/v1.0/groups/{group_id}/clusters/{host}/logs/{logname}'}, 'Organization API Keys': {'Create one or more whitelist entries for APi Key': '/api/atlas/v1.0/orgs/{GROUP_ID}/apiKeys/{API_KEY_ID}/whitelist', 'Get Whitelists for API Key': '/api/atlas/v1.0/orgs/{ORG_ID}/apiKeys/{API_KEY_ID}/whitelist', 'Get a single whitelist entry': '/api/atlas/v1.0/orgs/{GROUP_ID}/apiKeys/{API_KEY_ID}/whitelist/{IP_ADDRESS}', 'Get all Organization API Keys associated with org': '/api/atlas/v1.0/orgs/{GROUP_ID}/apiKeys', 'Get one Organization API Key': '/api/atlas/v1.0/orgs/{ORG_ID}/apiKeys/{API_KEY_ID}'}, 'Organizations': {'Atlas Users associated to Org': '/api/atlas/v1.0/orgs/{ORGS_ID}/users/', 'Org by org_id': '/api/atlas/v1.0/orgs/{ORG_ID}', 'Orgs the authenticated user can access': '/api/atlas/v1.0/orgs/', 'Projects associated with the Org': '/api/atlas/v1.0/groups/{ORG_ID}/groups'}, 'Project': {'Get One Project': '/api/atlas/v1.0/groups/{GROUP_ID}'}, 'Project API Keys': {'Get All API Keys Assigned to Project': '/api/atlas/v1.0/groups/{GROUP_ID}/apiKeys'}, 'Projects': {'Atlas Users assigned to project': '/api/atlas/v1.0/groups/{GROUP_ID}/users/', 'One Pending invitation to the project associated': '/api/atlas/v1.0/groups/{GROUP_ID}/invites{INVITATION_ID}', 'Pending invitations to the project associated ': '/api/atlas/v1.0/groups/{GROUP_ID}/invites', 'Project by group name': '/api/atlas/v1.0/groups/byName/{GROUP_NAME}', 'Project by group_id': '/api/atlas/v1.0/groups/{GROUP_ID}', 'Project teams by group_id': '/api/atlas/v1.0/groups/{GROUP_ID}/teams/', 'Projects that the authenticated user can access': '/api/atlas/v1.0/groups/', 'Remove Atlas Users assigned to project': '/api/atlas/v1.0/groups/{GROUP_ID}/users/{USER_ID}', 'Remove the specified Atlas team from the specified project.': '/api/atlas/v1.0/groups/{GROUP_ID}/teams/{TEAM_ID}', 'Settings for project': '/api/atlas/v1.0/groups/{GROUP_ID}/settings'}, 'Whitelist': {'Create Whitelist Entry': '/api/atlas/v1.0/groups/%s/whitelist', 'Delete Whitelist Entry': '/api/atlas/v1.0/groups/%s/whitelist/%s', 'Get All Whitelist Entries': '/api/atlas/v1.0/groups/%s/whitelist?pageNum=%d&itemsPerPage=%d', 'Get Whitelist Entry': '/api/atlas/v1.0/groups/%s/whitelist/%s'}}¶
-
databaseName
= 'admin'¶
-
file_request_timeout
= 360¶
-
itemsPerPage
= 1000¶
-
itemsPerPageMax
= 2000¶
-
itemsPerPageMin
= 1¶
-
pageNum
= 1¶
-
requests_timeout
= 10¶
-
atlasapi.specs module¶
Specs module
Provides some high level objects useful to use the Atlas API.
-
class
atlasapi.specs.
AlertStatusSpec
¶ Bases:
object
Alert Status
-
CLOSED
= 'CLOSED'¶
-
OPEN
= 'OPEN'¶
-
TRACKING
= 'TRACKING'¶
-
-
class
atlasapi.specs.
AtlasMeasurement
(name: atlasapi.specs.AtlasMeasurementTypes, period: atlasapi.lib.AtlasPeriods, granularity: atlasapi.lib.AtlasGranularities, measurements: List[atlasapi.specs.AtlasMeasurementValue] = None)¶ Bases:
object
A point in time container for an Atlas measurement.
For a certain period, granularity and measurementType holds a list fo measurementValues.
Parameters: - name (AtlasMeasurementTypes) – The name of the measurement type
- period (AtlasPeriods) – The period the measurement covers
- granularity (AtlasGranularities) – The granularity used for the measurement
- measurements (List[AtlasMeasurementValue]) – A list of the actual measurement values
-
as_dict
¶ Returns the measurement as a dict, including the computed properties.
Returns: Return type: dict
-
date_end
¶ The date of the last measurement
Returns: The date of the last measurement. Return type: datetime
-
date_start
¶ The date of the first measurement.
Returns: The date of the first measurement. Return type: datetime
-
measurement_stats
¶ Returns a statistical info for measurement data
-
measurement_stats_friendly_bytes
¶ Returns statistical info for measurement data in friendly bytes format
-
measurement_stats_friendly_number
¶ Returns statistical info for measurement data in friendly bytes format
-
measurements
¶ Getter for the measurements.
Returns: An iterator containing values objects. Return type: Iterator[AtlasMeasurementValue]
-
measurements_as_tuples
()¶
-
measurements_count
¶ The count of measurements
Returns: The count of measurements in the set Return type: int
-
class
atlasapi.specs.
AtlasMeasurementTypes
¶ Bases:
atlasapi.lib._GetAll
Helper class for all available atlas measurements.
All classes and embedded classes have a get_all class method that returns an iterator of all measurements and sub measurements.
-
class
Asserts
¶ Bases:
atlasapi.lib._GetAll
-
msg
= 'ASSERT_MSG'¶
-
regular
= 'ASSERT_REGULAR'¶
-
user
= 'ASSERT_USER'¶
-
warning
= 'ASSERT_WARNING'¶
-
-
class
CPU
¶ Bases:
atlasapi.lib._GetAll
-
class
Process
¶ Bases:
atlasapi.lib._GetAll
-
children_kernel
= 'PROCESS_CPU_CHILDREN_KERNEL'¶
-
children_user
= 'PROCESS_CPU_CHILDREN_USER'¶
-
kernel
= 'PROCESS_CPU_KERNEL'¶
-
user
= 'PROCESS_CPU_USER'¶
-
-
class
ProcessNormalized
¶ Bases:
atlasapi.lib._GetAll
-
children_kernel
= 'PROCESS_NORMALIZED_CPU_CHILDREN_KERNEL'¶
-
children_user
= 'PROCESS_NORMALIZED_CPU_CHILDREN_USER'¶
-
kernel
= 'PROCESS_NORMALIZED_CPU_KERNEL'¶
-
user
= 'PROCESS_NORMALIZED_CPU_USER'¶
-
-
class
System
¶ Bases:
atlasapi.lib._GetAll
-
guest
= 'SYSTEM_CPU_GUEST'¶
-
iowait
= 'SYSTEM_CPU_IOWAIT'¶
-
irq
= 'SYSTEM_CPU_IRQ'¶
-
kernel
= 'SYSTEM_CPU_KERNEL'¶
-
nice
= 'SYSTEM_CPU_NICE'¶
-
softirq
= 'SYSTEM_CPU_SOFTIRQ'¶
-
steal
= 'SYSTEM_CPU_STEAL'¶
-
user
= 'SYSTEM_CPU_USER'¶
-
-
class
SystemNormalized
¶ Bases:
atlasapi.lib._GetAll
-
guest
= 'SYSTEM_NORMALIZED_CPU_GUEST'¶
-
iowait
= 'SYSTEM_NORMALIZED_CPU_IOWAIT'¶
-
irq
= 'SYSTEM_NORMALIZED_CPU_IRQ'¶
-
kernel
= 'SYSTEM_NORMALIZED_CPU_KERNEL'¶
-
nice
= 'SYSTEM_NORMALIZED_CPU_NICE'¶
-
softirq
= 'SYSTEM_NORMALIZED_CPU_SOFTIRQ'¶
-
steal
= 'SYSTEM_NORMALIZED_CPU_STEAL'¶
-
user
= 'SYSTEM_NORMALIZED_CPU_USER'¶
-
-
class
-
class
Cache
¶ Bases:
atlasapi.lib._GetAll
-
bytes_read
= 'CACHE_BYTES_READ_INTO'¶
-
bytes_written
= 'CACHE_BYTES_WRITTEN_FROM'¶
-
dirty
= 'CACHE_DIRTY_BYTES'¶
-
used
= 'CACHE_USED_BYTES'¶
-
-
class
Cursors
¶ Bases:
atlasapi.lib._GetAll
-
open
= 'CURSORS_TOTAL_OPEN'¶
-
timed_out
= 'CURSORS_TOTAL_TIMED_OUT'¶
-
-
class
Db
¶ Bases:
atlasapi.lib._GetAll
-
data_size
= 'DB_DATA_SIZE_TOTAL'¶
-
storage
= 'DB_STORAGE_TOTAL'¶
-
-
class
DocumentMetrics
¶ Bases:
atlasapi.lib._GetAll
-
deleted
= 'DOCUMENT_METRICS_DELETED'¶
-
inserted
= 'DOCUMENT_METRICS_INSERTED'¶
-
returned
= 'DOCUMENT_METRICS_RETURNED'¶
-
updated
= 'DOCUMENT_METRICS_UPDATED'¶
-
-
class
GlobalLockCurrentQueue
¶ Bases:
atlasapi.lib._GetAll
-
readers
= 'GLOBAL_LOCK_CURRENT_QUEUE_READERS'¶
-
total
= 'GLOBAL_LOCK_CURRENT_QUEUE_TOTAL'¶
-
writers
= 'GLOBAL_LOCK_CURRENT_QUEUE_WRITERS'¶
-
-
class
Memory
¶ Bases:
atlasapi.lib._GetAll
-
mapped
= 'MEMORY_MAPPED'¶
-
resident
= 'MEMORY_RESIDENT'¶
-
virtual
= 'MEMORY_VIRTUAL'¶
-
-
class
Network
¶ Bases:
atlasapi.lib._GetAll
-
bytes_id
= 'NETWORK_BYTES_IN'¶
-
bytes_in
= 'NETWORK_BYTES_IN'¶
-
bytes_out
= 'NETWORK_BYTES_OUT'¶
-
num_requests
= 'NETWORK_NUM_REQUESTS'¶
-
-
class
Opcounter
¶ Bases:
atlasapi.lib._GetAll
-
class
Repl
¶ Bases:
atlasapi.lib._GetAll
-
cmd
= 'OPCOUNTER_REPL_CMD'¶
-
delete
= 'OPCOUNTER_REPL_DELETE'¶
-
insert
= 'OPCOUNTER_REPL_INSERT'¶
-
update
= 'OPCOUNTER_REPL_UPDATE'¶
-
-
cmd
= 'OPCOUNTER_CMD'¶
-
delete
= 'OPCOUNTER_DELETE'¶
-
getmore
= 'OPCOUNTER_GETMORE'¶
-
insert
= 'OPCOUNTER_INSERT'¶
-
query
= 'OPCOUNTER_QUERY'¶
-
update
= 'OPCOUNTER_UPDATE'¶
-
class
-
class
Operations
¶ Bases:
atlasapi.lib._GetAll
-
class
ExecutionTime
¶ Bases:
atlasapi.lib._GetAll
-
commands
= 'OP_EXECUTION_TIME_COMMANDS'¶
-
reads
= 'OP_EXECUTION_TIME_READS'¶
-
writes
= 'OP_EXECUTION_TIME_WRITES'¶
-
-
scan_and_order
= 'OPERATIONS_SCAN_AND_ORDER'¶
-
class
-
class
Oplog
¶ Bases:
atlasapi.lib._GetAll
-
master_time
= 'OPLOG_MASTER_TIME'¶
-
rate
= 'OPLOG_RATE_GB_PER_HOUR'¶
-
-
class
QueryExecutor
¶ Bases:
atlasapi.lib._GetAll
-
scanned
= 'QUERY_EXECUTOR_SCANNED'¶
-
scanned_objects
= 'QUERY_EXECUTOR_SCANNED_OBJECTS'¶
-
-
class
QueryTargetingScanned
¶ Bases:
atlasapi.lib._GetAll
-
objects_per_returned
= 'QUERY_TARGETING_SCANNED_OBJECTS_PER_RETURNED'¶
-
per_returned
= 'QUERY_TARGETING_SCANNED_PER_RETURNED'¶
-
-
class
TicketsAvailable
¶ Bases:
atlasapi.lib._GetAll
-
reads
= 'TICKETS_AVAILABLE_READS'¶
-
writes
= 'TICKETS_AVAILABLE_WRITES'¶
-
-
connections
= 'CONNECTIONS'¶
-
class
-
class
atlasapi.specs.
AtlasMeasurementValue
(value_dict: dict)¶ Bases:
object
-
as_dict
() → dict¶
-
as_tuple
¶ Returns a MeasurementValue as a tuple, timestamp first. :rtype: Tuple[datetime,OptionalFloat] :return: A tuple with a datetime and a float
-
value_float
¶
-
value_int
¶
-
-
class
atlasapi.specs.
DatabaseUsersPermissionsSpecs
(username: str, password: str = None, aws_iam_type: Optional[atlasapi.specs.IAMType] = None, databaseName='admin')¶ Bases:
object
Permissions spec for Database User
Constructor
Parameters: - username (str) – Username of the DB
- password (str) – Password for the username
- aws_iam_type (IAMType) – AWS IAM method by which the database applies IAM credentials to authenticates the database user. Atlas defaults to NONE. (optional)
Keyword Arguments: databaseName (str) – Auth Database Name
-
add_role
(databaseName: str, roleName: str, collectionName: NewType.<locals>.new_type = None)¶ Add one role
Parameters: - databaseName (
str
:param roleName: :param databaseName: :type collectionName: str) – Database Name - roleName (
str
) – role
Keyword Arguments: collectionName (str) – Collection
Raises: ErrRole
– role not compatible with the databaseName and/or collectionNameTODO: Need to test if this works correctly, looks like their may be a type problem.
- databaseName (
-
add_roles
(databaseName: str, roleNames: List[atlasapi.specs.RoleSpecs], collectionName: str = None)¶ Add multiple roles
Parameters: - databaseName (
str
:param databaseName: Database Name :param roleNames: roles :param collectionName: Collection) – Database Name - roleNames (list of RoleSpecs) – roles
Keyword Arguments: collectionName (str) – Collection
Raises: ErrRoleException
– role not compatible with the databaseName and/or collectionName- databaseName (
-
clear_roles
()¶
-
getSpecs
() → dict¶ Get specs
Returns: Representation of the object Return type: dict
-
remove_role
(databaseName, roleName, collectionName=None)¶ Remove one role
Parameters: - databaseName (str) – Database Name
- roleName (RoleSpecs) – role
Keyword Arguments: collectionName (str) – Collection
-
remove_roles
(databaseName, roleNames, collectionName=None)¶ Remove multiple roles
Parameters: - collectionName (str) –
- databaseName (str) – Database Name
- roleNames (list of RoleSpecs) – roles
Keyword Arguments: collectionName (str) – Collection
-
class
atlasapi.specs.
DatabaseUsersUpdatePermissionsSpecs
(password=None)¶ Bases:
atlasapi.specs.DatabaseUsersPermissionsSpecs
Update Permissions spec for Database User
Constructor
Keyword Arguments: password (str) – Password for the username -
getSpecs
()¶ Get specs
Returns: Representation of the object Return type: dict
-
-
class
atlasapi.specs.
Host
(data: dict)¶ Bases:
object
-
add_log_file
(name: atlasapi.lib.AtlasLogNames, file: BinaryIO) → None¶ Adds the passed log file to the hosts object
Parameters: - name (AtlasLogNames) – The type of logfile to be appended.
- file (BinaryIO) – The file to be appended
-
add_measurements
(measurement) → None¶
-
get_measurement_for_host
(atlas_obj, granularity: Optional[atlasapi.lib.AtlasGranularities] = None, period: Optional[atlasapi.lib.AtlasPeriods] = None, measurement: Optional[atlasapi.specs.AtlasMeasurementTypes] = None, iterable: bool = True) → Union[dict, Iterable[atlasapi.specs.AtlasMeasurement]]¶ Get measurement(s) for a host
Returns measurements for the Host object.
url: https://docs.atlas.mongodb.com/reference/api/process-measurements/
Accepts either a single measurement, but will retrieve more than one measurement if the measurement (using the AtlasMeasurementTypes class)
/api/atlas/v1.0/groups/{GROUP-ID}/processes/{HOST}:{PORT}/measurements
Keyword Arguments: - host_obj (Host) – the host
- granularity (AtlasGranularities) – the desired granularity
- period (AtlasPeriods) – The desired period
- measurement (AtlasMeasurementTypes) – The desired measurement or Measurement class
- iterable (bool) – To return an iterable high level object instead of a low level API response
Returns: Iterable object representing this function OR Response payload
Return type: Iterable[AtlasMeasurement] or dict
Raises:
-
-
class
atlasapi.specs.
HostLogFile
(log_name: atlasapi.lib.AtlasLogNames = None, log_file_binary: BinaryIO = None)¶ Bases:
object
-
class
atlasapi.specs.
IAMType
¶ Bases:
enum.Enum
An enumeration.
-
NONE
= 'None'¶
-
ROLE
= 'ROLE'¶
-
USER
= 'USER'¶
-
-
class
atlasapi.specs.
ReplicaSetTypes
¶ Bases:
enum.Enum
An enumeration.
-
NO_DATA
= 'No data available'¶
-
RECOVERING
= 'Recovering'¶
-
REPLICA_PRIMARY
= 'ReplicaSet primary'¶
-
REPLICA_SECONDARY
= 'ReplicaSet secondary'¶
-
SHARD_CONFIG
= 'Config server'¶
-
SHARD_CONFIG_PRIMARY
= 'Config server'¶
-
SHARD_CONFIG_SECONDARY
= 'Config server'¶
-
SHARD_MONGOS
= 'Mongos router'¶
-
SHARD_PRIMARY
= 'Shard primary'¶
-
SHARD_SECONDARY
= 'Shard secondary'¶
-
SHARD_STANDALONE
= 'Standalone'¶
-
-
class
atlasapi.specs.
RoleSpecs
¶ Bases:
object
Roles supported by Atlas
-
atlasAdmin
= 'atlasAdmin'¶
-
backup
= 'backup'¶
-
clusterMonitor
= 'clusterMonitor'¶
-
dbAdmin
= 'dbAdmin'¶
-
dbAdminAnyDatabase
= 'dbAdminAnyDatabase'¶
-
enableSharding
= 'enableSharding'¶
-
read
= 'read'¶
-
readAnyDatabase
= 'readAnyDatabase'¶
-
readWrite
= 'readWrite'¶
-
readWriteAnyDatabase
= 'readWriteAnyDatabase'¶
-
-
class
atlasapi.specs.
StatisticalValues
(data_list: list)¶ Bases:
object
-
class
atlasapi.specs.
StatisticalValuesFriendly
(data_list: list, data_type: str = None)¶ Bases:
object
-
atlasapi.specs.
clean_list
(data_list: list) → list¶ Returns a list with any none values removed
Parameters: data_list (list) – The list to be cleaned Returns (list): The list cleaned of None values.
atlasapi.maintenance_window module¶
Maint Window Module
The maintenanceWindow resource provides access to retrieve or update the current Atlas project maintenance window. To learn more about Maintenance Windows, see the Set Preferred Cluster Maintenance Start Time setting on the View/Modify Project Settings page.
-
class
atlasapi.maintenance_window.
MaintenanceWindow
(day_of_week: atlasapi.maintenance_window.Weekdays = <Weekdays.SUNDAY: 1>, hour_of_day: int = 23, number_of_deferrals: int = 1, start_asap: bool = False)¶ Bases:
object
-
as_dict
() → dict¶ Returns the Maintenance object as a serializable dict
Converts enums Returns:
-
as_update_dict
() → dict¶ Returns a dict with immutable properties removed. Returns: dict
-
classmethod
from_dict
(data_dict: dict)¶ Creates a maint window definition from a dict. :param data_dict: An atlas formated dict
Returns:
-
atlasapi.cloud_backup module¶
Cloud Backups Module
Provides access to Cloud Backups and Cloud backup restore endpoints
-
class
atlasapi.cloud_backup.
CloudBackupRequest
(cluster_name: str, retention_days: int = 1, description: str = 'Created by pyAtlasAPI')¶ Bases:
object
-
as_dict
¶
-
-
class
atlasapi.cloud_backup.
CloudBackupSnapshot
(id: Optional[str] = None, cloud_provider: Optional[atlasapi.lib.ProviderName] = None, created_at: Optional[datetime.datetime] = None, description: Optional[str] = None, expires_at: Optional[datetime.datetime] = None, links: Optional[List[T]] = None, masterkey_uuid: Optional[str] = None, members: Optional[list] = None, mongod_version: Optional[str] = None, replica_set_name: Optional[str] = None, snapshot_ids: Optional[list] = None, snapshot_type: Optional[atlasapi.cloud_backup.SnapshotType] = None, status: Optional[atlasapi.cloud_backup.SnapshotStatus] = None, storage_size_bytes: Optional[int] = None, type: Optional[atlasapi.lib.ClusterType] = None)¶ Bases:
object
-
classmethod
from_dict
(data_dict: dict)¶
-
classmethod
-
class
atlasapi.cloud_backup.
DeliveryType
¶ Bases:
enum.Enum
An enumeration.
-
automated
= 'Automated restore to Atlas cluster'¶
-
download
= 'manual download of archived data directory'¶
-
pointInTime
= 'Automated point in time restore to Atlas Cluster'¶
-
-
class
atlasapi.cloud_backup.
SnapshotRestore
(delivery_type: atlasapi.cloud_backup.DeliveryType, snapshot_id: str, target_cluster_name: str = None, target_group_id: str = None)¶ Bases:
object
-
as_dict
¶
-
-
class
atlasapi.cloud_backup.
SnapshotRestoreResponse
(restore_id: str, delivery_type: atlasapi.cloud_backup.DeliveryType, snapshot_id: str, target_cluster_name: str, target_group_id: str, cancelled: bool = False, created_at: datetime.datetime = None, expired: bool = False, expires_at: datetime.datetime = None, finished_at: datetime.datetime = None, links: list = None, snapshot_timestamp: datetime.datetime = None, target_deployment_item_name: str = None, delivery_url: str = None)¶ Bases:
atlasapi.cloud_backup.SnapshotRestore
-
classmethod
from_dict
(data_dict)¶
-
classmethod
-
class
atlasapi.cloud_backup.
SnapshotStatus
¶ Bases:
enum.Enum
An enumeration.
-
COMPLETED
= 'Completed'¶
-
FAILED
= 'Failed'¶
-
INPROGRESS
= 'In Progress'¶
-
QUEUED
= 'Queued'¶
-
-
class
atlasapi.cloud_backup.
SnapshotType
¶ Bases:
enum.Enum
An enumeration.
-
FALLBACK
= 'Fallback'¶
-
ONDEMAND
= 'On Demand'¶
-
SCHEDULED
= 'Scheduled'¶
-
-
atlasapi.cloud_backup.
try_bool
(str_in: str) → bool¶
-
atlasapi.cloud_backup.
try_date
(str_in: str) → Optional[datetime.datetime]¶
atlasapi.lib module¶
-
class
atlasapi.lib.
AtlasGranularities
¶ Bases:
object
Helper class to create ISO 8601 durations to pass to the API
To add more possible granularities, add them here.
-
DAY
= 'P1D'¶
-
FIVE_MINUTE
= 'PT5M'¶
-
HOUR
= 'PT1H'¶
-
MINUTE
= 'PT1M'¶
-
-
class
atlasapi.lib.
AtlasLogNames
¶ Bases:
enum.Enum
The name of the log file that you want to retrieve:
-
MONGODB
= 'mongodb.gz'¶
-
MONGOD_AUDIT
= 'mongodb-audit-log.gz'¶
-
MONGOS
= 'mongos.gz'¶
-
MONGOS_AUDIT
= 'mongos-audit-log.gz'¶
-
-
class
atlasapi.lib.
AtlasPeriods
¶ Bases:
object
Helper class to create ISO 8601 durations to send to the Atlas period parameter.
To add more periods, add them here.
-
HOURS_1
= 'PT1H'¶
-
HOURS_24
= 'P1D'¶
-
HOURS_48
= 'P2D'¶
-
HOURS_8
= 'PT8H'¶
-
MINUTES_15
= 'PT15M'¶
-
MONTHS_1
= 'P1M'¶
-
MONTHS_2
= 'P2M'¶
-
WEEKS_1
= 'P7D'¶
-
WEEKS_4
= 'P28D'¶
-
YEARS_1
= 'P1Y'¶
-
YEARS_2
= 'P2Y'¶
-
-
class
atlasapi.lib.
AtlasUnits
¶ Bases:
enum.Enum
An enumeration.
-
BYTES
= 'BYTES'¶
-
BYTES_PER_SECOND
= 'BYTES_PER_SECOND'¶
-
GIGABYTES
= 'GIGABYTES'¶
-
GIGABYTES_PER_HOUR
= 'GIGABYTES_PER_HOUR'¶
-
MEGABYTES_PER_SECOND
= 'MEGABYTES_PER_SECOND'¶
-
MILLISECONDS
= 'MILLISECONDS'¶
-
PERCENT
= 'PERCENT'¶
-
SCALAR
= 'SCALAR'¶
-
SCALAR_PER_SECOND
= 'SCALAR_PER_SECOND'¶
-
-
class
atlasapi.lib.
ClusterType
¶ Bases:
enum.Enum
The types of clusteres available in Atlas.
GEOSHARDED is a Global write cluster sharded by geo information.
-
GEOSHARDED
= 'Global Cluster'¶
-
REPLICASET
= 'Replica Set'¶
-
SHARDED
= 'Sharded Cluster'¶
-
SHARDEDCLUSTER
= 'Sharded Cluster'¶
-
-
class
atlasapi.lib.
LogLine
(raw_line)¶ Bases:
object
atlasapi.projects module¶
-
class
atlasapi.projects.
Project
(name: str, org_id: str, created_date: Optional[datetime.datetime] = None, cluster_count: Optional[int] = None, id: Optional[str] = None, links: list = None, with_default_alert_settings: Optional[bool] = True, project_owner_id: str = None)¶ Bases:
object
-
create_dict
¶ A dictionary in the format Atlas API “create project expects”
Returns: A dictionary in the format Atlas API “create project expects”
-
classmethod
for_create
(name: str, org_id: str, with_default_alert_settings: bool = True, project_owner_id: str = None)¶ Creates a new Project object for use in creating a new project.
Only name and org_id are required.
Parameters: - project_owner_id (str) – Unique 24-hexadecimal digit string that identifies the Atlas user account to be granted the Project Owner role on the specified project. If you set this parameter, it overrides the default value of the oldest Organization Owner.
- name (str) – The name of the project. You can use this value for populating the {GROUP-NAME} parameter of the /groups/byName/{GROUP-NAME} endpoint.
- org_id (str) – The unique identifier of the Atlas organization to which the project belongs.
- with_default_alert_settings (bool) – Flag that indicates whether to create the new project with the default alert settings enabled. This parameter defaults to true.
Returns: None
-
classmethod
from_dict
(data_dict)¶ Creates a Project object from a passed dict, in the format of the Atlas API.
Parameters: data_dict (dict) – A dictionary in the format of the Atlas API. Returns: None
-
-
class
atlasapi.projects.
ProjectSettings
(is_collect_db_stats: Optional[bool] = None, is_data_explorer: Optional[bool] = None, is_performance_advisor: Optional[bool] = None, is_realtime_perf: Optional[bool] = None, is_schema_advisor: Optional[bool] = None)¶ Bases:
object
-
classmethod
from_dict
(data_dict: dict)¶
-
classmethod