Skip to main content
Solved

How assign a category to a vm within REST API Prism Central

  • October 19, 2021
  • 2 replies
  • 1204 views

Hello

I would like to use REST API within Prism Central to assign a category to a VM.

I dont know how to do that

Do I need to use this API 

- “Update an existing VM” (put /vms/{uuid})

or this API

- “Create or Update a category value” (put /categories/{name}/{value})


And how can I use it to assign a new category and not remove previous category ?

Regards

Pascal

 

 

 

Best answer by PascalM

Ahhh finally I answer to myself :-)

I have to use  “Update an existing VM” (put /vms/{uuid})

and the difficulty for me was to understand what I need to pass for the request payload/body

I need to specify a JSON with the current SPEC of the VM + the metadata with category list

{
  "spec": {
      < every thing of current vm >
  },
  "metadata": {
    "kind": "vm"
    "uuid": <VM UUID>,
    "spec_version": 3,
    "categories_mapping": {
      "ABC1": [
        "abc_1_1"
      ],
      "TEST2": [
        "test1"
      ]
    },
    "categories": {
      "ABC1": "abc_1_1",
      "TEST2": "test1"
    }
  }
}

 

Not so easy to do but it was ok at the end

Regards

This topic has been closed for replies.

2 replies

  • Author
  • Voyager
  • Answer
  • October 19, 2021

Ahhh finally I answer to myself :-)

I have to use  “Update an existing VM” (put /vms/{uuid})

and the difficulty for me was to understand what I need to pass for the request payload/body

I need to specify a JSON with the current SPEC of the VM + the metadata with category list

{
  "spec": {
      < every thing of current vm >
  },
  "metadata": {
    "kind": "vm"
    "uuid": <VM UUID>,
    "spec_version": 3,
    "categories_mapping": {
      "ABC1": [
        "abc_1_1"
      ],
      "TEST2": [
        "test1"
      ]
    },
    "categories": {
      "ABC1": "abc_1_1",
      "TEST2": "test1"
    }
  }
}

 

Not so easy to do but it was ok at the end

Regards


JoseNutanix
Nutanix Employee
Forum|alt.badge.img+5
  • Nutanix Employee
  • October 19, 2021

Good to heard you found what you were looking for. In case you want to know more about Nutanix APIs and get familiar on how to use them, you have several blog posts in our Nutanix.dev website.