Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion atlasapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# __init__.py

# Version of the realpython-reader package
__version__ = "2.0.6"
__version__ = "2.0.7"
7 changes: 5 additions & 2 deletions atlasapi/clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,10 @@ def __init__(self, backup_enabled: bool = False,
srv_address: Optional[str] = None,
providerSettings: Optional[ProviderSettings] = None,
links: list = None,
id: Optional[str] = None
id: Optional[str] = None,
create_date: Optional[datetime] = None
) -> None:
self.create_date: Optional[datetime] = create_date
self.id: Optional[str] = id
self.providerSettings: Optional[ProviderSettings] = providerSettings
self.backup_enabled: bool = backup_enabled
Expand Down Expand Up @@ -341,10 +343,11 @@ def fill_from_dict(cls, data_dict: dict):
providerSettings = ProviderSettings.from_dict(provider_settings_dict)
links = data_dict.get('links', [])
id = data_dict.get('id', None)
create_date = datetime.strptime(data_dict.get('createDate', None), FORMAT).astimezone(tz=pytz.UTC)
return cls(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,id)
srv_address, providerSettings, links,id, create_date)

def as_dict(self) -> dict:
return_dict = self.__dict__
Expand Down
8 changes: 8 additions & 0 deletions atlasapi/events_event_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,14 @@ class AtlasEventTypes(Enum):
ATLAS_MAINTENANCE_AUTO_DEFER_DISABLED = 'Atlas Maintenance Auto Defer Disabled'
ATLAS_MAINTENANCE_START_ASAP = 'Atlas Maintenance Start Asap'
ATLAS_MAINTENANCE_SCHEDULED_FOR_NEXT_WINDOW = 'Atlas Maintenance Scheduled For Next Window'
MAINTENANCE_WINDOW_ADDED = 'Atlas Maintenance Window Added'
MAINTENANCE_WINDOW_MODIFIED = 'Atlas Maintenance Window Modified'
MAINTENANCE_WINDOW_REMOVED = 'Atlas Maintenance Window Removed'
MAINTENANCE_DEFERRED = 'Atlas Maintenance Deferred'
MAINTENANCE_AUTO_DEFER_ENABLED = 'Atlas Maintenance Auto Defer Enabled'
MAINTENANCE_AUTO_DEFER_DISABLED = 'Atlas Maintenance Auto Defer Disabled'
MAINTENANCE_START_ASAP = 'Atlas Maintenance Start Asap'
MAINTENANCE_SCHEDULED_FOR_NEXT_WINDOW = 'Atlas Maintenance Scheduled For Next Window'
COMPUTE_AUTO_SCALE_UNNECESSARY = 'Compute Auto Scale Unnecessary'
COMPUTE_AUTO_SCALE_TRIGGERED = 'Compute Auto Scale Triggered'
COMPUTE_AUTO_SCALE_SKIPPED = 'Compute Auto Scale Skipped'
Expand Down
17 changes: 2 additions & 15 deletions atlasapi/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ def from_dict(cls, data_dict):
Returns: None

"""
created_date = isodatetime.parse_datetime(data_dict.get("created"))
return cls(id=data_dict.get("id"), name=data_dict.get("name"),
links=data_dict.get("links", []), org_id=data_dict.get("orgId"),
created_date=data_dict.get("created"), cluster_count=data_dict.get("clusterCount"))
created_date=created_date, cluster_count=data_dict.get("clusterCount"))

@property
def create_dict(self) -> dict:
Expand Down Expand Up @@ -107,17 +108,3 @@ def from_dict(cls,data_dict: dict):
bool(data_dict.get("isRealtimePerformancePanelEnabled", False)),
bool(data_dict.get("isSchemaAdvisorEnabled", False)),
)


"""
test_dict = {
"clusterCount": 2,
"created": "2016-07-14T14:19:33Z",
"id": "5a0a1e7e0f2912c554080ae6",
"links": [],
"name": "DocsFeedbackGroup",
"orgId": "5a0a1e7e0f2912c554080adc"
}

print(Project.for_create(org_id='34', name='test_project').as_create_dict)
"""
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='atlasapi',
version='2.0.6',
version='2.0.7',
python_requires='>=3.7',
packages=find_packages(exclude=("tests",)),
install_requires=['requests', 'python-dateutil', 'isodate', 'future', 'pytz', 'coolname', 'humanfriendly', 'nose'],
Expand Down
9 changes: 9 additions & 0 deletions tests/test_clusters.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from atlasapi.atlas import Atlas
from atlasapi.lib import AtlasPeriods, AtlasUnits, AtlasGranularities
from json import dumps
from datetime import datetime
from atlasapi.clusters import AtlasBasicReplicaSet, ClusterConfig
from atlasapi.lib import MongoDBMajorVersion as mdb_version
from atlasapi.clusters import ClusterConfig, ProviderSettings, ReplicationSpecs, InstanceSizeName
Expand Down Expand Up @@ -179,3 +180,11 @@ def test_13_set_advanced_options(self):



def test_14_issue_154_additional_data(self):
cluster = self.a.Clusters.get_single_cluster_as_obj(self.TEST_CLUSTER_NAME)
self.assertTrue(type(cluster) is ClusterConfig)
self.assertEqual(cluster.name, self.TEST_CLUSTER_NAME)
self.assertIsInstance(cluster.create_date, datetime)
pprint(cluster.as_dict())

test_02_get_a_cluster_as_obj.basic = True
9 changes: 9 additions & 0 deletions tests/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


"""
import datetime
from pprint import pprint
from os import environ, getenv
from atlasapi.atlas import Atlas
Expand Down Expand Up @@ -128,3 +129,11 @@ def test_10_get_project_settings(self):
self.assertIsInstance(out, ProjectSettings, "The response must be a ProjectSettings obj")

test_10_get_project_settings.basic = True


def test_11_get_project_create_date(self):
out = self.a.Projects.project_by_id(self.a.group)
pprint(out.__dict__)
self.assertIsInstance(out.created_date, datetime.datetime, "An datetime should be returned")

test_02_get_project_by_id.basic = True