Skip to content

Create method #1

Open
Open

Description

@semihyonet

We have to add a create a record option into our CLI. This method will work with the command create. It will check the parameters it needs through the response it gets on our option request to our API ( an example of the response body can be found under).

We get the needed parameters from the following json in "methods"-> "POST"->"fields"->0 . Request the details from the user like this.

Plusclouds > create iaas virtual-machines

name (required) :  <user-input>
hostname ( required ) : <user-input> 
total_cpu  ( required ) : <user-input>
total_ram ( required ) : <user-input>
description : <user-input>
datacenter_node_ref ( required ) : <user-input>
compute_member_ref : <user-input>

extra to do's

  • check if the 'POST' method exists in data["methods"] and has a 'fields' field.
  • At the first version you only need to get the name and if it's required or not.
  • Set it null if pressed entered and field is not required and throw error if it is.
  • After the operation is completed send it to our api with the post method of our httpgateway file
{
    "uri": "v2/iaas/virtual-machines",
    "description": "",
    "directories": [
        ".",
        "..",
        "meta-data",
        "{vm}",
        "templates",
        "snapshots",
        "wizards",
        "overview"
    ],
    "methods": {
        "GET": {
            "list": {
                "uri": "v2/iaas/virtual-machines",
                "description": null,
                "search": {
                    "uri": "v2/iaas/virtual-machines",
                    "parameters": [
                        {
                            "name": "datacenterNode",
                            "type": "string",
                            "description": ""
                        },
                        {
                            "name": "name",
                            "type": "string",
                            "description": ""
                        },
                        {
                            "name": "tags",
                            "type": "$tags",
                            "description": ""
                        },
                        {
                            "name": "status",
                            "type": "string",
                            "description": ""
                        },
                        {
                            "name": "uuid",
                            "type": "string",
                            "description": ""
                        },
                        {
                            "name": "haPriority",
                            "type": "int",
                            "description": ""
                        },
                        {
                            "name": "snapshots",
                            "type": null,
                            "description": ""
                        },
                        {
                            "name": "templates",
                            "type": null,
                            "description": ""
                        },
                        {
                            "name": "defaultTemplates",
                            "type": null,
                            "description": ""
                        },
                        {
                            "name": "losts",
                            "type": null,
                            "description": ""
                        },
                        {
                            "name": "locked",
                            "type": null,
                            "description": ""
                        },
                        {
                            "name": "passive",
                            "type": null,
                            "description": ""
                        },
                        {
                            "name": "ipAddr",
                            "type": "string",
                            "description": ""
                        }
                    ]
                },
                "returns": "json|array",
                "authentication": "required"
            }
        },
        "POST": {
            "fields": [
                {
                    "name": "required|max:150",
                    "hostname": "max:150",
                    "total_cpu": "required|integer|min:1|max:32",
                    "total_ram": "required|integer|min:512|max:524288",
                    "description": "max:500",
                    "datacenter_node_ref": "required|exists:datacenter_nodes,id_ref",
                    "compute_member_ref": "nullable|exists:compute_members,id_ref"
                }
            ]
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions