Skip to content

Issues with modify_cluster_instance_size (datetime in not JSON serializable) #182

@matiasblancor

Description

@matiasblancor

Hi, I am writen a script that changes our Mogo atlas cluster instance size at night, and then changes it again during the day, but when I want to update the instance size this error is logged

TypeError: Object of type datetime is not JSON serializable

this is my code

from atlasapi.atlas import Atlas
from atlasapi.clusters import InstanceSizeName

atlas_instance_size = {
    "M2": {
        "scale_down": InstanceSizeName.M0,
        "scale_default": InstanceSizeName.M2
    },
    "M5": {
        "scale_down": InstanceSizeName.M2,
        "scale_default": InstanceSizeName.M5
    },
    "M10": {
        "scale_down": InstanceSizeName.M5,
        "scale_default": InstanceSizeName.M10
    },
    "M20": {
        "scale_down": InstanceSizeName.M10,
        "scale_default": InstanceSizeName.M20
    },
    "M30": {
        "scale_down": InstanceSizeName.M20,
        "scale_default": InstanceSizeName.M30
    },
    "M40": {
        "scale_down": InstanceSizeName.M30,
        "scale_default": InstanceSizeName.M40
    },
    "M50": {
        "scale_down": InstanceSizeName.M40,
        "scale_default": InstanceSizeName.M50
    }
}


public_key="xxxxxxx"
private_key="xxxxxxx"
group_id="xxxxx"
cluster_name = "Cluster0"
default_instance_size = "M5"
atlas = Atlas(public_key, private_key, group_id)

out = atlas.Clusters.modify_cluster_instance_size(cluster=cluster_name, new_cluster_size=atlas_instance_size[default_instance_size]['scale_default'])

if someone knows what I'm doing wrong 🙏🏻


python version: 3.10.0
atlasapi version: 2.0.8

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions